GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/hpp/fcl/serialization/hfield.h Lines: 27 27 100.0 %
Date: 2024-02-09 12:57:42 Branches: 18 36 50.0 %

Line Branch Exec Source
1
//
2
// Copyright (c) 2021 INRIA
3
//
4
5
#ifndef HPP_FCL_SERIALIZATION_HFIELD_H
6
#define HPP_FCL_SERIALIZATION_HFIELD_H
7
8
#include "hpp/fcl/hfield.h"
9
10
#include "hpp/fcl/serialization/fwd.h"
11
#include "hpp/fcl/serialization/OBBRSS.h"
12
13
namespace boost {
14
namespace serialization {
15
16
template <class Archive>
17
630416
void serialize(Archive &ar, hpp::fcl::HFNodeBase &node,
18
               const unsigned int /*version*/) {
19
630416
  ar &make_nvp("first_child", node.first_child);
20
630416
  ar &make_nvp("x_id", node.x_id);
21
630416
  ar &make_nvp("x_size", node.x_size);
22
630416
  ar &make_nvp("y_id", node.y_id);
23
630416
  ar &make_nvp("y_size", node.y_size);
24
630416
  ar &make_nvp("max_height", node.max_height);
25
630416
}
26
27
template <class Archive, typename BV>
28
630416
void serialize(Archive &ar, hpp::fcl::HFNode<BV> &node,
29
               const unsigned int /*version*/) {
30
630416
  ar &make_nvp("base",
31
630416
               boost::serialization::base_object<hpp::fcl::HFNodeBase>(node));
32
630416
  ar &make_nvp("bv", node.bv);
33
630416
}
34
35
namespace internal {
36
template <typename BV>
37
struct HeightFieldAccessor : hpp::fcl::HeightField<BV> {
38
  typedef hpp::fcl::HeightField<BV> Base;
39
  using Base::bvs;
40
  using Base::heights;
41
  using Base::max_height;
42
  using Base::min_height;
43
  using Base::num_bvs;
44
  using Base::x_dim;
45
  using Base::x_grid;
46
  using Base::y_dim;
47
  using Base::y_grid;
48
};
49
}  // namespace internal
50
51
template <class Archive, typename BV>
52
16
void serialize(Archive &ar, hpp::fcl::HeightField<BV> &hf_model,
53
               const unsigned int /*version*/) {
54
16
  ar &make_nvp(
55
      "base",
56
16
      boost::serialization::base_object<hpp::fcl::CollisionGeometry>(hf_model));
57
58
  typedef internal::HeightFieldAccessor<BV> Accessor;
59
16
  Accessor &access = reinterpret_cast<Accessor &>(hf_model);
60
61
16
  ar &make_nvp("x_dim", access.x_dim);
62
16
  ar &make_nvp("y_dim", access.y_dim);
63
16
  ar &make_nvp("heights", access.heights);
64
16
  ar &make_nvp("min_height", access.min_height);
65
16
  ar &make_nvp("max_height", access.max_height);
66
16
  ar &make_nvp("x_grid", access.x_grid);
67
16
  ar &make_nvp("y_grid", access.y_grid);
68
69
16
  ar &make_nvp("bvs", access.bvs);
70
16
  ar &make_nvp("num_bvs", access.num_bvs);
71
16
}
72
}  // namespace serialization
73
}  // namespace boost
74
75
#endif  // ifndef HPP_FCL_SERIALIZATION_HFIELD_H