38 #ifndef FCL_BV_FITTER_INL_H 39 #define FCL_BV_FITTER_INL_H 41 #include "fcl/geometry/bvh/detail/BV_fitter.h" 50 template <
typename BV>
57 template <
typename S,
typename BV>
61 template <
typename BV>
63 Vector3<
typename BVFitter<BV>::S>* vertices_,
71 template <
typename BV>
73 Vector3<
typename BVFitter<BV>::S>* vertices_,
74 Vector3<
typename BVFitter<BV>::S>* prev_vertices_,
79 *
this, vertices_, prev_vertices_, tri_indices_, type_);
83 template <
typename S,
typename BV>
87 template <
typename BV>
91 *
this, primitive_indices, num_primitives);
95 template <
typename BV>
99 prev_vertices =
nullptr;
100 tri_indices =
nullptr;
101 type = BVH_MODEL_UNKNOWN;
105 template <
typename S,
typename BV>
110 Vector3<S>* vertices_,
114 fitter.vertices = vertices_;
115 fitter.prev_vertices =
nullptr;
116 fitter.tri_indices = tri_indices_;
122 Vector3<S>* vertices_,
123 Vector3<S>* prev_vertices_,
127 fitter.vertices = vertices_;
128 fitter.prev_vertices = prev_vertices_;
129 fitter.tri_indices = tri_indices_;
135 template <
typename S>
140 Vector3<S>* vertices_,
144 fitter.vertices = vertices_;
145 fitter.prev_vertices =
nullptr;
146 fitter.tri_indices = tri_indices_;
152 Vector3<S>* vertices_,
153 Vector3<S>* prev_vertices_,
157 fitter.vertices = vertices_;
158 fitter.prev_vertices = prev_vertices_;
159 fitter.tri_indices = tri_indices_;
165 template <
typename S>
170 Vector3<S>* vertices_,
174 fitter.vertices = vertices_;
175 fitter.prev_vertices =
nullptr;
176 fitter.tri_indices = tri_indices_;
182 Vector3<S>* vertices_,
183 Vector3<S>* prev_vertices_,
187 fitter.vertices = vertices_;
188 fitter.prev_vertices = prev_vertices_;
189 fitter.tri_indices = tri_indices_;
195 template <
typename S>
200 Vector3<S>* vertices_,
204 fitter.vertices = vertices_;
205 fitter.prev_vertices =
nullptr;
206 fitter.tri_indices = tri_indices_;
212 Vector3<S>* vertices_,
213 Vector3<S>* prev_vertices_,
217 fitter.vertices = vertices_;
218 fitter.prev_vertices = prev_vertices_;
219 fitter.tri_indices = tri_indices_;
225 template <
typename S>
230 Vector3<S>* vertices_,
234 fitter.vertices = vertices_;
235 fitter.prev_vertices =
nullptr;
236 fitter.tri_indices = tri_indices_;
242 Vector3<S>* vertices_,
243 Vector3<S>* prev_vertices_,
247 fitter.vertices = vertices_;
248 fitter.prev_vertices = prev_vertices_;
249 fitter.tri_indices = tri_indices_;
255 template <
typename S,
typename BV>
260 unsigned int* primitive_indices,
267 for(
int i = 0; i < num_primitives; ++i)
269 Triangle t = fitter.tri_indices[primitive_indices[i]];
270 bv += fitter.vertices[t[0]];
271 bv += fitter.vertices[t[1]];
272 bv += fitter.vertices[t[2]];
274 if(fitter.prev_vertices)
276 bv += fitter.prev_vertices[t[0]];
277 bv += fitter.prev_vertices[t[1]];
278 bv += fitter.prev_vertices[t[2]];
284 for(
int i = 0; i < num_primitives; ++i)
286 bv += fitter.vertices[primitive_indices[i]];
288 if(fitter.prev_vertices)
290 bv += fitter.prev_vertices[primitive_indices[i]];
300 template <
typename S>
305 unsigned int* primitive_indices,
314 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
315 primitive_indices, num_primitives, M);
317 axisFromEigen(E, s, bv.
axis);
321 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
322 primitive_indices, num_primitives,
330 template <
typename S>
335 unsigned int* primitive_indices,
344 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
345 primitive_indices, num_primitives, M);
347 axisFromEigen(E, s, bv.
axis);
350 getRadiusAndOriginAndRectangleSize(
351 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
352 primitive_indices, num_primitives, bv.
axis, bv.
To, bv.
l, bv.
r);
359 template <
typename S>
364 unsigned int* primitive_indices,
373 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
374 primitive_indices, num_primitives, M);
376 axisFromEigen(E, s, bv.
obb.
axis);
380 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
383 const Vector3<S>& center = bv.
obb.
To;
384 const Vector3<S>& extent = bv.
obb.
extent;
385 S r0 = maximumDistance(
386 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
387 primitive_indices, num_primitives, center);
404 bv.
spheres[1].o = center - delta;
405 bv.
spheres[2].o = center + delta;
407 S r11 = maximumDistance(
408 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
409 primitive_indices, num_primitives, bv.
spheres[1].o);
410 S r12 = maximumDistance(
411 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
412 primitive_indices, num_primitives, bv.
spheres[2].o);
424 Vector3<S> delta = bv.
obb.
axis.col(1) * (sqrt(r10 * r10 - extent[0] * extent[0] - extent[2] * extent[2]) - extent[1]);
429 r21 = maximumDistance(
430 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
431 primitive_indices, num_primitives, bv.
spheres[3].o);
432 r22 = maximumDistance(
433 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
434 primitive_indices, num_primitives, bv.
spheres[4].o);
448 template <
typename S>
453 unsigned int* primitive_indices,
461 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
462 primitive_indices, num_primitives, M);
464 axisFromEigen(E, s, bv.
obb.
axis);
468 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
471 getRadiusAndOriginAndRectangleSize(
472 fitter.vertices, fitter.prev_vertices, fitter.tri_indices,
473 primitive_indices, num_primitives,
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
triangle model
Definition: BVH_internal.h:79
BVHModelType
BVH model type.
Definition: BVH_internal.h:75
void set(Vector3< S > *vertices_, Triangle *tri_indices_, BVHModelType type_)
Prepare the geometry primitive data for fitting.
virtual ~BVFitter()
default deconstructor
Definition: BV_fitter-inl.h:51
Definition: BV_fitter-inl.h:84
Definition: BV_fitter-inl.h:58
Triangle with 3 indices for points.
Definition: triangle.h:47
unknown model type
Definition: BVH_internal.h:78
BV fit(unsigned int *primitive_indices, int num_primitives)
Compute a bounding volume that fits a set of primitives (points or triangles). The primitive data was...
Definition: BV_fitter-inl.h:88
OBB< S > obb
OBB related with kIOS.
Definition: kIOS.h:72
static BV run(const BVFitter< BV > &fitter, unsigned int *primitive_indices, int num_primitives)
Definition: BV_fitter-inl.h:258
unsigned int num_spheres
The number of spheres, no larger than 5.
Definition: kIOS.h:69
Vector3< S > extent
Half dimensions of OBB.
Definition: OBB.h:68
Matrix3< S > axis
Orientation of OBB. The axes of the rotation matrix are the principle directions of the box...
Definition: OBB.h:62
void clear()
Clear the geometry primitive data.
Definition: BV_fitter-inl.h:96
The class for the default algorithm fitting a bounding volume to a set of points. ...
Definition: BV_fitter.h:56
Vector3< S > To
Center of OBB.
Definition: OBB.h:65
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:48
kIOS_Sphere spheres[5]
The (at most) five spheres for intersection.
Definition: kIOS.h:66
Oriented bounding box class.
Definition: OBB.h:51