C3D Toolkit  Kernel - 117982, Vision - 2.9.2.2
MbCubeTree< Type, Cube, Point, Vector > Class Template Reference

Tree of objects with bounding boxes. More...

#include <mb_cube_tree.h>

Public Types

enum  DistanceMeasure { edm_MaxCoord = 0 , edm_CubeCenter }
 Algorithm type that is used to measure distance between point and bounding box. More...
 
enum  BranchingDirections { ebd_WasDirX = 0x01 , ebd_WasDirY = 0x02 , ebd_WasDirZ = 0x04 }
 Bit flags of branching directions. More...
 

Public Member Functions

 MbCubeTree (std::vector< ItemIndex > &objects, DistanceMeasure dm=edm_MaxCoord)
 Tree constructor by objects. More...
 
 MbCubeTree (std::vector< ItemIndex > &objects, const Cube &gabarit, DistanceMeasure dm=edm_MaxCoord)
 Tree constructor by objects. More...
 
 MbCubeTree (DistanceMeasure dm=edm_MaxCoord)
 Constructor of empty tree. More...
 
 ~MbCubeTree ()
 Destuctror.
 
bool InitTree (std::vector< ItemIndex > &objects, const Cube &gabarit, DistanceMeasure dm=edm_MaxCoord)
 Initialize tree by objects. More...
 
bool InitTree (const MbCubeTree &srcTree, const std::vector< ItemIndex > &srcObjects, const std::vector< ItemIndex > &dstObjects)
 Copy the tree. More...
 
void Clear ()
 Clear the tree.
 
void Move (const Vector &)
 Move the tree.
 
DistanceMeasure GetDistanceMeasure () const
 Get algorithm type that is used to measure distance between point and bounding box.
 
size_t Count () const
 Number of objects in the tree (does not store, tree calculates it by traversing tree nodes).
 
size_t NodeCount () const
 Number of branches in the tree.
 
bool IsReady () const
 Whether tree is ready.
 
size_t GetTreeDepth () const
 Get tree depth (shared variable).
 
void SetTreeDepth (size_t k)
 Set tree depth (shared variable).
 
void ResetTreeDepth ()
 Reset tree depth (shared variable).
 
size_t GetLeafMinElementsCount () const
 Get a minimum number of elements in the leaf branch (shared variable).
 
void SetLeafMinElementsCount (size_t k)
 Set a minimum number of elements in the leaf branch (shared variable).
 
void ResetLeafMinElementsCount ()
 Reset the minimum number of elements in the leaf branch (shared variable).
 
void GetContainsObjects (const Point &pnt, double epsilon, std::vector< const Type * > &objects) const
 Get tree objects containing a point.
 
void GetContainsObjects (const Point &pnt, double epsilon, std::vector< size_t > &indices) const
 Get tree objects containing a point.
 
void GetIntersectObjects (const Cube &gabarit, double epsilon, std::vector< const Type * > &objects, bool skipOwnself=false) const
 Get objects of the tree intersecting with the bounding box.
 
void GetIntersectObjects (const Cube &gabarit, double epsilon, std::vector< size_t > &indices, bool skipOwnself=false) const
 Get objects of the tree intersecting with the bounding box.
 
void GetIntersectObjects (const Point &rayPnt1, const Point &rayPnt2, double epsilon, std::vector< size_t > &indices) const
 Get objects of the tree intersecting with the ray segment.
 
void FindNearestObject (const Cube &gabarit, double &distance, const Type *&object, double eps=MbCubeTree::defaultEpsilon) const
 Find the nearest tree object to a bounding box.
 
void FindNearestObject (const Cube &gabarit, double &distance, size_t &index, double eps=MbCubeTree::defaultEpsilon) const
 Find the nearest tree object to a bounding box (as an index in initial array of objects).
 
void FindNearestObject (const Point &pnt, double &distance, const Type *&object, double eps=MbCubeTree::defaultEpsilon) const
 Find the nearest tree object to a point.
 
void FindNearestObject (const Point &pnt, double &distance, size_t &index, double eps=MbCubeTree::defaultEpsilon) const
 Find the nearest tree object to a point (as an index in initial array of objects).
 
void GetNearestObjects (const Cube &gabarit, const double distance, std::vector< IndexDistance > &itemDistances, double eps=MbCubeTree::defaultEpsilon) const
 Get tree objects that are closer to the cube than the specified distance.
 
void GetNearestObjects (const Point &pnt, const double distance, std::vector< ItemDistance > &itemDistances, double eps=MbCubeTree::defaultEpsilon) const
 Get tree objects that are closer to the point than the specified distance.
 
