hpp-fcl 2.3.6
HPP fork of FCL -- The Flexible Collision Library
Loading...
Searching...
No Matches
convex.h
Go to the documentation of this file.
1//
2// Copyright (c) 2022 INRIA
3//
4
5#ifndef HPP_FCL_SERIALIZATION_CONVEX_H
6#define HPP_FCL_SERIALIZATION_CONVEX_H
7
9
15
16namespace boost {
17namespace serialization {
18
19namespace internal {
23};
24
25} // namespace internal
26
27template <class Archive>
28void serialize(Archive &ar, hpp::fcl::ConvexBase &convex_base,
29 const unsigned int /*version*/) {
30 using namespace hpp::fcl;
31
32 typedef internal::ConvexBaseAccessor Accessor;
33 Accessor &accessor = reinterpret_cast<Accessor &>(convex_base);
34
35 ar &make_nvp("base", boost::serialization::base_object<hpp::fcl::ShapeBase>(
36 convex_base));
37 const unsigned int num_points_previous = convex_base.num_points;
38 ar &make_nvp("num_points", convex_base.num_points);
39
40 if (Archive::is_loading::value) {
41 if (num_points_previous != convex_base.num_points ||
42 !accessor.own_storage_) {
43 delete[] convex_base.points;
44 convex_base.points = new hpp::fcl::Vec3f[convex_base.num_points];
45 accessor.own_storage_ = true;
46 }
47 }
48
49 {
50 typedef Eigen::Matrix<FCL_REAL, 3, Eigen::Dynamic> MatrixPoints;
51 Eigen::Map<MatrixPoints> points_map(
52 reinterpret_cast<double *>(convex_base.points), 3,
53 convex_base.num_points);
54 ar &make_nvp("points", points_map);
55 }
56
57 ar &make_nvp("center", convex_base.center);
58 // We don't save neighbors as they will be computed directly by calling
59 // fillNeighbors.
60}
61
62namespace internal {
63template <typename PolygonT>
64struct ConvexAccessor : hpp::fcl::Convex<PolygonT> {
67};
68
69} // namespace internal
70
71template <class Archive, typename PolygonT>
72void serialize(Archive &ar, hpp::fcl::Convex<PolygonT> &convex_,
73 const unsigned int /*version*/) {
74 using namespace hpp::fcl;
76
77 Accessor &convex = reinterpret_cast<Accessor &>(convex_);
78 ar &make_nvp("base", boost::serialization::base_object<ConvexBase>(convex));
79
80 const unsigned int num_polygons_previous = convex.num_polygons;
81 ar &make_nvp("num_polygons", convex.num_polygons);
82
83 if (Archive::is_loading::value) {
84 if (num_polygons_previous != convex.num_polygons) {
85 delete[] convex.polygons;
86 convex.polygons = new PolygonT[convex.num_polygons];
87 }
88 }
89
90 ar &make_array<PolygonT>(convex.polygons, convex.num_polygons);
91
92 if (Archive::is_loading::value) convex.fillNeighbors();
93}
94
95} // namespace serialization
96} // namespace boost
97
98namespace hpp {
99namespace fcl {
100
101// namespace internal {
102// template <typename BV>
103// struct memory_footprint_evaluator< ::hpp::fcl::BVHModel<BV> > {
104// static size_t run(const ::hpp::fcl::BVHModel<BV> &bvh_model) {
105// return static_cast<size_t>(bvh_model.memUsage(false));
106// }
107// };
108// } // namespace internal
109
110} // namespace fcl
111} // namespace hpp
112
113#endif // ifndef HPP_FCL_SERIALIZATION_CONVEX_H
Base for convex polytope.
Definition: geometric_shapes.h:581
Convex polytope.
Definition: convex.h:50
void fillNeighbors()
Definition: convex.hxx:204
Vec3f * points
An array of the points of the polygon.
Definition: geometric_shapes.h:623
bool own_storage_
Definition: geometric_shapes.h:693
unsigned int num_points
Definition: geometric_shapes.h:624
Vec3f center
center of the convex polytope, this is used for collision: center is guaranteed in the internal of th...
Definition: geometric_shapes.h:659
void serialize(Archive &ar, hpp::fcl::AABB &aabb, const unsigned int)
Definition: AABB.h:15
Definition: AABB.h:11
Definition: broadphase_bruteforce.h:45
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:66
Main namespace.
Definition: broadphase_bruteforce.h:44
hpp::fcl::Convex< PolygonT > Base
Definition: convex.h:65
hpp::fcl::ConvexBase Base
Definition: convex.h:21