Go to the documentation of this file.
39 #ifndef HPP_FCL_BVH_MODEL_H
40 #define HPP_FCL_BVH_MODEL_H
56 template <
typename BV>
58 template <
typename BV>
88 if (num_tris && num_vertices)
90 else if (num_vertices)
105 delete[] tri_indices;
106 delete[] prev_vertices;
113 void computeLocalAABB();
116 int beginModel(
unsigned int num_tris = 0,
unsigned int num_vertices = 0);
119 int addVertex(
const Vec3f& p);
122 int addVertices(
const Matrixx3f& points);
125 int addTriangles(
const Matrixx3i& triangles);
131 int addSubModel(
const std::vector<Vec3f>& ps,
132 const std::vector<Triangle>& ts);
135 int addSubModel(
const std::vector<Vec3f>& ps);
143 int beginReplaceModel();
146 int replaceVertex(
const Vec3f& p);
152 int replaceSubModel(
const std::vector<Vec3f>& ps);
156 int endReplaceModel(
bool refit =
true,
bool bottomup =
true);
161 int beginUpdateModel();
164 int updateVertex(
const Vec3f& p);
170 int updateSubModel(
const std::vector<Vec3f>& ps);
174 int endUpdateModel(
bool refit =
true,
bool bottomup =
true);
180 void buildConvexRepresentation(
bool share_memory);
193 bool buildConvexHull(
bool keepTriangle,
const char* qhullCommand = NULL);
195 virtual int memUsage(
const bool msg =
false)
const = 0;
201 virtual void makeParentRelative() = 0;
206 for (
unsigned int i = 0; i < num_tris; ++i) {
207 const Triangle& tri = tri_indices[i];
209 (vertices[tri[0]].cross(vertices[tri[1]])).dot(vertices[tri[2]]);
212 (vertices[tri[0]] + vertices[tri[1]] + vertices[tri[2]]) * d_six_vol;
215 return com / (vol * 4);
220 for (
unsigned int i = 0; i < num_tris; ++i) {
221 const Triangle& tri = tri_indices[i];
223 (vertices[tri[0]].cross(vertices[tri[1]])).dot(vertices[tri[2]]);
234 C_canonical << 1 / 60.0, 1 / 120.0, 1 / 120.0, 1 / 120.0, 1 / 60.0,
235 1 / 120.0, 1 / 120.0, 1 / 120.0, 1 / 60.0;
237 for (
unsigned int i = 0; i < num_tris; ++i) {
238 const Triangle& tri = tri_indices[i];
239 const Vec3f& v1 = vertices[tri[0]];
240 const Vec3f& v2 = vertices[tri[1]];
241 const Vec3f& v3 = vertices[tri[2]];
243 A << v1.transpose(), v2.transpose(), v3.transpose();
244 C +=
A.derived().transpose() * C_canonical *
A * (v1.cross(v2)).dot(v3);
247 return C.trace() * Matrix3f::Identity() - C;
251 virtual void deleteBVs() = 0;
252 virtual bool allocateBVs() = 0;
255 virtual int buildTree() = 0;
258 virtual int refitTree(
bool bottomup) = 0;
272 template <
typename BV>
298 delete[] primitive_indices;
323 int memUsage(
const bool msg)
const;
331 makeParentRelativeRecurse(0, I, Vec3f::Zero());
351 int refitTree(
bool bottomup);
355 int refitTree_topdown();
359 int refitTree_bottomup();
362 int recursiveBuildTree(
int bv_id,
unsigned int first_primitive,
363 unsigned int num_primitives);
366 int recursiveRefitTree_bottomup(
int bv_id);
372 const Vec3f& parent_c) {
373 if (!bvs[bv_id].isLeaf()) {
374 makeParentRelativeRecurse(bvs[bv_id].first_child, parent_axes,
375 bvs[bv_id].getCenter());
377 makeParentRelativeRecurse(bvs[bv_id].first_child + 1, parent_axes,
378 bvs[bv_id].getCenter());
381 bvs[bv_id].
bv =
translate(bvs[bv_id].bv, -parent_c);
387 if (other_ptr ==
nullptr)
return false;
391 if (!
res)
return false;
436 if (num_bvs != other.
num_bvs)
return false;
438 for (
unsigned int k = 0; k < num_bvs; ++k) {
439 if (bvs[k] != other.
bvs[k])
return false;
450 const Vec3f& parent_c);
454 const Vec3f& parent_c);
459 const Vec3f& parent_c);
478 NODE_TYPE BVHModel<KDOP<16> >::getNodeType()
const;
481 NODE_TYPE BVHModel<KDOP<18> >::getNodeType()
const;
484 NODE_TYPE BVHModel<KDOP<24> >::getNodeType()
const;
unsigned int num_bvs_allocated
bool isEqual(const Eigen::MatrixBase< Derived > &lhs, const Eigen::MatrixBase< OtherDerived > &rhs, const FCL_REAL tol=std::numeric_limits< FCL_REAL >::epsilon() *100)
virtual bool isEqual(const CollisionGeometry &_other) const
for ccd vertex update
BVNode< BV > & getBV(unsigned int i)
Access the bv giving the its index.
BVHBuildState build_state
The state of BVH building process.
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Vec3f computeCOM() const
compute center of mass
shared_ptr< BVFitter< BV > > bv_fitter
Fitting rule to fit a BV node to a set of geometry primitives.
Eigen::Matrix< Eigen::DenseIndex, Eigen::Dynamic, 3 > Matrixx3i
virtual ~BVHModelBase()
deconstruction, delete mesh data related.
unsigned int num_bvs
Number of BV nodes in bounding volume hierarchy.
unsigned int num_vertices_allocated
shared_ptr< ConvexBase > convex
Convex<Triangle> representation of this object.
unsigned int num_vertices
Number of points.
BVNode< BV > * bvs
Bounding volume hierarchy.
The geometry for the object for collision or distance computation.
Triangle * tri_indices
Geometry triangle index data, will be NULL for point clouds.
NODE_TYPE
traversal node type: bounding volume (AABB, OBB, RSS, kIOS, OBBRSS, KDOP16, KDOP18,...
shared_ptr< BVSplitter< BV > > bv_splitter
Split rule to split one BV node into two children.
OBJECT_TYPE
object type: BVH (mesh, points), basic geometry, octree
@ BVH_MODEL_TRIANGLES
unknown model type
BV bv
bounding volume storing the geometry
Vec3f * prev_vertices
Geometry point data in previous frame.
NODE_TYPE getNodeType() const
Get the BV type: default is unknown.
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
BVHBuildState
States for BVH construction empty->begun->processed ->replace_begun->processed -> ....
BVHModelType getModelType() const
Model type described by the instance.
BVHModelType
BVH model type.
unsigned int num_vertex_updated
The class for the default algorithm fitting a bounding volume to a set of points.
Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
void makeParentRelativeRecurse(int bv_id, Matrix3f &parent_axes, const Vec3f &parent_c)
unsigned int * primitive_indices
unsigned int getNumBVs() const
Get the number of bv in the BVH.
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
unsigned int num_tris_allocated
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
A class describing the split rule that splits each BV node.
void makeParentRelative()
This is a special acceleration: BVH_model default stores the BV's transform in world coordinate....
~BVHModel()
deconstruction, delete mesh data related.
Eigen::Matrix< FCL_REAL, Eigen::Dynamic, 3 > Matrixx3f
OBJECT_TYPE getObjectType() const
Get the object type: it is a BVH.
A base class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewe...
Triangle with 3 indices for points.
virtual BVHModel< BV > * clone() const
Clone *this into a new BVHModel.
FCL_REAL computeVolume() const
compute the volume
@ BVH_MODEL_POINTCLOUD
triangle model
static AABB translate(const AABB &aabb, const Vec3f &t)
translate the center of AABB by t
Vec3f * vertices
Geometry point data.
unsigned int num_tris
Number of triangles.
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...
hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:13