broadphase_collision_manager.hh
Go to the documentation of this file.
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"
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 
58  bp::wrapper<BroadPhaseCollisionManager> {
60 
61  void registerObjects(const std::vector<CollisionObject *> &other_objs) {
62  this->get_override("registerObjects")(other_objs);
63  }
65  this->get_override("registerObjects")(obj);
66  }
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 
88  this->get_override("collide")(callback);
89  }
91  this->get_override("collide")(obj, callback);
92  }
93  void collide(BroadPhaseCollisionManager *other_manager,
95  this->get_override("collide")(other_manager, callback);
96  }
97 
99  this->get_override("distance")(callback);
100  }
102  this->get_override("collide")(obj, callback);
103  }
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  static void expose() {
123  bp::class_<BroadPhaseCollisionManagerWrapper, boost::noncopyable>(
124  "BroadPhaseCollisionManager", bp::no_init)
125  .def("registerObjects", bp::pure_virtual(&Base::registerObjects),
127  bp::with_custodian_and_ward_postcall<1, 2>())
128  .def("registerObject", bp::pure_virtual(&Base::registerObject),
130  bp::with_custodian_and_ward_postcall<1, 2>())
131  .def("unregisterObject", bp::pure_virtual(&Base::unregisterObject),
133 
134  .def("update", bp::pure_virtual((void(Base::*)()) & Base::update),
136  .def("update",
137  bp::pure_virtual(
138  (void(Base::*)(const std::vector<CollisionObject *> &)) &
139  Base::update),
140  doxygen::member_func_doc((void(Base::*)(
141  const std::vector<CollisionObject *> &))(&Base::update)),
142  bp::with_custodian_and_ward_postcall<1, 2>())
143  .def("update",
144  bp::pure_virtual((void(Base::*)(CollisionObject * obj)) &
145  Base::update),
147  (void(Base::*)(CollisionObject * obj))(&Base::update)),
148  bp::with_custodian_and_ward_postcall<1, 2>())
149 
150  .def("setup", bp::pure_virtual(&Base::setup),
152  .def("clear", bp::pure_virtual(&Base::clear),
154  .def("empty", bp::pure_virtual(&Base::empty),
156  .def("size", bp::pure_virtual(&Base::size),
158 
159  .def(
160  "getObjects",
161  bp::pure_virtual((std::vector<CollisionObject *>(Base::*)() const) &
164  (std::vector<CollisionObject *>(Base::*)() const) &
166  bp::with_custodian_and_ward_postcall<0, 1>())
167 
168  .def(
169  "collide",
170  bp::pure_virtual((void(Base::*)(CollisionCallBackBase *) const) &
171  Base::collide),
173  (void(Base::*)(CollisionCallBackBase *) const) & Base::collide))
174  .def("collide",
175  bp::pure_virtual((void(Base::*)(CollisionObject *,
176  CollisionCallBackBase *) const) &
177  Base::collide),
180  const) &
181  Base::collide))
182  .def("collide",
183  bp::pure_virtual((void(Base::*)(BroadPhaseCollisionManager *,
184  CollisionCallBackBase *) const) &
185  Base::collide),
187  (void(Base::*)(BroadPhaseCollisionManager *,
188  CollisionCallBackBase *) const) &
189  Base::collide))
190 
191  .def(
192  "distance",
193  bp::pure_virtual((void(Base::*)(DistanceCallBackBase *) const) &
196  (void(Base::*)(DistanceCallBackBase *) const) & Base::distance))
197  .def("distance",
198  bp::pure_virtual((void(Base::*)(CollisionObject *,
199  DistanceCallBackBase *) const) &
203  const) &
205  .def("distance",
206  bp::pure_virtual((void(Base::*)(BroadPhaseCollisionManager *,
207  DistanceCallBackBase *) const) &
210  (void(Base::*)(BroadPhaseCollisionManager *,
211  DistanceCallBackBase *) const) &
212  Base::distance));
213  }
214 
215  template <typename Derived>
216  static void exposeDerived() {
217  std::string class_name = boost::typeindex::type_id<Derived>().pretty_name();
218  boost::algorithm::replace_all(class_name, "coal::", "");
219 #if defined(WIN32)
220  boost::algorithm::replace_all(class_name, "class ", "");
221 #endif
222 
223  bp::class_<Derived, bp::bases<BroadPhaseCollisionManager> >(
224  class_name.c_str(), bp::no_init)
225  .def(dv::init<Derived>());
226  }
227 
228 }; // BroadPhaseCollisionManagerWrapper
229 
230 } // namespace coal
231 
232 #endif // ifndef COAL_PYTHON_BROADPHASE_BROADPHASE_COLLISION_MANAGER_HH
coal::BroadPhaseCollisionManagerWrapper::Base
BroadPhaseCollisionManager Base
Definition: broadphase_collision_manager.hh:59
coal::BroadPhaseCollisionManagerWrapper::registerObjects
void registerObjects(const std::vector< CollisionObject * > &other_objs)
add objects to the manager
Definition: broadphase_collision_manager.hh:61
coal::BroadPhaseCollisionManager::size
virtual size_t size() const =0
the number of objects managed by the manager
collision_manager.callback
callback
Definition: collision_manager.py:27
coal::BroadPhaseCollisionManagerWrapper::collide
void collide(CollisionCallBackBase *callback) const
perform collision test for the objects belonging to the manager (i.e., N^2 self collision)
Definition: broadphase_collision_manager.hh:87
coal::BroadPhaseCollisionManager::distance
virtual void distance(CollisionObject *obj, DistanceCallBackBase *callback) const =0
perform distance computation between one object and all the objects belonging to the manager
coal::BroadPhaseCollisionManagerWrapper::registerObject
void registerObject(CollisionObject *obj)
add one object to the manager
Definition: broadphase_collision_manager.hh:64
eigenpy.hpp
coal::BroadPhaseCollisionManagerWrapper::empty
bool empty() const
whether the manager is empty
Definition: broadphase_collision_manager.hh:109
coal::BroadPhaseCollisionManagerWrapper::size
size_t size() const
the number of objects managed by the manager
Definition: broadphase_collision_manager.hh:115
coal::BroadPhaseCollisionManagerWrapper::getObjects
std::vector< CollisionObject * > getObjects() const
return the objects managed by the manager
Definition: broadphase_collision_manager.hh:80
coal::BroadPhaseCollisionManager::clear
virtual void clear()=0
clear the manager
coal::BroadPhaseCollisionManager
Base class for broad phase collision. It helps to accelerate the collision/distance between N objects...
Definition: coal/broadphase/broadphase_collision_manager.h:53
coal::BroadPhaseCollisionManagerWrapper::collide
void collide(BroadPhaseCollisionManager *other_manager, CollisionCallBackBase *callback) const
perform collision test with objects belonging to another manager
Definition: broadphase_collision_manager.hh:93
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::BroadPhaseCollisionManager::getObjects
virtual std::vector< CollisionObject * > getObjects() const
return the objects managed by the manager
Definition: coal/broadphase/broadphase_collision_manager.h:87
coal::BroadPhaseCollisionManagerWrapper::setup
void setup()
initialize the manager, related with the specific type of manager
Definition: broadphase_collision_manager.hh:77
default_broadphase_callbacks.h
doxygen::def
void def(const char *name, Func func)
Definition: doxygen-boost.hh:106
coal::BroadPhaseCollisionManager::registerObjects
virtual void registerObjects(const std::vector< CollisionObject * > &other_objs)
add objects to the manager
Definition: broadphase_collision_manager.cpp:54
broadphase_collision_manager.h
coal::BroadPhaseCollisionManager::setup
virtual void setup()=0
initialize the manager, related with the specific type of manager
coal::BroadPhaseCollisionManagerWrapper::collide
void collide(CollisionObject *obj, CollisionCallBackBase *callback) const
perform collision test between one object and all the objects belonging to the manager
Definition: broadphase_collision_manager.hh:90
coal::BroadPhaseCollisionManagerWrapper
Definition: broadphase_collision_manager.hh:56
coal::BroadPhaseCollisionManagerWrapper::exposeDerived
static void exposeDerived()
Definition: broadphase_collision_manager.hh:216
fwd.hh
coal::BroadPhaseCollisionManagerWrapper::expose
static void expose()
Definition: broadphase_collision_manager.hh:122
coal::BroadPhaseCollisionManager::update
virtual void update()=0
update the condition of manager
coal::BroadPhaseCollisionManagerWrapper::update
void update(const std::vector< CollisionObject * > &other_objs)
update the manager by explicitly given the set of objects update
Definition: broadphase_collision_manager.hh:71
coal::DistanceCallBackBase
Base callback class for distance queries. This class can be supersed by child classes to provide desi...
Definition: coal/broadphase/broadphase_callbacks.h:72
coal::CollisionObject
the object for collision or distance computation, contains the geometry and the transform information
Definition: coal/collision_object.h:214
coal::BroadPhaseCollisionManagerWrapper::update
void update()
update the condition of manager
Definition: broadphase_collision_manager.hh:75
coal::BroadPhaseCollisionManager::empty
virtual bool empty() const =0
whether the manager is empty
coal::BroadPhaseCollisionManagerWrapper::unregisterObject
void unregisterObject(CollisionObject *obj)
remove one object from the manager
Definition: broadphase_collision_manager.hh:67
coal::BroadPhaseCollisionManagerWrapper::clear
void clear()
clear the manager
Definition: broadphase_collision_manager.hh:78
coal::BroadPhaseCollisionManagerWrapper::distance
void distance(DistanceCallBackBase *callback) const
perform distance test for the objects belonging to the manager (i.e., N^2 self distance)
Definition: broadphase_collision_manager.hh:98
coal::BroadPhaseCollisionManager::registerObject
virtual void registerObject(CollisionObject *obj)=0
add one object to the manager
coal::BroadPhaseCollisionManagerWrapper::distance
void distance(BroadPhaseCollisionManager *other_manager, DistanceCallBackBase *callback) const
perform distance test with objects belonging to another manager
Definition: broadphase_collision_manager.hh:104
coal::CollisionCallBackBase
Base callback class for collision queries. This class can be supersed by child classes to provide des...
Definition: coal/broadphase/broadphase_callbacks.h:49
coal::BroadPhaseCollisionManager::collide
virtual void collide(CollisionObject *obj, CollisionCallBackBase *callback) const =0
perform collision test between one object and all the objects belonging to the manager
coal::BroadPhaseCollisionManager::unregisterObject
virtual void unregisterObject(CollisionObject *obj)=0
remove one object from the manager
coal::BroadPhaseCollisionManagerWrapper::update
void update(CollisionObject *obj)
update the manager by explicitly given the object updated
Definition: broadphase_collision_manager.hh:74
doxygen::member_func_doc
const char * member_func_doc(FuncPtr)
Definition: doxygen.hh:33
coal::BroadPhaseCollisionManagerWrapper::distance
void distance(CollisionObject *obj, DistanceCallBackBase *callback) const
perform distance computation between one object and all the objects belonging to the manager
Definition: broadphase_collision_manager.hh:101


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57