.. _program_listing_file__tmp_ws_src_hpp-fcl_include_hpp_fcl_serialization_convex.h: Program Listing for File convex.h ================================= |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/hpp-fcl/include/hpp/fcl/serialization/convex.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // // Copyright (c) 2022 INRIA // #ifndef HPP_FCL_SERIALIZATION_CONVEX_H #define HPP_FCL_SERIALIZATION_CONVEX_H #include "hpp/fcl/shape/convex.h" #include "hpp/fcl/serialization/fwd.h" #include "hpp/fcl/serialization/geometric_shapes.h" #include "hpp/fcl/serialization/memory.h" #include "hpp/fcl/serialization/triangle.h" #include "hpp/fcl/serialization/quadrilateral.h" namespace boost { namespace serialization { namespace internal { struct ConvexBaseAccessor : hpp::fcl::ConvexBase { typedef hpp::fcl::ConvexBase Base; using Base::own_storage_; }; } // namespace internal template void serialize(Archive &ar, hpp::fcl::ConvexBase &convex_base, const unsigned int /*version*/) { using namespace hpp::fcl; typedef internal::ConvexBaseAccessor Accessor; Accessor &accessor = reinterpret_cast(convex_base); ar &make_nvp("base", boost::serialization::base_object( convex_base)); const unsigned int num_points_previous = convex_base.num_points; ar &make_nvp("num_points", convex_base.num_points); if (Archive::is_loading::value) { if (num_points_previous != convex_base.num_points || !accessor.own_storage_) { delete[] convex_base.points; convex_base.points = new hpp::fcl::Vec3f[convex_base.num_points]; accessor.own_storage_ = true; } } { typedef Eigen::Matrix MatrixPoints; Eigen::Map points_map( reinterpret_cast(convex_base.points), 3, convex_base.num_points); ar &make_nvp("points", points_map); } ar &make_nvp("center", convex_base.center); // We don't save neighbors as they will be computed directly by calling // fillNeighbors. } namespace internal { template struct ConvexAccessor : hpp::fcl::Convex { typedef hpp::fcl::Convex Base; using Base::fillNeighbors; }; } // namespace internal template void serialize(Archive &ar, hpp::fcl::Convex &convex_, const unsigned int /*version*/) { using namespace hpp::fcl; typedef internal::ConvexAccessor Accessor; Accessor &convex = reinterpret_cast(convex_); ar &make_nvp("base", boost::serialization::base_object(convex)); const unsigned int num_polygons_previous = convex.num_polygons; ar &make_nvp("num_polygons", convex.num_polygons); if (Archive::is_loading::value) { if (num_polygons_previous != convex.num_polygons) { delete[] convex.polygons; convex.polygons = new PolygonT[convex.num_polygons]; } } ar &make_array(convex.polygons, convex.num_polygons); if (Archive::is_loading::value) convex.fillNeighbors(); } } // namespace serialization } // namespace boost namespace hpp { namespace fcl { // namespace internal { // template // struct memory_footprint_evaluator< ::hpp::fcl::BVHModel > { // static size_t run(const ::hpp::fcl::BVHModel &bvh_model) { // return static_cast(bvh_model.memUsage(false)); // } // }; // } // namespace internal } // namespace fcl } // namespace hpp #endif // ifndef HPP_FCL_SERIALIZATION_CONVEX_H