GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/* |
||
2 |
* Software License Agreement (BSD License) |
||
3 |
* |
||
4 |
* Copyright (c) 2014-2015, CNRS-LAAS and AIST |
||
5 |
* All rights reserved. |
||
6 |
* |
||
7 |
* Redistribution and use in source and binary forms, with or without |
||
8 |
* modification, are permitted provided that the following conditions |
||
9 |
* are met: |
||
10 |
* |
||
11 |
* * Redistributions of source code must retain the above copyright |
||
12 |
* notice, this list of conditions and the following disclaimer. |
||
13 |
* * Redistributions in binary form must reproduce the above |
||
14 |
* copyright notice, this list of conditions and the following |
||
15 |
* disclaimer in the documentation and/or other materials provided |
||
16 |
* with the distribution. |
||
17 |
* * Neither the name of CNRS-LAAS and AIST nor the names of its |
||
18 |
* contributors may be used to endorse or promote products derived |
||
19 |
* from this software without specific prior written permission. |
||
20 |
* |
||
21 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
22 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
23 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
||
24 |
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
||
25 |
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
26 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
||
27 |
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||
28 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
29 |
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||
30 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||
31 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
32 |
* POSSIBILITY OF SUCH DAMAGE. |
||
33 |
*/ |
||
34 |
|||
35 |
/** \author Florent Lamiraux */ |
||
36 |
|||
37 |
#define BOOST_TEST_MODULE FCL_GEOMETRIC_SHAPES |
||
38 |
#include <boost/test/included/unit_test.hpp> |
||
39 |
|||
40 |
#define CHECK_CLOSE_TO_0(x, eps) BOOST_CHECK_CLOSE((x + 1.0), (1.0), (eps)) |
||
41 |
|||
42 |
#include "utility.h" |
||
43 |
|||
44 |
#include <cmath> |
||
45 |
#include <hpp/fcl/distance.h> |
||
46 |
#include <hpp/fcl/math/transform.h> |
||
47 |
#include <hpp/fcl/collision.h> |
||
48 |
#include <hpp/fcl/collision_object.h> |
||
49 |
#include <hpp/fcl/shape/geometric_shapes.h> |
||
50 |
|||
51 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(distance_capsule_box) { |
52 |
typedef hpp::fcl::shared_ptr<hpp::fcl::CollisionGeometry> |
||
53 |
CollisionGeometryPtr_t; |
||
54 |
// Capsule of radius 2 and of height 4 |
||
55 |
✓✗✓✗ ✓✗ |
4 |
CollisionGeometryPtr_t capsuleGeometry(new hpp::fcl::Capsule(2., 4.)); |
56 |
// Box of size 1 by 2 by 4 |
||
57 |
✓✗✓✗ ✓✗ |
4 |
CollisionGeometryPtr_t boxGeometry(new hpp::fcl::Box(1., 2., 4.)); |
58 |
|||
59 |
// Enable computation of nearest points |
||
60 |
✓✗ | 2 |
hpp::fcl::DistanceRequest distanceRequest(true, 0, 0); |
61 |
✓✗ | 2 |
hpp::fcl::DistanceResult distanceResult; |
62 |
|||
63 |
// Rotate capsule around y axis by pi/2 and move it behind box |
||
64 |
✓✗ | 2 |
hpp::fcl::Transform3f tf1(hpp::fcl::makeQuat(sqrt(2) / 2, 0, sqrt(2) / 2, 0), |
65 |
✓✗✓✗ |
4 |
hpp::fcl::Vec3f(-10., 0.8, 1.5)); |
66 |
✓✗ | 2 |
hpp::fcl::Transform3f tf2; |
67 |
✓✗ | 4 |
hpp::fcl::CollisionObject capsule(capsuleGeometry, tf1); |
68 |
✓✗ | 4 |
hpp::fcl::CollisionObject box(boxGeometry, tf2); |
69 |
|||
70 |
// test distance |
||
71 |
✓✗ | 2 |
distanceResult.clear(); |
72 |
✓✗ | 2 |
hpp::fcl::distance(&capsule, &box, distanceRequest, distanceResult); |
73 |
✓✗ | 2 |
hpp::fcl::Vec3f o1 = distanceResult.nearest_points[0]; |
74 |
✓✗ | 2 |
hpp::fcl::Vec3f o2 = distanceResult.nearest_points[1]; |
75 |
|||
76 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✓ |
2 |
BOOST_CHECK_CLOSE(distanceResult.min_distance, 5.5, 1e-2); |
77 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK_CLOSE(o1[0], -6, 1e-2); |
78 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK_CLOSE(o1[1], 0.8, 1e-1); |
79 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK_CLOSE(o1[2], 1.5, 1e-2); |
80 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK_CLOSE(o2[0], -0.5, 1e-2); |
81 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK_CLOSE(o2[1], 0.8, 1e-1); |
82 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✓ |
2 |
BOOST_CHECK_CLOSE(o2[2], 1.5, 1e-2); |
83 |
2 |
} |
Generated by: GCOVR (Version 4.2) |