SORTIE Core C++ Documentation
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
clTreeSearch Class Reference

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...
 
clTreeNextTree ()
 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

clTreeFindNextDHTree ()
 Optimized for finding trees where only distance and height are specified. More...
 
clTreeFindNextTSTree ()
 Optimized for finding trees where only type and species are specified. More...
 
clTreeFindNextTTree ()
 Optimized for finding trees where only type is specified. More...
 
clTreeFindNextAllTree ()
 Sets up the object to find all trees. More...
 
clTreeFindFirstDHTree ()
 Finds the first tree in a distance/height search. More...
 
clTreeFindFirstTSTree ()
 Finds the first tree in a type/species search. More...
 
clTreeFindFirstTTree ()
 Finds the first tree in a type search. More...
 
clTreeFindFirstAllTree ()
 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

clTreePopulationmp_oTreePop
 Pointer to tree population. More...
 
clPlotmp_oPlot
 Pointer to plot object. More...
 
clTree *(clTreeSearch::* function )()
 Function pointer for the appropriate "FindNext..." function. More...
 
clTreemp_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...
 

Detailed Description

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.

Author
Lora E. Murphy


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)

Constructor & Destructor Documentation

◆ clTreeSearch()

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.

Parameters
p_oTreePopPointer to the tree population object
p_oPlotPointer to the plot object

◆ ~clTreeSearch()

clTreeSearch::~clTreeSearch ( )

Destructor.

Frees memory.

Member Function Documentation

◆ FindFirstAllTree()

clTree* clTreeSearch::FindFirstAllTree ( )
protected

Finds the first tree in an "all" search.

Then sets up the current tree pointer and the current grid numbers.

Returns
The first tree in the search, or NULL if no trees match.

◆ FindFirstDHTree()

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.

Returns
The first tree in the search, or NULL if no trees match.

◆ FindFirstTSTree()

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.

Returns
The first tree in the search, or NULL if no trees match.

◆ FindFirstTTree()

clTree* clTreeSearch::FindFirstTTree ( )
protected

Finds the first tree in a type search.

Then sets up the current tree pointer and the current grid numbers.

Returns
The first tree in the search, or NULL if no trees match.

◆ FindNextAllTree()

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.

Returns
The next tree in the search, or NULL if all trees have been found.

◆ FindNextDHTree()

clTree* clTreeSearch::FindNextDHTree ( )
protected

Optimized for finding trees where only distance and height are specified.

Returns
The next tree in the search, or NULL if all trees have been found.

◆ FindNextTSTree()

clTree* clTreeSearch::FindNextTSTree ( )
protected

Optimized for finding trees where only type and species are specified.

Returns
The next tree in the search, or NULL if all trees have been found.

◆ FindNextTTree()

clTree* clTreeSearch::FindNextTTree ( )
protected

Optimized for finding trees where only type is specified.

Returns
The next tree in the search, or NULL if all trees have been found.

◆ GetEndHeightDiv()

int clTreeSearch::GetEndHeightDiv ( )
inline

Gets ending height division to search in tree hash table in a type search.

Returns
Ending height division to search in tree hash table in a type search.

◆ GetMinMaxX()

void clTreeSearch::GetMinMaxX ( const int &  iY,
const int &  iGrLen 
)
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.

Parameters
iYThe Y grid cell, uncorrected for torus.
iGrLenGrid length

◆ GetStartHeightDiv()

int clTreeSearch::GetStartHeightDiv ( )
inline

Gets starting height division to search in tree hash table in a type search.

Returns
Starting height division to search in tree hash table in a type search.

◆ NextTree()

clTree* clTreeSearch::NextTree ( )
inline

Returns the next tree matching this search's criteria.

NextTree just calls the appropriate FindNext... function.

◆ Setup()

void clTreeSearch::Setup ( )
protected

Does final data validation and gets things ready for the NextTree() methods.

◆ StartOver()

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.)

Friends And Related Function Documentation

◆ clTestTreePopulation

friend class clTestTreePopulation
friend

For testing purposes.

