-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathexpose-broadphase-callbacks.cpp
92 lines (78 loc) · 3.06 KB
/
expose-broadphase-callbacks.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// Copyright (c) 2022 INRIA
//
#include <eigenpy/eigenpy.hpp>
#include "pinocchio/collision/broadphase-callbacks.hpp"
namespace bp = boost::python;
namespace pinocchio
{
namespace python
{
struct CollisionCallBackBaseWrapper
: CollisionCallBackBase
, bp::wrapper<CollisionCallBackBase>
{
typedef CollisionCallBackBase Base;
bool stop() const
{
return this->get_override("stop")();
}
void done()
{
if (bp::override done = this->get_override("done"))
done();
Base::done();
}
void done_default()
{
return this->Base::done();
}
static void expose()
{
bp::class_<
CollisionCallBackBaseWrapper, bp::bases<hpp::fcl::CollisionCallBackBase>,
boost::noncopyable>("CollisionCallBackBase", bp::no_init)
.def(
"getGeometryModel", &CollisionCallBackDefault::getGeometryModel, bp::arg("self"),
bp::return_value_policy<bp::copy_const_reference>())
.def(
"getGeometryData",
(GeometryData & (CollisionCallBackDefault::*)())
& CollisionCallBackDefault::getGeometryData,
bp::arg("self"), bp::return_internal_reference<>())
.def_readonly(
"collision", &CollisionCallBackDefault::collision,
"Whether there is a collision or not.")
.def_readonly(
"accumulate", &CollisionCallBackDefault::accumulate,
"Whether the callback is used in an accumulate mode where several collide "
"methods are called successively.")
.def(
"stop", bp::pure_virtual(&Base::stop), bp::arg("self"),
"If true, the stopping criteria related to the collision callback has been met and "
"one can stop.")
.def(
"done", &Base::done, &CollisionCallBackBaseWrapper::done_default,
"Callback method called after the termination of a collisition detection algorithm.");
}
};
void exposeBroadphaseCallbacks()
{
CollisionCallBackBaseWrapper::expose();
bp::class_<CollisionCallBackDefault, bp::bases<CollisionCallBackBase>>(
"CollisionCallBackDefault", bp::no_init)
.def(bp::init<const GeometryModel &, GeometryData &, bp::optional<bool>>(
bp::args("self", "geometry_model", "geometry_data", "stopAtFirstCollision"),
"Default constructor from a given GeometryModel and a GeometryData")
[bp::with_custodian_and_ward<1, 2>(), bp::with_custodian_and_ward<1, 3>()])
.def_readwrite(
"stopAtFirstCollision", &CollisionCallBackDefault::stopAtFirstCollision,
"Whether to stop or not when localizing a first collision")
.def_readonly(
"collisionPairIndex", &CollisionCallBackDefault::collisionPairIndex,
"The collision index of the first pair in collision")
.def_readonly(
"count", &CollisionCallBackDefault::count, "Number of visits of the collide method");
}
} // namespace python
} // namespace pinocchio