coal  3.0.1
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
coal::BVHModel< BV > Class Template Reference

A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as a degraded version of mesh) More...

#include <coal/BVH/BVH_model.h>

Inheritance diagram for coal::BVHModel< BV >:
Collaboration diagram for coal::BVHModel< BV >:

Public Types

using bv_node_vector_t = std::vector< BVNode< BV >, Eigen::aligned_allocator< BVNode< BV > >>
 

Public Member Functions

 BVHModel ()
 Default constructor to build an empty BVH. More...
 
 BVHModel (const BVHModel &other)
 Copy constructor from another BVH. More...
 
virtual BVHModel< BV > * clone () const
 Clone *this into a new BVHModel. More...
 
 ~BVHModel ()
 deconstruction, delete mesh data related. More...
 
const BVNode< BV > & getBV (unsigned int i) const
 We provide getBV() and getNumBVs() because BVH may be compressed (in future), so we must provide some flexibility here. More...
 
BVNode< BV > & getBV (unsigned int i)
 Access the bv giving the its index. More...
 
unsigned int getNumBVs () const
 Get the number of bv in the BVH. More...
 
NODE_TYPE getNodeType () const
 Get the BV type: default is unknown. More...
 
int memUsage (const bool msg) const
 Check the number of memory used. More...
 
void makeParentRelative ()
 This is a special acceleration: BVH_model default stores the BV's transform in world coordinate. However, we can also store each BV's transform related to its parent BV node. When traversing the BVH, this can save one matrix transformation. More...
 
NODE_TYPE getNodeType () const
 Specialization of getNodeType() for BVHModel with different BV types. More...
 
NODE_TYPE getNodeType () const
 get the node type More...
 
NODE_TYPE getNodeType () const
 get the node type More...
 
NODE_TYPE getNodeType () const
 get the node type More...
 
NODE_TYPE getNodeType () const
 get the node type More...
 
NODE_TYPE getNodeType () const
 get the node type More...
 
NODE_TYPE getNodeType () const
 get the node type More...
 
NODE_TYPE getNodeType () const
 get the node type More...
 
- Public Member Functions inherited from coal::BVHModelBase
BVHModelType getModelType () const
 Model type described by the instance. More...
 
 BVHModelBase ()
 Constructing an empty BVH. More...
 
 BVHModelBase (const BVHModelBase &other)
 copy from another BVH More...
 
virtual ~BVHModelBase ()
 deconstruction, delete mesh data related. More...
 
OBJECT_TYPE getObjectType () const
 Get the object type: it is a BVH. More...
 
void computeLocalAABB ()
 Compute the AABB for the BVH, used for broad-phase collision. More...
 
int beginModel (unsigned int num_tris=0, unsigned int num_vertices=0)
 Begin a new BVH model. More...
 
int addVertex (const Vec3s &p)
 Add one point in the new BVH model. More...
 
int addVertices (const MatrixX3s &points)
 Add points in the new BVH model. More...
 
int addTriangles (const Matrixx3i &triangles)
 Add triangles in the new BVH model. More...
 
int addTriangle (const Vec3s &p1, const Vec3s &p2, const Vec3s &p3)
 Add one triangle in the new BVH model. More...
 
int addSubModel (const std::vector< Vec3s > &ps, const std::vector< Triangle > &ts)
 Add a set of triangles in the new BVH model. More...
 
int addSubModel (const std::vector< Vec3s > &ps)
 Add a set of points in the new BVH model. More...
 
int endModel ()
 End BVH model construction, will build the bounding volume hierarchy. More...
 
int beginReplaceModel ()
 Replace the geometry information of current frame (i.e. should have the same mesh topology with the previous frame) More...
 
int replaceVertex (const Vec3s &p)
 Replace one point in the old BVH model. More...
 
int replaceTriangle (const Vec3s &p1, const Vec3s &p2, const Vec3s &p3)
 Replace one triangle in the old BVH model. More...
 
int replaceSubModel (const std::vector< Vec3s > &ps)
 Replace a set of points in the old BVH model. More...
 
int endReplaceModel (bool refit=true, bool bottomup=true)
 End BVH model replacement, will also refit or rebuild the bounding volume hierarchy. More...
 
int beginUpdateModel ()
 Replace the geometry information of current frame (i.e. should have the same mesh topology with the previous frame). The current frame will be saved as the previous frame in prev_vertices. More...
 
