38 #ifndef HPP_FCL_BV_SPLITTER_H 39 #define HPP_FCL_BV_SPLITTER_H 58 template <
typename BV>
76 void computeRule(
const BV& bv,
unsigned int* primitive_indices,
77 unsigned int num_primitives) {
89 std::cerr <<
"Split method not supported" << std::endl;
130 Vec3f center = bv.center();
133 if (bv.width() >= bv.height() && bv.width() >= bv.depth())
135 else if (bv.height() >= bv.width() && bv.height() >= bv.depth())
139 split_value = center[axis];
145 unsigned int num_primitives) {
148 if (bv.width() >= bv.height() && bv.width() >= bv.depth())
150 else if (bv.height() >= bv.width() && bv.height() >= bv.depth())
157 for (
unsigned int i = 0; i < num_primitives; ++i) {
158 const Triangle& t = tri_indices[primitive_indices[i]];
165 for (
unsigned int i = 0; i < num_primitives; ++i) {
166 sum += vertices[primitive_indices[i]][
split_axis];
170 split_value = sum / num_primitives;
176 unsigned int num_primitives) {
179 if (bv.width() >= bv.height() && bv.width() >= bv.depth())
181 else if (bv.height() >= bv.width() && bv.height() >= bv.depth())
185 std::vector<FCL_REAL> proj((
size_t)num_primitives);
188 for (
unsigned int i = 0; i < num_primitives; ++i) {
189 const Triangle& t = tri_indices[primitive_indices[i]];
195 for (
unsigned int i = 0; i < num_primitives; ++i)
196 proj[i] = vertices[primitive_indices[i]][split_axis];
199 std::sort(proj.begin(), proj.end());
201 if (num_primitives % 2 == 1) {
202 split_value = proj[(num_primitives - 1) / 2];
205 (proj[num_primitives / 2] + proj[num_primitives / 2 - 1]) / 2;
224 const OBB& bv,
unsigned int* primitive_indices,
225 unsigned int num_primitives);
229 const OBB& bv,
unsigned int* primitive_indices,
230 unsigned int num_primitives);
234 const OBB& bv,
unsigned int* primitive_indices,
235 unsigned int num_primitives);
239 const RSS& bv,
unsigned int* primitive_indices,
240 unsigned int num_primitives);
244 const RSS& bv,
unsigned int* primitive_indices,
245 unsigned int num_primitives);
249 const RSS& bv,
unsigned int* primitive_indices,
250 unsigned int num_primitives);
254 const kIOS& bv,
unsigned int* primitive_indices,
255 unsigned int num_primitives);
259 const kIOS& bv,
unsigned int* primitive_indices,
260 unsigned int num_primitives);
264 const kIOS& bv,
unsigned int* primitive_indices,
265 unsigned int num_primitives);
269 const OBBRSS& bv,
unsigned int* primitive_indices,
270 unsigned int num_primitives);
274 const OBBRSS& bv,
unsigned int* primitive_indices,
275 unsigned int num_primitives);
279 const OBBRSS& bv,
unsigned int* primitive_indices,
280 unsigned int num_primitives);
Main namespace.
Definition: broadphase_bruteforce.h:44
virtual ~BVSplitter()
Default deconstructor.
Definition: BV_splitter.h:65
Definition: BVH_internal.h:81
SplitMethodType split_method
The split algorithm used.
Definition: BV_splitter.h:126
void computeRule_bvcenter(const BV &bv, unsigned int *, unsigned int)
Split algorithm 1: Split the node from center.
Definition: BV_splitter.h:129
Triangle * tri_indices
The triangles handled by the splitter.
Definition: BV_splitter.h:120
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:53
unknown model type
Definition: BVH_internal.h:82
double FCL_REAL
Definition: data_types.h:65
Definition: BV_splitter.h:53
Vec3f * vertices
The mesh vertices or points handled by the splitter.
Definition: BV_splitter.h:117
BVHModelType
BVH model type.
Definition: BVH_internal.h:80
BVSplitter(SplitMethodType method)
Definition: BV_splitter.h:61
Definition: BV_splitter.h:52
FCL_REAL split_value
The split threshold, different primitives are splitted according whether their projection on the spli...
Definition: BV_splitter.h:114
Definition: BV_splitter.h:54
Triangle with 3 indices for points.
Definition: data_types.h:96
SplitMethodType
Three types of split algorithms are provided in FCL as default.
Definition: BV_splitter.h:51
void computeRule(const BV &bv, unsigned int *primitive_indices, unsigned int num_primitives)
Compute the split rule according to a subset of geometry and the corresponding BV node...
Definition: BV_splitter.h:76
int split_axis
The axis based on which the split decision is made. For most BV, the axis is aligned with one of the ...
Definition: BV_splitter.h:108
bool apply(const Vec3f &q) const
Apply the split rule on a given point.
Definition: BV_splitter.h:94
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:66
BVHModelType type
Whether the geometry is mesh or point cloud.
Definition: BV_splitter.h:123
void clear()
Clear the geometry data set before.
Definition: BV_splitter.h:97
triangle model
Definition: BVH_internal.h:83
void computeRule_mean(const BV &bv, unsigned int *primitive_indices, unsigned int num_primitives)
Split algorithm 2: Split the node according to the mean of the data contained.
Definition: BV_splitter.h:144
Vec3f split_vector
Definition: BV_splitter.h:109
#define HPP_FCL_DLLAPI
Definition: config.hh:64
void computeRule_median(const BV &bv, unsigned int *primitive_indices, unsigned int num_primitives)
Split algorithm 3: Split the node according to the median of the data contained.
Definition: BV_splitter.h:175
Oriented bounding box class.
Definition: OBB.h:52