◆ clTreePopulation

friend class clTreePopulation
friend

Member Data Documentation

◆ function

clTree*(clTreeSearch::* clTreeSearch::function) ()
protected

Function pointer for the appropriate "FindNext..." function.

◆ m_bAdults

bool clTreeSearch::m_bAdults
protected

Whether adults are being searched for in a type search.

◆ m_bAllUsed

bool clTreeSearch::m_bAllUsed
protected

Whether or not this should simply return all - trumps everything else.

◆ m_bDistanceHeightUsed

bool clTreeSearch::m_bDistanceHeightUsed
protected

Whether or not this is a distance and height search.

◆ m_bSaplings

bool clTreeSearch::m_bSaplings
protected

Whether saplings are being searched for in a type search.

◆ m_bSeedlings

bool clTreeSearch::m_bSeedlings
protected

Whether seedlings are being searched for in a type search.

◆ m_bSeeds

bool clTreeSearch::m_bSeeds
protected

Whether seeds are being searched for in a type search.

◆ m_bSnags

bool clTreeSearch::m_bSnags
protected

Whether snags are being searched for in a type search.

◆ m_bSpeciesUsed

bool clTreeSearch::m_bSpeciesUsed
protected

Whether or not this is searching by species.

◆ m_bTypeUsed

bool clTreeSearch::m_bTypeUsed
protected

Whether or not this is searching by tree type.

◆ m_bWoody_Debris

bool clTreeSearch::m_bWoody_Debris
protected

Whether woody debris is being searched for in a type search.

◆ m_fDistanceCutoff

float clTreeSearch::m_fDistanceCutoff
protected

Target maximum distance, in meters, in a distance/height seach.

◆ m_fFromX

float clTreeSearch::m_fFromX
protected

X coordinate of search point in a distance/height search.

◆ m_fFromY

float clTreeSearch::m_fFromY
protected

Y coordinate of search point in a distance/height search.

◆ m_fHeightCutoff

float clTreeSearch::m_fHeightCutoff
protected

Target minimum height, in meters, in a distance/height search - can be zero.

◆ m_iCurrentXGrid

int clTreeSearch::m_iCurrentXGrid
protected

Current X grid number in an "all" search.

◆ m_iCurrentYGrid

int clTreeSearch::m_iCurrentYGrid
protected

Current Y grid number in an "all" search.

◆ m_iEndHeightDiv

short int clTreeSearch::m_iEndHeightDiv
protected

Ending height division to search in tree hash table in a type search.

◆ m_iHomeX

short int clTreeSearch::m_iHomeX
protected

X grid cell of target point in a distance/height search.

◆ m_iHomeY

short int clTreeSearch::m_iHomeY
protected

Y grid cell of target point in a distance/height search.

◆ m_iMaxX

short int clTreeSearch::m_iMaxX
protected

Maximum X grid cell number to search in a distance/height search.

◆ m_iMaxY

short int clTreeSearch::m_iMaxY
protected

Maximum Y grid cell number to search in a distance/height search.

◆ m_iMinX

short int clTreeSearch::m_iMinX
protected

Minimum X grid cell number to search in a distance/height search.

◆ m_iMinY

short int clTreeSearch::m_iMinY
protected

Minimum Y grid cell number to search in a distance/height search.

◆ m_iStartHeightDiv

short int clTreeSearch::m_iStartHeightDiv
protected

Starting height division to search in tree hash table in a type search.

◆ m_iWhatTypes

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.

◆ mp_bWhatSpecies

bool* clTreeSearch::mp_bWhatSpecies
protected

Which species to search for in a search involving species.

This array is sized # species.

◆ mp_oCurrentTree

clTree* clTreeSearch::mp_oCurrentTree
protected

The tree that the search is currently on.

◆ mp_oPlot

clPlot* clTreeSearch::mp_oPlot
protected

Pointer to plot object.

◆ mp_oTreePop

clTreePopulation* clTreeSearch::mp_oTreePop
protected

Pointer to tree population.


The documentation for this class was generated from the following file: