Directory: | ./ |
---|---|
File: | include/coal/serialization/hfield.h |
Date: | 2025-04-01 09:23:31 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 31 | 31 | 100.0% |
Branches: | 19 | 38 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2021-2024 INRIA | ||
3 | // | ||
4 | |||
5 | #ifndef COAL_SERIALIZATION_HFIELD_H | ||
6 | #define COAL_SERIALIZATION_HFIELD_H | ||
7 | |||
8 | #include "coal/hfield.h" | ||
9 | |||
10 | #include "coal/serialization/fwd.h" | ||
11 | #include "coal/serialization/OBBRSS.h" | ||
12 | |||
13 | namespace boost { | ||
14 | namespace serialization { | ||
15 | |||
16 | template <class Archive> | ||
17 | 1418436 | void serialize(Archive &ar, coal::HFNodeBase &node, | |
18 | const unsigned int /*version*/) { | ||
19 |
1/2✓ Branch 2 taken 709218 times.
✗ Branch 3 not taken.
|
1418436 | ar &make_nvp("first_child", node.first_child); |
20 |
1/2✓ Branch 2 taken 709218 times.
✗ Branch 3 not taken.
|
1418436 | ar &make_nvp("x_id", node.x_id); |
21 |
1/2✓ Branch 2 taken 709218 times.
✗ Branch 3 not taken.
|
1418436 | ar &make_nvp("x_size", node.x_size); |
22 |
1/2✓ Branch 2 taken 709218 times.
✗ Branch 3 not taken.
|
1418436 | ar &make_nvp("y_id", node.y_id); |
23 |
1/2✓ Branch 2 taken 709218 times.
✗ Branch 3 not taken.
|
1418436 | ar &make_nvp("y_size", node.y_size); |
24 |
1/2✓ Branch 2 taken 709218 times.
✗ Branch 3 not taken.
|
1418436 | ar &make_nvp("max_height", node.max_height); |
25 |
1/2✓ Branch 2 taken 709218 times.
✗ Branch 3 not taken.
|
1418436 | ar &make_nvp("contact_active_faces", node.contact_active_faces); |
26 | 1418436 | } | |
27 | |||
28 | template <class Archive, typename BV> | ||
29 | 1418436 | void serialize(Archive &ar, coal::HFNode<BV> &node, | |
30 | const unsigned int /*version*/) { | ||
31 |
1/2✓ Branch 1 taken 709218 times.
✗ Branch 2 not taken.
|
1418436 | ar &make_nvp("base", |
32 | 1418436 | boost::serialization::base_object<coal::HFNodeBase>(node)); | |
33 |
1/2✓ Branch 2 taken 709218 times.
✗ Branch 3 not taken.
|
1418436 | ar &make_nvp("bv", node.bv); |
34 | 1418436 | } | |
35 | |||
36 | namespace internal { | ||
37 | template <typename BV> | ||
38 | struct HeightFieldAccessor : coal::HeightField<BV> { | ||
39 | typedef coal::HeightField<BV> Base; | ||
40 | using Base::bvs; | ||
41 | using Base::heights; | ||
42 | using Base::max_height; | ||
43 | using Base::min_height; | ||
44 | using Base::num_bvs; | ||
45 | using Base::x_dim; | ||
46 | using Base::x_grid; | ||
47 | using Base::y_dim; | ||
48 | using Base::y_grid; | ||
49 | }; | ||
50 | } // namespace internal | ||
51 | |||
52 | template <class Archive, typename BV> | ||
53 | 36 | void serialize(Archive &ar, coal::HeightField<BV> &hf_model, | |
54 | const unsigned int /*version*/) { | ||
55 |
1/2✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
|
36 | ar &make_nvp( |
56 | "base", | ||
57 | 36 | boost::serialization::base_object<coal::CollisionGeometry>(hf_model)); | |
58 | |||
59 | typedef internal::HeightFieldAccessor<BV> Accessor; | ||
60 | 36 | Accessor &access = reinterpret_cast<Accessor &>(hf_model); | |
61 | |||
62 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("x_dim", access.x_dim); |
63 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("y_dim", access.y_dim); |
64 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("heights", access.heights); |
65 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("min_height", access.min_height); |
66 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("max_height", access.max_height); |
67 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("x_grid", access.x_grid); |
68 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("y_grid", access.y_grid); |
69 | |||
70 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("bvs", access.bvs); |
71 |
1/2✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
36 | ar &make_nvp("num_bvs", access.num_bvs); |
72 | 36 | } | |
73 | } // namespace serialization | ||
74 | } // namespace boost | ||
75 | |||
76 | 36 | COAL_SERIALIZATION_DECLARE_EXPORT(::coal::HeightField<::coal::AABB>) | |
77 | 36 | COAL_SERIALIZATION_DECLARE_EXPORT(::coal::HeightField<::coal::OBB>) | |
78 | 36 | COAL_SERIALIZATION_DECLARE_EXPORT(::coal::HeightField<::coal::OBBRSS>) | |
79 | |||
80 | #endif // ifndef COAL_SERIALIZATION_HFIELD_H | ||
81 |