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(
int num_tris = 0,
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(
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(
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(
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>
300 delete [] primitive_indices;
306 bool res = Base::operator==(other);
310 int other_num_primitives = 0;
317 other_num_primitives = num_tris;
320 other_num_primitives = num_vertices;
356 for(
int k = 0; k < num_bvs; ++k)
358 if(bvs[k] != other.
bvs[k])
368 return !(*
this == other);
376 assert (
id < num_bvs);
383 assert (
id < num_bvs);
397 int memUsage(
const bool msg)
const;
404 makeParentRelativeRecurse(0, I,
Vec3f());
424 int refitTree(
bool bottomup);
427 int refitTree_topdown();
430 int refitTree_bottomup();
433 int recursiveBuildTree(
int bv_id,
int first_primitive,
int num_primitives);
436 int recursiveRefitTree_bottomup(
int bv_id);
442 if(!bvs[bv_id].isLeaf())
444 makeParentRelativeRecurse(bvs[bv_id].first_child, parent_axes, bvs[bv_id].getCenter());
446 makeParentRelativeRecurse(bvs[bv_id].first_child + 1, parent_axes, bvs[bv_id].getCenter());
449 bvs[bv_id].
bv =
translate(bvs[bv_id].bv, -parent_c);
Vec3f * prev_vertices
Geometry point data in previous frame.
Definition: BVH_model.h:74
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
BVNode< BV > & getBV(int id)
Access the bv giving the its index.
Definition: BVH_model.h:381
int num_tris_allocated
Definition: BVH_model.h:268
Definition: collision_object.h:58
BV bv
bounding volume storing the geometry
Definition: BV_node.h:114
Definition: BVH_internal.h:79
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:68
int num_tris
Number of triangles.
Definition: BVH_model.h:77
virtual BVHModel< BV > * clone() const
Clone *this into a new BVHModel.
Definition: BVH_model.h:294
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
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:440
int getNumBVs() const
Get the number of bv in the BVH.
Definition: BVH_model.h:388
unsigned int * primitive_indices
Definition: BVH_model.h:412
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
double FCL_REAL
Definition: data_types.h:66
Eigen::Matrix< Eigen::DenseIndex, Eigen::Dynamic, 3 > Matrixx3i
Definition: data_types.h:70
int num_vertex_updated
Definition: BVH_model.h:270
BVHModelType getModelType() const
Model type described by the instance.
Definition: BVH_model.h:89
int num_bvs
Number of BV nodes in bounding volume hierarchy.
Definition: BVH_model.h:418
Eigen::Matrix< FCL_REAL, Eigen::Dynamic, 3 > Matrixx3f
Definition: data_types.h:69
BVHModelType
BVH model type.
Definition: BVH_internal.h:77
int num_bvs_allocated
Definition: BVH_model.h:411
const BVNode< BV > & getBV(int id) const
We provide getBV() and getNumBVs() because BVH may be compressed (in future), so we must provide some...
Definition: BVH_model.h:374
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:401
~BVHModel()
deconstruction, delete mesh data related.
Definition: BVH_model.h:297
int num_vertices_allocated
Definition: BVH_model.h:269
Triangle with 3 indices for points.
Definition: data_types.h:74
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:394
bool operator!=(const BVHModel &other) const
Difference operator.
Definition: BVH_model.h:366
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:415
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:304
The geometry for the object for collision or distance computation.
Definition: collision_object.h:65
virtual ~BVHModelBase()
deconstruction, delete mesh data related.
Definition: BVH_model.h:106
triangle model
Definition: BVH_internal.h:81
int num_vertices
Number of points.
Definition: BVH_model.h:80
#define HPP_FCL_DLLAPI
Definition: config.hh:64