coal/serialization/contact_patch.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2024 INRIA
3 //
4 
5 #ifndef COAL_SERIALIZATION_CONTACT_PATCH_H
6 #define COAL_SERIALIZATION_CONTACT_PATCH_H
7 
8 #include "coal/collision_data.h"
11 
12 namespace boost {
13 namespace serialization {
14 
15 template <class Archive>
16 void serialize(Archive& ar, coal::ContactPatch& contact_patch,
17  const unsigned int /*version*/) {
18  using namespace coal;
19  typedef Eigen::Matrix<CoalScalar, 2, Eigen::Dynamic> PolygonPoints;
20 
21  size_t patch_size = contact_patch.size();
22  ar& make_nvp("patch_size", patch_size);
23  if (patch_size > 0) {
24  if (Archive::is_loading::value) {
25  contact_patch.points().resize(patch_size);
26  }
27  Eigen::Map<PolygonPoints> points_map(
28  reinterpret_cast<CoalScalar*>(contact_patch.points().data()), 2,
29  static_cast<Eigen::Index>(patch_size));
30  ar& make_nvp("points", points_map);
31  }
32 
33  ar& make_nvp("penetration_depth", contact_patch.penetration_depth);
34  ar& make_nvp("direction", contact_patch.direction);
35  ar& make_nvp("tf", contact_patch.tf);
36 }
37 
38 template <class Archive>
39 void serialize(Archive& ar, coal::ContactPatchRequest& request,
40  const unsigned int /*version*/) {
41  using namespace coal;
42 
43  ar& make_nvp("max_num_patch", request.max_num_patch);
44 
45  size_t num_samples_curved_shapes = request.getNumSamplesCurvedShapes();
46  CoalScalar patch_tolerance = request.getPatchTolerance();
47  ar& make_nvp("num_samples_curved_shapes", num_samples_curved_shapes);
48  ar& make_nvp("patch_tolerance", num_samples_curved_shapes);
49 
50  if (Archive::is_loading::value) {
51  request.setNumSamplesCurvedShapes(num_samples_curved_shapes);
52  request.setPatchTolerance(patch_tolerance);
53  }
54 }
55 
56 template <class Archive>
57 void serialize(Archive& ar, coal::ContactPatchResult& result,
58  const unsigned int /*version*/) {
59  using namespace coal;
60 
61  size_t num_patches = result.numContactPatches();
62  ar& make_nvp("num_patches", num_patches);
63 
64  std::vector<ContactPatch> patches;
65  patches.resize(num_patches);
66  if (Archive::is_loading::value) {
67  ar& make_nvp("patches", patches);
68 
69  const ContactPatchRequest request(num_patches);
70  result.set(request);
71  for (size_t i = 0; i < num_patches; ++i) {
72  ContactPatch& patch = result.getUnusedContactPatch();
73  patch = patches[i];
74  }
75  } else {
76  patches.clear();
77  for (size_t i = 0; i < num_patches; ++i) {
78  patches.emplace_back(result.getContactPatch(i));
79  }
80  ar& make_nvp("patches", patches);
81  }
82 }
83 
84 } // namespace serialization
85 } // namespace boost
86 
87 #endif // COAL_SERIALIZATION_CONTACT_PATCH_H
coal::ContactPatch::penetration_depth
CoalScalar penetration_depth
Penetration depth of the contact patch. This value corresponds to the signed distance d between the s...
Definition: coal/collision_data.h:545
fwd.h
coal::ContactPatchResult::getUnusedContactPatch
ContactPatchRef getUnusedContactPatch()
Returns a new unused contact patch from the internal data vector.
Definition: coal/collision_data.h:862
boost::serialization::serialize
void serialize(Archive &ar, coal::AABB &aabb, const unsigned int)
Definition: coal/serialization/AABB.h:15
coal::ContactPatchRequest::setPatchTolerance
void setPatchTolerance(const CoalScalar patch_tolerance)
Tolerance below which points are added to a contact patch. In details, given two shapes S1 and S2,...
Definition: coal/collision_data.h:798
collision_data.h
coal::ContactPatchRequest::max_num_patch
size_t max_num_patch
Maximum number of contact patches that will be computed.
Definition: coal/collision_data.h:726
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::ContactPatchResult::numContactPatches
size_t numContactPatches() const
Number of contact patches in the result.
Definition: coal/collision_data.h:859
boost
coal::ContactPatchResult::getContactPatch
const ContactPatch & getContactPatch(const size_t i) const
Const getter for the i-th contact patch of the result.
Definition: coal/collision_data.h:882
coal::ContactPatch
This structure allows to encode contact patches. A contact patch is defined by a set of points belong...
Definition: coal/collision_data.h:512
coal::ContactPatch::direction
PatchDirection direction
Direction of this contact patch.
Definition: coal/collision_data.h:532
coal::ContactPatchResult
Result for a contact patch computation.
Definition: coal/collision_data.h:822
coal::ContactPatchRequest
Request for a contact patch computation.
Definition: coal/collision_data.h:724
coal::ContactPatchRequest::getNumSamplesCurvedShapes
size_t getNumSamplesCurvedShapes() const
Maximum samples to compute the support sets of curved shapes, i.e. when the normal is perpendicular t...
Definition: coal/collision_data.h:793
coal::ContactPatchRequest::setNumSamplesCurvedShapes
void setNumSamplesCurvedShapes(const size_t num_samples_curved_shapes)
Maximum samples to compute the support sets of curved shapes, i.e. when the normal is perpendicular t...
Definition: coal/collision_data.h:781
coal::ContactPatch::tf
Transform3s tf
Frame of the set, expressed in the world coordinates. The z-axis of the frame's rotation is the conta...
Definition: coal/collision_data.h:518
coal::ContactPatch::clear
void clear()
Clear the set.
Definition: coal/collision_data.h:640
coal::ContactPatchResult::set
void set(const ContactPatchRequest &request)
Set up a ContactPatchResult from a ContactPatchRequest
Definition: coal/collision_data.h:919
coal::ContactPatch::points
Polygon & points()
Getter for the 2D points in the set.
Definition: coal/collision_data.h:616
coal::ContactPatchRequest::getPatchTolerance
CoalScalar getPatchTolerance() const
Tolerance below which points are added to a contact patch. In details, given two shapes S1 and S2,...
Definition: coal/collision_data.h:810
coal::ContactPatch::size
size_t size() const
Returns the number of points in the contact patch.
Definition: coal/collision_data.h:577
transform.h
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57