Subversion Repositories public iLand

Rev

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

Rev 1162 Rev 1165
Line 10... Line 10...
10
struct SaplingTree {
10
struct SaplingTree {
11
    SaplingTree() { clear(); }
11
    SaplingTree() { clear(); }
12
    short unsigned int age;  // number of consectuive years the sapling suffers from dire conditions
12
    short unsigned int age;  // number of consectuive years the sapling suffers from dire conditions
13
    short signed int species_index; // index of the species within the resource-unit-species container
13
    short signed int species_index; // index of the species within the resource-unit-species container
14
    unsigned char stress_years; // (upper 16bits) + age of sapling (lower 16 bits)
14
    unsigned char stress_years; // (upper 16bits) + age of sapling (lower 16 bits)
15
    unsigned char flags;
15
    unsigned char flags; // flags, e.g. whether sapling stems from sprouting
16
    float height; // height of the sapling in meter
16
    float height; // height of the sapling in meter
17
    bool is_occupied() const { return height>0.f; }
17
    bool is_occupied() const { return height>0.f; }
18
    void clear()  {  age=0; species_index=-1; stress_years=0; flags=0; height=0.f;  }
18
    void clear()  {  age=0; species_index=-1; stress_years=0; flags=0; height=0.f;  }
19
    void setSapling(const float h_m, const int age_yrs, const int species_idx) { height=h_m; age=static_cast<short unsigned int>(age_yrs); stress_years=0; species_index=static_cast<short signed int>(species_idx); }
19
    void setSapling(const float h_m, const int age_yrs, const int species_idx) { height=h_m; age=static_cast<short unsigned int>(age_yrs); stress_years=0; species_index=static_cast<short signed int>(species_idx); }
-
 
20
    // flags
-
 
21
    bool is_sprout() const { return flags & 1; }
-
 
22
    void set_sprout(const bool sprout) {if (sprout) flags |= 1; else flags &= (1 ^ 0xffffff ); }
20
};
23
};
21
#define NSAPCELLS 5
24
#define NSAPCELLS 5
22
struct SaplingCell {
25
struct SaplingCell {
23
    enum ECellState { CellInvalid=0, CellFree=1, CellFull=2};
26
    enum ECellState { CellInvalid=0, CellFree=1, CellFull=2};
24
    SaplingCell() {
27
    SaplingCell() {
Line 130... Line 133...
130
    /// return the SaplingCell (i.e. container for the ind. saplings) for the given 2x2m coordinates
133
    /// return the SaplingCell (i.e. container for the ind. saplings) for the given 2x2m coordinates
131
    /// if 'only_valid' is true, then 0 is returned if no living saplings are on the cell
134
    /// if 'only_valid' is true, then 0 is returned if no living saplings are on the cell
132
    /// 'rRUPtr' is a pointer to a RU-ptr: if provided, a pointer to the resource unit is stored
135
    /// 'rRUPtr' is a pointer to a RU-ptr: if provided, a pointer to the resource unit is stored
133
    SaplingCell *cell(QPoint lif_coords, bool only_valid=true, ResourceUnit **rRUPtr=0);
136
    SaplingCell *cell(QPoint lif_coords, bool only_valid=true, ResourceUnit **rRUPtr=0);
134
    /// clear/kill all saplings within the rectangle given by 'rectangle'.
137
    /// clear/kill all saplings within the rectangle given by 'rectangle'.
135
    /// If 'remove_biomass' is true, then the biomass is extracted (e.g. burnt)
138
    /// If 'remove_biomass' is true, then the biomass is extracted (e.g. burnt), otherwise they are moved to soil
136
    void clearSaplings(const QRectF &rectangle, const bool remove_biomass);
139
    void clearSaplings(const QRectF &rectangle, const bool remove_biomass);
-
 
140
    /// clear all saplings on a given cell 's' (if 'remove_biomass' is true: biomass removed from system (e.g. burnt))
-
 
141
    void clearSaplings(SaplingCell *s, ResourceUnit *ru, const bool remove_biomass);
-
 
142
-
 
143
    /// generate vegetative offspring from 't' (sprouts)
-
 
144
    int addSprout(const Tree *t);
137
145
138
    static void setRecruitmentVariation(const double variation) { mRecruitmentVariation = variation; }
146
    static void setRecruitmentVariation(const double variation) { mRecruitmentVariation = variation; }
139
    static void updateBrowsingPressure();
147
    static void updateBrowsingPressure();
140
148
141
private:
149
private: