38 #define BOOST_TEST_MODULE FCL_DISTANCE
41 #include <boost/test/included/unit_test.hpp>
42 #include <boost/filesystem.hpp>
46 #include "../src/collision_node.h"
50 #include "fcl_resources/config.h"
53 namespace utf = boost::unit_test::framework;
58 template <
typename BV>
60 const std::vector<Triangle>& triangles1,
61 const std::vector<Vec3f>& vertices2,
62 const std::vector<Triangle>& triangles2,
67 const std::vector<Vec3f>& vertices1,
68 const std::vector<Triangle>& triangles1,
69 const std::vector<Vec3f>& vertices2,
70 const std::vector<Triangle>& triangles2,
73 template <
typename BV,
typename TraversalNode>
75 const std::vector<Vec3f>& vertices1,
76 const std::vector<Triangle>& triangles1,
77 const std::vector<Vec3f>& vertices2,
78 const std::vector<Triangle>& triangles2,
83 if (fabs(
a[0] -
b[0]) >
DELTA)
return false;
84 if (fabs(
a[1] -
b[1]) >
DELTA)
return false;
85 if (fabs(
a[2] -
b[2]) >
DELTA)
return false;
90 std::vector<Vec3f>
p1, p2;
91 std::vector<Triangle> t1, t2;
96 std::vector<Transform3f> transforms;
98 #ifndef NDEBUG // if debug mode
103 n =
getNbRun(utf::master_test_suite().argc, utf::master_test_suite().argv, n);
111 for (std::size_t i = 0; i < transforms.size(); ++i) {
112 auto timer_col = std::chrono::high_resolution_clock::now();
114 col_time += std::chrono::duration_cast<std::chrono::duration<double>>(
115 std::chrono::high_resolution_clock::now() - timer_col)
118 auto timer_dist = std::chrono::high_resolution_clock::now();
119 distance_Test_Oriented<RSS, MeshDistanceTraversalNodeRSS>(
121 dis_time += std::chrono::duration_cast<std::chrono::duration<double>>(
122 std::chrono::high_resolution_clock::now() - timer_dist)
125 distance_Test_Oriented<RSS, MeshDistanceTraversalNodeRSS>(
130 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
134 distance_Test_Oriented<RSS, MeshDistanceTraversalNodeRSS>(
139 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
143 distance_Test_Oriented<RSS, MeshDistanceTraversalNodeRSS>(
147 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
151 distance_Test_Oriented<RSS, MeshDistanceTraversalNodeRSS>(
156 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
160 distance_Test_Oriented<RSS, MeshDistanceTraversalNodeRSS>(
165 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
169 distance_Test_Oriented<kIOS, MeshDistanceTraversalNodekIOS>(
173 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
177 distance_Test_Oriented<kIOS, MeshDistanceTraversalNodekIOS>(
182 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
186 distance_Test_Oriented<kIOS, MeshDistanceTraversalNodekIOS>(
191 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
195 distance_Test_Oriented<kIOS, MeshDistanceTraversalNodekIOS>(
199 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
203 distance_Test_Oriented<kIOS, MeshDistanceTraversalNodekIOS>(
208 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
212 distance_Test_Oriented<kIOS, MeshDistanceTraversalNodekIOS>(
217 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
221 distance_Test_Oriented<OBBRSS, MeshDistanceTraversalNodeOBBRSS>(
225 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
229 distance_Test_Oriented<OBBRSS, MeshDistanceTraversalNodeOBBRSS>(
234 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
238 distance_Test_Oriented<OBBRSS, MeshDistanceTraversalNodeOBBRSS>(
243 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
247 distance_Test_Oriented<OBBRSS, MeshDistanceTraversalNodeOBBRSS>(
251 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
255 distance_Test_Oriented<OBBRSS, MeshDistanceTraversalNodeOBBRSS>(
260 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
264 distance_Test_Oriented<OBBRSS, MeshDistanceTraversalNodeOBBRSS>(
269 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
277 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
285 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
293 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
301 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
309 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
317 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
325 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
333 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
341 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
349 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
357 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
365 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
373 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
381 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
389 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
397 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
405 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
413 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
421 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
429 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
437 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
445 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
453 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
461 BOOST_CHECK(fabs(
res.distance) <
DELTA ||
466 BOOST_TEST_MESSAGE(
"distance timing: " << dis_time <<
" sec");
467 BOOST_TEST_MESSAGE(
"collision timing: " << col_time <<
" sec");
470 template <
typename BV,
typename TraversalNode>
472 const std::vector<Vec3f>& vertices1,
473 const std::vector<Triangle>& triangles1,
474 const std::vector<Vec3f>& vertices2,
475 const std::vector<Triangle>& triangles2,
495 std::cout <<
"initialize error" << std::endl;
497 node.enable_statistics =
verbose;
506 distance_result.
p1 =
p1;
507 distance_result.
p2 = p2;
510 std::cout <<
"distance " << local_result.
min_distance << std::endl;
512 std::cout <<
p1[0] <<
" " <<
p1[1] <<
" " <<
p1[2] << std::endl;
513 std::cout << p2[0] <<
" " << p2[1] <<
" " << p2[2] << std::endl;
514 std::cout << node.num_bv_tests <<
" " << node.num_leaf_tests << std::endl;
518 template <
typename BV>
520 const std::vector<Triangle>& triangles1,
521 const std::vector<Vec3f>& vertices2,
522 const std::vector<Triangle>& triangles2,
541 MeshDistanceTraversalNode<BV> node;
545 std::cout <<
"initialize error" << std::endl;
547 node.enable_statistics =
verbose;
556 std::cout <<
"distance " << local_result.
min_distance << std::endl;
564 std::cout << node.num_bv_tests <<
" " << node.num_leaf_tests << std::endl;
569 const std::vector<Vec3f>& vertices1,
570 const std::vector<Triangle>& triangles1,
571 const std::vector<Vec3f>& vertices2,
572 const std::vector<Triangle>& triangles2,
589 MeshCollisionTraversalNodeOBB node(request);
593 BOOST_REQUIRE(success);
595 node.enable_statistics =
verbose;
597 collide(&node, request, local_result);