iLand
actthinning.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
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********************************************************************************************/
19#ifndef ACTTHINNING_H
20#define ACTTHINNING_H
21#include "activity.h"
22#include "grid.h"
23
24class Species; // forward
25
26namespace ABE {
27
28class FMSTP; // forward
29class FMStand; // forward
30class FMTreeList; // forward
31
32
33class ActThinning : public Activity
34{
35public:
36 ActThinning(FMSTP *parent);
38 QString type() const;
39 void setup(QJSValue value);
40 bool evaluate(FMStand *stand);
41 bool execute(FMStand *stand);
42private:
43 struct SCustomThinning {
44 QString filter;
45 bool usePercentiles;
46 bool removal;
47 bool relative;
48 QJSValue targetValue;
49 bool targetRelative;
50 QString targetVariable;
51 QVector<double> classValues;
52 QVector<int> classPercentiles;
53 QJSValue minDbh;
54 QJSValue remainingStems;
55 };
56 struct SSelectiveThinning {
57 int N; // stems pro ha target
58 };
59
60 SSelectiveThinning mSelectiveThinning;
61
62 QVector<SCustomThinning> mCustomThinnings;
64 void setupCustom(QJSValue value);
66 void setupSelective(QJSValue value);
67
68 // setup a single thinning definition
69 void setupSingleCustom(QJSValue value, SCustomThinning &custom);
70 bool evaluateCustom(FMStand *stand, SCustomThinning &custom);
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);
73 void clearTreeMarks(FMTreeList *list);
74 QHash<const Species*, double> mSpeciesSelectivity;
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);
81 ThinningType mThinningType;
82
83 // syntax checking
84 static QStringList mSyntaxCustom;
85 static QStringList mSyntaxSelective;
86
87};
88
89
90} // namespace
91#endif // ACTTHINNING_H
The ActThinning class implements a very general interface to thinning activties.
Definition: actthinning.h:34
ActThinning(FMSTP *parent)
Definition: actthinning.cpp:46
bool evaluate(FMStand *stand)
executes the evaluation of the forest stand.
Definition: actthinning.cpp:93
ThinningType
Definition: actthinning.h:37
@ FromBelow
Definition: actthinning.h:37
@ FromAbove
Definition: actthinning.h:37
@ Invalid
Definition: actthinning.h:37
@ Custom
Definition: actthinning.h:37
@ Selection
Definition: actthinning.h:37
bool execute(FMStand *stand)
executes the action (usually defined in derived classes) using the context of 'stand'.
Definition: actthinning.cpp:109
void setup(QJSValue value)
setup of the activity (events, schedule, constraints). additional setup in derived classes.
Definition: actthinning.cpp:73
QString type() const
Definition: actthinning.cpp:59
Activity is the base class for management activities.
Definition: activity.h:162
friend class FMStand
Definition: activity.h:218
int index() const
index of the activity within the STP
Definition: activity.h:175
The FMSTP class encapsulates a stand treatment program, which is defined in Javascript.
Definition: fmstp.h:39
FMStand encapsulates a forest stand for the forest management engine.
Definition: fmstand.h:49
The behavior and general properties of tree species.
Definition: species.h:75
Definition: abegrid.h:22