Directory: | ./ |
---|---|
File: | tests/test-oriented-triangles2.cc |
Date: | 2025-03-07 12:08:39 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 37 | 37 | 100.0% |
Branches: | 83 | 160 | 51.9% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (C) 2016 LAAS-CNRS | ||
2 | // Author: Anna Seppala | ||
3 | // | ||
4 | // This file is part of the hpp-affordance. | ||
5 | // | ||
6 | // hpp-affordance is free software: you can redistribute it and/or modify | ||
7 | // it under the terms of the GNU Lesser General Public License as published by | ||
8 | // the Free Software Foundation, either version 3 of the License, or | ||
9 | // (at your option) any later version. | ||
10 | // | ||
11 | // hpp-affordance is distributed in the hope that it will be useful, | ||
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | // GNU Lesser General Public License for more details. | ||
15 | // | ||
16 | // You should have received a copy of the GNU Lesser General Public License | ||
17 | // along with hpp-affordance. If not, see <http://www.gnu.org/licenses/>. | ||
18 | |||
19 | #include <coal/BVH/BVH_model.h> | ||
20 | #include <coal/shape/geometric_shape_to_BVH_model.h> | ||
21 | |||
22 | #include <hpp/affordance/affordance-extraction.hh> | ||
23 | #include <hpp/affordance/operations.hh> | ||
24 | |||
25 | #define BOOST_TEST_MODULE test - oriented - triangles2 | ||
26 | #include <boost/test/included/unit_test.hpp> | ||
27 | |||
28 | using namespace hpp; | ||
29 | BOOST_AUTO_TEST_SUITE(test_affordance) | ||
30 | |||
31 |
33/66✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 24 not taken.
✓ Branch 27 taken 1 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 1 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 times.
✗ Branch 37 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 1 times.
✗ Branch 46 not taken.
✓ Branch 48 taken 1 times.
✗ Branch 49 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 66 taken 1 times.
✗ Branch 67 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 times.
✗ Branch 84 not taken.
✓ Branch 86 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 95 taken 1 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 1 times.
✗ Branch 99 not taken.
✓ Branch 102 taken 1 times.
✗ Branch 103 not taken.
✓ Branch 105 taken 1 times.
✗ Branch 106 not taken.
✓ Branch 108 taken 1 times.
✗ Branch 109 not taken.
✓ Branch 111 taken 1 times.
✗ Branch 112 not taken.
✓ Branch 116 taken 1 times.
✗ Branch 117 not taken.
|
4 | BOOST_AUTO_TEST_CASE(oriented_triangles2) { |
32 | hpp::affordance::SupportOperationPtr_t support( | ||
33 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
2 | new hpp::affordance::SupportOperation()); |
34 | hpp::affordance::LeanOperationPtr_t lean( | ||
35 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
2 | new hpp::affordance::LeanOperation(0.1)); |
36 | |||
37 | 2 | std::vector<hpp::affordance::OperationBasePtr_t> operations; | |
38 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | operations.push_back(support); |
39 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | operations.push_back(lean); |
40 | |||
41 | 2 | std::vector<coal::Vec3f> vertices; | |
42 | 2 | std::vector<coal::Triangle> triangles; | |
43 | |||
44 | typedef coal::BVHModel<coal::OBBRSS> Model; | ||
45 | |||
46 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | coal::Vec3f vert1(-1, 0, 0); |
47 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | coal::Vec3f vert2(1, 0, 1); |
48 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | coal::Vec3f vert3(1, 0, -1); |
49 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | vertices.push_back(vert1); |
50 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | vertices.push_back(vert2); |
51 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | vertices.push_back(vert3); |
52 | |||
53 | 2 | int size_ = 7; | |
54 | 2 | int affFound = 0; | |
55 | 2 | int affNotFound = 0; | |
56 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | coal::Vec3f T(0, 0, 0); |
57 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | coal::Vec3f axis(1, 0, 0); |
58 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | coal::Matrix3f R; |
59 | |||
60 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
|
16 | for (int i = 0; i < size_; ++i) { |
61 |
3/6✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
|
14 | coal::shared_ptr<Model> model(new Model()); |
62 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | coal::Triangle tri(0, 1, 2); |
63 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | triangles.push_back(tri); |
64 | |||
65 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
14 | R = Eigen::AngleAxisd(3.1416 * double(i) / 180.0, axis); |
66 | |||
67 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | coal::Transform3s pose(R, T); |
68 | |||
69 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
14 | model->beginModel(); |
70 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
14 | model->addSubModel(vertices, triangles); |
71 |
1/2✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
14 | model->endModel(); |
72 | |||
73 |
2/4✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
|
14 | coal::CollisionObject* obj(new coal::CollisionObject(model, pose)); |
74 | |||
75 | hpp::affordance::SemanticsDataPtr_t h = | ||
76 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
14 | hpp::affordance::affordanceAnalysis(obj, operations); |
77 | |||
78 |
5/6✓ Branch 3 taken 6 times.
✓ Branch 4 taken 1 times.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 1 times.
|
14 | if (h->affordances_[1].size() == 1 && h->affordances_[0].size() == 0) { |
79 | 12 | affFound += 1; | |
80 | } else { | ||
81 | 2 | affNotFound += 1; | |
82 | } | ||
83 | 14 | } | |
84 |
12/24✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 1 times.
✗ Branch 30 not taken.
✓ Branch 32 taken 1 times.
✗ Branch 33 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
|
2 | BOOST_CHECK_MESSAGE(affFound == 6 && affNotFound == 1, |
85 | "Strictly six lean affordances should have been found " | ||
86 | "and one rejected. Now " | ||
87 | << affFound << "were found and " << affNotFound | ||
88 | << " rejected."); | ||
89 | 2 | } | |
90 | BOOST_AUTO_TEST_SUITE_END() | ||
91 |