void GetNearestObjects (const Point &pnt, const double distance, std::vector< IndexDistance > &indexDistances, double eps=MbCubeTree::defaultEpsilon) const
 Get tree objects indices that are closer to the point than the specified distance.
 
void GetNearestObjects (const Point &pnt, const double distance, std::vector< size_t > &indices, double eps=MbCubeTree::defaultEpsilon) const
 Get tree objects indices that are closer to the point than the specified distance.
 
double FindNearestObject (const Point &pnt, const MbTreeDistanceToElementBase< Point > &calc, size_t &index) const
 Get tree objects index that are closest to the point, and squared distance to object.
 
void FindObjectsInsideSphere (const Point &pnt, double radius, const MbTreeDistanceToElementBase< Point > &calc, c3d::IndicesVector &indices) const
 Get an array of tree object indices at least partially lying inside a given sphere.
 

Detailed Description

template<class Type, class Cube, class Point, class Vector>
class MbCubeTree< Type, Cube, Point, Vector >

Tree of objects with bounding boxes.

Tree of objects with bounding boxes.
Tree objects must have functions : "const Cube & Type::GetCube() const", "double Type::DistanceToCube( const Cube & cube, double eps )".

Member Enumeration Documentation

◆ DistanceMeasure

template<class Type , class Cube , class Point , class Vector >
enum MbCubeTree::DistanceMeasure

Algorithm type that is used to measure distance between point and bounding box.

Enumerator
edm_MaxCoord 

Distance maximum along one of coordinate axes.

edm_CubeCenter 

Distance to central point of bounding box.

◆ BranchingDirections

template<class Type , class Cube , class Point , class Vector >
enum MbCubeTree::BranchingDirections

Bit flags of branching directions.

Enumerator
ebd_WasDirX 

An attempt was made to branch along the Ox axis.

ebd_WasDirY 

An attempt was made to branch along the Oy axis.

ebd_WasDirZ 

An attempt was made to branch along the Oz axis.

Constructor & Destructor Documentation

◆ MbCubeTree() [1/3]

template<class Type , class Cube , class Point , class Vector >
MbCubeTree< Type, Cube, Point, Vector >::MbCubeTree ( std::vector< ItemIndex > &  objects,
DistanceMeasure  dm = edm_MaxCoord 
)
inline

Tree constructor by objects.

Tree constructor by objects.

Parameters
[in]objects- Tree objects.
[in]dm- Distance measure type between point and bounding box.

◆ MbCubeTree() [2/3]

template<class Type , class Cube , class Point , class Vector >
MbCubeTree< Type, Cube, Point, Vector >::MbCubeTree ( std::vector< ItemIndex > &  objects,
const Cube &  gabarit,
DistanceMeasure  dm = edm_MaxCoord 
)
inline

Tree constructor by objects.

Tree constructor by objects.

Parameters
[in]objects- Tree objects.
[in]gabarit- The total bounding box of all objects in the tree, it must not be empty.
[in]dm- Distance measure type between point and bounding box.

◆ MbCubeTree() [3/3]

template<class Type , class Cube , class Point , class Vector >
MbCubeTree< Type, Cube, Point, Vector >::MbCubeTree ( DistanceMeasure  dm = edm_MaxCoord)
inline

Constructor of empty tree.

Constructor of empty tree.

Parameters
[in]dm- Distance measure type between point and bounding box.

Member Function Documentation

◆ InitTree() [1/2]

template<class Type , class Cube , class Point , class Vector >
bool MbCubeTree< Type, Cube, Point, Vector >::InitTree ( std::vector< ItemIndex > &  objects,
const Cube &  gabarit,
DistanceMeasure  dm = edm_MaxCoord 
)
inline

Initialize tree by objects.

Initialize tree by objects.

Parameters
[in]objects- Tree objects.
[in]gabarit- The total bounding box of all objects in the tree, it must not be empty.
[in]dm- Distance measure type between point and bounding box.

◆ InitTree() [2/2]

template<class Type , class Cube , class Point , class Vector >
bool MbCubeTree< Type, Cube, Point, Vector >::InitTree ( const MbCubeTree< Type, Cube, Point, Vector > &  srcTree,
const std::vector< ItemIndex > &  srcObjects,
const std::vector< ItemIndex > &  dstObjects 
)
inline

Copy the tree.

Copy the tree.

Parameters
[in]srcTree- Initial tree.
[in]copiedObjects- Copies of tree objects.

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