hpp-fcl
2.4.1
HPP fork of FCL -- The Flexible Collision Library
|
Go to the documentation of this file.
5 #ifndef HPP_FCL_SERIALIZATION_BVH_MODEL_H
6 #define HPP_FCL_SERIALIZATION_BVH_MODEL_H
18 namespace serialization {
28 template <
class Archive>
30 const unsigned int ) {
35 throw std::invalid_argument(
36 "The BVH model is not in a BVH_BUILD_STATE_PROCESSED or "
37 "BVH_BUILD_STATE_UPDATED state.\n"
38 "The BVHModel could not be serialized.");
42 boost::serialization::base_object<hpp::fcl::CollisionGeometry>(
47 typedef Eigen::Matrix<FCL_REAL, 3, Eigen::Dynamic> AsVertixMatrix;
48 const Eigen::Map<const AsVertixMatrix> vertices_map(
49 reinterpret_cast<const double *
>(bvh_model.
vertices), 3,
51 ar &make_nvp(
"vertices", vertices_map);
54 ar &make_nvp(
"num_tris", bvh_model.
num_tris);
56 typedef Eigen::Matrix<Triangle::index_type, 3, Eigen::Dynamic>
58 const Eigen::Map<const AsTriangleMatrix> tri_indices_map(
61 ar &make_nvp(
"tri_indices", tri_indices_map);
66 const bool has_prev_vertices =
true;
67 ar << make_nvp(
"has_prev_vertices", has_prev_vertices);
68 typedef Eigen::Matrix<FCL_REAL, 3, Eigen::Dynamic> AsVertixMatrix;
69 const Eigen::Map<const AsVertixMatrix> prev_vertices_map(
72 ar &make_nvp(
"prev_vertices", prev_vertices_map);
74 const bool has_prev_vertices =
false;
75 ar &make_nvp(
"has_prev_vertices", has_prev_vertices);
90 template <
class Archive>
92 const unsigned int ) {
95 ar >> make_nvp(
"base",
96 boost::serialization::base_object<hpp::fcl::CollisionGeometry>(
99 unsigned int num_vertices;
100 ar >> make_nvp(
"num_vertices", num_vertices);
105 if (num_vertices > 0) bvh_model.
vertices =
new Vec3f[num_vertices];
107 if (num_vertices > 0) {
108 typedef Eigen::Matrix<FCL_REAL, 3, Eigen::Dynamic> AsVertixMatrix;
109 Eigen::Map<AsVertixMatrix> vertices_map(
110 reinterpret_cast<double *
>(bvh_model.
vertices), 3,
112 ar >> make_nvp(
"vertices", vertices_map);
116 unsigned int num_tris;
117 ar >> make_nvp(
"num_tris", num_tris);
119 if (num_tris != bvh_model.
num_tris) {
126 typedef Eigen::Matrix<Triangle::index_type, 3, Eigen::Dynamic>
128 Eigen::Map<AsTriangleMatrix> tri_indices_map(
131 ar &make_nvp(
"tri_indices", tri_indices_map);
135 ar >> make_nvp(
"build_state", bvh_model.
build_state);
138 reinterpret_cast<Accessor &
>(bvh_model).num_tris_allocated = num_tris;
139 reinterpret_cast<Accessor &
>(bvh_model).num_vertices_allocated = num_vertices;
141 bool has_prev_vertices;
142 ar >> make_nvp(
"has_prev_vertices", has_prev_vertices);
143 if (has_prev_vertices) {
149 if (num_vertices > 0) {
150 typedef Eigen::Matrix<FCL_REAL, 3, Eigen::Dynamic> AsVertixMatrix;
151 Eigen::Map<AsVertixMatrix> prev_vertices_map(
154 ar &make_nvp(
"prev_vertices", prev_vertices_map);
166 template <
typename BV>
176 template <
class Archive,
typename BV>
178 const unsigned int version) {
179 split_free(ar, bvh_model, version);
182 template <
class Archive,
typename BV>
184 const unsigned int ) {
189 const Accessor &bvh_model =
reinterpret_cast<const Accessor &
>(bvh_model_);
191 boost::serialization::base_object<BVHModelBase>(bvh_model));
232 const bool with_bvs =
true;
233 ar &make_nvp(
"with_bvs", with_bvs);
234 ar &make_nvp(
"num_bvs", bvh_model.num_bvs);
238 reinterpret_cast<const char *
>(bvh_model.bvs),
240 (std::size_t)bvh_model.num_bvs));
242 const bool with_bvs =
false;
243 ar &make_nvp(
"with_bvs", with_bvs);
247 template <
class Archive,
typename BV>
249 const unsigned int ) {
254 Accessor &bvh_model =
reinterpret_cast<Accessor &
>(bvh_model_);
256 ar >> make_nvp(
"base",
257 boost::serialization::base_object<BVHModelBase>(bvh_model));
278 ar >> make_nvp(
"with_bvs", with_bvs);
280 unsigned int num_bvs;
281 ar >> make_nvp(
"num_bvs", num_bvs);
283 if (num_bvs != bvh_model.num_bvs) {
284 delete[] bvh_model.bvs;
285 bvh_model.bvs = NULL;
286 bvh_model.num_bvs = num_bvs;
287 if (num_bvs > 0) bvh_model.bvs =
new BVNode<BV>[num_bvs];
290 ar >> make_nvp(
"bvs", make_array(
reinterpret_cast<char *
>(bvh_model.bvs),
291 sizeof(Node) * (std::size_t)num_bvs));
293 bvh_model.bvs = NULL;
304 template <
typename BV>
306 static size_t run(const ::hpp::fcl::BVHModel<BV> &bvh_model) {
307 return static_cast<size_t>(bvh_model.memUsage(
false));
315 #endif // ifndef HPP_FCL_SERIALIZATION_BVH_MODEL_H
unsigned int num_bvs_allocated
Definition: BVH_model.h:338
BVHBuildState build_state
The state of BVH building process.
Definition: BVH_model.h:81
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:66
Definition: BVH_model.h:167
hpp::fcl::BVHModel< BV > Base
Definition: BVH_model.h:168
std::size_t index_type
Definition: data_types.h:98
unsigned int num_bvs
Number of BV nodes in bounding volume hierarchy.
Definition: BVH_model.h:345
unsigned int num_vertices_allocated
Definition: BVH_model.h:261
#define HPP_FCL_SERIALIZATION_SPLIT(Type)
Definition: fwd.h:13
@ BVH_BUILD_STATE_PROCESSED
Definition: BVH_internal.h:54
hpp::fcl::BVHModelBase Base
Definition: BVH_model.h:22
unsigned int num_vertices
Number of points.
Definition: BVH_model.h:78
BVNode< BV > * bvs
Bounding volume hierarchy.
Definition: BVH_model.h:342
Triangle * tri_indices
Geometry triangle index data, will be NULL for point clouds.
Definition: BVH_model.h:69
void load(Archive &ar, hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:44
@ BVH_MODEL_TRIANGLES
unknown model type
Definition: BVH_internal.h:82
Vec3f * prev_vertices
Geometry point data in previous frame.
Definition: BVH_model.h:72
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
Definition: BV_node.h:109
BVHModelType getModelType() const
Model type described by the instance.
Definition: BVH_model.h:87
Main namespace.
Definition: broadphase_bruteforce.h:44
Definition: broadphase_bruteforce.h:45
unsigned int * primitive_indices
Definition: BVH_model.h:339
Definition: BVH_model.h:21
unsigned int num_tris_allocated
Definition: BVH_model.h:260
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: BVH_model.h:273
void serialize(Archive &ar, hpp::fcl::AABB &aabb, const unsigned int)
Definition: AABB.h:15
@ BVH_BUILD_STATE_UPDATED
Definition: BVH_internal.h:57
A base class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewe...
Definition: BVH_model.h:63
Triangle with 3 indices for points.
Definition: data_types.h:96
void save(Archive &ar, const hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:30
Vec3f * vertices
Geometry point data.
Definition: BVH_model.h:66
unsigned int num_tris
Number of triangles.
Definition: BVH_model.h:75