clTreeSearch Class Reference

Tree Search Class - Version 1.0 This class controls the feeding of individual trees to behavior objects. More...

#include <TreeSearch.h>

List of all members.

Public Member Functions

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

clTreeFindNextDHTree ()
 Optimized for finding trees where only distance and height are specified.
clTreeFindNextTSTree ()
 Optimized for finding trees where only type and species are specified.
clTreeFindNextTTree ()
 Optimized for finding trees where only type is specified.
clTreeFindNextAllTree ()
 Sets up the object to find all trees.
clTreeFindFirstDHTree ()
 Finds the first tree in a distance/height search.
clTreeFindFirstTSTree ()
 Finds the first tree in a type/species search.
clTreeFindFirstTTree ()
 Finds the first tree in a type search.
clTreeFindFirstAllTree ()
 Finds the first tree in an "all" search.
void Setup ()
 Does final data validation and gets things ready for the NextTree() methods.

Protected Attributes

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


Detailed Description

Tree Search Class - Version 1.0 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)


Constructor & Destructor Documentation

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_oTreePop Pointer to the tree population object
p_oPlot Pointer to the plot object

clTreeSearch::~clTreeSearch (  ) 

Destructor.

Frees memory.


Member Function Documentation

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

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.

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.

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.

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.

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.

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.

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.

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.


Member Data Documentation

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.

short int clTreeSearch::m_iStartHeightDiv [protected]

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

short int clTreeSearch::m_iEndHeightDiv [protected]

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

bool clTreeSearch::m_bSeeds [protected]

Whether seeds are being searched for in a type search.

bool clTreeSearch::m_bSeedlings [protected]

Whether seedlings are being searched for in a type search.

bool clTreeSearch::m_bSaplings [protected]

Whether saplings are being searched for in a type search.

bool clTreeSearch::m_bAdults [protected]

Whether adults are being searched for in a type search.

bool clTreeSearch::m_bSnags [protected]

Whether snags are being searched for in a type search.

bool clTreeSearch::m_bWoody_Debris [protected]

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

bool* clTreeSearch::mp_bWhatSpecies [protected]

Which species to search for in a search involving species.

This array is sized # species.


The documentation for this class was generated from the following file:
Generated on Thu May 24 09:30:46 2007 for SORTIE Core C++ Documentation by  doxygen 1.5.2