Subversion Repositories public iLand

Rev

Rev 825 | Rev 914 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 825 Rev 848
Line 295... Line 295...
295
{
295
{
296
    mScriptFile = fileName;
296
    mScriptFile = fileName;
297
    ScriptGlobal::loadScript(fileName);
297
    ScriptGlobal::loadScript(fileName);
298
}
298
}
299
299
300
int Management::filter(QVariantList idList)
300
int Management::filterIdList(QVariantList idList)
301
{
301
{
302
    QVector<int> ids;
302
    QVector<int> ids;
303
    foreach(const QVariant &v, idList)
303
    foreach(const QVariant &v, idList)
304
        if (!v.isNull())
304
        if (!v.isNull())
305
            ids << v.toInt();
305
            ids << v.toInt();
Line 326... Line 326...
326
    int n_before = mTrees.count();
326
    int n_before = mTrees.count();
327
    QList<QPair<Tree*, double> >::iterator tp=mTrees.begin();
327
    QList<QPair<Tree*, double> >::iterator tp=mTrees.begin();
328
    try {
328
    try {
329
        while (tp!=mTrees.end()) {
329
        while (tp!=mTrees.end()) {
330
            tw.setTree(tp->first);
330
            tw.setTree(tp->first);
331
            if (expr.calculate(tw))
331
            double value = expr.calculate(tw);
-
 
332
            // keep if expression returns true (1)
-
 
333
            bool keep = value==1.;
-
 
334
            // if value is >0 (i.e. not "false"), then draw a random number
-
 
335
            if (!keep && value>0.)
-
 
336
                keep = drandom() < value;
-
 
337
-
 
338
            if (!keep)
332
                tp = mTrees.erase(tp);
339
                tp = mTrees.erase(tp);
333
            else
340
            else
334
                ++tp;
341
                ++tp;
335
        }
342
        }
336
    } catch(const IException &e) {
343
    } catch(const IException &e) {