39 #ifndef HPP_FCL_BVH_MODEL_H 40 #define HPP_FCL_BVH_MODEL_H 91 if(num_tris && num_vertices)
109 delete [] tri_indices;
110 delete [] prev_vertices;
119 return !(*
this == other);
126 void computeLocalAABB();
129 int beginModel(
unsigned int num_tris = 0,
unsigned int num_vertices = 0);
132 int addVertex(
const Vec3f& p);
135 int addVertices(
const Matrixx3f & points);
138 int addTriangles(
const Matrixx3i & triangles);
144 int addSubModel(
const std::vector<Vec3f>& ps,
const std::vector<Triangle>& ts);
147 int addSubModel(
const std::vector<Vec3f>& ps);
153 int beginReplaceModel();
156 int replaceVertex(
const Vec3f& p);
159 int replaceTriangle(
const Vec3f& p1,
const Vec3f& p2,
const Vec3f& p3);
162 int replaceSubModel(
const std::vector<Vec3f>& ps);
165 int endReplaceModel(
bool refit =
true,
bool bottomup =
true);
169 int beginUpdateModel();
172 int updateVertex(
const Vec3f& p);
178 int updateSubModel(
const std::vector<Vec3f>& ps);
181 int endUpdateModel(
bool refit =
true,
bool bottomup =
true);
187 void buildConvexRepresentation(
bool share_memory);
200 bool buildConvexHull(
bool keepTriangle,
const char* qhullCommand = NULL);
202 virtual int memUsage(
const bool msg =
false)
const = 0;
206 virtual void makeParentRelative() = 0;
212 for(
unsigned int i = 0; i < num_tris; ++i)
214 const Triangle& tri = tri_indices[i];
215 FCL_REAL d_six_vol = (vertices[tri[0]].cross(vertices[tri[1]])).dot(vertices[tri[2]]);
217 com += (vertices[tri[0]] + vertices[tri[1]] + vertices[tri[2]]) * d_six_vol;
220 return com / (vol * 4);
226 for(
unsigned int i = 0; i < num_tris; ++i)
228 const Triangle& tri = tri_indices[i];
229 FCL_REAL d_six_vol = (vertices[tri[0]].cross(vertices[tri[1]])).dot(vertices[tri[2]]);
241 C_canonical << 1/60.0, 1/120.0, 1/120.0,
242 1/120.0, 1/60.0, 1/120.0,
243 1/120.0, 1/120.0, 1/60.0;
245 for(
unsigned int i = 0; i < num_tris; ++i)
247 const Triangle& tri = tri_indices[i];
248 const Vec3f& v1 = vertices[tri[0]];
249 const Vec3f& v2 = vertices[tri[1]];
250 const Vec3f& v3 = vertices[tri[2]];
251 Matrix3f A; A << v1.transpose(), v2.transpose(), v3.transpose();
252 C += A.derived().transpose() * C_canonical * A * (v1.cross(v2)).dot(v3);
255 return C.trace() * Matrix3f::Identity() - C;
259 virtual void deleteBVs() = 0;
260 virtual bool allocateBVs() = 0;
263 virtual int buildTree() = 0;
266 virtual int refitTree(
bool bottomup) = 0;
275 template<
typename BV>
303 delete [] primitive_indices;
309 bool res = Base::operator==(other);
359 for(
unsigned int k = 0; k < num_bvs; ++k)
361 if(bvs[k] != other.
bvs[k])
371 return !(*
this == other);
379 assert (i < num_bvs);
386 assert (i < num_bvs);
400 int memUsage(
const bool msg)
const;
407 makeParentRelativeRecurse(0, I,
Vec3f());
427 int refitTree(
bool bottomup);
430 int refitTree_topdown();
433 int refitTree_bottomup();
436 int recursiveBuildTree(
int bv_id,
unsigned int first_primitive,
unsigned int num_primitives);
439 int recursiveRefitTree_bottomup(
int bv_id);
445 if(!bvs[bv_id].isLeaf())
447 makeParentRelativeRecurse(bvs[bv_id].first_child, parent_axes, bvs[bv_id].getCenter());
449 makeParentRelativeRecurse(bvs[bv_id].first_child + 1, parent_axes, bvs[bv_id].getCenter());
452 bvs[bv_id].
bv =
translate(bvs[bv_id].bv, -parent_c);
485 NODE_TYPE BVHModel<KDOP<16> >::getNodeType()
const;
488 NODE_TYPE BVHModel<KDOP<18> >::getNodeType()
const;
491 NODE_TYPE BVHModel<KDOP<24> >::getNodeType()
const;
Vec3f * prev_vertices
Geometry point data in previous frame.
Definition: BVH_model.h:74
unsigned int getNumBVs() const
Get the number of bv in the BVH.
Definition: BVH_model.h:391
unsigned int num_vertex_updated
Definition: BVH_model.h:270
bool operator!=(const BVHModelBase &other) const
Difference operator.
Definition: BVH_model.h:117
FCL_REAL computeVolume() const
compute the volume
Definition: BVH_model.h:223
shared_ptr< ConvexBase > convex
Convex<Triangle> representation of this object.
Definition: BVH_model.h:86
OBJECT_TYPE
object type: BVH (mesh, points), basic geometry, octree
Definition: collision_object.h:55
Main namespace.
Definition: AABB.h:43
Definition: collision_object.h:58
BV bv
bounding volume storing the geometry
Definition: BV_node.h:114
Definition: BVH_internal.h:79
BVNode< BV > & getBV(unsigned int i)
Access the bv giving the its index.
Definition: BVH_model.h:384
shared_ptr< BVFitter< BV > > bv_fitter
Fitting rule to fit a BV node to a set of geometry primitives.
Definition: BVH_model.h:285
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:69
virtual BVHModel< BV > * clone() const
Clone *this into a new BVHModel.
Definition: BVH_model.h:297
A base class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewe...
Definition: BVH_model.h:62
KDOP< N > translate(const KDOP< N > &bv, const Vec3f &t)
translate the KDOP BV
unsigned int num_vertices
Number of points.
Definition: BVH_model.h:80
unsigned int num_vertices_allocated
Definition: BVH_model.h:269
Vec3f computeCOM() const
compute center of mass
Definition: BVH_model.h:208
unknown model type
Definition: BVH_internal.h:80
OBJECT_TYPE getObjectType() const
Get the object type: it is a BVH.
Definition: BVH_model.h:123
void makeParentRelativeRecurse(int bv_id, Matrix3f &parent_axes, const Vec3f &parent_c)
Definition: BVH_model.h:443
unsigned int * primitive_indices
Definition: BVH_model.h:415
Triangle * tri_indices
Geometry triangle index data, will be NULL for point clouds.
Definition: BVH_model.h:71
BVHBuildState
States for BVH construction empty->begun->processed ->replace_begun->processed -> ...
Definition: BVH_internal.h:52
Vec3f * vertices
Geometry point data.
Definition: BVH_model.h:68
unsigned int num_tris
Number of triangles.
Definition: BVH_model.h:77
double FCL_REAL
Definition: data_types.h:66
Eigen::Matrix< Eigen::DenseIndex, Eigen::Dynamic, 3 > Matrixx3i
Definition: data_types.h:71
BVHModelType getModelType() const
Model type described by the instance.
Definition: BVH_model.h:89
unsigned int num_tris_allocated
Definition: BVH_model.h:268
Eigen::Matrix< FCL_REAL, Eigen::Dynamic, 3 > Matrixx3f
Definition: data_types.h:70
BVHModelType
BVH model type.
Definition: BVH_internal.h:77
unsigned int num_bvs
Number of BV nodes in bounding volume hierarchy.
Definition: BVH_model.h:421
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
Definition: BV_node.h:109
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: BVH_model.h:276
void makeParentRelative()
This is a special acceleration: BVH_model default stores the BV's transform in world coordinate...
Definition: BVH_model.h:404
~BVHModel()
deconstruction, delete mesh data related.
Definition: BVH_model.h:300
Triangle with 3 indices for points.
Definition: data_types.h:76
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...
Definition: BVH_model.h:377
NODE_TYPE
traversal node type: bounding volume (AABB, OBB, RSS, kIOS, OBBRSS, KDOP16, KDOP18, kDOP24), basic shape (box, sphere, capsule, cone, cylinder, convex, plane, triangle), and octree
Definition: collision_object.h:58
NODE_TYPE getNodeType() const
Get the BV type: default is unknown.
Definition: BVH_model.h:397
bool operator!=(const BVHModel &other) const
Difference operator.
Definition: BVH_model.h:369
Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: BVH_model.h:236
Definition: collision_object.h:55
BVHBuildState build_state
The state of BVH building process.
Definition: BVH_model.h:83
BVNode< BV > * bvs
Bounding volume hierarchy.
Definition: BVH_model.h:418
unsigned int num_bvs_allocated
Definition: BVH_model.h:414
shared_ptr< BVSplitter< BV > > bv_splitter
Split rule to split one BV node into two children.
Definition: BVH_model.h:282
The class for the default algorithm fitting a bounding volume to a set of points. ...
Definition: BVH_model.h:58
A class describing the split rule that splits each BV node.
Definition: BVH_model.h:59
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
bool operator==(const BVHModel &other) const
Equality operator.
Definition: BVH_model.h:307
The geometry for the object for collision or distance computation.
Definition: collision_object.h:66
virtual ~BVHModelBase()
deconstruction, delete mesh data related.
Definition: BVH_model.h:106
triangle model
Definition: BVH_internal.h:81
#define HPP_FCL_DLLAPI
Definition: config.hh:64