int updateVertex (const Vec3s &p)
 Update one point in the old BVH model. More...
 
int updateTriangle (const Vec3s &p1, const Vec3s &p2, const Vec3s &p3)
 Update one triangle in the old BVH model. More...
 
int updateSubModel (const std::vector< Vec3s > &ps)
 Update a set of points in the old BVH model. More...
 
int endUpdateModel (bool refit=true, bool bottomup=true)
 End BVH model update, will also refit or rebuild the bounding volume hierarchy. More...
 
void buildConvexRepresentation (bool share_memory)
 Build this Convex<Triangle> representation of this model. The result is stored in attribute convex. More...
 
bool buildConvexHull (bool keepTriangle, const char *qhullCommand=NULL)
 Build a convex hull and store it in attribute convex. More...
 
Vec3s computeCOM () const
 compute center of mass More...
 
Scalar computeVolume () const
 compute the volume More...
 
Matrix3s computeMomentofInertia () const
 compute the inertia matrix, related to the origin More...
 
- Public Member Functions inherited from coal::CollisionGeometry
 CollisionGeometry ()
 
 CollisionGeometry (const CollisionGeometry &other)=default
 Copy constructor. More...
 
virtual ~CollisionGeometry ()
 
bool operator== (const CollisionGeometry &other) const
 Equality operator. More...
 
bool operator!= (const CollisionGeometry &other) const
 Difference operator. More...
 
void * getUserData () const
 get user data in geometry More...
 
void setUserData (void *data)
 set user data in geometry More...
 
bool isOccupied () const
 whether the object is completely occupied More...
 
bool isFree () const
 whether the object is completely free More...
 
bool isUncertain () const
 whether the object has some uncertainty More...
 
virtual Matrix3s computeMomentofInertiaRelatedToCOM () const
 compute the inertia matrix, related to the com More...
 

Public Attributes

shared_ptr< BVSplitter< BV > > bv_splitter
 Split rule to split one BV node into two children. More...
 
shared_ptr< BVFitter< BV > > bv_fitter
 Fitting rule to fit a BV node to a set of geometry primitives. More...
 
- Public Attributes inherited from coal::BVHModelBase
std::shared_ptr< std::vector< Vec3s > > vertices
 Geometry point data. More...
 
std::shared_ptr< std::vector< Triangle > > tri_indices
 Geometry triangle index data, will be NULL for point clouds. More...
 
std::shared_ptr< std::vector< Vec3s > > prev_vertices
 Geometry point data in previous frame. More...
 
unsigned int num_tris
 Number of triangles. More...
 
unsigned int num_vertices
 Number of points. More...
 
BVHBuildState build_state
 The state of BVH building process. More...
 
shared_ptr< ConvexBaseconvex
 Convex<Triangle> representation of this object. More...
 
- Public Attributes inherited from coal::CollisionGeometry
Vec3s aabb_center
 AABB center in local coordinate. More...
 
Scalar aabb_radius
 AABB radius. More...
 
AABB aabb_local
 AABB in local coordinate, used for tight AABB when only translation transform. More...
 
void * user_data
 pointer to user defined data specific to this object More...
 
Scalar cost_density
 collision cost for unit volume More...
 
Scalar threshold_occupied
 threshold for occupied ( >= is occupied) More...
 
Scalar threshold_free
 threshold for free (<= is free) More...
 

Protected Member Functions

void deleteBVs ()
 
bool allocateBVs ()
 
int buildTree ()
 Build the bounding volume hierarchy. More...
 
int refitTree (bool bottomup)
 Refit the bounding volume hierarchy. More...
 
int refitTree_topdown ()
 Refit the bounding volume hierarchy in a top-down way (slow but more compact) More...
 
int refitTree_bottomup ()
 Refit the bounding volume hierarchy in a bottom-up way (fast but less compact) More...
 
int recursiveBuildTree (int bv_id, unsigned int first_primitive, unsigned int num_primitives)
 Recursive kernel for hierarchy construction. More...
 
int recursiveRefitTree_bottomup (int bv_id)
 Recursive kernel for bottomup refitting. More...
 
void makeParentRelativeRecurse (int bv_id, Matrix3s &parent_axes, const Vec3s &parent_c)
 
void makeParentRelativeRecurse (int bv_id, Matrix3s &parent_axes, const Vec3s &parent_c)
 
