coal  3.0.1
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
coal::BVHModelBase Class Referenceabstract

A base 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::BVHModelBase:
Collaboration diagram for coal::BVHModelBase:

Public Member Functions

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...
 
virtual int memUsage (const bool msg=false) const =0
 
virtual void makeParentRelative ()=0
 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...
 
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 ()
 
virtual CollisionGeometryclone () const =0
 Clone *this into a new CollisionGeometry. More...
 
bool operator== (const CollisionGeometry &other) const
 Equality operator. More...
 
bool operator!= (const CollisionGeometry &other) const
 Difference operator. More...
 
virtual NODE_TYPE getNodeType () const
 get the node type 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

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

virtual void deleteBVs ()=0
 
virtual bool allocateBVs ()=0
 
virtual int buildTree ()=0
 Build the bounding volume hierarchy. More...
 
virtual int refitTree (bool bottomup)=0
 Refit the bounding volume hierarchy. More...
 
virtual bool isEqual (const CollisionGeometry &other) const
 for ccd vertex update More...
 

Protected Attributes

unsigned int num_tris_allocated
 
unsigned int num_vertices_allocated
 
unsigned int num_vertex_updated
 

Detailed Description

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

Constructor & Destructor Documentation

◆ BVHModelBase() [1/2]

coal::BVHModelBase::BVHModelBase ( )

Constructing an empty BVH.

◆ BVHModelBase() [2/2]

coal::BVHModelBase::BVHModelBase ( const BVHModelBase other)

copy from another BVH

◆ ~BVHModelBase()

virtual coal::BVHModelBase::~BVHModelBase ( )
inlinevirtual

deconstruction, delete mesh data related.

Member Function Documentation

◆ addSubModel() [1/2]

int coal::BVHModelBase::addSubModel ( const std::vector< Vec3s > &  ps)

Add a set of points in the new BVH model.

◆ addSubModel() [2/2]

int coal::BVHModelBase::addSubModel ( const std::vector< Vec3s > &  ps,
const std::vector< Triangle > &  ts 
)

Add a set of triangles in the new BVH model.

◆ addTriangle()

int coal::BVHModelBase::addTriangle ( const Vec3s p1,
const Vec3s p2,
const Vec3s p3 
)

Add one triangle in the new BVH model.

◆ addTriangles()

int coal::BVHModelBase::addTriangles ( const Matrixx3i triangles)

Add triangles in the new BVH model.

◆ addVertex()

int coal::BVHModelBase::addVertex ( const Vec3s p)

Add one point in the new BVH model.

◆ addVertices()

int coal::BVHModelBase::addVertices ( const MatrixX3s points)

Add points in the new BVH model.

◆ allocateBVs()

virtual bool coal::BVHModelBase::allocateBVs ( )
protectedpure virtual

Implemented in coal::BVHModel< BV >.

◆ beginModel()

int coal::BVHModelBase::beginModel ( unsigned int  num_tris = 0,
unsigned int  num_vertices = 0 
)

Begin a new BVH model.

◆ beginReplaceModel()

int coal::BVHModelBase::beginReplaceModel ( )

Replace the geometry information of current frame (i.e. should have the same mesh topology with the previous frame)

◆ beginUpdateModel()

int coal::BVHModelBase::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.

◆ buildConvexHull()

bool coal::BVHModelBase::buildConvexHull ( bool  keepTriangle,
const char *  qhullCommand = NULL 
)

Build a convex hull and store it in attribute convex.

Parameters
keepTrianglewhether the convex should be triangulated.
qhullCommandsee ConvexBase::convexHull.
Returns
true if this object is convex, hence the convex hull represents the same object.
See also
ConvexBase::convexHull
Warning
At the moment, the return value only checks whether there are as many points in the convex hull as in the original object. This is neither necessary (duplicated vertices get merged) nor sufficient (think of a U with 4 vertices and 3 edges).

◆ buildConvexRepresentation()

void coal::BVHModelBase::buildConvexRepresentation ( bool  share_memory)

Build this Convex<Triangle> representation of this model. The result is stored in attribute convex.

Note
this only takes the points of this model. It does not check that the object is convex. It does not compute a convex hull.

◆ buildTree()

virtual int coal::BVHModelBase::buildTree ( )
protectedpure virtual

Build the bounding volume hierarchy.

Implemented in coal::BVHModel< BV >.

◆ computeCOM()

Vec3s coal::BVHModelBase::computeCOM ( ) const
inlinevirtual

compute center of mass

Reimplemented from coal::CollisionGeometry.

◆ computeLocalAABB()

