5#ifndef HPP_FCL_SERIALIZATION_BVH_MODEL_H
6#define HPP_FCL_SERIALIZATION_BVH_MODEL_H
18 namespace serialization
31 template <
class Archive>
36 ar & make_nvp(
"p0",triangle[0]);
37 ar & make_nvp(
"p1",triangle[1]);
38 ar & make_nvp(
"p2",triangle[2]);
41 template <
class Archive>
47 if(!(bvh_model.
build_state == BVH_BUILD_STATE_PROCESSED || bvh_model.
build_state == BVH_BUILD_STATE_UPDATED)
50 throw std::invalid_argument(
"The BVH model is not in a BVH_BUILD_STATE_PROCESSED or BVH_BUILD_STATE_UPDATED state.\n"
51 "The BVHModel could not be serialized.");
54 ar & make_nvp(
"base",boost::serialization::base_object<hpp::fcl::CollisionGeometry>(bvh_model));
59 typedef Eigen::Matrix<FCL_REAL,3,Eigen::Dynamic> AsVertixMatrix;
60 const Eigen::Map<const AsVertixMatrix> vertices_map(
reinterpret_cast<const double *
>(bvh_model.
vertices),3,bvh_model.
num_vertices);
61 ar & make_nvp(
"vertices",vertices_map);
64 ar & make_nvp(
"num_tris",bvh_model.
num_tris);
67 typedef Eigen::Matrix<Triangle::index_type,3,Eigen::Dynamic> AsTriangleMatrix;
69 ar & make_nvp(
"tri_indices",tri_indices_map);
75 const bool has_prev_vertices =
true;
76 ar << make_nvp(
"has_prev_vertices",has_prev_vertices);
77 typedef Eigen::Matrix<FCL_REAL,3,Eigen::Dynamic> AsVertixMatrix;
78 const Eigen::Map<const AsVertixMatrix> prev_vertices_map(
reinterpret_cast<const double *
>(bvh_model.
prev_vertices),3,bvh_model.
num_vertices);
79 ar & make_nvp(
"prev_vertices",prev_vertices_map);
83 const bool has_prev_vertices =
false;
84 ar & make_nvp(
"has_prev_vertices",has_prev_vertices);
99 template <
class Archive>
106 ar >> make_nvp(
"base",boost::serialization::base_object<hpp::fcl::CollisionGeometry>(bvh_model));
108 unsigned int num_vertices;
109 ar >> make_nvp(
"num_vertices",num_vertices);
120 typedef Eigen::Matrix<FCL_REAL,3,Eigen::Dynamic> AsVertixMatrix;
121 Eigen::Map<AsVertixMatrix> vertices_map(
reinterpret_cast<double *
>(bvh_model.
vertices),3,bvh_model.
num_vertices);
122 ar >> make_nvp(
"vertices",vertices_map);
127 unsigned int num_tris;
128 ar >> make_nvp(
"num_tris",num_tris);
140 typedef Eigen::Matrix<Triangle::index_type,3,Eigen::Dynamic> AsTriangleMatrix;
142 ar & make_nvp(
"tri_indices",tri_indices_map);
147 ar >> make_nvp(
"build_state",bvh_model.
build_state);
150 reinterpret_cast<Accessor &
>(bvh_model).num_tris_allocated = num_tris;
151 reinterpret_cast<Accessor &
>(bvh_model).num_vertices_allocated = num_vertices;
153 bool has_prev_vertices;
154 ar >> make_nvp(
"has_prev_vertices",has_prev_vertices);
155 if(has_prev_vertices)
166 typedef Eigen::Matrix<FCL_REAL,3,Eigen::Dynamic> AsVertixMatrix;
167 Eigen::Map<AsVertixMatrix> prev_vertices_map(
reinterpret_cast<double *
>(bvh_model.
prev_vertices),3,bvh_model.
num_vertices);
168 ar & make_nvp(
"prev_vertices",prev_vertices_map);
182 template<
typename BV>
193 template <
class Archive,
typename BV>
196 const unsigned int version)
198 split_free(ar,bvh_model,version);
201 template <
class Archive,
typename BV>
210 const Accessor & bvh_model =
reinterpret_cast<const Accessor &
>(bvh_model_);
211 ar & make_nvp(
"base",boost::serialization::base_object<BVHModelBase>(bvh_model));
249 const bool with_bvs =
true;
250 ar & make_nvp(
"with_bvs",with_bvs);
251 ar & make_nvp(
"num_bvs",bvh_model.num_bvs);
252 ar & make_nvp(
"bvs",make_array(
reinterpret_cast<const char *
>(bvh_model.bvs),
sizeof(Node)*(std::size_t)bvh_model.num_bvs));
256 const bool with_bvs =
false;
257 ar & make_nvp(
"with_bvs",with_bvs);
261 template <
class Archive,
typename BV>
270 Accessor & bvh_model =
reinterpret_cast<Accessor &
>(bvh_model_);
272 ar >> make_nvp(
"base",boost::serialization::base_object<BVHModelBase>(bvh_model));
292 ar >> make_nvp(
"with_bvs",with_bvs);
295 unsigned int num_bvs;
296 ar >> make_nvp(
"num_bvs",num_bvs);
298 if(num_bvs != bvh_model.num_bvs)
300 delete[] bvh_model.bvs;
301 bvh_model.bvs = NULL;
302 bvh_model.num_bvs = num_bvs;
308 ar >> make_nvp(
"bvs",make_array(
reinterpret_cast<char *
>(bvh_model.bvs),
sizeof(Node)*(std::size_t)num_bvs));
311 bvh_model.bvs = NULL;
323 template<
typename BV>
326 static size_t run(const ::hpp::fcl::BVHModel<BV> & bvh_model)
328 return static_cast<size_t>(bvh_model.memUsage(
false));
A base class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewe...
Definition: BVH_model.h:64
Vec3f * prev_vertices
Geometry point data in previous frame.
Definition: BVH_model.h:74
unsigned int num_tris
Number of triangles.
Definition: BVH_model.h:77
Triangle * tri_indices
Geometry triangle index data, will be NULL for point clouds.
Definition: BVH_model.h:71
unsigned int num_vertices_allocated
Definition: BVH_model.h:269
BVHBuildState build_state
The state of BVH building process.
Definition: BVH_model.h:83
BVHModelType getModelType() const
Model type described by the instance.
Definition: BVH_model.h:89
Vec3f * vertices
Geometry point data.
Definition: BVH_model.h:68
unsigned int num_vertices
Number of points.
Definition: BVH_model.h:80
unsigned int num_tris_allocated
Definition: BVH_model.h:268
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: BVH_model.h:278
unsigned int * primitive_indices
Definition: BVH_model.h:415
BVNode< BV > * bvs
Bounding volume hierarchy.
Definition: BVH_model.h:418
unsigned int num_bvs_allocated
Definition: BVH_model.h:414
unsigned int num_bvs
Number of BV nodes in bounding volume hierarchy.
Definition: BVH_model.h:421
Triangle with 3 indices for points.
Definition: data_types.h:77
std::size_t index_type
Definition: data_types.h:79
#define HPP_FCL_SERIALIZATION_SPLIT(Type)
Definition: fwd.h:13
void save(Archive &ar, const hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:34
void load(Archive &ar, hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:50
void serialize(Archive &ar, hpp::fcl::AABB &aabb, const unsigned int)
Definition: AABB.h:17
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
Main namespace.
Definition: AABB.h:44
Definition: BVH_model.h:184
hpp::fcl::BVHModel< BV > Base
Definition: BVH_model.h:185
Definition: BVH_model.h:24
hpp::fcl::BVHModelBase Base
Definition: BVH_model.h:25
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
Definition: BV_node.h:110