void makeParentRelativeRecurse (int bv_id, Matrix3s &parent_axes, const Vec3s &parent_c)
 
void makeParentRelativeRecurse (int bv_id, Matrix3s &parent_axes, const Vec3s &parent_c)
 

Protected Attributes

unsigned int num_bvs_allocated
 
std::shared_ptr< std::vector< unsigned int > > primitive_indices
 
std::shared_ptr< bv_node_vector_tbvs
 Bounding volume hierarchy. More...
 
unsigned int num_bvs
 Number of BV nodes in bounding volume hierarchy. More...
 
- Protected Attributes inherited from coal::BVHModelBase
unsigned int num_tris_allocated
 
unsigned int num_vertices_allocated
 
unsigned int num_vertex_updated
 

Detailed Description

template<typename BV>
class coal::BVHModel< BV >

A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as a degraded version of mesh)

Template Parameters
BVone of the bounding volume class in Bounding volumes.

Member Typedef Documentation

◆ bv_node_vector_t

template<typename BV >
using coal::BVHModel< BV >::bv_node_vector_t = std::vector<BVNode<BV>, Eigen::aligned_allocator<BVNode<BV> >>

Constructor & Destructor Documentation

◆ BVHModel() [1/2]

template<typename BV >
coal::BVHModel< BV >::BVHModel ( )

Default constructor to build an empty BVH.

◆ BVHModel() [2/2]

template<typename BV >
coal::BVHModel< BV >::BVHModel ( const BVHModel< BV > &  other)

Copy constructor from another BVH.

Parameters
[in]otherBVHModel to copy.

◆ ~BVHModel()

template<typename BV >
coal::BVHModel< BV >::~BVHModel ( )
inline

deconstruction, delete mesh data related.

Member Function Documentation

◆ allocateBVs()

template<typename BV >
bool coal::BVHModel< BV >::allocateBVs ( )
protectedvirtual

Implements coal::BVHModelBase.

◆ buildTree()

template<typename BV >
int coal::BVHModel< BV >::buildTree ( )
protectedvirtual

Build the bounding volume hierarchy.

Implements coal::BVHModelBase.

◆ clone()

template<typename BV >
virtual BVHModel<BV>* coal::BVHModel< BV >::clone ( ) const
inlinevirtual

Clone *this into a new BVHModel.

Implements coal::CollisionGeometry.

◆ deleteBVs()

template<typename BV >
void coal::BVHModel< BV >::deleteBVs ( )
protectedvirtual

Implements coal::BVHModelBase.

◆ getBV() [1/2]

template<typename BV >
BVNode<BV>& coal::BVHModel< BV >::getBV ( unsigned int  i)
inline

Access the bv giving the its index.

◆ getBV() [2/2]

template<typename BV >
const BVNode<BV>& coal::BVHModel< BV >::getBV ( unsigned int  i) const
inline

We provide getBV() and getNumBVs() because BVH may be compressed (in future), so we must provide some flexibility here.

Access the bv giving the its index

◆ getNodeType() [1/9]

template<typename BV >
NODE_TYPE coal::BVHModel< BV >::getNodeType ( ) const
inlinevirtual

Get the BV type: default is unknown.

Reimplemented from coal::CollisionGeometry.

◆ getNodeType() [2/9]

NODE_TYPE coal::BVHModel< AABB >::getNodeType ( ) const
virtual

Specialization of getNodeType() for BVHModel with different BV types.

Reimplemented from coal::CollisionGeometry.

◆ getNodeType() [3/9]

NODE_TYPE coal::BVHModel< OBB >::getNodeType ( ) const
virtual

get the node type

Reimplemented from coal::CollisionGeometry.

◆ getNodeType() [4/9]

NODE_TYPE coal::BVHModel< RSS >::getNodeType ( ) const
virtual

get the node type

Reimplemented from coal::CollisionGeometry.

◆ getNodeType() [5/9]

NODE_TYPE coal::BVHModel< kIOS >::getNodeType ( ) const
virtual

get the node type

Reimplemented from coal::CollisionGeometry.

◆ getNodeType() [6/9]

NODE_TYPE coal::BVHModel< OBBRSS >::getNodeType ( ) const
virtual

get the node type

Reimplemented from coal::CollisionGeometry.

◆ getNodeType() [7/9]

NODE_TYPE coal::BVHModel< KDOP< 16 > >::getNodeType ( ) const
virtual

get the node type

