#include <TreeSearch.h>
Public Member Functions | |
clTree * | NextTree () |
Returns the next tree matching this search's criteria. | |
void | StartOver () |
Starts the tree search over. | |
clTreeSearch (clTreePopulation *p_oTreePop, clPlot *p_oPlot) | |
Constructor. | |
~clTreeSearch () | |
Destructor. | |
Protected Member Functions | |
clTree * | FindNextDHTree () |
Optimized for finding trees where only distance and height are specified. | |
clTree * | FindNextTSTree () |
Optimized for finding trees where only type and species are specified. | |
clTree * | FindNextTTree () |
Optimized for finding trees where only type is specified. | |
clTree * | FindNextAllTree () |
Sets up the object to find all trees. | |
clTree * | FindFirstDHTree () |
Finds the first tree in a distance/height search. | |
clTree * | FindFirstTSTree () |
Finds the first tree in a type/species search. | |
clTree * | FindFirstTTree () |
Finds the first tree in a type search. | |
clTree * | FindFirstAllTree () |
Finds the first tree in an "all" search. | |
void | Setup () |
Does final data validation and gets things ready for the NextTree() methods. | |
Protected Attributes | |
clTreePopulation * | mp_oTreePop |
Pointer to tree population. | |
clPlot * | mp_oPlot |
Pointer to plot object. | |
clTree *(clTreeSearch::* | function )() |
Function pointer for the appropriate "FindNext..." function. | |
clTree * | mp_oCurrentTree |
The tree that the search is currently on. | |
bool | m_bDistanceHeightUsed |
Whether or not this is a distance and height search. | |
bool | m_bTypeUsed |
Whether or not this is searching by tree type. | |
bool | m_bSpeciesUsed |
Whether or not this is searching by species. | |
bool | m_bAllUsed |
Whether or not this should simply return all - trumps everything else. | |
int | m_iCurrentXGrid |
Current X grid number in an "all" search. | |
int | m_iCurrentYGrid |
Current Y grid number in an "all" search. | |
float | m_fFromX |
X coordinate of search point in a distance/height search. | |
float | m_fFromY |
Y coordinate of search point in a distance/height search. | |
float | m_fDistanceCutoff |
Target maximum distance, in meters, in a distance/height seach. | |
float | m_fHeightCutoff |
Target minimum height, in meters, in a distance/height search - can be zero. | |
short int | m_iMaxX |
Maximum X grid cell number to search in a distance/height search. | |
short int | m_iMaxY |
Maximum Y grid cell number to search in a distance/height search. | |
short int | m_iMinX |
Minimum X grid cell number to search in a distance/height search. | |
short int | m_iMinY |
Minimum Y grid cell number to search in a distance/height search. | |
short int | m_iHomeX |
X grid cell of target point in a distance/height search. | |
short int | m_iHomeY |
Y grid cell of target point in a distance/height search. | |
bool | m_bCellOnEdge |
Whether the current grid cell being searched is on the edge of the circle search radius. | |
short int | m_iWhatTypes |
Which types to search for in a search involving type. | |
short int | m_iStartHeightDiv |
Starting height division to search in tree hash table in a type search. | |
short int | m_iEndHeightDiv |
Ending height division to search in tree hash table in a type search. | |
bool | m_bSeeds |
Whether seeds are being searched for in a type search. | |
bool | m_bSeedlings |
Whether seedlings are being searched for in a type search. | |
bool | m_bSaplings |
Whether saplings are being searched for in a type search. | |
bool | m_bAdults |
Whether adults are being searched for in a type search. | |
bool | m_bSnags |
Whether snags are being searched for in a type search. | |
bool | m_bWoody_Debris |
Whether woody debris is being searched for in a type search. | |
bool * | mp_bWhatSpecies |
Which species to search for in a search involving species. | |
Friends | |
class | clTreePopulation |
class | clTestTreePopulation |
For testing purposes. |
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.
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.
clTree* clTreeSearch::FindFirstAllTree | ( | ) | [protected] |
Finds the first tree in an "all" search.
Then sets up the current tree pointer and the current grid numbers.
clTree* clTreeSearch::FindFirstDHTree | ( | ) | [protected] |
Finds the first tree in a distance/height search.
Then sets up the current tree pointer and the current grid numbers.
clTree* clTreeSearch::FindFirstTSTree | ( | ) | [protected] |
Finds the first tree in a type/species search.
Then sets up the current tree pointer and the current grid numbers.
clTree* clTreeSearch::FindFirstTTree | ( | ) | [protected] |
Finds the first tree in a type search.
Then sets up the current tree pointer and the current grid numbers.
clTree* clTreeSearch::FindNextAllTree | ( | ) | [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.
clTree* clTreeSearch::FindNextDHTree | ( | ) | [protected] |
Optimized for finding trees where only distance and height are specified.
clTree* clTreeSearch::FindNextTSTree | ( | ) | [protected] |
Optimized for finding trees where only type and species are specified.
clTree* clTreeSearch::FindNextTTree | ( | ) | [protected] |
Optimized for finding trees where only type is specified.
clTree* clTreeSearch::NextTree | ( | ) | [inline] |
Returns the next tree matching this search's criteria.
NextTree just calls the appropriate FindNext... function.
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.)
bool clTreeSearch::m_bCellOnEdge [protected] |
Whether the current grid cell being searched is on the edge of the circle search radius.
If false, we can to skip some distance calculations.
short int clTreeSearch::m_iWhatTypes [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.
bool* clTreeSearch::mp_bWhatSpecies [protected] |
Which species to search for in a search involving species.
This array is sized # species.