Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2014 CNRS |
3 |
|
|
// Authors: Florent Lamiraux |
4 |
|
|
// |
5 |
|
|
|
6 |
|
|
// Redistribution and use in source and binary forms, with or without |
7 |
|
|
// modification, are permitted provided that the following conditions are |
8 |
|
|
// met: |
9 |
|
|
// |
10 |
|
|
// 1. Redistributions of source code must retain the above copyright |
11 |
|
|
// notice, this list of conditions and the following disclaimer. |
12 |
|
|
// |
13 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright |
14 |
|
|
// notice, this list of conditions and the following disclaimer in the |
15 |
|
|
// documentation and/or other materials provided with the distribution. |
16 |
|
|
// |
17 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
18 |
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
19 |
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
20 |
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
21 |
|
|
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
22 |
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
23 |
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 |
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 |
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
28 |
|
|
// DAMAGE. |
29 |
|
|
|
30 |
|
|
#ifndef HPP_CORE_COLLISION_VALIDATION_REPORT_HH |
31 |
|
|
#define HPP_CORE_COLLISION_VALIDATION_REPORT_HH |
32 |
|
|
|
33 |
|
|
#include <coal/collision_data.h> |
34 |
|
|
|
35 |
|
|
#include <hpp/core/collision-pair.hh> |
36 |
|
|
#include <hpp/core/validation-report.hh> |
37 |
|
|
#include <hpp/pinocchio/collision-object.hh> |
38 |
|
|
#include <hpp/util/indent.hh> |
39 |
|
|
|
40 |
|
|
namespace hpp { |
41 |
|
|
namespace core { |
42 |
|
|
/// \addtogroup validation |
43 |
|
|
/// \{ |
44 |
|
|
|
45 |
|
|
/// Validate a configuration with respect to collision |
46 |
|
|
/// |
47 |
|
|
struct HPP_CORE_DLLAPI CollisionValidationReport : public ValidationReport { |
48 |
|
|
CollisionValidationReport() {} |
49 |
|
|
|
50 |
|
|
CollisionValidationReport(CollisionObjectConstPtr_t o1, |
51 |
|
|
CollisionObjectConstPtr_t o2, |
52 |
|
|
const coal::CollisionResult& r) |
53 |
|
|
: object1(o1), object2(o2), result(r) {} |
54 |
|
|
|
55 |
|
204 |
CollisionValidationReport(const CollisionPair_t& pair, |
56 |
|
|
const coal::CollisionResult& r) |
57 |
1/2
✓ Branch 6 taken 204 times.
✗ Branch 7 not taken.
|
204 |
: object1(pair.first), object2(pair.second), result(r) {} |
58 |
|
|
|
59 |
|
|
/// First object in collision |
60 |
|
|
CollisionObjectConstPtr_t object1; |
61 |
|
|
std::string objectName1; |
62 |
|
|
/// Second object in collision |
63 |
|
|
CollisionObjectConstPtr_t object2; |
64 |
|
|
std::string objectName2; |
65 |
|
|
/// coal collision results |
66 |
|
|
coal::CollisionResult result; |
67 |
|
|
/// Write report in a stream |
68 |
|
✗ |
virtual std::ostream& print(std::ostream& os) const { |
69 |
|
|
os << "Collision between object " |
70 |
|
✗ |
<< (object1 ? object1->name() : objectName1) << " and " |
71 |
|
✗ |
<< (object2 ? object2->name() : objectName2); |
72 |
|
✗ |
return os; |
73 |
|
|
} |
74 |
|
|
std::pair<std::string, std::string> getObjectNames() const { |
75 |
|
|
return std::pair<std::string, std::string>( |
76 |
|
|
object1 ? object1->name() : objectName1, |
77 |
|
|
object2 ? object2->name() : objectName2); |
78 |
|
|
} |
79 |
|
|
}; // class CollisionValidationReport |
80 |
|
|
|
81 |
|
|
/// Validate a configuration with respect to collision |
82 |
|
|
/// |
83 |
|
|
struct HPP_CORE_DLLAPI AllCollisionsValidationReport |
84 |
|
|
: public CollisionValidationReport { |
85 |
|
|
AllCollisionsValidationReport() {} |
86 |
|
|
|
87 |
|
|
AllCollisionsValidationReport(CollisionObjectConstPtr_t o1, |
88 |
|
|
CollisionObjectConstPtr_t o2, |
89 |
|
|
const coal::CollisionResult& r) |
90 |
|
|
: CollisionValidationReport(o1, o2, r) {} |
91 |
|
|
|
92 |
|
✗ |
AllCollisionsValidationReport(const CollisionPair_t& pair, |
93 |
|
|
const coal::CollisionResult& r) |
94 |
|
✗ |
: CollisionValidationReport(pair, r) {} |
95 |
|
|
|
96 |
|
|
std::vector<CollisionValidationReportPtr_t> collisionReports; |
97 |
|
✗ |
virtual std::ostream& print(std::ostream& os) const { |
98 |
|
✗ |
os << " Number of collisions : " << collisionReports.size() << "." |
99 |
|
✗ |
<< incendl; |
100 |
|
✗ |
for (std::vector<CollisionValidationReportPtr_t>::const_iterator it = |
101 |
|
✗ |
collisionReports.begin(); |
102 |
|
✗ |
it != collisionReports.end(); ++it) { |
103 |
|
✗ |
os << **it << iendl; |
104 |
|
|
} |
105 |
|
✗ |
return os << decindent; |
106 |
|
|
} |
107 |
|
|
}; // class AllCollisionsValidationReport |
108 |
|
|
/// \} |
109 |
|
|
} // namespace core |
110 |
|
|
} // namespace hpp |
111 |
|
|
|
112 |
|
|
#endif // HPP_CORE_COLLISION_VALIDATION_REPORT_HH |
113 |
|
|
|