SORTIE Core C++ Documentation
|
TREE POPULATION CLASS - Version 1.4. More...
#include <TreePopulation.h>
Classes | |
struct | speciesCodes |
For maintaining a list of species and their codes. More... | |
struct | stcOpenSearches |
Holds open tree searches. More... | |
Public Types | |
enum | iTreeType { seed, seedling, sapling, adult, stump, snag, woody_debris } |
Tree life history stages, or tree type. More... | |
Public Member Functions | |
~clTreePopulation () | |
Destructor. More... | |
clTreePopulation (clSimManager *p_oSimManager) | |
Constructor. More... | |
clTreeSearch * | Find (std::string sArgs) |
Acquires trees which meet certain criteria. More... | |
clTree * | CreateTree (float fX, float fY, int iSp, int iType, float fDiam) |
Creates a new tree and organizes it into the hash table. More... | |
clTree * | KillTree (clTree *p_deadTree, deadCode iReason) |
Kills a tree. More... | |
void | BarebonesDataSetup (xercesc::DOMDocument *p_oDoc) |
Reads type and species info from the parameter file. More... | |
short int | TranslateSpeciesNameToCode (std::string sSpeciesName) |
Translates a species name string into its code. More... | |
std::string | TranslateSpeciesCodeToName (int iSpecies) |
Translates a species code into its name string. More... | |
short int | RegisterInt (std::string sLabel, int iSpecies, int iType) |
Adds an integer data member to the tree data structure. More... | |
short int | RegisterFloat (std::string sLabel, int iSpecies, int iType) |
Adds a float data member to the tree data structure. More... | |
short int | RegisterChar (std::string sLabel, int iSpecies, int iType) |
Adds a char data member to the tree data structure. More... | |
short int | RegisterBool (std::string sLabel, int iSpecies, int iType) |
Adds a boolean data member to the tree data structure. More... | |
short int | GetIntDataCode (std::string sLabel, int iSpecies, int iType) |
Gets the data code for accessing an integer tree data member. More... | |
short int | GetFloatDataCode (std::string sLabel, int iSpecies, int iType) |
Gets the data code for accessing a float tree data member. More... | |
short int | GetStringDataCode (std::string sLabel, int iSpecies, int iType) |
Gets the data code for accessing a string tree data member. More... | |
short int | GetBoolDataCode (std::string sLabel, int iSpecies, int iType) |
Gets the data code for accessing a bool tree data member. More... | |
std::string | GetIntDataLabel (short int iCode, int iSpecies, int iType) |
Gets the label for an integer tree data member. More... | |
std::string | GetFloatDataLabel (short int iCode, int iSpecies, int iType) |
Gets the label for a float tree data member. More... | |
std::string | GetStringDataLabel (short int iCode, int iSpecies, int iType) |
Gets the label for a string tree data member. More... | |
std::string | GetBoolDataLabel (short int iCode, int iSpecies, int iType) |
Gets the label for a bool tree data member. More... | |
void | DoDataUpdates () |
Determines if the hash table needs to be sorted by checking the bDoUpdates flag, and if it does, it sorts it. More... | |
void | EmptyHashTable () |
Deletes all trees from the hash table without deleting the table itself. More... | |
void | SortHashTable () |
Sorts the hash table by height. More... | |
float | GetRandomDiam10Value (float fDiam10Seed=0) |
Gets a random diameter at 10 cm value for a seedling. More... | |
short int | GetXCode (int iSpecies, int iType) |
Gets the code for the "X" data member, which is registered by the tree population. More... | |
short int | GetYCode (int iSpecies, int iType) |
Gets the code for the "Y" data member, which is registered by the tree population. More... | |
short int | GetHeightCode (int iSpecies, int iType) |
Gets the code for the "Height" data member, which is registered by the tree population. More... | |
short int | GetDbhCode (int iSpecies, int iType) |
Gets the code for the "DBH" data member, which is registered by the tree population. More... | |
short int | GetDiam10Code (int iSpecies, int iType) |
Gets the code for the "Diam10" data member, which is registered by the tree population. More... | |
short int | GetCrownRadiusCode (int iSpecies, int iType) |
Gets the code for the "Crown Radius" data member, which is registered by the tree population. More... | |
short int | GetCrownDepthCode (int iSpecies, int iType) |
Gets the code for the "Crown Depth" data member, which is registered by the tree population. More... | |
short int | GetWhyDeadCode (int iSpecies) |
Gets the code for the "Why dead" snag data member, which is registered by the tree population. More... | |
short int | GetAgeCode (int iSpecies) |
Gets the code for the "Age" snag data member, which is registered by the tree population. More... | |
float | GetMinAdultDBH (int iSpecies) |
Gets the minimum adult DBH. More... | |
clAllometry * | GetAllometryObject () |
Gets the allometry object. More... | |
int | GetNumberOfSpecies () |
Gets the total number of species. More... | |
int | GetNumberOfTypes () |
Gets the total number of tree types (life history stages). More... | |
int | GetGridCellSize () |
Gets the tree population internal grid cell size (grids are square). More... | |
int | GetNumXCells () |
Gets the number of cells in the X direction for the tree population's internal tree organizational grid. More... | |
int | GetNumYCells () |
Gets the number of cells in the Y direction for the tree population's internal tree organizational grid. More... | |
bool | GetUsesSnags () |
Gets whether or not this run uses snags. More... | |
float | GetXPlotLength () |
Gets the length in the X direction of the tree's internal grid (should match the value received from the plot object). More... | |
float | GetYPlotLength () |
Gets the length in the Y direction of the tree's internal grid (should match the value received from the plot object). More... | |
float | GetMaxSeedlingHeight (int iSpecies) |
Gets the maximum possible seedling height for a species. More... | |
float | GetMinimumAdultHeight () |
Gets the minimum possible adult height. More... | |
float | GetNewSeedlingDiam10 () |
Gets the default new seedling diameter at 10 cm. More... | |
float | GetMaxSaplingHeight () |
Gets the max sapling height. More... | |
clTree * | GetShortestTreeInCell (int iX, int iY) |
Allows direct access to the tree hash table. More... | |
clTree * | GetTallestTreeInCell (int iX, int iY) |
Allows direct access to the tree hash table. More... | |
clTree * | GetShortestInCellHeightDiv (int iX, int iY, int iDiv) |
clTree * | GetTallestInCellHeightDiv (int iX, int iY, int iDiv) |
clTree * | GetFirstStump () |
Gets first stump in the stump linked list. More... | |
Public Member Functions inherited from clPopulationBase | |
virtual | ~clPopulationBase () |
Destructor. More... | |
clPopulationBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
Public Member Functions inherited from clWorkerBase | |
clWorkerBase (clSimManager *p_oSimManager) | |
Constructor. More... | |
virtual | ~clWorkerBase () |
Destructor. More... | |
std::string | GetName () |
Gets the object's namestring. More... | |
clSimManager * | GetSimManager () |
void | DoObjectSetup (xercesc::DOMDocument *p_oDoc, fileType iFileType) |
Triggers the setup process. More... | |
virtual void | EndOfRunCleanup () |
Performs any necessary cleanup operations at the end of a run. More... | |
Protected Member Functions | |
void | DataMemberRegistrations () |
Triggers the tree data member registration process for all behaviors. More... | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Performs setup. More... | |
void | TimestepCleanup () |
Performs end-of-timestep cleanup tasks. More... | |
void | GetPlotDimensions () |
Retrieves the plot dimensions. More... | |
void | SetupCalculations () |
Performs setup calculations. More... | |
void | CreateHashTable () |
Allocates memory for the hash table. More... | |
short int | RegisterDataMember (std::string sLabel, int iSpecies, int iType, short int **p_iNumTreeVals, std::string ***p_sLabels) |
Core function for registering new tree data members. More... | |
void | DoTreeDataStructureSetup () |
Queries all behaviors for data members that they wish to add to the tree's data structure. More... | |
void | ReadParameters (xercesc::DOMDocument *p_oDoc) |
Allocates memory and reads data from the parameter file into arrays. More... | |
void | CreateTreesFromInitialDensities (xercesc::DOMDocument *p_oDoc) |
Creates trees according to initial density information in an input file. More... | |
void | CreateTreesFromTreeMap (xercesc::DOMDocument *p_oDoc) |
Creates trees according to tree map information in an input file. More... | |
void | CreateTreesFromTextTreeMap (xercesc::DOMDocument *p_oDoc) |
Creates trees by reading in a text tree map, if such a map has been specified. More... | |
void | AddTreeToHashTable (clTree *p_oNewTree) |
Adds a tree to the hash table. More... | |
void | UpdateTreeInHashTable (clTree *p_oChangedTree) |
Updates a tree's position in the hash table. More... | |
void | RemoveTreeFromHashTable (clTree *p_oByeTree) |
Removes a tree from the hash table. More... | |
void | DeleteStumps () |
Deletes stumps from the stump linked list and sets the linked list pointer to NULL. More... | |
void | ChangeTreeType (clTree *p_oTree, enum iTreeType iNewType) |
Changes a tree's type (life history stage). More... | |
void | UpdateTree (clTree *p_oTree, short int iCode, int iValue) |
Updates an integer data member of a tree. More... | |
void | UpdateTree (clTree *p_oTree, short int iCode, float fValue, bool bUpdateNow, bool bUpdateAllometry) |
Updates a float data member of a tree. More... | |
void | UpdateTree (clTree *p_oTree, short int iCode, std::string sValue) |
Updates a char data member of a tree. More... | |
void | UpdateTree (clTree *p_oTree, short int iCode, bool bValue) |
Updates a bool data member of a tree. More... | |
Protected Member Functions inherited from clWorkerBase | |
void | AssembleFileCode (int iFileType, int iFileVersion, char *cCode) |
Creates the proper identifying filecode for an XML file. More... | |
Protected Attributes | |
struct clTreePopulation::stcOpenSearches * | mp_openSearches |
The linked list of open search requests. More... | |
double | m_fNewSeedlingDiam10 |
New diameter at 10 cm for seedlings. More... | |
float | m_fMinAdultHeight |
Shortest possible adult tree height, in meters. More... | |
float | m_fMaxSaplingHeight |
Maximum possible height a sapling can have, in meters. More... | |
double * | mp_fMaxSeedlingHeight |
Maximum possible seedling height, in meters. More... | |
double * | mp_fMinAdultDbh |
Minimum adult DBH, in cm, for each species. More... | |
float | m_fPlotLengthX |
Plot length in X dimension, in meters. More... | |
float | m_fPlotLengthY |
Plot length in Y dimension, in meters. More... | |
float * | mp_fSizeClasses |
Size classes for live trees. More... | |
int | m_iNumHeightDivs |
Number of height divisions in tree hash table. More... | |
int | m_iSizeHeightDivs |
size of height divisions in tree hash table, in meters. More... | |
int | m_iNumSpecies |
Number of species. More... | |
int | m_iNumTypes |
Number of tree types (life history stages). More... | |
int | m_iNumXCells |
Mumber of tree population internal grid cells in the X direction. More... | |
int | m_iNumYCells |
Mumber of tree population internal grid cells in the Y direction. More... | |
int | m_iNumSizeClasses |
Number of tree size classes defined. More... | |
int | m_iLengthGrids |
Length of internal grid cells, in meters. More... | |
bool | m_bDoUpdates |
Whether or not to sort the hash table when DoDataUpdates is called. More... | |
bool * | mp_bMakeStump |
Whether a harvested tree should be made into a stump, for each species. More... | |
bool | m_bMakeSnag |
Whether a dead adult should be made into a snag. More... | |
short int ** | mp_iNumTreeIntVals |
Number of tree integer data members that have been defined for this run. More... | |
short int ** | mp_iNumTreeFloatVals |
Number of tree float data members that have been defined for this run. More... | |
short int ** | mp_iNumTreeStringVals |
Number of tree string data members that have been defined for this run. More... | |
short int ** | mp_iNumTreeBoolVals |
Number of tree bool data members that have been defined for this run. More... | |
std::string *** | mp_sIntLabels |
List of tree integer data member labels. More... | |
std::string *** | mp_sFloatLabels |
List of tree float data member labels. More... | |
std::string *** | mp_sStringLabels |
List of tree string data member labels. More... | |
std::string *** | mp_sBoolLabels |
List of tree bool data member labels. More... | |
short int ** | mp_iXCode |
Codes for "X" tree data member. More... | |
short int ** | mp_iYCode |
Codes for "Y" tree data member. More... | |
short int ** | mp_iHeightCode |
Codes for "Height" tree data member. More... | |
short int ** | mp_iDiam10Code |
Codes for "Diam10" tree data member. More... | |
short int ** | mp_iDbhCode |
Codes for "DBH" tree data member. More... | |
short int ** | mp_iCrownRadCode |
Codes for "Crown Radius" tree data member. More... | |
short int ** | mp_iCrownDepthCode |
Codes for "Crown Depth" tree data member. More... | |
short int * | mp_iAgeCode |
Codes for "Age" snag tree data member. More... | |
short int * | mp_iWhyDeadCode |
Codes for "Why dead" snag tree data member. More... | |
speciesCodes * | mp_speciesCodes |
List of species codes and names. More... | |
clAllometry * | mp_oAllom |
Allometry object. More... | |
clTree **** | mp_oTreeTallest |
Hash table of tallest tree links. More... | |
clTree **** | mp_oTreeShortest |
Hash table of shortest tree links. More... | |
clTree * | mp_oStumps |
Linked list of stumps. More... | |
clGhostTreePopulation * | mp_oGhosts |
Link to the ghost population. More... | |
Protected Attributes inherited from clWorkerBase | |
std::string | m_sNameString |
If a behavior has registered a command line command with the sim manager, this allows it to be called. More... | |
clSimManager * | mp_oSimManager |
Pointer to the simulation manager object. More... | |
int * | mp_iAllowedFileTypes |
List of the input file types this object can handle. More... | |
int | m_iNumAllowedTypes |
Number of input file types this object can handle. More... | |
Private Member Functions | |
clTreePopulation (const clTreePopulation &oldPop) | |
Copy constructor. More... | |
Friends | |
class | clTreeSearch |
class | clTree |
class | clAllometry |
TREE POPULATION CLASS - Version 1.4.
The tree population class encapsulates all the types of trees and provides a common interface for accessing them. The trees are organized into a hash table. The trees are organized spatially in an internal grid and then by height within that grid. All seedlings, saplings, adults, and snags appear in the hash table. Stumps are organized separately since they have no height (if they are even used at all); seeds and woody debris currently don't exist.
When behavior objects operate on trees, they receive a pointer to the tree population in order to do so. Then they use the search method to get the trees they need.
Plot trees can only be created by the tree population class (if other objects want to create their own local trees for some reason, that's fine). Behaviors can ask the pop. to create seedlings (i.e. as a reproduction calculation). If it turns out to be necessary for other kinds of trees to be created then we can add those methods.
The population takes care of all organization and housekeeping skills related to trees. When a tree dies it tells the population so that the population can remove it. When a tree changes its height it tells the population so that the population can update its position in the hash table.
The hash table array holding the trees is based on grid cells of 8X8 m (no matter what the user has them set to), and the trees within each grid cell are organized by height. By far, the greatest number of searches that SORTIE has to do are distance and height searches (neighborhood searches) so the table is optimized for this. This class keeps some shortcut values calculated in order to handle other types of searches more quickly. The reason the grid is 8X8 m is because since 8 is a power of two, we can do very fast bitwise shifts instead of very slow division when we're doing grid cell calculations. (I leave it to the compiler to turn my divisions into shifts - makes the code easier to read.)
Copyright 2003 Charles D. Canham.
Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
November 12, 2012 - Chars became strings (LEM)
Tree life history stages, or tree type.
|
private |
Copy constructor.
Off limits! It's too much to try to copy all the trees, and too dangerous to allow two objects running around with pointers to the same trees.
clTreePopulation::~clTreePopulation | ( | ) |
Destructor.
clTreePopulation::clTreePopulation | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
|
protected |
Adds a tree to the hash table.
p_oNewTree | Tree to add to hash table. |
void clTreePopulation::BarebonesDataSetup | ( | xercesc::DOMDocument * | p_oDoc | ) |
Reads type and species info from the parameter file.
This function should be called before GetData. This is because behaviors need to validate against species and type in the CreateObjects phase.
p_oDoc | DOM tree of parsed input file. |
Changes a tree's type (life history stage).
This will change a tree's type and copy over all the applicable variables. If a variable has no counterpart in the new type, it will be discarded. Allometric values will not be recalculated (with the exception of the seedling to sapling transition, where the new dbh value will be calculated and assigned).
p_oTree | The tree whose type will be changed |
iNewType | The new tree type |
|
protected |
Allocates memory for the hash table.
GetPlotDimensions() must be called first.
clTree* clTreePopulation::CreateTree | ( | float | fX, |
float | fY, | ||
int | iSp, | ||
int | iType, | ||
float | fDiam | ||
) |
Creates a new tree and organizes it into the hash table.
If this is supposed to be a seedling, and the diam10 creates a height taller than 1.35 m, the tree becomes a sapling. If the dbh is larger than the min adult dbh and the type is given as sapling, the tree is created as an adult.
fX | X coordinate of the new tree |
fY | Y coordinate of the new tree |
iSp | Species number of the new tree |
iType | The type (life history stage) of the new tree |
fDiam | The diameter of the new tree. If this is a seedling, this is diam at 10 cm. For all others, this is dbh. If this is set to 0, a random diam10 is chosen. |
BAD_DATA | error if:
|
|
protected |
Creates trees according to initial density information in an input file.
If initial density information it is not present, no trees are created. This is not considered an error condition. In addition to as many DBH size classes as the user wants, this can also handle three height classes for seedling initial densities.
p_oDoc | DOM tree of parsed input file. |
|
protected |
Creates trees by reading in a text tree map, if such a map has been specified.
This type of tree map file is a tab-delimited text file, with the first row being column headers. The columns are in the following order: X, Y, Species (as a text string), Type (as a text string), Diam, and Height. If height is 0, the allometric equations will set it.
p_oDoc | DOM tree of parsed input file. |
BAD_FILE | if the file can't be found. BAD_DATA if coordinates, diameters, or heights are negative, or if the species or type is unrecognized. |
|
protected |
Creates trees according to tree map information in an input file.
If tree map information it is not present, no trees are created. This is not considered an error condition.
p_oDoc | DOM tree of parsed input file. |
BAD_DATA | error if the tree map data member codes do not match those already defined. |
|
protected |
Triggers the tree data member registration process for all behaviors.
|
protected |
Deletes stumps from the stump linked list and sets the linked list pointer to NULL.
|
virtual |
Determines if the hash table needs to be sorted by checking the bDoUpdates flag, and if it does, it sorts it.
Reimplemented from clPopulationBase.
|
protected |
Queries all behaviors for data members that they wish to add to the tree's data structure.
The data members to be added are only added for the species and types that the behavior works on. This will also check for any behaviors that work on stumps and snags. If any are found, the appropriate bucket in mp_bMakeStump is set to true or m_bMakeSnag is set to true, respectively.
The tree population also uses this opportunity to add its own tree data member registrations. It registers "Diam10" for seedlings and saplings; "DBH" for saplings, adults, stumps, and snags; "Height" for seedlings, saplings, adults, and snags; "Age" and "Why dead" for snags; and "X" and "Y" for seedlings, saplings, adults, stumps, and snags.
void clTreePopulation::EmptyHashTable | ( | ) |
Deletes all trees from the hash table without deleting the table itself.
clTreeSearch* clTreePopulation::Find | ( | std::string | sArgs | ) |
Acquires trees which meet certain criteria.
Any function needing to act on trees uses this function to find them. A clTreeSearch object is returned, and the trees can then be accessed repeatedly by calling the clTreeSearch object's NextTree() method. Stumps are not returned by this method. Use the GetFirstStump() method to access them directly.
To set up a search, a search string is passed to Find(). The string is formatted as follows: search term 1::search term 2:: ... search term n where the search terms are described below. Only those terms of interest are used; when a search term is ommitted, it is assumed that any value for that term is acceptable.
Valid terms:
Type and species may be combined or separate. Distance must be alone.
Example: Find("species=0,2,3::type=1") or Find("distance=10.5 FROM x=5.5,y=5.6::height=4.5")
If no trees are found as the result of a search, the NextTree() method of the returned treeSearch object returns NULL.
sArgs | String with query terms for the search. |
Error | if the query cannot be understood, such as an unrecognized argument or text that cannot be turned into a number. |
short int clTreePopulation::GetAgeCode | ( | int | iSpecies | ) |
Gets the code for the "Age" snag data member, which is registered by the tree population.
iSpecies | The species. |
Error | if given a bad species code. |
|
inline |
Gets the allometry object.
short int clTreePopulation::GetBoolDataCode | ( | std::string | sLabel, |
int | iSpecies, | ||
int | iType | ||
) |
Gets the data code for accessing a bool tree data member.
This code can be used for accessing its value through the tree's GetValue() and SetValue() functions. This function will not be responsible for duplicate labels.
sLabel | The data member's label. |
iSpecies | The species. |
iType | The tree type. |
An | error if an unrecognized species or type is passed. |
std::string clTreePopulation::GetBoolDataLabel | ( | short int | iCode, |
int | iSpecies, | ||
int | iType | ||
) |
Gets the label for a bool tree data member.
This function will not be responsible for duplicate labels.
iCode | The data member's label. |
iSpecies | The species. |
iType | The tree type. |
An | error if an unrecognized species or type is passed. |
short int clTreePopulation::GetCrownDepthCode | ( | int | iSpecies, |
int | iType | ||
) |
Gets the code for the "Crown Depth" data member, which is registered by the tree population.
iSpecies | The species. |
iType | The tree type. |
Error | if given bad species or type codes. |
short int clTreePopulation::GetCrownRadiusCode | ( | int | iSpecies, |
int | iType | ||
) |
Gets the code for the "Crown Radius" data member, which is registered by the tree population.
iSpecies | The species. |
iType | The tree type. |
Error | if given bad species or type codes. |
|
protectedvirtual |
Performs setup.
If the input file is a parameter file, this calls:
If the input file is a tree map or detailed output file, only the CreateTrees... functions are called.
p_oDoc | DOM tree of parsed input file. |
Implements clWorkerBase.
short int clTreePopulation::GetDbhCode | ( | int | iSpecies, |
int | iType | ||
) |
Gets the code for the "DBH" data member, which is registered by the tree population.
iSpecies | The species. |
iType | The tree type. |
Error | if given bad species or type codes. |
short int clTreePopulation::GetDiam10Code | ( | int | iSpecies, |
int | iType | ||
) |
Gets the code for the "Diam10" data member, which is registered by the tree population.
iSpecies | The species. |
iType | The tree type. |
Error | if given bad species or type codes. |
|
inline |
Gets first stump in the stump linked list.
short int clTreePopulation::GetFloatDataCode | ( | std::string | sLabel, |
int | iSpecies, | ||
int | iType | ||
) |
Gets the data code for accessing a float tree data member.
This code can be used for accessing its value through the tree's GetValue() and SetValue() functions. This function will not be responsible for duplicate labels.
sLabel | The data member's label. |
iSpecies | The species. |
iType | The tree type. |
An | error if an unrecognized species or type is passed. |
std::string clTreePopulation::GetFloatDataLabel | ( | short int | iCode, |
int | iSpecies, | ||
int | iType | ||
) |
Gets the label for a float tree data member.
This function will not be responsible for duplicate labels.
iCode | The data member's label. |
iSpecies | The species. |
iType | The tree type. |
An | error if an unrecognized species or type is passed. |
|
inline |
Gets the tree population internal grid cell size (grids are square).
short int clTreePopulation::GetHeightCode | ( | int | iSpecies, |
int | iType | ||
) |
Gets the code for the "Height" data member, which is registered by the tree population.
iSpecies | The species. |
iType | The tree type. |
Error | if given bad species or type codes. |
short int clTreePopulation::GetIntDataCode | ( | std::string | sLabel, |
int | iSpecies, | ||
int | iType | ||
) |
Gets the data code for accessing an integer tree data member.
This code can be used for accessing its value through the tree's GetValue() and SetValue() functions. This function will not be responsible for duplicate labels.
sLabel | The data member's label. |
iSpecies | The species. |
iType | The tree type. |
An | error if an unrecognized species or type is passed. |
std::string clTreePopulation::GetIntDataLabel | ( | short int | iCode, |
int | iSpecies, | ||
int | iType | ||
) |
Gets the label for an integer tree data member.
This function will not be responsible for duplicate labels.
iCode | The data member's label. |
iSpecies | The species. |
iType | The tree type. |
An | error if an unrecognized species or type is passed. |
|
inline |
Gets the max sapling height.
|
inline |
Gets the maximum possible seedling height for a species.
iSpecies | Species for which to get the maximum height. |
float clTreePopulation::GetMinAdultDBH | ( | int | iSpecies | ) |
Gets the minimum adult DBH.
iSpecies | Species for which to get the minimum adult DBH. |
Error | if the species isn't valid. |
|
inline |
Gets the minimum possible adult height.
|
inline |
Gets the default new seedling diameter at 10 cm.
|
inline |
Gets the total number of species.
|
inline |
Gets the total number of tree types (life history stages).
|
inline |
Gets the number of cells in the X direction for the tree population's internal tree organizational grid.
|
inline |
Gets the number of cells in the Y direction for the tree population's internal tree organizational grid.
|
protected |
Retrieves the plot dimensions.
modelErr | if the plot object cannot be found. |
float clTreePopulation::GetRandomDiam10Value | ( | float | fDiam10Seed = 0 | ) |
Gets a random diameter at 10 cm value for a seedling.
This function slightly randomizes the diameter at 10 cm value around a "seed" value.
fDiam10Seed | The "seed" value around which to randomize the new value. Optional. If no "seed" is passed, the new seedling diam10 value is used. |
|
inline |
clTree* clTreePopulation::GetShortestTreeInCell | ( | int | iX, |
int | iY | ||
) |
Allows direct access to the tree hash table.
iX | X cell number of tree population internal grid cell. |
iY | Y cell number of tree population internal grid cell. |
short int clTreePopulation::GetStringDataCode | ( | std::string | sLabel, |
int | iSpecies, | ||
int | iType | ||
) |
Gets the data code for accessing a string tree data member.
This code can be used for accessing its value through the tree's GetValue() and SetValue() functions. This function will not be responsible for duplicate labels.
sLabel | The data member's label. |
iSpecies | The species. |
iType | The tree type. |
An | error if an unrecognized species or type is passed. |
std::string clTreePopulation::GetStringDataLabel | ( | short int | iCode, |
int | iSpecies, | ||
int | iType | ||
) |
Gets the label for a string tree data member.
This function will not be responsible for duplicate labels.
iCode | The data member's label. |
iSpecies | The species. |
iType | The tree type. |
An | error if an unrecognized species or type is passed. |
|
inline |
clTree* clTreePopulation::GetTallestTreeInCell | ( | int | iX, |
int | iY | ||
) |
Allows direct access to the tree hash table.
iX | X cell number of tree population internal grid cell. |
iY | Y cell number of tree population internal grid cell. |
|
inline |
Gets whether or not this run uses snags.
short int clTreePopulation::GetWhyDeadCode | ( | int | iSpecies | ) |
Gets the code for the "Why dead" snag data member, which is registered by the tree population.
iSpecies | The species. |
Error | if given a bad species code. |
short int clTreePopulation::GetXCode | ( | int | iSpecies, |
int | iType | ||
) |
Gets the code for the "X" data member, which is registered by the tree population.
iSpecies | The species. |
iType | The tree type. |
Error | if given bad species or type codes. |
|
inline |
Gets the length in the X direction of the tree's internal grid (should match the value received from the plot object).
short int clTreePopulation::GetYCode | ( | int | iSpecies, |
int | iType | ||
) |
Gets the code for the "Y" data member, which is registered by the tree population.
iSpecies | The species. |
iType | The tree type. |
Error | if given bad species or type codes. |
|
inline |
Gets the length in the Y direction of the tree's internal grid (should match the value received from the plot object).
Kills a tree.
What happens to the tree depends on what kind it is, why it died, and what behaviors are set up.
No matter what the reason, a copy of the tree is transferred to the ghost tree population.
p_deadTree | Tree to delete. |
iReason | Why the tree is being deleted. This should be an enum from iWhyDead. |
|
protected |
Allocates memory and reads data from the parameter file into arrays.
short int clTreePopulation::RegisterBool | ( | std::string | sLabel, |
int | iSpecies, | ||
int | iType | ||
) |
Adds a boolean data member to the tree data structure.
A behavior must only register as many data members as it indicated that it wanted to add in its new data member variables. This does not check to make sure that there is not already a variable registered with that name.
sLabel | The name of the new data member - keep it short. |
iSpecies | Species to register the new variable for |
iType | Tree type to register the new variable for |
ILLEGAL_OP | error if there is no more space for new data members. |
short int clTreePopulation::RegisterChar | ( | std::string | sLabel, |
int | iSpecies, | ||
int | iType | ||
) |
Adds a char data member to the tree data structure.
A behavior must only register as many data members as it indicated that it wanted to add in its new data member variables. This does not check to make sure that there is not already a variable registered with that name.
sLabel | The name of the new data member - keep it short. |
iSpecies | Species to register the new variable for |
iType | Tree type to register the new variable for |
ILLEGAL_OP | error if there is no more space for new data members. |
|
protected |
Core function for registering new tree data members.
sLabel | Name of the new data member. |
iSpecies | Species for which to register the new data member |
iType | Tree type (life history stage) for which to register the new data member |
p_iNumTreeVals | Pointer to the correct mp_iNumTree[x]Vals array |
p_sLabels | Pointer to the correct mp_s[x]Labels array |
BAD_DATA | or ILLEGAL_OP error if the registration was unsuccessful. |
short int clTreePopulation::RegisterFloat | ( | std::string | sLabel, |
int | iSpecies, | ||
int | iType | ||
) |
Adds a float data member to the tree data structure.
A behavior must only register as many data members as it indicated that it wanted to add in its new data member variables. This does not check to make sure that there is not already a variable registered with that name.
sLabel | The name of the new data member - keep it short. |
iSpecies | Species to register the new variable for |
iType | Tree type to register the new variable for |
ILLEGAL_OP | error if there is no more space for new data members. |
short int clTreePopulation::RegisterInt | ( | std::string | sLabel, |
int | iSpecies, | ||
int | iType | ||
) |
Adds an integer data member to the tree data structure.
A behavior must only register as many data members as it indicated that it wanted to add in its new data member variables. This does not check to make sure that there is not already a variable registered with that name.
sLabel | The name of the new data member - keep it short. |
iSpecies | Species to register the new variable for |
iType | Tree type to register the new variable for |
ILLEGAL_OP | error if there is no more space for new data members. |
|
protected |
Removes a tree from the hash table.
The gap it left in the linked list is closed and the tallest/shortest markers are updated as necessary.
p_oByeTree | Tree to remove from hash table. |
|
protected |
Performs setup calculations.
This function creates the clAllometry object, and calculates m_fMinAdultHeight and m_fMaxSaplingHeight.
void clTreePopulation::SortHashTable | ( | ) |
Sorts the hash table by height.
This does a complete sort of the entire hash table using the Insertion Sort algorithm, which is good for almost-sorted datasets, which the hash table probably will be. This function will be used to sort the hash table if a behavior has been updating trees and has let them get out of order.
|
protectedvirtual |
Performs end-of-timestep cleanup tasks.
Reimplemented from clWorkerBase.
std::string clTreePopulation::TranslateSpeciesCodeToName | ( | int | iSpecies | ) |
Translates a species code into its name string.
iSpecies | Species code to translate. |
short int clTreePopulation::TranslateSpeciesNameToCode | ( | std::string | sSpeciesName | ) |
Translates a species name string into its code.
sSpeciesName | Species name to translate. |
|
protected |
Updates an integer data member of a tree.
If a tree receives a request to be updated, it passes it off to the tree population using this function.
p_oTree | The tree to be updated. |
iCode | The data member code - as passed to the tree. |
iValue | The new value - as passed to the tree. |
modelErr | if the code is invalid. |
|
protected |
Updates a float data member of a tree.
If a tree receives a request to be updated, it passes it off to the tree population using this function. The default is for this function to update the other parameters based on allometric relationships (for instance, if DBH is changed, height will automatically be updated too). If the update causes a tree move to a new life history stage, it will automatically be transitioned. So, if setting a value of either diam10 or height on a seedling causes it to be greater than the seedling height cutoff, the tree will become a sapling and all of its allometric parameters will be recalculated to match the value that was set.
You can override automatic allometry updating. If you do that, be aware that none of the other tree data members will be updated and you will need to do that yourself. (THERE IS ONE EXCEPTION. For saplings, DBH and diam10 are always kept in sync.) Be especially careful when there is a possibility of tree type transition. If the tree is a seedling and you set its height to a value greater than the height cutoff, it will transition, but its diam10 will not change. If the tree is a sapling and you set its DBH to be greater than the minimum adult DBH, it will transition. The setting of any other value will not cause transition. So, if you give a seedling a diam10 value that would, under automatic allometry updating, give it a height greater than the cutoff and cause it to become a sapling, the seedling will not become a sapling unless you explicitly set the height too.
p_oTree | The tree to be updated. |
iCode | The data member code - as passed to the tree. |
fValue | The new value - as passed to the tree. |
bUpdateNow | Whether or not the tree's hash table needs to be updated right away. If not, the hash table will be updated all at once later. |
bUpdateAllometry | If the change involves allometric changes, whether or not to automatically update the tree's other dimensions. For example, if this is set to false and you are updating a DBH value, tree height will not automatically be re-calculated. |
modelErr | if the code is invalid, or if an X or Y value is trying to be changed. |
|
protected |
Updates a char data member of a tree.
If a tree receives a request to be updated, it passes it off to the tree population using this function.
p_oTree | The tree to be updated. |
iCode | The data member code - as passed to the tree. |
sValue | The new value - as passed to the tree. |
modelErr | if the code is invalid. |
|
protected |
Updates a bool data member of a tree.
If a tree receives a request to be updated, it passes it off to the tree population using this function.
p_oTree | The tree to be updated. |
iCode | The data member code - as passed to the tree. |
bValue | The new value - as passed to the tree. |
modelErr | if the code is invalid. |
|
inlineprotected |
Updates a tree's position in the hash table.
p_oChangedTree Tree whose position is to be updated.
|
friend |
|
friend |
|
friend |
|
protected |
Whether or not to sort the hash table when DoDataUpdates is called.
|
protected |
Whether a dead adult should be made into a snag.
|
protected |
Maximum possible height a sapling can have, in meters.
In practice this number is actually a smidge taller than the tallest height.
|
protected |
Shortest possible adult tree height, in meters.
|
protected |
New diameter at 10 cm for seedlings.
Actual values are randomized around this value. From the parameter file.
|
protected |
Plot length in X dimension, in meters.
|
protected |
Plot length in Y dimension, in meters.
|
protected |
Length of internal grid cells, in meters.
Make this always a power of 2!
|
protected |
Number of height divisions in tree hash table.
|
protected |
Number of tree size classes defined.
|
protected |
Number of species.
From parameter file.
|
protected |
Number of tree types (life history stages).
|
protected |
Mumber of tree population internal grid cells in the X direction.
|
protected |
Mumber of tree population internal grid cells in the Y direction.
|
protected |
size of height divisions in tree hash table, in meters.
|
protected |
Whether a harvested tree should be made into a stump, for each species.
|
protected |
Maximum possible seedling height, in meters.
|
protected |
Minimum adult DBH, in cm, for each species.
From parameter file.
|
protected |
Size classes for live trees.
Number of size classes is user-settable. The value in each bin of the array is the upper limit in cm of the dbh for that class. There can also be a size class each for seeds and seedlings.
|
protected |
Codes for "Age" snag tree data member.
Array size is number of species.
|
protected |
Codes for "Crown Depth" tree data member.
Array size is number of species by number of types.
|
protected |
Codes for "Crown Radius" tree data member.
Array size is number of species by number of types.
|
protected |
Codes for "DBH" tree data member.
Array size is number of species by number of types.
|
protected |
Codes for "Diam10" tree data member.
Array size is number of species by number of types.
|
protected |
Codes for "Height" tree data member.
Array size is number of species by number of types.
|
protected |
Number of tree bool data members that have been defined for this run.
Array size is number of species by number of types.
|
protected |
Number of tree float data members that have been defined for this run.
Array size is number of species by number of types.
|
protected |
Number of tree integer data members that have been defined for this run.
Array size is number of species by number of types.
|
protected |
Number of tree string data members that have been defined for this run.
Array size is number of species by number of types.
|
protected |
Codes for "Why dead" snag tree data member.
Array size is number of species.
|
protected |
Codes for "X" tree data member.
Array size is number of species by number of types.
|
protected |
Codes for "Y" tree data member.
Array size is number of species by number of types.
|
protected |
Allometry object.
|
protected |
Link to the ghost population.
|
protected |
The linked list of open search requests.
The first record is always a dummy record.
|
protected |
Linked list of stumps.
Not sorted in any way.
|
protected |
Hash table of shortest tree links.
Array size is number of X grid cells by number of Y grid cells by number of height divisions. For instance, [2][3] is the grid cell which runs from X = 16-23 m and Y = 24-31 m. The tree pointer starts at the shortest, and the tree's "taller" pointer can be used to run downwards through all the trees in the cell. Tree taller pointers run across height divisions.
|
protected |
Hash table of tallest tree links.
Array size is number of X grid cells by number of Y grid cells by number of height divisions. For instance, [2][3] is the grid cell which runs from X = 16-23 m and Y = 24-31 m. The tree pointer starts at the tallest, and the tree's "shorter" pointer can be used to run downwards through all the trees in the cell. Tree shorter pointers run across height divisions.
|
protected |
List of tree bool data member labels.
Array size is number of species by number of types by number of integer data members. The code for a data member equals the third array index.
|
protected |
List of tree float data member labels.
Array size is number of species by number of types by number of integer data members. The code for a data member equals the third array index.
|
protected |
List of tree integer data member labels.
Array size is number of species by number of types by number of integer data members. The code for a data member equals the third array index.
|
protected |
List of species codes and names.
|
protected |
List of tree string data member labels.
Array size is number of species by number of types by number of integer data members. The code for a data member equals the third array index.