5 #ifndef COAL_SERIALIZATION_CONVEX_H
6 #define COAL_SERIALIZATION_CONVEX_H
17 namespace serialization {
26 template <
class Archive>
28 const unsigned int ) {
32 boost::serialization::base_object<coal::ShapeBase>(convex_base));
34 const unsigned int num_points_previous = convex_base.
num_points;
35 ar& make_nvp(
"num_points", convex_base.
num_points);
37 const unsigned int num_normals_and_offsets_previous =
41 const int num_warm_start_supports_previous =
43 assert(num_warm_start_supports_previous ==
45 int num_warm_start_supports = num_warm_start_supports_previous;
46 ar& make_nvp(
"num_warm_start_supports", num_warm_start_supports);
48 if (Archive::is_loading::value) {
49 if (num_points_previous != convex_base.
num_points) {
50 convex_base.
points.reset();
53 new std::vector<Vec3s>(convex_base.
num_points));
56 if (num_normals_and_offsets_previous !=
68 if (num_warm_start_supports_previous != num_warm_start_supports) {
70 static_cast<size_t>(num_warm_start_supports));
72 static_cast<size_t>(num_warm_start_supports));
76 typedef Eigen::Matrix<CoalScalar, 3, Eigen::Dynamic> MatrixPoints;
78 Eigen::Map<MatrixPoints> points_map(
81 ar& make_nvp(
"points", points_map);
84 typedef Eigen::Matrix<CoalScalar, 1, Eigen::Dynamic> VecOfReals;
86 Eigen::Map<MatrixPoints> normals_map(
89 ar& make_nvp(
"normals", normals_map);
91 Eigen::Map<VecOfReals> offsets_map(
94 ar& make_nvp(
"offsets", offsets_map);
97 typedef Eigen::Matrix<int, 1, Eigen::Dynamic> VecOfInts;
98 if (num_warm_start_supports > 0) {
99 Eigen::Map<MatrixPoints> warm_start_support_points_map(
102 3, num_warm_start_supports);
103 ar& make_nvp(
"warm_start_support_points", warm_start_support_points_map);
105 Eigen::Map<VecOfInts> warm_start_support_indices_map(
107 1, num_warm_start_supports);
108 ar& make_nvp(
"warm_start_support_indices", warm_start_support_indices_map);
111 ar& make_nvp(
"center", convex_base.
center);
117 template <
typename PolygonT>
125 template <
class Archive,
typename PolygonT>
127 const unsigned int ) {
128 using namespace coal;
131 Accessor& convex =
reinterpret_cast<Accessor&
>(convex_);
132 ar& make_nvp(
"base", boost::serialization::base_object<ConvexBase>(convex_));
134 const unsigned int num_polygons_previous = convex.num_polygons;
135 ar& make_nvp(
"num_polygons", convex.num_polygons);
137 if (Archive::is_loading::value) {
138 if (num_polygons_previous != convex.num_polygons) {
139 convex.polygons.reset(
new std::vector<PolygonT>(convex.num_polygons));
143 ar& make_array<PolygonT>(convex.polygons->data(), convex.num_polygons);
145 if (Archive::is_loading::value) convex.fillNeighbors();
167 #endif // ifndef COAL_SERIALIZATION_CONVEX_H