38 #ifndef FCL_DISTANCE_FUNC_MATRIX_INL_H
39 #define FCL_DISTANCE_FUNC_MATRIX_INL_H
43 #include "fcl/config.h"
75 #endif // FCL_HAVE_OCTOMAP
85 template <
typename Shape,
typename NarrowPhaseSolver>
86 typename Shape::S ShapeOcTreeDistance(
87 const CollisionGeometry<typename Shape::S>* o1,
88 const Transform3<typename Shape::S>& tf1,
89 const CollisionGeometry<typename Shape::S>* o2,
90 const Transform3<typename Shape::S>& tf2,
91 const NarrowPhaseSolver* nsolver,
92 const DistanceRequest<typename Shape::S>& request,
93 DistanceResult<typename Shape::S>& result)
95 using S =
typename Shape::S;
97 if(request.isSatisfied(result))
return result.min_distance;
98 ShapeOcTreeDistanceTraversalNode<Shape, NarrowPhaseSolver> node;
99 const Shape*
obj1 =
static_cast<const Shape*
>(o1);
100 const OcTree<S>*
obj2 =
static_cast<const OcTree<S>*
>(o2);
101 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
106 return result.min_distance;
109 template <
typename Shape,
typename NarrowPhaseSolver>
110 typename Shape::S OcTreeShapeDistance(
111 const CollisionGeometry<typename Shape::S>* o1,
112 const Transform3<typename Shape::S>& tf1,
113 const CollisionGeometry<typename Shape::S>* o2,
114 const Transform3<typename Shape::S>& tf2,
115 const NarrowPhaseSolver* nsolver,
116 const DistanceRequest<typename Shape::S>& request,
117 DistanceResult<typename Shape::S>& result)
119 using S =
typename Shape::S;
121 if(request.isSatisfied(result))
return result.min_distance;
122 OcTreeShapeDistanceTraversalNode<Shape, NarrowPhaseSolver> node;
123 const OcTree<S>*
obj1 =
static_cast<const OcTree<S>*
>(o1);
124 const Shape*
obj2 =
static_cast<const Shape*
>(o2);
125 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
130 return result.min_distance;
133 template <
typename NarrowPhaseSolver>
134 typename NarrowPhaseSolver::S OcTreeDistance(
135 const CollisionGeometry<typename NarrowPhaseSolver::S>* o1,
136 const Transform3<typename NarrowPhaseSolver::S>& tf1,
137 const CollisionGeometry<typename NarrowPhaseSolver::S>* o2,
138 const Transform3<typename NarrowPhaseSolver::S>& tf2,
139 const NarrowPhaseSolver* nsolver,
140 const DistanceRequest<typename NarrowPhaseSolver::S>& request,
141 DistanceResult<typename NarrowPhaseSolver::S>& result)
143 using S =
typename NarrowPhaseSolver::S;
145 if(request.isSatisfied(result))
return result.min_distance;
146 OcTreeDistanceTraversalNode<NarrowPhaseSolver> node;
147 const OcTree<S>*
obj1 =
static_cast<const OcTree<S>*
>(o1);
148 const OcTree<S>*
obj2 =
static_cast<const OcTree<S>*
>(o2);
149 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
154 return result.min_distance;
157 template <
typename BV,
typename NarrowPhaseSolver>
158 typename BV::S BVHOcTreeDistance(
159 const CollisionGeometry<typename BV::S>* o1,
160 const Transform3<typename BV::S>& tf1,
161 const CollisionGeometry<typename BV::S>* o2,
162 const Transform3<typename BV::S>& tf2,
163 const NarrowPhaseSolver* nsolver,
164 const DistanceRequest<typename BV::S>& request,
165 DistanceResult<typename BV::S>& result)
167 using S =
typename BV::S;
169 if(request.isSatisfied(result))
return result.min_distance;
170 MeshOcTreeDistanceTraversalNode<BV, NarrowPhaseSolver> node;
171 const BVHModel<BV>*
obj1 =
static_cast<const BVHModel<BV>*
>(o1);
172 const OcTree<S>*
obj2 =
static_cast<const OcTree<S>*
>(o2);
173 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
178 return result.min_distance;
181 template <
typename BV,
typename NarrowPhaseSolver>
182 typename BV::S OcTreeBVHDistance(
183 const CollisionGeometry<typename BV::S>* o1,
184 const Transform3<typename BV::S>& tf1,
185 const CollisionGeometry<typename BV::S>* o2,
186 const Transform3<typename BV::S>& tf2,
187 const NarrowPhaseSolver* nsolver,
188 const DistanceRequest<typename BV::S>& request,
189 DistanceResult<typename BV::S>& result)
191 using S =
typename BV::S;
193 if(request.isSatisfied(result))
return result.min_distance;
194 OcTreeMeshDistanceTraversalNode<BV, NarrowPhaseSolver> node;
195 const OcTree<S>*
obj1 =
static_cast<const OcTree<S>*
>(o1);
196 const BVHModel<BV>*
obj2 =
static_cast<const BVHModel<BV>*
>(o2);
197 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
202 return result.min_distance;
207 template <
typename Shape1,
typename Shape2,
typename NarrowPhaseSolver>
213 const NarrowPhaseSolver* nsolver,
219 const Shape1*
obj1 =
static_cast<const Shape1*
>(o1);
220 const Shape2*
obj2 =
static_cast<const Shape2*
>(o2);
228 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
231 using S =
typename BV::S;
238 const NarrowPhaseSolver* nsolver,
247 const Shape*
obj2 =
static_cast<const Shape*
>(o2);
249 initialize(node, *obj1_tmp, tf1_tmp, *
obj2, tf2, nsolver, request, result);
257 template <
typename OrientedMeshShapeDistanceTraversalNode,
258 typename BV,
typename Shape,
typename NarrowPhaseSolver>
264 const NarrowPhaseSolver* nsolver,
269 OrientedMeshShapeDistanceTraversalNode node;
271 const Shape*
obj2 =
static_cast<const Shape*
>(o2);
279 template <
typename Shape,
typename NarrowPhaseSolver>
287 const NarrowPhaseSolver* nsolver,
296 o1, tf1, o2, tf2, nsolver, request, result);
300 template <
typename Shape,
typename NarrowPhaseSolver>
308 const NarrowPhaseSolver* nsolver,
317 o1, tf1, o2, tf2, nsolver, request, result);
321 template <
typename Shape,
typename NarrowPhaseSolver>
329 const NarrowPhaseSolver* nsolver,
338 o1, tf1, o2, tf2, nsolver, request, result);
343 template <
typename S,
typename BV>
363 initialize(node, *obj1_tmp, tf1_tmp, *obj2_tmp, tf2_tmp, request, result);
373 template <
typename BV>
383 o1, tf1, o2, tf2, request, result);
386 template <
typename OrientedMeshDistanceTraversalNode,
typename BV>
396 OrientedMeshDistanceTraversalNode node;
407 template <
typename S>
420 o1, tf1, o2, tf2, request, result);
425 template <
typename S>
438 o1, tf1, o2, tf2, request, result);
443 template <
typename S>
456 o1, tf1, o2, tf2, request, result);
461 template <
typename BV,
typename NarrowPhaseSolver>
467 const NarrowPhaseSolver* nsolver,
473 return BVHDistance<BV>(o1, tf1, o2, tf2, request, result);
476 template <
typename NarrowPhaseSolver>
482 distance_matrix[i][j] =
nullptr;
660 distance_matrix[
BV_AABB][
BV_AABB] = &BVHDistance<AABB<S>, NarrowPhaseSolver>;
661 distance_matrix[
BV_RSS][
BV_RSS] = &BVHDistance<RSS<S>, NarrowPhaseSolver>;
662 distance_matrix[
BV_kIOS][
BV_kIOS] = &BVHDistance<kIOS<S>, NarrowPhaseSolver>;
688 distance_matrix[
GEOM_OCTREE][
BV_AABB] = &OcTreeBVHDistance<AABB<S>, NarrowPhaseSolver>;
689 distance_matrix[
GEOM_OCTREE][
BV_OBB] = &OcTreeBVHDistance<OBB<S>, NarrowPhaseSolver>;
690 distance_matrix[
GEOM_OCTREE][
BV_RSS] = &OcTreeBVHDistance<RSS<S>, NarrowPhaseSolver>;
692 distance_matrix[
GEOM_OCTREE][
BV_kIOS] = &OcTreeBVHDistance<kIOS<S>, NarrowPhaseSolver>;
697 distance_matrix[
BV_AABB][
GEOM_OCTREE] = &BVHOcTreeDistance<AABB<S>, NarrowPhaseSolver>;
698 distance_matrix[
BV_OBB][
GEOM_OCTREE] = &BVHOcTreeDistance<OBB<S>, NarrowPhaseSolver>;
699 distance_matrix[
BV_RSS][
GEOM_OCTREE] = &BVHOcTreeDistance<RSS<S>, NarrowPhaseSolver>;
701 distance_matrix[
BV_kIOS][
GEOM_OCTREE] = &BVHOcTreeDistance<kIOS<S>, NarrowPhaseSolver>;