Reimplemented from coal::CollisionGeometry.

◆ getNodeType() [8/9]

NODE_TYPE coal::BVHModel< KDOP< 18 > >::getNodeType ( ) const
virtual

get the node type

Reimplemented from coal::CollisionGeometry.

◆ getNodeType() [9/9]

NODE_TYPE coal::BVHModel< KDOP< 24 > >::getNodeType ( ) const
virtual

get the node type

Reimplemented from coal::CollisionGeometry.

◆ getNumBVs()

template<typename BV >
unsigned int coal::BVHModel< BV >::getNumBVs ( ) const
inline

Get the number of bv in the BVH.

◆ makeParentRelative()

template<typename BV >
void coal::BVHModel< BV >::makeParentRelative ( )
inlinevirtual

This is a special acceleration: BVH_model default stores the BV's transform in world coordinate. However, we can also store each BV's transform related to its parent BV node. When traversing the BVH, this can save one matrix transformation.

Implements coal::BVHModelBase.

◆ makeParentRelativeRecurse() [1/4]

template<typename BV >
void coal::BVHModel< BV >::makeParentRelativeRecurse ( int  bv_id,
Matrix3s parent_axes,
const Vec3s parent_c 
)
inlineprotected

@ recursively compute each bv's transform related to its parent. For default BV, only the translation works. For oriented BV (OBB, RSS, OBBRSS), special implementation is provided.

◆ makeParentRelativeRecurse() [2/4]

void coal::BVHModel< OBB >::makeParentRelativeRecurse ( int  bv_id,
Matrix3s parent_axes,
const Vec3s parent_c 
)
protected

◆ makeParentRelativeRecurse() [3/4]

void coal::BVHModel< RSS >::makeParentRelativeRecurse ( int  bv_id,
Matrix3s parent_axes,
const Vec3s parent_c 
)
protected

◆ makeParentRelativeRecurse() [4/4]

void coal::BVHModel< OBBRSS >::makeParentRelativeRecurse ( int  bv_id,
Matrix3s parent_axes,
const Vec3s parent_c 
)
protected

◆ memUsage()

template<typename BV >
int coal::BVHModel< BV >::memUsage ( const bool  msg) const
virtual

Check the number of memory used.

Implements coal::BVHModelBase.

◆ recursiveBuildTree()

template<typename BV >
int coal::BVHModel< BV >::recursiveBuildTree ( int  bv_id,
unsigned int  first_primitive,
unsigned int  num_primitives 
)
protected

Recursive kernel for hierarchy construction.

◆ recursiveRefitTree_bottomup()

template<typename BV >
int coal::BVHModel< BV >::recursiveRefitTree_bottomup ( int  bv_id)
protected

Recursive kernel for bottomup refitting.

◆ refitTree()

template<typename BV >
int coal::BVHModel< BV >::refitTree ( bool  bottomup)
protectedvirtual

Refit the bounding volume hierarchy.

Implements coal::BVHModelBase.

◆ refitTree_bottomup()

template<typename BV >
int coal::BVHModel< BV >::refitTree_bottomup ( )
protected

Refit the bounding volume hierarchy in a bottom-up way (fast but less compact)

◆ refitTree_topdown()

template<typename BV >
int coal::BVHModel< BV >::refitTree_topdown ( )
protected

Refit the bounding volume hierarchy in a top-down way (slow but more compact)

Member Data Documentation

◆ bv_fitter

template<typename BV >
shared_ptr<BVFitter<BV> > coal::BVHModel< BV >::bv_fitter

Fitting rule to fit a BV node to a set of geometry primitives.

◆ bv_splitter

template<typename BV >
shared_ptr<BVSplitter<BV> > coal::BVHModel< BV >::bv_splitter

Split rule to split one BV node into two children.

◆ bvs

template<typename BV >
std::shared_ptr<bv_node_vector_t> coal::BVHModel< BV >::bvs
protected

Bounding volume hierarchy.

◆ num_bvs

template<typename BV >
unsigned int coal::BVHModel< BV >::num_bvs
protected

Number of BV nodes in bounding volume hierarchy.

◆ num_bvs_allocated

template<typename BV >
unsigned int coal::BVHModel< BV >::num_bvs_allocated
protected

◆ primitive_indices

template<typename BV >
std::shared_ptr<std::vector<unsigned int> > coal::BVHModel< BV >::primitive_indices
protected

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