Rev 157 | Rev 159 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 157 | Rev 158 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | #ifndef TREE_H
|
2 | #ifndef TREE_H
|
3 | #define TREE_H
|
3 | #define TREE_H
|
4 | #include <QPointF>
|
4 | #include <QPointF>
|
5 | 5 | ||
6 | #include "grid.h"
|
6 | #include "grid.h"
|
7 | - | ||
- | 7 | // forwards
|
|
8 | class Species; |
8 | class Species; |
9 | class Stamp; |
9 | class Stamp; |
10 | class RessourceUnit; |
10 | class RessourceUnit; |
11 | struct HeightGridValue; |
11 | struct HeightGridValue; |
12 | 12 | ||
Line 17... | Line 17... | ||
17 | Tree(); |
17 | Tree(); |
18 | void setup(); |
18 | void setup(); |
19 | 19 | ||
20 | // access to properties
|
20 | // access to properties
|
21 | int id() const { return mId; } |
21 | int id() const { return mId; } |
22 | void setNewId() { mId = m_nextId++; } ///< force a new id for this object (after copying trees) |
- | |
23 | /// @property position The tree does not store the floating point coordinates but only the index of pixel on the LIF grid
|
22 | /// @property position The tree does not store the floating point coordinates but only the index of pixel on the LIF grid
|
24 | const QPointF position() const { Q_ASSERT(mGrid!=0); return mGrid->cellCenterPoint(mPositionIndex); } |
23 | const QPointF position() const { Q_ASSERT(mGrid!=0); return mGrid->cellCenterPoint(mPositionIndex); } |
- | 24 | float dbh() const { return mDbh; } |
|
- | 25 | float height() const { return mHeight; } |
|
- | 26 | const Species* species() const { Q_ASSERT(mRU!=0); return mSpecies; } ///< pointer to the tree species of the tree. |
|
- | 27 | const RessourceUnit *ru() const { Q_ASSERT(mRU!=0); return mRU; } ///< pointer to the ressource unit the tree belongs to. |
|
- | 28 | ||
- | 29 | float lightRessourceIndex() const { return mLRI; } ///< LRI of the tree (update during readStamp()) |
|
- | 30 | double volume() const; ///< volume (m3) of stem volume based on geometry and density calculated on the fly. |
|
- | 31 | bool isDead() const { return flag(Tree::TreeDead); } ///< returns true if the tree is already dead. |
|
- | 32 | // actions
|
|
- | 33 | void die() { setFlag(Tree::TreeDead, true); } ///< kills the tree. |
|
- | 34 | void enableDebugging(const bool enable=true) {setFlag(Tree::TreeDebugging, enable); } |
|
- | 35 | ||
- | 36 | // setters for initialization
|
|
- | 37 | void setNewId() { mId = m_nextId++; } ///< force a new id for this object (after copying trees) |
|
25 | void setPosition(const QPointF pos) { Q_ASSERT(mGrid!=0); mPositionIndex = mGrid->indexAt(pos); } |
38 | void setPosition(const QPointF pos) { Q_ASSERT(mGrid!=0); mPositionIndex = mGrid->indexAt(pos); } |
26 | void setDbh(const float dbh) { mDbh=dbh; } |
39 | void setDbh(const float dbh) { mDbh=dbh; } |
27 | float dbh() const { return mDbh; } |
- | |
28 | void setHeight(const float height) { mHeight=height; } |
40 | void setHeight(const float height) { mHeight=height; } |
29 | float height() const { return mHeight; } |
- | |
30 | float lightRessourceIndex() const { return mLRI; } |
- | |
31 | const Species* species() const { Q_ASSERT(mRU!=0); return mSpecies; } |
- | |
32 | void setSpecies(Species *ts) { mSpecies=ts; } |
41 | void setSpecies(Species *ts) { mSpecies=ts; } |
33 | const RessourceUnit *ru() const { Q_ASSERT(mRU!=0); return mRU; } |
- | |
34 | void setRU(RessourceUnit *ru) { mRU = ru; } |
42 | void setRU(RessourceUnit *ru) { mRU = ru; } |
35 | double volume() const; ///< volume (m3) of stem volume based on geometry and density calculated on the fly. |
- | |
36 | bool dead() const { return flag(Tree::TreeDead); } |
- | |
37 | // actions
|
- | |
38 | void die() { setFlag(Tree::TreeDead, true); } |
- | |
39 | void enableDebugging(const bool enable=true) {setFlag(Tree::TreeDebugging, enable); } |
- | |
- | 43 | ||
40 | // grid based light-concurrency functions
|
44 | // grid based light-concurrency functions
|
41 | void applyStamp(); ///< apply LightInfluencePattern onto the global grid |
- | |
42 | void readStamp(); ///< calculate the lightRessourceIndex with multiplicative approach |
- | |
- | 45 | void applyLIP(); ///< apply LightInfluencePattern onto the global grid |
|
- | 46 | void readLIF(); ///< calculate the lightRessourceIndex with multiplicative approach |
|
43 | void heightGrid(); ///< calculate the height grid |
47 | void heightGrid(); ///< calculate the height grid |
44 | 48 | ||
45 | void applyStampTorus(); ///< apply LightInfluencePattern on a closed 1ha area |
- | |
46 | void readStampTorus(); ///< calculate LRI from a closed 1ha area |
- | |
47 | void heightGridTorus(); ///< calculate the height grid |
- | |
- | 49 | void applyLIP_torus(); ///< apply LightInfluencePattern on a closed 1ha area |
|
- | 50 | void readLIF_torus(); ///< calculate LRI from a closed 1ha area |
|
- | 51 | void heightGrid_torus(); ///< calculate the height grid |
|
48 | 52 | ||
49 | // growth, etc.
|
53 | // growth, etc.
|
50 | void grow(); |
- | |
51 | void grow_diameter(const double &net_stem_npp); |
- | |
52 | double relative_height_growth(); |
- | |
- | 54 | void grow(); ///< main growth function to update the tree state. |
|
53 | 55 | ||
54 | // static functions
|
56 | // static functions
|
55 | static void setGrid(FloatGrid* gridToStamp, Grid<HeightGridValue> *dominanceGrid); |
57 | static void setGrid(FloatGrid* gridToStamp, Grid<HeightGridValue> *dominanceGrid); |
56 | // statistics
|
58 | // statistics
|
57 | static void resetStatistics(); |
59 | static void resetStatistics(); |
Line 61... | Line 63... | ||
61 | QString dump(); |
63 | QString dump(); |
62 | void dumpList(QList<QVariant> &rTargetList); |
64 | void dumpList(QList<QVariant> &rTargetList); |
63 | 65 | ||
64 | private: |
66 | private: |
65 | // helping functions
|
67 | // helping functions
|
66 | void partitioning(double npp); |
- | |
- | 68 | void partitioning(double npp); ///< split NPP into various plant pools. |
|
- | 69 | double relative_height_growth(); ///< estimate height growth based on light status. |
|
- | 70 | void grow_diameter(const double &net_stem_npp); ///< actual growth of the tree's stem. |
|
67 | // state variables
|
71 | // state variables
|
68 | int mId; |
72 | int mId; |
69 | float mDbh; ///< diameter at breast height [cm] |
73 | float mDbh; ///< diameter at breast height [cm] |
70 | float mHeight; ///< tree height [m] |
74 | float mHeight; ///< tree height [m] |
71 | QPoint mPositionIndex; ///< index of the trees position on the basic LIF grid |
75 | QPoint mPositionIndex; ///< index of the trees position on the basic LIF grid |
72 | // biomass compartements
|
76 | // biomass compartements
|
73 | float mLeafArea; ///< m2 leaf area |
77 | float mLeafArea; ///< m2 leaf area |
74 | float mOpacity; ///< multiplier on LIP weights, depending on leaf area status (opacity of the crown) |
78 | float mOpacity; ///< multiplier on LIP weights, depending on leaf area status (opacity of the crown) |
75 | - | ||
76 | - | ||
77 | float mFoliageMass; // kg |
79 | float mFoliageMass; // kg |
78 | float mWoodyMass; // kg |
80 | float mWoodyMass; // kg |
79 | float mRootMass; // kg |
81 | float mRootMass; // kg |
80 | // production relevant
|
82 | // production relevant
|
81 | float mNPPReserve; // kg |
83 | float mNPPReserve; // kg |
82 | - | ||
83 | float mDbhDelta; ///< diameter growth [cm] |
84 | float mDbhDelta; ///< diameter growth [cm] |
84 | - | ||
85 | float mLRI; ///< resulting lightRessourceIndex |
85 | float mLRI; ///< resulting lightRessourceIndex |
86 | // Stamp, Species, Ressource Unit
|
86 | // Stamp, Species, Ressource Unit
|
- | 87 | ||
87 | const Stamp *mStamp; |
88 | const Stamp *mStamp; |
88 | - | ||
89 | Species *mSpecies; |
89 | Species *mSpecies; |
90 | RessourceUnit *mRU; |
90 | RessourceUnit *mRU; |
91 | 91 | ||
92 | // various flags
|
92 | // various flags
|
93 | int mFlags; |
93 | int mFlags; |
Line 95... | Line 95... | ||
95 | void setFlag(const Tree::Flags flag, const bool value) { if (value) mFlags |= flag; else mFlags &= (flag ^ 0xffffff );} |
95 | void setFlag(const Tree::Flags flag, const bool value) { if (value) mFlags |= flag; else mFlags &= (flag ^ 0xffffff );} |
96 | bool flag(const Tree::Flags flag) const { return mFlags & flag; } |
96 | bool flag(const Tree::Flags flag) const { return mFlags & flag; } |
97 | 97 | ||
98 | // special functions
|
98 | // special functions
|
99 | bool isDebugging() { return flag(Tree::TreeDebugging); } |
99 | bool isDebugging() { return flag(Tree::TreeDebugging); } |
100 | - | ||
101 | 100 | ||
102 | // static data
|
101 | // static data
|
103 | static FloatGrid *mGrid; |
102 | static FloatGrid *mGrid; |
104 | static Grid<HeightGridValue> *mHeightGrid; |
103 | static Grid<HeightGridValue> *mHeightGrid; |
105 | - | ||
106 | 104 | ||
107 | // statistics
|
105 | // statistics
|
108 | static int m_statPrint; |
106 | static int m_statPrint; |
109 | static int m_statAboveZ; |
107 | static int m_statAboveZ; |
110 | static int m_statCreated; |
108 | static int m_statCreated; |