void coal::BVHModelBase::computeLocalAABB ( )
virtual

Compute the AABB for the BVH, used for broad-phase collision.

Implements coal::CollisionGeometry.

◆ computeMomentofInertia()

Matrix3s coal::BVHModelBase::computeMomentofInertia ( ) const
inlinevirtual

compute the inertia matrix, related to the origin

Reimplemented from coal::CollisionGeometry.

◆ computeVolume()

Scalar coal::BVHModelBase::computeVolume ( ) const
inlinevirtual

compute the volume

Reimplemented from coal::CollisionGeometry.

◆ deleteBVs()

virtual void coal::BVHModelBase::deleteBVs ( )
protectedpure virtual

Implemented in coal::BVHModel< BV >.

◆ endModel()

int coal::BVHModelBase::endModel ( )

End BVH model construction, will build the bounding volume hierarchy.

◆ endReplaceModel()

int coal::BVHModelBase::endReplaceModel ( bool  refit = true,
bool  bottomup = true 
)

End BVH model replacement, will also refit or rebuild the bounding volume hierarchy.

◆ endUpdateModel()

int coal::BVHModelBase::endUpdateModel ( bool  refit = true,
bool  bottomup = true 
)

End BVH model update, will also refit or rebuild the bounding volume hierarchy.

◆ getModelType()

BVHModelType coal::BVHModelBase::getModelType ( ) const
inline

Model type described by the instance.

◆ getObjectType()

OBJECT_TYPE coal::BVHModelBase::getObjectType ( ) const
inlinevirtual

Get the object type: it is a BVH.

Reimplemented from coal::CollisionGeometry.

◆ isEqual()

virtual bool coal::BVHModelBase::isEqual ( const CollisionGeometry other) const
protectedvirtual

for ccd vertex update

Comparison operators

Implements coal::CollisionGeometry.

◆ makeParentRelative()

virtual void coal::BVHModelBase::makeParentRelative ( )
pure virtual

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.

Implemented in coal::BVHModel< BV >.

◆ memUsage()

virtual int coal::BVHModelBase::memUsage ( const bool  msg = false) const
pure virtual

Implemented in coal::BVHModel< BV >.

◆ refitTree()

virtual int coal::BVHModelBase::refitTree ( bool  bottomup)
protectedpure virtual

Refit the bounding volume hierarchy.

Implemented in coal::BVHModel< BV >.

◆ replaceSubModel()

int coal::BVHModelBase::replaceSubModel ( const std::vector< Vec3s > &  ps)

Replace a set of points in the old BVH model.

◆ replaceTriangle()

int coal::BVHModelBase::replaceTriangle ( const Vec3s p1,
const Vec3s p2,
const Vec3s p3 
)

Replace one triangle in the old BVH model.

◆ replaceVertex()

int coal::BVHModelBase::replaceVertex ( const Vec3s p)

Replace one point in the old BVH model.

◆ updateSubModel()

int coal::BVHModelBase::updateSubModel ( const std::vector< Vec3s > &  ps)

Update a set of points in the old BVH model.

◆ updateTriangle()

int coal::BVHModelBase::updateTriangle ( const Vec3s p1,
const Vec3s p2,
const Vec3s p3 
)

Update one triangle in the old BVH model.

◆ updateVertex()

int coal::BVHModelBase::updateVertex ( const Vec3s p)

Update one point in the old BVH model.

Member Data Documentation

◆ build_state

BVHBuildState coal::BVHModelBase::build_state

The state of BVH building process.

◆ convex

shared_ptr<ConvexBase> coal::BVHModelBase::convex

Convex<Triangle> representation of this object.

◆ num_tris

unsigned int coal::BVHModelBase::num_tris

Number of triangles.

◆ num_tris_allocated

unsigned int coal::BVHModelBase::num_tris_allocated
protected

◆ num_vertex_updated

unsigned int coal::BVHModelBase::num_vertex_updated
protected

◆ num_vertices

unsigned int coal::BVHModelBase::num_vertices

Number of points.

◆ num_vertices_allocated

unsigned int coal::BVHModelBase::num_vertices_allocated
protected

◆ prev_vertices

std::shared_ptr<std::vector<Vec3s> > coal::BVHModelBase::prev_vertices

Geometry point data in previous frame.

◆ tri_indices

std::shared_ptr<std::vector<Triangle> > coal::BVHModelBase::tri_indices

Geometry triangle index data, will be NULL for point clouds.

◆ vertices

std::shared_ptr<std::vector<Vec3s> > coal::BVHModelBase::vertices

Geometry point data.


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