Open CASCADE Technology 7.8.0
BVH_BaseTraverse< MetricType > Class Template Reference

The classes implement the traverse of the BVH tree. More...

#include <BVH_Traverse.hxx>

Inheritance diagram for BVH_BaseTraverse< MetricType >:
Inheritance graph
[legend]

Public Member Functions

Metrics comparison for choosing the best branch
virtual Standard_Boolean IsMetricBetter (const MetricType &, const MetricType &) const
 Compares the two metrics and chooses the best one. Returns true if the first metric is better than the second, false otherwise.
 
Rejection of the node by metric
virtual Standard_Boolean RejectMetric (const MetricType &) const
 Rejects the node by the metric.
 
Condition to stop the descend
virtual Standard_Boolean Stop () const
 Returns the flag controlling the tree descend. Returns true if the tree descend should be stopped.
 

Protected Member Functions

Constructors
 BVH_BaseTraverse ()
 Constructor.
 
virtual ~BVH_BaseTraverse ()
 Destructor.
 

Detailed Description

template<class MetricType>
class BVH_BaseTraverse< MetricType >

The classes implement the traverse of the BVH tree.

There are two traverse methods implemented:

To perform Selection of the elements from BVH_Tree using the traverse methods implemented here it is required to define Acceptance/Rejection rules in the following methods:

The selector of a single tree has an extra method which allows accepting the whole branches without any further checks (e.g. full inclusion test):

Two ways of selection are possible:

  1. Set the BVH set containing the tree and use the method Select() which allows using common interface for setting the BVH Set for accessing the BVH tree and elements in the Accept method.
  2. Keep the BVHSetType void, do not set the BVH set and use the method Select (const BVH_Tree<>&) which allows performing selection on the arbitrary BVH tree.

Here is the example of usage of the traverse to find the point-triangulation minimal distance.

// Structure to contain points of the triangle
struct Triangle
{
Triangle() {}
Triangle(const BVH_Vec3d& theNode1,
: Node1 (theNode1), Node2 (theNode2), Node3 (theNode3)
{}
BVH_Vec3d Node1;
BVH_Vec3d Node2;
BVH_Vec3d Node3;
};
// Selector for min point-triangulation distance
public BVH_Distance<Standard_Real, 3, BVH_Vec3d, BVH_BoxSet<Standard_Real, 3, Triangle>>
{
public:
// Computes the distance from the point to bounding box
virtual Standard_Boolean RejectNode (const BVH_Vec3d& theCMin,
Standard_Real& theDistance) const Standard_OVERRIDE
{
return RejectMetric (theDistance);
}
// Computes the distance from the point to triangle
virtual Standard_Boolean Accept (const Standard_Integer theIndex,
{
const Triangle& aTri = myBVHSet->Element (theIndex);
if (aDist < myDistance)
{
myDistance = aDist;
return Standard_True;
}
}
};
// Point to which the distance is required
// BVH Set containing triangulation
aDistTool.SetObject (aPoint);
aDistTool.SetBVHSet (aTriangulationSet.get());
aDistTool.ComputeDistance();
if (aDistTool.IsDone())
{
}
BVH::VectorType< Standard_Real, 3 >::Type BVH_Vec3d
3D vector of double precision reals.
Definition BVH_Types.hxx:150
#define Standard_OVERRIDE
Should be used in declarations of virtual methods overridden in the derived classes,...
Definition Standard_Macro.hxx:41
bool Standard_Boolean
Definition Standard_TypeDef.hxx:64
#define Standard_False
Definition Standard_TypeDef.hxx:56
int Standard_Integer
Definition Standard_TypeDef.hxx:61
#define Standard_True
Definition Standard_TypeDef.hxx:57
double Standard_Real
Definition Standard_TypeDef.hxx:63
Abstract class for computation of the min distance between some Object and elements of BVH tree....
Definition BVH_Distance.hxx:33
static T PointTriangleSquareDistance(const BVH_VecNt &thePoint, const BVH_VecNt &theNode0, const BVH_VecNt &theNode1, const BVH_VecNt &theNode2)
Computes square distance between point and triangle.
Definition BVH_Tools.hxx:239
static T PointBoxSquareDistance(const BVH_VecNt &thePoint, const BVH_Box< T, N > &theBox)
Computes square distance between point and bounding box.
Definition BVH_Tools.hxx:74
Definition NCollection_UBTree.hxx:64
Intrusive smart pointer for use with Standard_Transient class and its descendants.
Definition Standard_Handle.hxx:51

Abstract class implementing the base Traverse interface required for selection of the elements from BVH tree.

Template Parameters
MetricTypeType of metric to perform more optimal tree descend

Constructor & Destructor Documentation

◆ BVH_BaseTraverse()

Constructor.

◆ ~BVH_BaseTraverse()

template<class MetricType >
virtual BVH_BaseTraverse< MetricType >::~BVH_BaseTraverse ( )
inlineprotectedvirtual

Destructor.

Member Function Documentation

◆ IsMetricBetter()

template<class MetricType >
virtual Standard_Boolean BVH_BaseTraverse< MetricType >::IsMetricBetter ( const MetricType ,
const MetricType  
) const
inlinevirtual

Compares the two metrics and chooses the best one. Returns true if the first metric is better than the second, false otherwise.

◆ RejectMetric()

template<class MetricType >
virtual Standard_Boolean BVH_BaseTraverse< MetricType >::RejectMetric ( const MetricType ) const
inlinevirtual

Rejects the node by the metric.

◆ Stop()

template<class MetricType >
virtual Standard_Boolean BVH_BaseTraverse< MetricType >::Stop ( ) const
inlinevirtual

Returns the flag controlling the tree descend. Returns true if the tree descend should be stopped.

Reimplemented in BVH_Distance< NumType, Dimension, ObjectType, BVHSetType >, BVH_Distance< Standard_Real, 3, BVH_Vec3d, BRepExtrema_TriangleSet >, and BVH_PairDistance< NumType, Dimension, BVHSetType >.


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