38 #ifndef FCL_TRAVERSAL_MESHDISTANCETRAVERSALNODE_INL_H
39 #define FCL_TRAVERSAL_MESHDISTANCETRAVERSALNODE_INL_H
58 const Transform3<double>& tf1,
60 const Transform3<double>& tf2,
61 const DistanceRequest<double>& request,
62 DistanceResult<double>& result);
73 const Transform3<double>& tf1,
75 const Transform3<double>& tf2,
76 const DistanceRequest<double>& request,
77 DistanceResult<double>& result);
88 const Transform3<double>& tf1,
90 const Transform3<double>& tf2,
91 const DistanceRequest<double>& request,
92 DistanceResult<double>& result);
95 template <
typename BV>
100 tri_indices1 =
nullptr;
101 tri_indices2 =
nullptr;
103 rel_err = this->request.rel_err;
104 abs_err = this->request.abs_err;
108 template <
typename BV>
111 if(this->enable_statistics) this->num_leaf_tests++;
113 const BVNode<BV>& node1 = this->model1->getBV(b1);
114 const BVNode<BV>& node2 = this->model2->getBV(b2);
119 const Triangle& tri_id1 = tri_indices1[primitive_id1];
120 const Triangle& tri_id2 = tri_indices2[primitive_id2];
122 const Vector3<S>& t11 = vertices1[tri_id1[0]];
123 const Vector3<S>& t12 = vertices1[tri_id1[1]];
124 const Vector3<S>& t13 = vertices1[tri_id1[2]];
126 const Vector3<S>& t21 = vertices2[tri_id2[0]];
127 const Vector3<S>& t22 = vertices2[tri_id2[1]];
128 const Vector3<S>& t23 = vertices2[tri_id2[2]];
136 if(this->request.enable_nearest_points)
138 this->result->update(d, this->model1, this->model2, primitive_id1, primitive_id2, P1, P2);
142 this->result->update(d, this->model1, this->model2, primitive_id1, primitive_id2);
147 template <
typename BV>
150 if((c >= this->result->min_distance - abs_err) && (c * (1 + rel_err) >= this->result->min_distance))
156 template <
typename BV>
168 using S =
typename BV::S;
173 if(!tf1.matrix().isIdentity())
175 std::vector<Vector3<S>> vertices_transformed1(model1.
num_vertices);
180 vertices_transformed1[i] = new_v;
190 if(!tf2.matrix().isIdentity())
192 std::vector<Vector3<S>> vertices_transformed2(model2.
num_vertices);
197 vertices_transformed2[i] = new_v;
225 template <
typename S>
233 template <
typename S>
251 template <
typename S>
263 template <
typename S>
276 this->enable_statistics,
277 this->num_leaf_tests,
283 template <
typename S>
292 template <
typename S>
310 template <
typename S>
322 template <
typename S>
335 this->enable_statistics,
336 this->num_leaf_tests,
342 template <
typename S>
351 template <
typename S>
369 template <
typename S>
381 template <
typename S>
394 this->enable_statistics,
395 this->num_leaf_tests,
401 template <
typename BV>
412 bool enable_statistics,
417 using S =
typename BV::S;
419 if(enable_statistics) num_leaf_tests++;
427 const Triangle& tri_id1 = tri_indices1[primitive_id1];
428 const Triangle& tri_id2 = tri_indices2[primitive_id2];
430 const Vector3<S>& t11 = vertices1[tri_id1[0]];
431 const Vector3<S>& t12 = vertices1[tri_id1[1]];
432 const Vector3<S>& t13 = vertices1[tri_id1[2]];
434 const Vector3<S>& t21 = vertices2[tri_id2[0]];
435 const Vector3<S>& t22 = vertices2[tri_id2[1]];
436 const Vector3<S>& t23 = vertices2[tri_id2[2]];
446 result.
update(d, model1, model2, primitive_id1, primitive_id2, P1, P2);
448 result.
update(d, model1, model2, primitive_id1, primitive_id2);
452 template <
typename BV>
463 bool enable_statistics,
468 using S =
typename BV::S;
470 if(enable_statistics) num_leaf_tests++;
478 const Triangle& tri_id1 = tri_indices1[primitive_id1];
479 const Triangle& tri_id2 = tri_indices2[primitive_id2];
481 const Vector3<S>& t11 = vertices1[tri_id1[0]];
482 const Vector3<S>& t12 = vertices1[tri_id1[1]];
483 const Vector3<S>& t13 = vertices1[tri_id1[2]];
485 const Vector3<S>& t21 = vertices2[tri_id2[0]];
486 const Vector3<S>& t22 = vertices2[tri_id2[1]];
487 const Vector3<S>& t23 = vertices2[tri_id2[2]];
493 t11, t12, t13, t21, t22, t23, tf, P1, P2);
496 result.
update(d, model1, model2, primitive_id1, primitive_id2, P1, P2);
498 result.
update(d, model1, model2, primitive_id1, primitive_id2);
502 template <
typename BV>
517 using S =
typename BV::S;
519 const Triangle& init_tri1 = tri_indices1[init_tri_id1];
520 const Triangle& init_tri2 = tri_indices2[init_tri_id2];
525 init_tri1_points[0] = vertices1[init_tri1[0]];
526 init_tri1_points[1] = vertices1[init_tri1[1]];
527 init_tri1_points[2] = vertices1[init_tri1[2]];
529 init_tri2_points[0] = vertices2[init_tri2[0]];
530 init_tri2_points[1] = vertices2[init_tri2[1]];
531 init_tri2_points[2] = vertices2[init_tri2[2]];
535 init_tri2_points[0], init_tri2_points[1], init_tri2_points[2],
539 result.
update(
distance, model1, model2, init_tri_id1, init_tri_id2, p1, p2);
541 result.
update(
distance, model1, model2, init_tri_id1, init_tri_id2);
545 template <
typename BV>
559 using S =
typename BV::S;
561 const Triangle& init_tri1 = tri_indices1[init_tri_id1];
562 const Triangle& init_tri2 = tri_indices2[init_tri_id2];
567 init_tri1_points[0] = vertices1[init_tri1[0]];
568 init_tri1_points[1] = vertices1[init_tri1[1]];
569 init_tri1_points[2] = vertices1[init_tri1[2]];
571 init_tri2_points[0] = vertices2[init_tri2[0]];
572 init_tri2_points[1] = vertices2[init_tri2[1]];
573 init_tri2_points[2] = vertices2[init_tri2[2]];
578 init_tri1_points[0], init_tri1_points[1], init_tri1_points[2],
579 init_tri2_points[0], init_tri2_points[1], init_tri2_points[2],
583 result.
update(
distance, model1, model2, init_tri_id1, init_tri_id2, p1, p2);
585 result.
update(
distance, model1, model2, init_tri_id1, init_tri_id2);
589 template <
typename BV>
605 template <
typename BV,
typename OrientedNode>
616 node.request = request;
617 node.result = &result;
619 node.model1 = &model1;
621 node.model2 = &model2;
630 node.tf = tf1.inverse(Eigen::Isometry) * tf2;
636 template <
typename S>
647 node, model1, tf1, model2, tf2, request, result);
651 template <
typename S>
662 node, model1, tf1, model2, tf2, request, result);
666 template <
typename S>
677 node, model1, tf1, model2, tf2, request, result);