GCC Code Coverage Report


Directory: ./
File: python/broadphase/broadphase_collision_manager.hh
Date: 2025-05-02 10:16:21
Exec Total Coverage
Lines: 43 48 89.6%
Branches: 38 76 50.0%

Line Branch Exec Source
1 //
2 // Software License Agreement (BSD License)
3 //
4 // Copyright (c) 2022 INRIA
5 // Author: Justin Carpentier
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following
16 // disclaimer in the documentation and/or other materials provided
17 // with the distribution.
18 // * Neither the name of INRIA nor the names of its
19 // contributors may be used to endorse or promote products derived
20 // from this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 // POSSIBILITY OF SUCH DAMAGE.
34
35 #ifndef COAL_PYTHON_BROADPHASE_BROADPHASE_COLLISION_MANAGER_HH
36 #define COAL_PYTHON_BROADPHASE_BROADPHASE_COLLISION_MANAGER_HH
37
38 #include <eigenpy/eigenpy.hpp>
39
40 #include "coal/fwd.hh"
41 #include "coal/broadphase/broadphase_collision_manager.h"
42 #include "coal/broadphase/default_broadphase_callbacks.h"
43
44 #include "../coal.hh"
45
46 #ifdef COAL_HAS_DOXYGEN_AUTODOC
47 #include "doxygen_autodoc/functions.h"
48 #include "doxygen_autodoc/coal/broadphase/broadphase_collision_manager.h"
49 #endif
50
51 #include <boost/algorithm/string/replace.hpp>
52 #include <boost/type_index.hpp>
53
54 namespace coal {
55
56 struct BroadPhaseCollisionManagerWrapper
57 : BroadPhaseCollisionManager,
58 bp::wrapper<BroadPhaseCollisionManager> {
59 typedef BroadPhaseCollisionManager Base;
60
61 void registerObjects(const std::vector<CollisionObject *> &other_objs) {
62 this->get_override("registerObjects")(other_objs);
63 }
64 void registerObject(CollisionObject *obj) {
65 this->get_override("registerObjects")(obj);
66 }
67 void unregisterObject(CollisionObject *obj) {
68 this->get_override("unregisterObject")(obj);
69 }
70
71 void update(const std::vector<CollisionObject *> &other_objs) {
72 this->get_override("update")(other_objs);
73 }
74 void update(CollisionObject *obj) { this->get_override("update")(obj); }
75 void update() { this->get_override("update")(); }
76
77 void setup() { this->get_override("setup")(); }
78 void clear() { this->get_override("clear")(); }
79
80 std::vector<CollisionObject *> getObjects() const {
81 #pragma GCC diagnostic push
82 #pragma GCC diagnostic ignored "-Wconversion"
83 return this->get_override("getObjects")();
84 #pragma GCC diagnostic pop
85 }
86
87 void collide(CollisionCallBackBase *callback) const {
88 this->get_override("collide")(callback);
89 }
90 void collide(CollisionObject *obj, CollisionCallBackBase *callback) const {
91 this->get_override("collide")(obj, callback);
92 }
93 void collide(BroadPhaseCollisionManager *other_manager,
94 CollisionCallBackBase *callback) const {
95 this->get_override("collide")(other_manager, callback);
96 }
97
98 void distance(DistanceCallBackBase *callback) const {
99 this->get_override("distance")(callback);
100 }
101 void distance(CollisionObject *obj, DistanceCallBackBase *callback) const {
102 this->get_override("collide")(obj, callback);
103 }
104 void distance(BroadPhaseCollisionManager *other_manager,
105 DistanceCallBackBase *callback) const {
106 this->get_override("collide")(other_manager, callback);
107 }
108
109 bool empty() const {
110 #pragma GCC diagnostic push
111 #pragma GCC diagnostic ignored "-Wconversion"
112 return this->get_override("empty")();
113 #pragma GCC diagnostic pop
114 }
115 size_t size() const {
116 #pragma GCC diagnostic push
117 #pragma GCC diagnostic ignored "-Wconversion"
118 return this->get_override("size")();
119 #pragma GCC diagnostic pop
120 }
121
122 5 static void expose() {
123 5 bp::class_<BroadPhaseCollisionManagerWrapper, boost::noncopyable>(
124 "BroadPhaseCollisionManager", bp::no_init)
125
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("registerObjects", bp::pure_virtual(&Base::registerObjects),
126
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(&Base::registerObjects),
127 bp::with_custodian_and_ward_postcall<1, 2>())
128
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("registerObject", bp::pure_virtual(&Base::registerObject),
129
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(&Base::registerObject),
130 bp::with_custodian_and_ward_postcall<1, 2>())
131
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("unregisterObject", bp::pure_virtual(&Base::unregisterObject),
132
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(&Base::unregisterObject))
133
134
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("update", bp::pure_virtual((void (Base::*)())&Base::update),
135
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc((void (Base::*)())(&Base::update)))
136
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("update",
137 bp::pure_virtual((void (Base::*)(
138 const std::vector<CollisionObject *> &))&Base::update),
139
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc((void (Base::*)(
140 const std::vector<CollisionObject *> &))(&Base::update)),
141 bp::with_custodian_and_ward_postcall<1, 2>())
142
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("update",
143 bp::pure_virtual(
144 (void (Base::*)(CollisionObject *obj))&Base::update),
145
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(
146 (void (Base::*)(CollisionObject *obj))(&Base::update)),
147 bp::with_custodian_and_ward_postcall<1, 2>())
148
149
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("setup", bp::pure_virtual(&Base::setup),
150
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(&Base::setup))
151
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("clear", bp::pure_virtual(&Base::clear),
152
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(&Base::clear))
153
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("empty", bp::pure_virtual(&Base::empty),
154
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(&Base::empty))
155
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("size", bp::pure_virtual(&Base::size),
156
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(&Base::size))
157
158
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("getObjects",
159 bp::pure_virtual(
160 (std::vector<CollisionObject *> (Base::*)() const) &
161 Base::getObjects),
162
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(
163 (std::vector<CollisionObject *> (Base::*)() const) &
164 Base::getObjects),
165 bp::with_custodian_and_ward_postcall<0, 1>())
166
167
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("collide",
168 bp::pure_virtual((void (Base::*)(CollisionCallBackBase *) const) &
169 Base::collide),
170
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(
171 (void (Base::*)(CollisionCallBackBase *) const) &
172 Base::collide))
173
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("collide",
174 bp::pure_virtual((void (Base::*)(CollisionObject *,
175 CollisionCallBackBase *) const) &
176 Base::collide),
177
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(
178 (void (Base::*)(CollisionObject *, CollisionCallBackBase *)
179 const) &
180 Base::collide))
181
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("collide",
182 bp::pure_virtual((void (Base::*)(BroadPhaseCollisionManager *,
183 CollisionCallBackBase *) const) &
184 Base::collide),
185
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(
186 (void (Base::*)(BroadPhaseCollisionManager *,
187 CollisionCallBackBase *) const) &
188 Base::collide))
189
190
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("distance",
191 bp::pure_virtual((void (Base::*)(DistanceCallBackBase *) const) &
192 Base::distance),
193
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(
194 (void (Base::*)(DistanceCallBackBase *) const) &
195 Base::distance))
196
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("distance",
197 bp::pure_virtual((void (Base::*)(CollisionObject *,
198 DistanceCallBackBase *) const) &
199 Base::distance),
200
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 doxygen::member_func_doc(
201 (void (Base::*)(CollisionObject *, DistanceCallBackBase *)
202 const) &
203 Base::distance))
204
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 .def("distance",
205 bp::pure_virtual((void (Base::*)(BroadPhaseCollisionManager *,
206 DistanceCallBackBase *) const) &
207 Base::distance),
208
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
10 doxygen::member_func_doc(
209 (void (Base::*)(BroadPhaseCollisionManager *,
210 DistanceCallBackBase *) const) &
211 Base::distance));
212 5 }
213
214 template <typename Derived>
215 60 static void exposeDerived() {
216
1/2
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 std::string class_name = boost::typeindex::type_id<Derived>().pretty_name();
217
1/2
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
60 boost::algorithm::replace_all(class_name, "coal::", "");
218 #if defined(WIN32)
219 boost::algorithm::replace_all(class_name, "class ", "");
220 #endif
221
222
1/2
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 bp::class_<Derived, bp::bases<BroadPhaseCollisionManager> >(
223 class_name.c_str(), bp::no_init)
224
1/2
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 .def(dv::init<Derived>());
225 60 }
226
227 }; // BroadPhaseCollisionManagerWrapper
228
229 } // namespace coal
230
231 #endif // ifndef COAL_PYTHON_BROADPHASE_BROADPHASE_COLLISION_MANAGER_HH
232