Directory: | ./ |
---|---|
File: | include/pinocchio/serialization/geometry.hpp |
Date: | 2025-02-12 21:03:38 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 45 | 45 | 100.0% |
Branches: | 37 | 74 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2021-2024 INRIA | ||
3 | // | ||
4 | |||
5 | #ifndef __pinocchio_serialization_multibody_geometry_hpp__ | ||
6 | #define __pinocchio_serialization_multibody_geometry_hpp__ | ||
7 | |||
8 | #include <boost/serialization/vector.hpp> | ||
9 | #include <boost/serialization/map.hpp> | ||
10 | #include <boost/serialization/shared_ptr.hpp> | ||
11 | |||
12 | #ifdef PINOCCHIO_WITH_HPP_FCL | ||
13 | #define HPP_FCL_SKIP_EIGEN_BOOST_SERIALIZATION | ||
14 | #include <hpp/fcl/serialization/collision_data.h> | ||
15 | #undef HPP_FCL_SKIP_EIGEN_BOOST_SERIALIZATION | ||
16 | #include <hpp/fcl/serialization/geometric_shapes.h> | ||
17 | #include <hpp/fcl/serialization/hfield.h> | ||
18 | #if HPP_FCL_VERSION_AT_LEAST(3, 0, 0) | ||
19 | #include <hpp/fcl/serialization/octree.h> | ||
20 | #endif | ||
21 | #include <hpp/fcl/serialization/convex.h> | ||
22 | #include <hpp/fcl/serialization/BVH_model.h> | ||
23 | #endif // PINOCCHIO_WITH_HPP_FCL | ||
24 | |||
25 | #include "pinocchio/multibody/geometry.hpp" | ||
26 | #include "pinocchio/serialization/aligned-vector.hpp" | ||
27 | #include "pinocchio/serialization/spatial.hpp" | ||
28 | #include "pinocchio/serialization/fcl.hpp" | ||
29 | |||
30 | namespace boost | ||
31 | { | ||
32 | namespace serialization | ||
33 | { | ||
34 | template<class Archive> | ||
35 | 28 | void serialize( | |
36 | Archive & ar, pinocchio::CollisionPair & collision_pair, const unsigned int /*version*/) | ||
37 | { | ||
38 |
1/2✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
|
28 | ar & make_nvp("pair", base_object<pinocchio::CollisionPair::Base>(collision_pair)); |
39 | 28 | } | |
40 | |||
41 | template<class Archive, typename Derived> | ||
42 | 1708 | void serialize( | |
43 | Archive & ar, pinocchio::ModelItem<Derived> & model_item, const unsigned int /*version*/) | ||
44 | { | ||
45 |
1/2✓ Branch 2 taken 854 times.
✗ Branch 3 not taken.
|
1708 | ar & make_nvp("name", model_item.name); |
46 |
1/2✓ Branch 2 taken 854 times.
✗ Branch 3 not taken.
|
1708 | ar & make_nvp("parentFrame", model_item.parentFrame); |
47 |
1/2✓ Branch 2 taken 854 times.
✗ Branch 3 not taken.
|
1708 | ar & make_nvp("parentJoint", model_item.parentJoint); |
48 |
1/2✓ Branch 2 taken 854 times.
✗ Branch 3 not taken.
|
1708 | ar & make_nvp("placement", model_item.placement); |
49 | 1708 | } | |
50 | |||
51 | template<class Archive> | ||
52 | 868 | void serialize( | |
53 | Archive & ar, pinocchio::GeometryObject & geometry_object, const unsigned int /*version*/) | ||
54 | { | ||
55 |
1/2✓ Branch 3 taken 434 times.
✗ Branch 4 not taken.
|
868 | ar & make_nvp("base", base_object<pinocchio::GeometryObject::Base>(geometry_object)); |
56 |
1/2✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
|
868 | ar & make_nvp("geometry", geometry_object.geometry); |
57 |
1/2✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
|
868 | ar & make_nvp("meshPath", geometry_object.meshPath); |
58 |
1/2✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
|
868 | ar & make_nvp("meshScale", geometry_object.meshScale); |
59 |
1/2✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
|
868 | ar & make_nvp("overrideMaterial", geometry_object.overrideMaterial); |
60 |
1/2✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
|
868 | ar & make_nvp("meshColor", geometry_object.meshColor); |
61 |
1/2✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
|
868 | ar & make_nvp("meshTexturePath", geometry_object.meshTexturePath); |
62 |
1/2✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
|
868 | ar & make_nvp("disableCollision", geometry_object.disableCollision); |
63 | 868 | } | |
64 | |||
65 | template<class Archive> | ||
66 | 406 | void save_construct_data( | |
67 | Archive & ar, | ||
68 | const pinocchio::GeometryObject * geometry_object_ptr, | ||
69 | const unsigned int /*version*/) | ||
70 | { | ||
71 |
1/2✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
|
406 | ar << make_nvp( |
72 | "base", *static_cast<const pinocchio::GeometryObject::Base *>(geometry_object_ptr)); | ||
73 | 406 | } | |
74 | |||
75 | template<class Archive> | ||
76 | 406 | void load_construct_data( | |
77 | Archive & ar, pinocchio::GeometryObject * geometry_object_ptr, const unsigned int /*version*/) | ||
78 | { | ||
79 |
1/2✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
|
406 | pinocchio::GeometryObject::Base base_obj; |
80 |
1/2✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
|
406 | ar >> make_nvp("base", base_obj); |
81 | |||
82 |
7/14✓ Branch 3 taken 203 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 203 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 203 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 203 times.
✗ Branch 13 not taken.
✓ Branch 16 taken 203 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 203 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 203 times.
✗ Branch 24 not taken.
|
406 | new (geometry_object_ptr) pinocchio::GeometryObject( |
83 | base_obj.name, base_obj.parentJoint, base_obj.parentFrame, base_obj.placement, nullptr); | ||
84 | 406 | } | |
85 | |||
86 | template<class Archive> | ||
87 | void | ||
88 | 56 | serialize(Archive & ar, pinocchio::GeometryModel & geom_model, const unsigned int /*version*/) | |
89 | { | ||
90 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("ngeoms", geom_model.ngeoms); |
91 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("geometryObjects", geom_model.geometryObjects); |
92 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("collisionPairs", geom_model.collisionPairs); |
93 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("collisionPairMapping", geom_model.collisionPairMapping); |
94 | 56 | } | |
95 | |||
96 | template<class Archive> | ||
97 | void | ||
98 | 56 | serialize(Archive & ar, pinocchio::GeometryData & geom_data, const unsigned int /*version*/) | |
99 | { | ||
100 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("oMg", geom_data.oMg); |
101 | |||
102 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("activeCollisionPairs", geom_data.activeCollisionPairs); |
103 | |||
104 | #ifdef PINOCCHIO_WITH_HPP_FCL | ||
105 | // TODO(jcarpent): check whether the archive has been registered with HPP_FCL module ON or | ||
106 | // OFF. | ||
107 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("distanceRequests", geom_data.distanceRequests); |
108 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("distanceResults", geom_data.distanceResults); |
109 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("collisionRequests", geom_data.collisionRequests); |
110 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("collisionResults", geom_data.collisionResults); |
111 | |||
112 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("radius", geom_data.radius); |
113 | |||
114 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("collisionPairIndex", geom_data.collisionPairIndex); |
115 | #endif // PINOCCHIO_WITH_HPP_FCL | ||
116 | |||
117 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("innerObjects", geom_data.innerObjects); |
118 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
56 | ar & make_nvp("outerObjects", geom_data.outerObjects); |
119 | 56 | } | |
120 | |||
121 | } // namespace serialization | ||
122 | } // namespace boost | ||
123 | |||
124 | #endif // ifndef __pinocchio_serialization_multibody_geometry_hpp__ | ||
125 |