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 HPP_FCL_PYTHON_BROADPHASE_BROADPHASE_COLLISION_MANAGER_HH |
36 |
|
|
#define HPP_FCL_PYTHON_BROADPHASE_BROADPHASE_COLLISION_MANAGER_HH |
37 |
|
|
|
38 |
|
|
#include <eigenpy/eigenpy.hpp> |
39 |
|
|
|
40 |
|
|
#include <hpp/fcl/fwd.hh> |
41 |
|
|
#include <hpp/fcl/broadphase/broadphase_collision_manager.h> |
42 |
|
|
#include <hpp/fcl/broadphase/default_broadphase_callbacks.h> |
43 |
|
|
|
44 |
|
|
#include "../fcl.hh" |
45 |
|
|
|
46 |
|
|
#ifdef HPP_FCL_HAS_DOXYGEN_AUTODOC |
47 |
|
|
#include "doxygen_autodoc/functions.h" |
48 |
|
|
#include "doxygen_autodoc/hpp/fcl/broadphase/broadphase_collision_manager.h" |
49 |
|
|
#endif |
50 |
|
|
|
51 |
|
|
#include <boost/algorithm/string/replace.hpp> |
52 |
|
|
#include <boost/type_index.hpp> |
53 |
|
|
|
54 |
|
|
namespace hpp { |
55 |
|
|
namespace fcl { |
56 |
|
|
|
57 |
|
|
struct BroadPhaseCollisionManagerWrapper |
58 |
|
|
: BroadPhaseCollisionManager, |
59 |
|
|
bp::wrapper<BroadPhaseCollisionManager> { |
60 |
|
|
typedef BroadPhaseCollisionManager Base; |
61 |
|
|
|
62 |
|
|
void registerObjects(const std::vector<CollisionObject *> &other_objs) { |
63 |
|
|
this->get_override("registerObjects")(other_objs); |
64 |
|
|
} |
65 |
|
|
void registerObject(CollisionObject *obj) { |
66 |
|
|
this->get_override("registerObjects")(obj); |
67 |
|
|
} |
68 |
|
|
void unregisterObject(CollisionObject *obj) { |
69 |
|
|
this->get_override("unregisterObject")(obj); |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
void update(const std::vector<CollisionObject *> &other_objs) { |
73 |
|
|
this->get_override("update")(other_objs); |
74 |
|
|
} |
75 |
|
|
void update(CollisionObject *obj) { this->get_override("update")(obj); } |
76 |
|
|
void update() { this->get_override("update")(); } |
77 |
|
|
|
78 |
|
|
void setup() { this->get_override("setup")(); } |
79 |
|
|
void clear() { this->get_override("clear")(); } |
80 |
|
|
|
81 |
|
|
std::vector<CollisionObject *> getObjects() const { |
82 |
|
|
#pragma GCC diagnostic push |
83 |
|
|
#pragma GCC diagnostic ignored "-Wconversion" |
84 |
|
|
return this->get_override("getObjects")(); |
85 |
|
|
#pragma GCC diagnostic pop |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
void collide(CollisionCallBackBase *callback) const { |
89 |
|
|
this->get_override("collide")(callback); |
90 |
|
|
} |
91 |
|
|
void collide(CollisionObject *obj, CollisionCallBackBase *callback) const { |
92 |
|
|
this->get_override("collide")(obj, callback); |
93 |
|
|
} |
94 |
|
|
void collide(BroadPhaseCollisionManager *other_manager, |
95 |
|
|
CollisionCallBackBase *callback) const { |
96 |
|
|
this->get_override("collide")(other_manager, callback); |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
void distance(DistanceCallBackBase *callback) const { |
100 |
|
|
this->get_override("distance")(callback); |
101 |
|
|
} |
102 |
|
|
void distance(CollisionObject *obj, DistanceCallBackBase *callback) const { |
103 |
|
|
this->get_override("collide")(obj, callback); |
104 |
|
|
} |
105 |
|
|
void distance(BroadPhaseCollisionManager *other_manager, |
106 |
|
|
DistanceCallBackBase *callback) const { |
107 |
|
|
this->get_override("collide")(other_manager, callback); |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
bool empty() const { |
111 |
|
|
#pragma GCC diagnostic push |
112 |
|
|
#pragma GCC diagnostic ignored "-Wconversion" |
113 |
|
|
return this->get_override("empty")(); |
114 |
|
|
#pragma GCC diagnostic pop |
115 |
|
|
} |
116 |
|
|
size_t size() const { |
117 |
|
|
#pragma GCC diagnostic push |
118 |
|
|
#pragma GCC diagnostic ignored "-Wconversion" |
119 |
|
|
return this->get_override("size")(); |
120 |
|
|
#pragma GCC diagnostic pop |
121 |
|
|
} |
122 |
|
|
|
123 |
|
5 |
static void expose() { |
124 |
|
5 |
bp::class_<BroadPhaseCollisionManagerWrapper, boost::noncopyable>( |
125 |
|
|
"BroadPhaseCollisionManager", bp::no_init) |
126 |
|
|
.def("registerObjects", bp::pure_virtual(&Base::registerObjects), |
127 |
|
5 |
doxygen::member_func_doc(&Base::registerObjects), |
128 |
✓✗✓✗
|
5 |
bp::with_custodian_and_ward_postcall<1, 2>()) |
129 |
|
|
.def("registerObject", bp::pure_virtual(&Base::registerObject), |
130 |
|
5 |
doxygen::member_func_doc(&Base::registerObject), |
131 |
✓✗✓✗
|
5 |
bp::with_custodian_and_ward_postcall<1, 2>()) |
132 |
|
|
.def("unregisterObject", bp::pure_virtual(&Base::unregisterObject), |
133 |
✓✗✓✗
|
5 |
doxygen::member_func_doc(&Base::unregisterObject)) |
134 |
|
|
|
135 |
|
|
.def("update", bp::pure_virtual((void(Base::*)()) & Base::update), |
136 |
✓✗✓✗
|
5 |
doxygen::member_func_doc((void(Base::*)())(&Base::update))) |
137 |
|
|
.def("update", |
138 |
|
|
bp::pure_virtual( |
139 |
|
|
(void(Base::*)(const std::vector<CollisionObject *> &)) & |
140 |
|
|
Base::update), |
141 |
|
5 |
doxygen::member_func_doc((void(Base::*)( |
142 |
|
|
const std::vector<CollisionObject *> &))(&Base::update)), |
143 |
✓✗✓✗
|
5 |
bp::with_custodian_and_ward_postcall<1, 2>()) |
144 |
|
|
.def("update", |
145 |
|
|
bp::pure_virtual((void(Base::*)(CollisionObject * obj)) & |
146 |
|
|
Base::update), |
147 |
|
5 |
doxygen::member_func_doc( |
148 |
|
|
(void(Base::*)(CollisionObject * obj))(&Base::update)), |
149 |
✓✗✓✗
|
5 |
bp::with_custodian_and_ward_postcall<1, 2>()) |
150 |
|
|
|
151 |
|
|
.def("setup", bp::pure_virtual(&Base::setup), |
152 |
✓✗✓✗
|
5 |
doxygen::member_func_doc(&Base::setup)) |
153 |
|
|
.def("clear", bp::pure_virtual(&Base::clear), |
154 |
✓✗✓✗
|
5 |
doxygen::member_func_doc(&Base::clear)) |
155 |
|
|
.def("empty", bp::pure_virtual(&Base::empty), |
156 |
✓✗✓✗
|
5 |
doxygen::member_func_doc(&Base::empty)) |
157 |
|
|
.def("size", bp::pure_virtual(&Base::size), |
158 |
✓✗✓✗
|
5 |
doxygen::member_func_doc(&Base::size)) |
159 |
|
|
|
160 |
|
|
.def( |
161 |
|
|
"getObjects", |
162 |
|
|
bp::pure_virtual((std::vector<CollisionObject *>(Base::*)() const) & |
163 |
|
|
Base::getObjects), |
164 |
|
5 |
doxygen::member_func_doc( |
165 |
|
|
(std::vector<CollisionObject *>(Base::*)() const) & |
166 |
|
|
Base::getObjects), |
167 |
✓✗✓✗
|
5 |
bp::with_custodian_and_ward_postcall<0, 1>()) |
168 |
|
|
|
169 |
|
|
.def( |
170 |
|
|
"collide", |
171 |
|
|
bp::pure_virtual((void(Base::*)(CollisionCallBackBase *) const) & |
172 |
|
|
Base::collide), |
173 |
|
5 |
doxygen::member_func_doc( |
174 |
✓✗✓✗
|
5 |
(void(Base::*)(CollisionCallBackBase *) const) & Base::collide)) |
175 |
|
|
.def("collide", |
176 |
|
|
bp::pure_virtual((void(Base::*)(CollisionObject *, |
177 |
|
|
CollisionCallBackBase *) const) & |
178 |
|
|
Base::collide), |
179 |
|
5 |
doxygen::member_func_doc( |
180 |
|
|
(void(Base::*)(CollisionObject *, CollisionCallBackBase *) |
181 |
|
|
const) & |
182 |
✓✗✓✗
|
5 |
Base::collide)) |
183 |
|
|
.def("collide", |
184 |
|
|
bp::pure_virtual((void(Base::*)(BroadPhaseCollisionManager *, |
185 |
|
|
CollisionCallBackBase *) const) & |
186 |
|
|
Base::collide), |
187 |
|
5 |
doxygen::member_func_doc( |
188 |
|
|
(void(Base::*)(BroadPhaseCollisionManager *, |
189 |
|
|
CollisionCallBackBase *) const) & |
190 |
✓✗✓✗
|
5 |
Base::collide)) |
191 |
|
|
|
192 |
|
|
.def( |
193 |
|
|
"distance", |
194 |
|
|
bp::pure_virtual((void(Base::*)(DistanceCallBackBase *) const) & |
195 |
|
|
Base::distance), |
196 |
|
5 |
doxygen::member_func_doc( |
197 |
✓✗✓✗
|
5 |
(void(Base::*)(DistanceCallBackBase *) const) & Base::distance)) |
198 |
|
|
.def("distance", |
199 |
|
|
bp::pure_virtual((void(Base::*)(CollisionObject *, |
200 |
|
|
DistanceCallBackBase *) const) & |
201 |
|
|
Base::distance), |
202 |
|
5 |
doxygen::member_func_doc( |
203 |
|
|
(void(Base::*)(CollisionObject *, DistanceCallBackBase *) |
204 |
|
|
const) & |
205 |
✓✗✓✗
|
5 |
Base::distance)) |
206 |
|
|
.def("distance", |
207 |
|
|
bp::pure_virtual((void(Base::*)(BroadPhaseCollisionManager *, |
208 |
|
|
DistanceCallBackBase *) const) & |
209 |
|
|
Base::distance), |
210 |
|
10 |
doxygen::member_func_doc( |
211 |
|
|
(void(Base::*)(BroadPhaseCollisionManager *, |
212 |
|
|
DistanceCallBackBase *) const) & |
213 |
✓✗✓✗
|
5 |
Base::distance)); |
214 |
|
5 |
} |
215 |
|
|
|
216 |
|
|
template <typename Derived> |
217 |
|
60 |
static void exposeDerived() { |
218 |
✓✗ |
60 |
std::string class_name = boost::typeindex::type_id<Derived>().pretty_name(); |
219 |
✓✗ |
60 |
boost::algorithm::replace_all(class_name, "hpp::fcl::", ""); |
220 |
|
|
#if defined(WIN32) |
221 |
|
|
boost::algorithm::replace_all(class_name, "class ", ""); |
222 |
|
|
#endif |
223 |
|
|
|
224 |
✓✗✓✗
|
180 |
bp::class_<Derived, bp::bases<BroadPhaseCollisionManager> >( |
225 |
|
|
class_name.c_str(), bp::no_init) |
226 |
|
120 |
.def(dv::init<Derived>()); |
227 |
|
60 |
} |
228 |
|
|
|
229 |
|
|
}; // BroadPhaseCollisionManagerWrapper |
230 |
|
|
|
231 |
|
|
} // namespace fcl |
232 |
|
|
} // namespace hpp |
233 |
|
|
|
234 |
|
|
#endif // ifndef HPP_FCL_PYTHON_BROADPHASE_BROADPHASE_COLLISION_MANAGER_HH |