Subversion Repositories public iLand

Rev

Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1033 werner 1
/********************************************************************************************
2
**    iLand - an individual based forest landscape and disturbance model
3
**    http://iland.boku.ac.at
4
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
5
**
6
**    This program is free software: you can redistribute it and/or modify
7
**    it under the terms of the GNU General Public License as published by
8
**    the Free Software Foundation, either version 3 of the License, or
9
**    (at your option) any later version.
10
**
11
**    This program is distributed in the hope that it will be useful,
12
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
**    GNU General Public License for more details.
15
**
16
**    You should have received a copy of the GNU General Public License
17
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
********************************************************************************************/
923 werner 19
#ifndef ACTTHINNING_H
20
#define ACTTHINNING_H
21
#include "activity.h"
951 werner 22
#include "grid.h"
923 werner 23
 
1061 werner 24
class Species; // forward
25
 
923 werner 26
namespace ABE {
27
 
28
class FMSTP; // forward
29
class FMStand; // forward
930 werner 30
class FMTreeList; // forward
923 werner 31
 
32
 
33
class ActThinning : public Activity
34
{
35
public:
36
    ActThinning(FMSTP *parent);
37
    enum ThinningType { Invalid, FromBelow, FromAbove, Custom, Selection};
38
    QString type() const;
39
    void setup(QJSValue value);
40
    bool evaluate(FMStand *stand);
41
    bool execute(FMStand *stand);
42
private:
43
    struct SCustomThinning {
930 werner 44
        QString filter; ///< additional filter
923 werner 45
        bool usePercentiles; ///< if true, classes relate to percentiles, if 'false' classes relate to relative dbh classes
46
        bool removal; ///< if true, classes define removals, if false trees should *stay* in the class
47
        bool relative; ///< if true, values are per cents, if false, values are absolute values per hectare
930 werner 48
        double targetValue; ///< the number (per ha) that should be removed, see targetVariable
49
        bool targetRelative; ///< if true, the target variable is relative to the stock, if false it is absolute
923 werner 50
        QString targetVariable; ///< target variable ('volume', 'basalArea', 'stems') / ha
51
        QVector<double> classValues; ///< class values (the number of values defines the number of classes)
52
        QVector<int> classPercentiles; ///< percentiles [0..100] for the classes (count = count(classValues) + 1
53
        double minDbh; ///< only trees with dbh > minDbh are considered (default: 0)
54
        int remainingStems; ///< minimum remaining stems/ha (>minDbh)
55
    };
951 werner 56
    struct SSelectiveThinning {
57
        int N; // stems pro ha target
58
    };
59
 
60
    SSelectiveThinning mSelectiveThinning;
61
 
930 werner 62
    QVector<SCustomThinning> mCustomThinnings;
63
    /// setup function for custom thinnings
923 werner 64
    void setupCustom(QJSValue value);
951 werner 65
    /// setup function for selective thinnings ("auslesedurchforstung")
66
    void setupSelective(QJSValue value);
67
 
930 werner 68
    // setup a single thinning definition
69
    void setupSingleCustom(QJSValue value, SCustomThinning &custom);
70
    bool evaluateCustom(FMStand *stand, SCustomThinning &custom);
1061 werner 71
    int selectRandomTree(FMTreeList *list, const int pct_min, const int pct_max, const bool selective);
72
    int selectSelectiveSpecies(FMTreeList *list, const bool is_selective, const int index);
930 werner 73
    void clearTreeMarks(FMTreeList *list);
1061 werner 74
    QHash<const Species*, double> mSpeciesSelectivity;
951 werner 75
 
76
    // selective
77
    bool evaluateSelective(FMStand *stand);
78
    bool markCropTrees(FMStand* stand);
79
    float testPixel(const QPointF &pos,  Grid<float> &grid);
80
    void setPixel(const QPointF &pos,  Grid<float> &grid);
923 werner 81
    ThinningType mThinningType;
82
 
951 werner 83
    // syntax checking
84
    static QStringList mSyntaxCustom;
85
    static QStringList mSyntaxSelective;
86
 
923 werner 87
};
88
 
89
 
90
} // namespace
91
#endif // ACTTHINNING_H