SORTIE Core C++ Documentation
|
Tree Search Class - Version 1.1 This class controls the feeding of individual trees to behavior objects. More...
#include <TreeSearch.h>
Public Member Functions | |
int | GetStartHeightDiv () |
Gets starting height division to search in tree hash table in a type search. More... | |
int | GetEndHeightDiv () |
Gets ending height division to search in tree hash table in a type search. More... | |
clTree * | NextTree () |
Returns the next tree matching this search's criteria. More... | |
void | StartOver () |
Starts the tree search over. More... | |
clTreeSearch (clTreePopulation *p_oTreePop, clPlot *p_oPlot) | |
Constructor. More... | |
~clTreeSearch () | |
Destructor. More... | |
Protected Member Functions | |
clTree * | FindNextDHTree () |
Optimized for finding trees where only distance and height are specified. More... | |
clTree * | FindNextTSTree () |
Optimized for finding trees where only type and species are specified. More... | |
clTree * | FindNextTTree () |
Optimized for finding trees where only type is specified. More... | |
clTree * | FindNextAllTree () |
Sets up the object to find all trees. More... | |
clTree * | FindFirstDHTree () |
Finds the first tree in a distance/height search. More... | |
clTree * | FindFirstTSTree () |
Finds the first tree in a type/species search. More... | |
clTree * | FindFirstTTree () |
Finds the first tree in a type search. More... | |
clTree * | FindFirstAllTree () |
Finds the first tree in an "all" search. More... | |
void | GetMinMaxX (const int &iY, const int &iGrLen) |
For distance-height searches, gets the min and max X grid cells for a given Y grid cell. More... | |
void | Setup () |
Does final data validation and gets things ready for the NextTree() methods. More... | |
Protected Attributes | |
clTreePopulation * | mp_oTreePop |
Pointer to tree population. More... | |
clPlot * | mp_oPlot |
Pointer to plot object. More... | |
clTree *(clTreeSearch::* | function )() |
Function pointer for the appropriate "FindNext..." function. More... | |
clTree * | mp_oCurrentTree |
The tree that the search is currently on. More... | |
bool | m_bDistanceHeightUsed |
Whether or not this is a distance and height search. More... | |
bool | m_bTypeUsed |
Whether or not this is searching by tree type. More... | |
bool | m_bSpeciesUsed |
Whether or not this is searching by species. More... | |
bool | m_bAllUsed |
Whether or not this should simply return all - trumps everything else. More... | |
int | m_iCurrentXGrid |
Current X grid number in an "all" search. More... | |
int | m_iCurrentYGrid |
Current Y grid number in an "all" search. More... | |
float | m_fFromX |
X coordinate of search point in a distance/height search. More... | |
float | m_fFromY |
Y coordinate of search point in a distance/height search. More... | |
float | m_fDistanceCutoff |
Target maximum distance, in meters, in a distance/height seach. More... | |
float | m_fHeightCutoff |
Target minimum height, in meters, in a distance/height search - can be zero. More... | |
short int | m_iMaxX |
Maximum X grid cell number to search in a distance/height search. More... | |
short int | m_iMaxY |
Maximum Y grid cell number to search in a distance/height search. More... | |
short int | m_iMinX |
Minimum X grid cell number to search in a distance/height search. More... | |
short int | m_iMinY |
Minimum Y grid cell number to search in a distance/height search. More... | |
short int | m_iHomeX |
X grid cell of target point in a distance/height search. More... | |
short int | m_iHomeY |
Y grid cell of target point in a distance/height search. More... | |
short int | m_iWhatTypes |
Which types to search for in a search involving type. More... | |
short int | m_iStartHeightDiv |
Starting height division to search in tree hash table in a type search. More... | |
short int | m_iEndHeightDiv |
Ending height division to search in tree hash table in a type search. More... | |
bool | m_bSeeds |
Whether seeds are being searched for in a type search. More... | |
bool | m_bSeedlings |
Whether seedlings are being searched for in a type search. More... | |
bool | m_bSaplings |
Whether saplings are being searched for in a type search. More... | |
bool | m_bAdults |
Whether adults are being searched for in a type search. More... | |
bool | m_bSnags |
Whether snags are being searched for in a type search. More... | |
bool | m_bWoody_Debris |
Whether woody debris is being searched for in a type search. More... | |
bool * | mp_bWhatSpecies |
Which species to search for in a search involving species. More... | |
Friends | |
class | clTreePopulation |
class | clTestTreePopulation |
For testing purposes. More... | |
Tree Search Class - Version 1.1 This class controls the feeding of individual trees to behavior objects.
For each request for a population to return a set of trees, a treeSearch object will be created. It will keep the required search attributes and control the tree flow.
When a clTreeSearch object is returned as a result of a query to a clTreePopulation object, use NextTree() (including for the first tree) to return trees until NextTree() returns NULL, indicating the end of the list.
A clTreeSearch object acts like a simultaneous placeholder and filter in the hash table. It keeps its place and, when NextTree() is called, sifts through until it finds the next tree meeting the appropriate criteria.
The clTreeSearch class and the clTreePopulation class are friends of each other. This lets them access each other's methods and data, which is importantvbecause the tree searching code lives in the clTreeSearch object but accesses trees in the clTreePopulation object.
Requirements for a successful search:
Copyright 2003 Charles D. Canham.
Edit history:
--------------—
April 28, 2004 - Submitted as beta (LEM)
March 3, 2005 - Changed species from bit-shifting int to bool array (LEM)
August 14, 2007 - Decided to skip edge testing for distance-height searches. It makes sense in theory but most searches are 10 meters or less. Plus there's a bug - short end cells are treated as full-size and may lead to their regular-sized neighbors being skipped. (LEM)
clTreeSearch::clTreeSearch | ( | clTreePopulation * | p_oTreePop, |
clPlot * | p_oPlot | ||
) |
Constructor.
The constructor initializes variables and sets up the tree results linked list.
In setting up the linked list, it makes the initial dummy record and sets mp_currentTree to that record. This makes sure that even if no trees are returned or there are errors thrown during searching, NextTree correctly returns NULL to the object that originally requested the search.
p_oTreePop | Pointer to the tree population object |
p_oPlot | Pointer to the plot object |
clTreeSearch::~clTreeSearch | ( | ) |
Destructor.
Frees memory.
|
protected |
Finds the first tree in an "all" search.
Then sets up the current tree pointer and the current grid numbers.
|
protected |
Finds the first tree in a distance/height search.
Then sets up the current tree pointer and the current grid numbers.
|
protected |
Finds the first tree in a type/species search.
Then sets up the current tree pointer and the current grid numbers.
|
protected |
Finds the first tree in a type search.
Then sets up the current tree pointer and the current grid numbers.
|
protected |
Sets up the object to find all trees.
Finds the first one and sets mp_gridList to hold the grid cell the search is traversing so it can traverse on the fly when requested.
|
protected |
Optimized for finding trees where only distance and height are specified.
|
protected |
Optimized for finding trees where only type and species are specified.
|
protected |
Optimized for finding trees where only type is specified.
|
inline |
Gets ending height division to search in tree hash table in a type search.
|
protected |
For distance-height searches, gets the min and max X grid cells for a given Y grid cell.
We search a circle, and we know XY of center, and Y of point on edge of circle - we can solve for X as X2 = X1 - square root(distance^2 - (Y1 - Y2)^2). The min and max values are set in m_iMinX and m_iMaxX, uncorrected for torus.
iY | The Y grid cell, uncorrected for torus. |
iGrLen | Grid length |
|
inline |
Gets starting height division to search in tree hash table in a type search.
|
inline |
Returns the next tree matching this search's criteria.
NextTree just calls the appropriate FindNext... function.
|
protected |
Does final data validation and gets things ready for the NextTree() methods.
void clTreeSearch::StartOver | ( | ) |
Starts the tree search over.
After this is called, the next call to NextTree() will return the first tree, and the whole list can be traversed again. (This does NOT trigger a new search.)
|
friend |
For testing purposes.
|
friend |
|
protected |
Function pointer for the appropriate "FindNext..." function.
|
protected |
Whether adults are being searched for in a type search.
|
protected |
Whether or not this should simply return all - trumps everything else.
|
protected |
Whether or not this is a distance and height search.
|
protected |
Whether saplings are being searched for in a type search.
|
protected |
Whether seedlings are being searched for in a type search.
|
protected |
Whether seeds are being searched for in a type search.
|
protected |
Whether snags are being searched for in a type search.
|
protected |
Whether or not this is searching by species.
|
protected |
Whether or not this is searching by tree type.
|
protected |
Whether woody debris is being searched for in a type search.
|
protected |
Target maximum distance, in meters, in a distance/height seach.
|
protected |
X coordinate of search point in a distance/height search.
|
protected |
Y coordinate of search point in a distance/height search.
|
protected |
Target minimum height, in meters, in a distance/height search - can be zero.
|
protected |
Current X grid number in an "all" search.
|
protected |
Current Y grid number in an "all" search.
|
protected |
Ending height division to search in tree hash table in a type search.
|
protected |
X grid cell of target point in a distance/height search.
|
protected |
Y grid cell of target point in a distance/height search.
|
protected |
Maximum X grid cell number to search in a distance/height search.
|
protected |
Maximum Y grid cell number to search in a distance/height search.
|
protected |
Minimum X grid cell number to search in a distance/height search.
|
protected |
Minimum Y grid cell number to search in a distance/height search.
|
protected |
Starting height division to search in tree hash table in a type search.
|
protected |
Which types to search for in a search involving type.
The types are indicated by flipped bits in this variable. From right to left the bits are seedling, sapling, adult. More in the header file.
|
protected |
Which species to search for in a search involving species.
This array is sized # species.
|
protected |
The tree that the search is currently on.
|
protected |
Pointer to plot object.
|
protected |
Pointer to tree population.