37 #ifndef HPP_FCL_INTERNAL_SHAPE_SHAPE_CONTACT_PATCH_FUNC_H
38 #define HPP_FCL_INTERNAL_SHAPE_SHAPE_CONTACT_PATCH_FUNC_H
52 template <
typename ShapeType1,
typename ShapeType2>
65 result.
check(request),
66 "The contact patch result and request are incompatible (issue of "
67 "contact patch size or maximum number of contact patches). Make sure "
68 "result is initialized with request.",
71 const ShapeType1& s1 =
static_cast<const ShapeType1&
>(*o1);
72 const ShapeType2& s2 =
static_cast<const ShapeType2&
>(*o2);
73 for (
size_t i = 0; i < collision_result.
numContacts(); ++i) {
80 csolver->
computePatch(s1, tf1, s2, tf2, contact, contact_patch);
90 template <
bool InvertShapes,
typename OtherShapeType,
typename PlaneOrHalfspace>
93 const PlaneOrHalfspace& s2,
122 support_set.
direction = ContactPatch::PatchDirection::INVERTED;
123 details::getShapeSupportSet<SupportOptions::WithSweptSphere>(
127 support_set.
direction = ContactPatch::PatchDirection::DEFAULT;
128 details::getShapeSupportSet<SupportOptions::WithSweptSphere>(
135 #define PLANE_OR_HSPACE_AND_OTHER_SHAPE_CONTACT_PATCH(PlaneOrHspace) \
136 template <typename OtherShapeType> \
137 struct ComputeShapeShapeContactPatch<OtherShapeType, PlaneOrHspace> { \
138 static void run(const CollisionGeometry* o1, const Transform3f& tf1, \
139 const CollisionGeometry* o2, const Transform3f& tf2, \
140 const CollisionResult& collision_result, \
141 const ContactPatchSolver* csolver, \
142 const ContactPatchRequest& request, \
143 ContactPatchResult& result) { \
144 if (!collision_result.isCollision()) { \
148 result.check(request), \
149 "The contact patch result and request are incompatible (issue of " \
150 "contact patch size or maximum number of contact patches). Make " \
152 "result is initialized with request.", \
155 const OtherShapeType& s1 = static_cast<const OtherShapeType&>(*o1); \
156 const PlaneOrHspace& s2 = static_cast<const PlaneOrHspace&>(*o2); \
157 for (size_t i = 0; i < collision_result.numContacts(); ++i) { \
158 if (i >= request.max_num_patch) { \
161 csolver->setSupportGuess(collision_result.cached_support_func_guess); \
162 const Contact& contact = collision_result.getContact(i); \
163 ContactPatch& contact_patch = result.getUnusedContactPatch(); \
164 computePatchPlaneOrHalfspace<false, OtherShapeType, PlaneOrHspace>( \
165 s1, tf1, s2, tf2, csolver, contact, contact_patch); \
170 template <typename OtherShapeType> \
171 struct ComputeShapeShapeContactPatch<PlaneOrHspace, OtherShapeType> { \
172 static void run(const CollisionGeometry* o1, const Transform3f& tf1, \
173 const CollisionGeometry* o2, const Transform3f& tf2, \
174 const CollisionResult& collision_result, \
175 const ContactPatchSolver* csolver, \
176 const ContactPatchRequest& request, \
177 ContactPatchResult& result) { \
178 if (!collision_result.isCollision()) { \
182 result.check(request), \
183 "The contact patch result and request are incompatible (issue of " \
184 "contact patch size or maximum number of contact patches). Make " \
186 "result is initialized with request.", \
189 const PlaneOrHspace& s1 = static_cast<const PlaneOrHspace&>(*o1); \
190 const OtherShapeType& s2 = static_cast<const OtherShapeType&>(*o2); \
191 for (size_t i = 0; i < collision_result.numContacts(); ++i) { \
192 if (i >= request.max_num_patch) { \
195 csolver->setSupportGuess(collision_result.cached_support_func_guess); \
196 const Contact& contact = collision_result.getContact(i); \
197 ContactPatch& contact_patch = result.getUnusedContactPatch(); \
198 computePatchPlaneOrHalfspace<true, OtherShapeType, PlaneOrHspace>( \
199 s2, tf2, s1, tf1, csolver, contact, contact_patch); \
207 #define PLANE_HSPACE_CONTACT_PATCH(PlaneOrHspace1, PlaneOrHspace2) \
209 struct ComputeShapeShapeContactPatch<PlaneOrHspace1, PlaneOrHspace2> { \
210 static void run(const CollisionGeometry* o1, const Transform3f& tf1, \
211 const CollisionGeometry* o2, const Transform3f& tf2, \
212 const CollisionResult& collision_result, \
213 const ContactPatchSolver* csolver, \
214 const ContactPatchRequest& request, \
215 ContactPatchResult& result) { \
216 HPP_FCL_UNUSED_VARIABLE(o1); \
217 HPP_FCL_UNUSED_VARIABLE(tf1); \
218 HPP_FCL_UNUSED_VARIABLE(o2); \
219 HPP_FCL_UNUSED_VARIABLE(tf2); \
220 HPP_FCL_UNUSED_VARIABLE(csolver); \
221 if (!collision_result.isCollision()) { \
225 result.check(request), \
226 "The contact patch result and request are incompatible (issue of " \
227 "contact patch size or maximum number of contact patches). Make " \
229 "result is initialized with request.", \
232 for (size_t i = 0; i < collision_result.numContacts(); ++i) { \
233 if (i >= request.max_num_patch) { \
236 const Contact& contact = collision_result.getContact(i); \
237 ContactPatch& contact_patch = result.getUnusedContactPatch(); \
238 constructContactPatchFrameFromContact(contact, contact_patch); \
239 contact_patch.addPoint(contact.pos); \
249 #undef PLANE_OR_HSPACE_AND_OTHER_SHAPE_CONTACT_PATCH
250 #undef PLANE_HSPACE_CONTACT_PATCH
252 template <
typename ShapeType1,
typename ShapeType2>
260 o1, tf1, o2, tf2, collision_result, csolver, request, result);
The geometry for the object for collision or distance computation.
Definition: collision_object.h:95
Half Space: this is equivalent to the Plane in ODE. A Half space has a priviledged direction: the dir...
Definition: geometric_shapes.h:885
Infinite plane. A plane can be viewed as two half spaces; it has no priviledged direction....
Definition: geometric_shapes.h:976
#define HPP_FCL_ASSERT(check, message, exception)
Definition: fwd.hh:82
#define HPP_FCL_UNUSED_VARIABLE(var)
Definition: fwd.hh:56
SupportOptions
Options for the computation of support points. NoSweptSphere option is used when the support function...
Definition: support_functions.h:59
void computePatchPlaneOrHalfspace(const OtherShapeType &s1, const Transform3f &tf1, const PlaneOrHalfspace &s2, const Transform3f &tf2, const ContactPatchSolver *csolver, const Contact &contact, ContactPatch &contact_patch)
Computes the contact patch between a Plane/Halfspace and another shape.
Definition: shape_shape_contact_patch_func.h:91
void constructContactPatchFrameFromContact(const Contact &contact, ContactPatch &contact_patch)
Construct a frame from a Contact's position and normal. Because both Contact's position and normal ar...
Definition: collision_data.h:706
void ShapeShapeContactPatch(const CollisionGeometry *o1, const Transform3f &tf1, const CollisionGeometry *o2, const Transform3f &tf2, const CollisionResult &collision_result, const ContactPatchSolver *csolver, const ContactPatchRequest &request, ContactPatchResult &result)
Definition: shape_shape_contact_patch_func.h:253
Main namespace.
Definition: broadphase_bruteforce.h:44
collision result
Definition: collision_data.h:391
const Contact & getContact(size_t i) const
get the i-th contact calculated
Definition: collision_data.h:449
bool isCollision() const
return binary collision result
Definition: collision_data.h:443
size_t numContacts() const
number of contacts found
Definition: collision_data.h:446
support_func_guess_t cached_support_func_guess
stores the last support function vertex index, when relevant.
Definition: collision_data.h:281
Definition: geometric_shapes_traits.h:56