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>
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;
68 const Eigen::Map<const AsTriangleMatrix> tri_indices_map(reinterpret_cast<const Triangle::index_type *>(bvh_model.
tri_indices),3,bvh_model.
num_tris);
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));
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);
128 ar >> make_nvp(
"num_tris",num_tris);
140 typedef Eigen::Matrix<Triangle::index_type,3,Eigen::Dynamic> AsTriangleMatrix;
141 Eigen::Map<AsTriangleMatrix> tri_indices_map(reinterpret_cast<Triangle::index_type *>(bvh_model.
tri_indices),3,bvh_model.
num_tris);
142 ar & make_nvp(
"tri_indices",tri_indices_map);
147 ar >> make_nvp(
"build_state",bvh_model.
build_state);
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>
186 using Base::num_bvs_allocated;
187 using Base::primitive_indices;
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);
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));
336 #endif // ifndef HPP_FCL_SERIALIZATION_BVH_MODEL_H
Vec3f * prev_vertices
Geometry point data in previous frame.
Definition: BVH_model.h:74
Definition: BVH_model.h:23
Main namespace.
Definition: AABB.h:43
#define HPP_FCL_SERIALIZATION_SPLIT(Type)
Definition: fwd.h:13
int num_tris_allocated
Definition: BVH_model.h:268
int num_tris
Number of triangles.
Definition: BVH_model.h:77
after beginModel(), state for adding geometry primitives
Definition: BVH_internal.h:56
void serialize(Archive &ar, hpp::fcl::AABB &aabb, const unsigned int)
Definition: AABB.h:17
A base class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewe...
Definition: BVH_model.h:62
hpp::fcl::BVHModelBase Base
Definition: BVH_model.h:25
Definition: BVH_model.h:183
unknown model type
Definition: BVH_internal.h:80
Triangle * tri_indices
Geometry triangle index data, will be NULL for point clouds.
Definition: BVH_model.h:71
Vec3f * vertices
Geometry point data.
Definition: BVH_model.h:68
void save(Archive &ar, const hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:34
BVHModelType getModelType() const
Model type described by the instance.
Definition: BVH_model.h:89
A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and...
Definition: BV_node.h:109
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Definition: BVH_model.h:276
int num_vertices_allocated
Definition: BVH_model.h:269
hpp::fcl::BVHModel< BV > Base
Definition: BVH_model.h:185
Triangle with 3 indices for points.
Definition: data_types.h:74
BVHBuildState build_state
The state of BVH building process.
Definition: BVH_model.h:83
after beginUpdateModel(), state for updating geometry primitives
Definition: BVH_internal.h:58
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
void load(Archive &ar, hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:50
int num_vertices
Number of points.
Definition: BVH_model.h:80