5 #ifndef HPP_FCL_SERIALIZATION_BVH_MODEL_H 6 #define HPP_FCL_SERIALIZATION_BVH_MODEL_H 17 namespace serialization
30 template <
class Archive>
35 ar & make_nvp(
"p0",triangle[0]);
36 ar & make_nvp(
"p1",triangle[1]);
37 ar & make_nvp(
"p2",triangle[2]);
40 template <
class Archive>
49 throw std::invalid_argument(
"The BVH model is not in a BVH_BUILD_STATE_PROCESSED or BVH_BUILD_STATE_UPDATED state.\n" 50 "The BVHModel could not be serialized.");
53 ar & make_nvp(
"base",boost::serialization::base_object<hpp::fcl::CollisionGeometry>(bvh_model));
58 typedef Eigen::Matrix<FCL_REAL,3,Eigen::Dynamic> AsVertixMatrix;
59 const Eigen::Map<const AsVertixMatrix> vertices_map(reinterpret_cast<const double *>(bvh_model.
vertices),3,bvh_model.
num_vertices);
60 ar & make_nvp(
"vertices",vertices_map);
63 ar & make_nvp(
"num_tris",bvh_model.
num_tris);
66 typedef Eigen::Matrix<Triangle::index_type,3,Eigen::Dynamic> AsTriangleMatrix;
67 const Eigen::Map<const AsTriangleMatrix> tri_indices_map(reinterpret_cast<const Triangle::index_type *>(bvh_model.
tri_indices),3,bvh_model.
num_tris);
68 ar & make_nvp(
"tri_indices",tri_indices_map);
74 const bool has_prev_vertices =
true;
75 ar << make_nvp(
"has_prev_vertices",has_prev_vertices);
76 typedef Eigen::Matrix<FCL_REAL,3,Eigen::Dynamic> AsVertixMatrix;
77 const Eigen::Map<const AsVertixMatrix> prev_vertices_map(reinterpret_cast<const double *>(bvh_model.
prev_vertices),3,bvh_model.
num_vertices);
78 ar & make_nvp(
"prev_vertices",prev_vertices_map);
82 const bool has_prev_vertices =
false;
83 ar & make_nvp(
"has_prev_vertices",has_prev_vertices);
98 template <
class Archive>
105 ar >> make_nvp(
"base",boost::serialization::base_object<hpp::fcl::CollisionGeometry>(bvh_model));
108 ar >> make_nvp(
"num_vertices",num_vertices);
119 typedef Eigen::Matrix<FCL_REAL,3,Eigen::Dynamic> AsVertixMatrix;
120 Eigen::Map<AsVertixMatrix> vertices_map(reinterpret_cast<double *>(bvh_model.
vertices),3,bvh_model.
num_vertices);
121 ar >> make_nvp(
"vertices",vertices_map);
127 ar >> make_nvp(
"num_tris",num_tris);
139 typedef Eigen::Matrix<Triangle::index_type,3,Eigen::Dynamic> AsTriangleMatrix;
140 Eigen::Map<AsTriangleMatrix> tri_indices_map(reinterpret_cast<Triangle::index_type *>(bvh_model.
tri_indices),3,bvh_model.
num_tris);
141 ar & make_nvp(
"tri_indices",tri_indices_map);
146 ar >> make_nvp(
"build_state",bvh_model.
build_state);
152 bool has_prev_vertices;
153 ar >> make_nvp(
"has_prev_vertices",has_prev_vertices);
154 if(has_prev_vertices)
165 typedef Eigen::Matrix<FCL_REAL,3,Eigen::Dynamic> AsVertixMatrix;
166 Eigen::Map<AsVertixMatrix> prev_vertices_map(reinterpret_cast<double *>(bvh_model.
prev_vertices),3,bvh_model.
num_vertices);
167 ar & make_nvp(
"prev_vertices",prev_vertices_map);
181 template<
typename BV>
185 using Base::num_bvs_allocated;
186 using Base::primitive_indices;
192 template <
class Archive,
typename BV>
195 const unsigned int version)
197 split_free(ar,bvh_model,version);
200 template <
class Archive,
typename BV>
209 const Accessor & bvh_model =
reinterpret_cast<const Accessor &
>(bvh_model_);
210 ar & make_nvp(
"base",boost::serialization::base_object<BVHModelBase>(bvh_model));
248 const bool with_bvs =
true;
249 ar & make_nvp(
"with_bvs",with_bvs);
250 ar & make_nvp(
"num_bvs",bvh_model.num_bvs);
251 ar & make_nvp(
"bvs",make_array(reinterpret_cast<const char *>(bvh_model.bvs),
sizeof(Node)*(std::size_t)bvh_model.num_bvs));
255 const bool with_bvs =
false;
256 ar & make_nvp(
"with_bvs",with_bvs);
260 template <
class Archive,
typename BV>
269 Accessor & bvh_model =
reinterpret_cast<Accessor &
>(bvh_model_);
271 ar >> make_nvp(
"base",boost::serialization::base_object<BVHModelBase>(bvh_model));
291 ar >> make_nvp(
"with_bvs",with_bvs);
295 ar >> make_nvp(
"num_bvs",num_bvs);
297 if(num_bvs != bvh_model.num_bvs)
299 delete[] bvh_model.bvs;
300 bvh_model.bvs = NULL;
301 bvh_model.num_bvs = num_bvs;
307 ar >> make_nvp(
"bvs",make_array(reinterpret_cast<char *>(bvh_model.bvs),
sizeof(Node)*(std::size_t)num_bvs));
310 bvh_model.bvs = NULL;
317 #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:22
#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:24
Definition: BVH_model.h:182
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:184
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