GCC Code Coverage Report


Directory: ./
File: include/coal/serialization/geometric_shapes.h
Date: 2025-04-01 09:23:31
Exec Total Coverage
Lines: 69 69 100.0%
Branches: 29 58 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2021-2024 INRIA
3 //
4
5 #ifndef COAL_SERIALIZATION_GEOMETRIC_SHAPES_H
6 #define COAL_SERIALIZATION_GEOMETRIC_SHAPES_H
7
8 #include "coal/shape/geometric_shapes.h"
9 #include "coal/serialization/fwd.h"
10 #include "coal/serialization/collision_object.h"
11
12 namespace boost {
13 namespace serialization {
14
15 template <class Archive>
16 284 void serialize(Archive& ar, coal::ShapeBase& shape_base,
17 const unsigned int /*version*/) {
18
1/2
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
284 ar& make_nvp(
19 "base",
20
1/2
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
284 boost::serialization::base_object<coal::CollisionGeometry>(shape_base));
21 284 ::coal::Scalar radius = shape_base.getSweptSphereRadius();
22
1/2
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
284 ar& make_nvp("swept_sphere_radius", radius);
23
24 if (Archive::is_loading::value) {
25
1/2
✓ Branch 1 taken 71 times.
✗ Branch 2 not taken.
142 shape_base.setSweptSphereRadius(radius);
26 }
27 284 }
28
29 template <class Archive>
30 28 void serialize(Archive& ar, coal::TriangleP& triangle,
31 const unsigned int /*version*/) {
32
1/2
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
28 ar& make_nvp("base",
33 28 boost::serialization::base_object<coal::ShapeBase>(triangle));
34
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& make_nvp("a", triangle.a);
35
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& make_nvp("b", triangle.b);
36
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& make_nvp("c", triangle.c);
37 28 }
38
39 template <class Archive>
40 32 void serialize(Archive& ar, coal::Box& box, const unsigned int /*version*/) {
41
1/2
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
32 ar& make_nvp("base", boost::serialization::base_object<coal::ShapeBase>(box));
42
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("halfSide", box.halfSide);
43 32 }
44
45 template <class Archive>
46 32 void serialize(Archive& ar, coal::Sphere& sphere,
47 const unsigned int /*version*/) {
48
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
32 ar& make_nvp("base",
49 32 boost::serialization::base_object<coal::ShapeBase>(sphere));
50
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("radius", sphere.radius);
51 32 }
52
53 template <class Archive>
54 32 void serialize(Archive& ar, coal::Ellipsoid& ellipsoid,
55 const unsigned int /*version*/) {
56
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
32 ar& make_nvp("base",
57 32 boost::serialization::base_object<coal::ShapeBase>(ellipsoid));
58
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("radii", ellipsoid.radii);
59 32 }
60
61 template <class Archive>
62 32 void serialize(Archive& ar, coal::Capsule& capsule,
63 const unsigned int /*version*/) {
64
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
32 ar& make_nvp("base",
65 32 boost::serialization::base_object<coal::ShapeBase>(capsule));
66
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("radius", capsule.radius);
67
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("halfLength", capsule.halfLength);
68 32 }
69
70 template <class Archive>
71 28 void serialize(Archive& ar, coal::Cone& cone, const unsigned int /*version*/) {
72
1/2
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
28 ar& make_nvp("base",
73 28 boost::serialization::base_object<coal::ShapeBase>(cone));
74
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& make_nvp("radius", cone.radius);
75
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar& make_nvp("halfLength", cone.halfLength);
76 28 }
77
78 template <class Archive>
79 32 void serialize(Archive& ar, coal::Cylinder& cylinder,
80 const unsigned int /*version*/) {
81
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
32 ar& make_nvp("base",
82 32 boost::serialization::base_object<coal::ShapeBase>(cylinder));
83
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("radius", cylinder.radius);
84
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("halfLength", cylinder.halfLength);
85 32 }
86
87 template <class Archive>
88 32 void serialize(Archive& ar, coal::Halfspace& half_space,
89 const unsigned int /*version*/) {
90
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
32 ar& make_nvp("base",
91 32 boost::serialization::base_object<coal::ShapeBase>(half_space));
92
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("n", half_space.n);
93
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("d", half_space.d);
94 32 }
95
96 template <class Archive>
97 32 void serialize(Archive& ar, coal::Plane& plane,
98 const unsigned int /*version*/) {
99
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
32 ar& make_nvp("base",
100 32 boost::serialization::base_object<coal::ShapeBase>(plane));
101
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("n", plane.n);
102
1/2
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ar& make_nvp("d", plane.d);
103 32 }
104
105 } // namespace serialization
106 } // namespace boost
107
108 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::ShapeBase)
109 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::CollisionGeometry)
110 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::TriangleP)
111 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::Box)
112 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::Sphere)
113 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::Ellipsoid)
114 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::Capsule)
115 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::Cone)
116 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::Cylinder)
117 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::Halfspace)
118 36 COAL_SERIALIZATION_DECLARE_EXPORT(::coal::Plane)
119
120 #endif // ifndef COAL_SERIALIZATION_GEOMETRIC_SHAPES_H
121