38 #ifndef HPP_FCL_BV_SPLITTER_H 39 #define HPP_FCL_BV_SPLITTER_H 73 tri_indices = tri_indices_;
78 void computeRule(
const BV& bv,
unsigned int* primitive_indices,
int num_primitives)
83 computeRule_mean(bv, primitive_indices, num_primitives);
86 computeRule_median(bv, primitive_indices, num_primitives);
89 computeRule_bvcenter(bv, primitive_indices, num_primitives);
92 std::cerr <<
"Split method not supported" << std::endl;
99 return q[split_axis] > split_value;
135 Vec3f center = bv.center();
138 if(bv.width() >= bv.height() && bv.width() >= bv.depth())
140 else if(bv.height() >= bv.width() && bv.height() >= bv.depth())
144 split_value = center[axis];
152 if(bv.width() >= bv.height() && bv.width() >= bv.depth())
154 else if(bv.height() >= bv.width() && bv.height() >= bv.depth())
162 for(
int i = 0; i < num_primitives; ++i)
164 const Triangle& t = tri_indices[primitive_indices[i]];
165 sum += (vertices[t[0]][split_axis] + vertices[t[1]][split_axis] + vertices[t[2]][split_axis]);
172 for(
int i = 0; i < num_primitives; ++i)
174 sum += vertices[primitive_indices[i]][split_axis];
178 split_value = sum / num_primitives;
186 if(bv.width() >= bv.height() && bv.width() >= bv.depth())
188 else if(bv.height() >= bv.width() && bv.height() >= bv.depth())
192 std::vector<FCL_REAL> proj((
size_t)num_primitives);
196 for(
int i = 0; i < num_primitives; ++i)
198 const Triangle& t = tri_indices[primitive_indices[i]];
199 proj[i] = (vertices[t[0]][split_axis] + vertices[t[1]][split_axis] + vertices[t[2]][split_axis]) / 3;
204 for(
int i = 0; i < num_primitives; ++i)
205 proj[i] = vertices[primitive_indices[i]][split_axis];
208 std::sort(proj.begin(), proj.end());
210 if(num_primitives % 2 == 1)
212 split_value = proj[(num_primitives - 1) / 2];
216 split_value = (proj[num_primitives / 2] + proj[num_primitives / 2 - 1]) / 2;
Main namespace.
Definition: AABB.h:43
virtual ~BVSplitter()
Default deconstructor.
Definition: BV_splitter.h:67
Definition: BVH_internal.h:79
SplitMethodType split_method
The split algorithm used.
Definition: BV_splitter.h:130
Triangle * tri_indices
The triangles handled by the splitter.
Definition: BV_splitter.h:124
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:55
unknown model type
Definition: BVH_internal.h:80
void computeRule(const BV &bv, unsigned int *primitive_indices, int num_primitives)
Compute the split rule according to a subset of geometry and the corresponding BV node...
Definition: BV_splitter.h:78
void computeRule_median(const BV &bv, unsigned int *primitive_indices, int num_primitives)
Split algorithm 3: Split the node according to the median of the data contained.
Definition: BV_splitter.h:182
double FCL_REAL
Definition: data_types.h:66
Definition: BV_splitter.h:53
Vec3f * vertices
The mesh vertices or points handled by the splitter.
Definition: BV_splitter.h:121
void computeRule_bvcenter(const BV &bv, unsigned int *, int)
Split algorithm 1: Split the node from center.
Definition: BV_splitter.h:133
BVHModelType
BVH model type.
Definition: BVH_internal.h:77
BVSplitter(SplitMethodType method)
Definition: BV_splitter.h:62
Definition: BV_splitter.h:53
FCL_REAL split_value
The split threshold, different primitives are splitted according whether their projection on the spli...
Definition: BV_splitter.h:118
Definition: BV_splitter.h:53
Triangle with 3 indices for points.
Definition: data_types.h:74
SplitMethodType
Three types of split algorithms are provided in FCL as default.
Definition: BV_splitter.h:53
void computeRule_mean(const BV &bv, unsigned int *primitive_indices, int num_primitives)
Split algorithm 2: Split the node according to the mean of the data contained.
Definition: BV_splitter.h:148
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:114
bool apply(const Vec3f &q) const
Apply the split rule on a given point.
Definition: BV_splitter.h:97
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
BVHModelType type
Whether the geometry is mesh or point cloud.
Definition: BV_splitter.h:127
void clear()
Clear the geometry data set before.
Definition: BV_splitter.h:103
triangle model
Definition: BVH_internal.h:81
Vec3f split_vector
Definition: BV_splitter.h:115
#define HPP_FCL_DLLAPI
Definition: config.hh:64
Oriented bounding box class.
Definition: OBB.h:54