hpp-fcl: include/hpp/fcl/serialization/collision_data.h Source File

hpp-fcl 1.7.3 HPP fork of FCL -- The Flexible Collision Library

collision_data.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021 INRIA
3 //
4
5 #ifndef HPP_FCL_SERIALIZATION_COLLISION_DATA_H
6 #define HPP_FCL_SERIALIZATION_COLLISION_DATA_H
7
8 #include "hpp/fcl/collision_data.h"
9 #include "hpp/fcl/serialization/fwd.h"
10
11 namespace boost
12 {
13 namespace serialization
14 {
15
16 template <class Archive>
17 void save(Archive & ar,
18 const hpp::fcl::Contact & contact,
19 const unsigned int /*version*/)
20 {
21 ar & make_nvp("b1",contact.b1);
22 ar & make_nvp("b2",contact.b2);
23 ar & make_nvp("normal",contact.normal);
24 ar & make_nvp("pos",contact.pos);
25 ar & make_nvp("penetration_depth",contact.penetration_depth);
26 }
27
28 template <class Archive>
29 void load(Archive & ar,
30 hpp::fcl::Contact & contact,
31 const unsigned int /*version*/)
32 {
33 ar >> make_nvp("b1",contact.b1);
34 ar >> make_nvp("b2",contact.b2);
35 ar >> make_nvp("normal",contact.normal);
36 ar >> make_nvp("pos",contact.pos);
37 ar >> make_nvp("penetration_depth",contact.penetration_depth);
38 contact.o1 = NULL;
39 contact.o2 = NULL;
40 }
41
42 HPP_FCL_SERIALIZATION_SPLIT(hpp::fcl::Contact)
43
44 template <class Archive>
45 void serialize(Archive & ar,
46 hpp::fcl::QueryRequest & query_request,
47 const unsigned int /*version*/)
48 {
49 ar & make_nvp("enable_cached_gjk_guess",query_request.enable_cached_gjk_guess);
50 ar & make_nvp("cached_gjk_guess",query_request.cached_gjk_guess);
51 ar & make_nvp("cached_support_func_guess",query_request.cached_support_func_guess);
52 ar & make_nvp("enable_timings",query_request.enable_timings);
53 }
54
55 template <class Archive>
56 void serialize(Archive & ar,
57 hpp::fcl::QueryResult & query_result,
58 const unsigned int /*version*/)
59 {
60 ar & make_nvp("cached_gjk_guess",query_result.cached_gjk_guess);
61 ar & make_nvp("cached_support_func_guess",query_result.cached_support_func_guess);
62 }
63
64 template <class Archive>
65 void serialize(Archive & ar,
66 hpp::fcl::CollisionRequest & collision_request,
67 const unsigned int /*version*/)
68 {
69 ar & make_nvp("base",boost::serialization::base_object<hpp::fcl::QueryRequest>(collision_request));
70 ar & make_nvp("num_max_contacts",collision_request.num_max_contacts);
71 ar & make_nvp("enable_contact",collision_request.enable_contact);
72 ar & make_nvp("enable_distance_lower_bound",collision_request.enable_distance_lower_bound);
73 ar & make_nvp("security_margin",collision_request.security_margin);
74 ar & make_nvp("break_distance",collision_request.break_distance);
75 }
76
77 template <class Archive>
78 void save(Archive & ar,
79 const hpp::fcl::CollisionResult & collision_result,
80 const unsigned int /*version*/)
81 {
82 ar & make_nvp("base",boost::serialization::base_object<hpp::fcl::QueryResult>(collision_result));
83 ar & make_nvp("contacts",collision_result.getContacts());
84 ar & make_nvp("distance_lower_bound",collision_result.distance_lower_bound);
85 }
86
87 template <class Archive>
88 void load(Archive & ar,
89 hpp::fcl::CollisionResult & collision_result,
90 const unsigned int /*version*/)
91 {
92 ar >> make_nvp("base",boost::serialization::base_object<hpp::fcl::QueryResult>(collision_result));
93 std::vector<hpp::fcl::Contact> contacts;
94 ar >> make_nvp("contacts",contacts);
95 collision_result.clear();
96 for(size_t k = 0; k < contacts.size(); ++k)
97 collision_result.addContact(contacts[k]);
98 ar >> make_nvp("distance_lower_bound",collision_result.distance_lower_bound);
99 }
100
101 HPP_FCL_SERIALIZATION_SPLIT(hpp::fcl::CollisionResult)
102
103 template <class Archive>
104 void serialize(Archive & ar,
105 hpp::fcl::DistanceRequest & distance_request,
106 const unsigned int /*version*/)
107 {
108 ar & make_nvp("base",boost::serialization::base_object<hpp::fcl::QueryRequest>(distance_request));
109 ar & make_nvp("enable_nearest_points",distance_request.enable_nearest_points);
110 ar & make_nvp("rel_err",distance_request.rel_err);
111 ar & make_nvp("abs_err",distance_request.abs_err);
112 }
113
114 template <class Archive>
115 void save(Archive & ar,
116 const hpp::fcl::DistanceResult & distance_result,
117 const unsigned int /*version*/)
118 {
119 ar & make_nvp("base",boost::serialization::base_object<hpp::fcl::QueryResult>(distance_result));
120 ar & make_nvp("min_distance",distance_result.min_distance);
121 ar & make_nvp("nearest_points",make_array(distance_result.nearest_points,2));
122 ar & make_nvp("normal",distance_result.normal);
123 ar & make_nvp("b1",distance_result.b1);
124 ar & make_nvp("b2",distance_result.b2);
125 }
126
127 template <class Archive>
128 void load(Archive & ar,
129 hpp::fcl::DistanceResult & distance_result,
130 const unsigned int /*version*/)
131 {
132 ar >> make_nvp("base",boost::serialization::base_object<hpp::fcl::QueryResult>(distance_result));
133 ar >> make_nvp("min_distance",distance_result.min_distance);
134 ar >> make_nvp("nearest_points",make_array(distance_result.nearest_points,2));
135 ar >> make_nvp("normal",distance_result.normal);
136 ar >> make_nvp("b1",distance_result.b1);
137 ar >> make_nvp("b2",distance_result.b2);
138 distance_result.o1 = NULL;
139 distance_result.o2 = NULL;
140 }
141
142 HPP_FCL_SERIALIZATION_SPLIT(hpp::fcl::DistanceResult)
143
144 }
145 }
146
147 #endif // ifndef HPP_FCL_SERIALIZATION_COLLISION_DATA_H
collision_data.h
fwd.h
HPP_FCL_SERIALIZATION_SPLIT
#define HPP_FCL_SERIALIZATION_SPLIT(Type)
Definition: fwd.h:13
boost::serialization::save
void save(Archive &ar, const hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:34
boost::serialization::load
void load(Archive &ar, hpp::fcl::BVSplitter< BV > &splitter_, const unsigned int)
Definition: BV_splitter.h:50
boost::serialization::serialize
void serialize(Archive &ar, hpp::fcl::AABB &aabb, const unsigned int)
Definition: AABB.h:17
boost
Definition: AABB.h:12
hpp::fcl::CollisionRequest
request to the collision algorithm
Definition: collision_data.h:209
hpp::fcl::CollisionRequest::num_max_contacts
size_t num_max_contacts
The maximum number of contacts will return.
Definition: collision_data.h:211
hpp::fcl::CollisionRequest::enable_distance_lower_bound
bool enable_distance_lower_bound
Whether a lower bound on distance is returned when objects are disjoint.
Definition: collision_data.h:217
hpp::fcl::CollisionRequest::security_margin
FCL_REAL security_margin
Distance below which objects are considered in collision. See Collision detection and distance lower ...
Definition: collision_data.h:221
hpp::fcl::CollisionRequest::enable_contact
bool enable_contact
whether the contact information (normal, penetration depth and contact position) will return
Definition: collision_data.h:214
hpp::fcl::CollisionRequest::break_distance
FCL_REAL break_distance
Distance below which bounding volumes are broken down. See Collision detection and distance lower bou...
Definition: collision_data.h:225
hpp::fcl::CollisionResult
collision result
Definition: collision_data.h:270
hpp::fcl::CollisionResult::clear
void clear()
clear the results obtained
Definition: collision_data.h:345
hpp::fcl::CollisionResult::addContact
void addContact(const Contact &c)
add one contact into result structure
Definition: collision_data.h:296
hpp::fcl::CollisionResult::getContacts
void getContacts(std::vector< Contact > &contacts_) const
get all the contacts
Definition: collision_data.h:333
hpp::fcl::CollisionResult::distance_lower_bound
FCL_REAL distance_lower_bound
Definition: collision_data.h:280
hpp::fcl::Contact
Contact information returned by collision.
Definition: collision_data.h:58
hpp::fcl::Contact::penetration_depth
FCL_REAL penetration_depth
penetration depth
Definition: collision_data.h:84
hpp::fcl::Contact::pos
Vec3f pos
contact position, in world space
Definition: collision_data.h:81
hpp::fcl::Contact::b1
int b1
contact primitive in object 1 if object 1 is mesh or point cloud, it is the triangle or point id if o...
Definition: collision_data.h:69
hpp::fcl::Contact::b2
int b2
contact primitive in object 2 if object 2 is mesh or point cloud, it is the triangle or point id if o...
Definition: collision_data.h:75
hpp::fcl::Contact::o2
const CollisionGeometry * o2
collision object 2
Definition: collision_data.h:63
hpp::fcl::Contact::o1
const CollisionGeometry * o1
collision object 1
Definition: collision_data.h:60
hpp::fcl::Contact::normal
Vec3f normal
contact normal, pointing from o1 to o2
Definition: collision_data.h:78
hpp::fcl::DistanceRequest
request to the distance computation
Definition: collision_data.h:362
hpp::fcl::DistanceRequest::enable_nearest_points
bool enable_nearest_points
whether to return the nearest points
Definition: collision_data.h:364
hpp::fcl::DistanceRequest::rel_err
FCL_REAL rel_err
error threshold for approximate distance
Definition: collision_data.h:367
hpp::fcl::DistanceRequest::abs_err
FCL_REAL abs_err
Definition: collision_data.h:368
hpp::fcl::DistanceResult
distance result
Definition: collision_data.h:396
hpp::fcl::DistanceResult::o2
const CollisionGeometry * o2
collision object 2
Definition: collision_data.h:413
hpp::fcl::DistanceResult::normal
Vec3f normal
In case both objects are in collision, store the normal.
Definition: collision_data.h:407
hpp::fcl::DistanceResult::o1
const CollisionGeometry * o1
collision object 1
Definition: collision_data.h:410
hpp::fcl::DistanceResult::b2
int b2
information about the nearest point in object 2 if object 2 is mesh or point cloud,...
Definition: collision_data.h:425
hpp::fcl::DistanceResult::nearest_points
Vec3f nearest_points[2]
nearest points
Definition: collision_data.h:404
hpp::fcl::DistanceResult::b1
int b1
information about the nearest point in object 1 if object 1 is mesh or point cloud,...
Definition: collision_data.h:419
hpp::fcl::DistanceResult::min_distance
FCL_REAL min_distance
minimum distance between two objects. if two objects are in collision, min_distance <= 0.
Definition: collision_data.h:401
hpp::fcl::QueryRequest
base class for all query requests
Definition: collision_data.h:139
hpp::fcl::QueryRequest::cached_gjk_guess
Vec3f cached_gjk_guess
the gjk intial guess set by user
Definition: collision_data.h:144
hpp::fcl::QueryRequest::cached_support_func_guess
support_func_guess_t cached_support_func_guess
the support function intial guess set by user
Definition: collision_data.h:147
hpp::fcl::QueryRequest::enable_timings
bool enable_timings
enable timings when performing collision/distance request
Definition: collision_data.h:150
hpp::fcl::QueryRequest::enable_cached_gjk_guess
bool enable_cached_gjk_guess
whether enable gjk intial guess
Definition: collision_data.h:141
hpp::fcl::QueryResult
base class for all query results
Definition: collision_data.h:173
hpp::fcl::QueryResult::cached_support_func_guess
support_func_guess_t cached_support_func_guess
stores the last support function vertex index, when relevant.
Definition: collision_data.h:178
hpp::fcl::QueryResult::cached_gjk_guess
Vec3f cached_gjk_guess
stores the last GJK ray when relevant.
Definition: collision_data.h:175