hpp-fcl  3.0.0
HPP fork of FCL -- The Flexible Collision Library
kIOS.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2024 INRIA
3 //
4 
5 #ifndef HPP_FCL_SERIALIZATION_kIOS_H
6 #define HPP_FCL_SERIALIZATION_kIOS_H
7 
8 #include "hpp/fcl/BV/kIOS.h"
9 
12 
13 namespace boost {
14 namespace serialization {
15 
16 template <class Archive>
17 void serialize(Archive& ar, hpp::fcl::kIOS& bv, const unsigned int version) {
18  split_free(ar, bv, version);
19 }
20 
21 template <class Archive>
22 void save(Archive& ar, const hpp::fcl::kIOS& bv,
23  const unsigned int /*version*/) {
24  // Number of spheres in kIOS is never larger than kIOS::kios_max_num_spheres
25  ar& make_nvp("num_spheres", bv.num_spheres);
26 
27  std::array<hpp::fcl::Vec3f, hpp::fcl::kIOS::max_num_spheres> centers{};
28  std::array<hpp::fcl::FCL_REAL, hpp::fcl::kIOS::max_num_spheres> radii;
29  for (std::size_t i = 0; i < hpp::fcl::kIOS::max_num_spheres; ++i) {
30  centers[i] = bv.spheres[i].o;
31  radii[i] = bv.spheres[i].r;
32  }
33  ar& make_nvp("centers", make_array(centers.data(), centers.size()));
34  ar& make_nvp("radii", make_array(radii.data(), radii.size()));
35 
36  ar& make_nvp("obb", bv.obb);
37 }
38 
39 template <class Archive>
40 void load(Archive& ar, hpp::fcl::kIOS& bv, const unsigned int /*version*/) {
41  ar >> make_nvp("num_spheres", bv.num_spheres);
42 
43  std::array<hpp::fcl::Vec3f, hpp::fcl::kIOS::max_num_spheres> centers;
44  std::array<hpp::fcl::FCL_REAL, hpp::fcl::kIOS::max_num_spheres> radii;
45  ar >> make_nvp("centers", make_array(centers.data(), centers.size()));
46  ar >> make_nvp("radii", make_array(radii.data(), radii.size()));
47  for (std::size_t i = 0; i < hpp::fcl::kIOS::max_num_spheres; ++i) {
48  bv.spheres[i].o = centers[i];
49  bv.spheres[i].r = radii[i];
50  }
51 
52  ar >> make_nvp("obb", bv.obb);
53 }
54 
55 } // namespace serialization
56 } // namespace boost
57 
58 #endif // HPP_FCL_SERIALIZATION_kIOS_H
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:53
static constexpr size_t max_num_spheres
Definition: kIOS.h:114
kIOS_Sphere spheres[max_num_spheres]
The (at most) five spheres for intersection.
Definition: kIOS.h:117
unsigned int num_spheres
The number of spheres, no larger than 5.
Definition: kIOS.h:120
OBB obb
@ OBB related with kIOS
Definition: kIOS.h:123
void save(Archive &ar, const hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:30
void load(Archive &ar, hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:44
void serialize(Archive &ar, hpp::fcl::AABB &aabb, const unsigned int)
Definition: AABB.h:15
Definition: AABB.h:11