5#ifndef __pinocchio_python_collision_pool_broadphase_manager_hpp__ 6#define __pinocchio_python_collision_pool_broadphase_manager_hpp__ 8#include <eigenpy/eigen-to-python.hpp> 10#include "pinocchio/collision/pool/broadphase-manager.hpp" 12#include <boost/python/overloads.hpp> 13#include <boost/algorithm/string/replace.hpp> 14#include <eigenpy/memory.hpp> 15#include <eigenpy/exception.hpp> 17#include "pinocchio/algorithm/check.hpp" 18#include "pinocchio/bindings/python/utils/copyable.hpp" 19#include "pinocchio/bindings/python/utils/std-vector.hpp" 25 namespace bp = boost::python;
29 template<
typename BroadPhaseManager>
32 static std::string get();
35 template<
typename Manager>
38 static std::string get()
40 return "BroadPhaseManager";
44 template<
typename Manager>
47 static std::string get()
49 return "TreeBroadPhaseManager";
54 template<
typename BroadPhaseManagerPool>
55 struct BroadPhaseManagerPoolPythonVisitor
56 :
public bp::def_visitor<BroadPhaseManagerPoolPythonVisitor<BroadPhaseManagerPool>>
59 typedef typename BroadPhaseManagerPool::Base Base;
60 typedef typename BroadPhaseManagerPool::Model Model;
61 typedef typename BroadPhaseManagerPool::GeometryModel
GeometryModel;
62 typedef typename BroadPhaseManagerPool::GeometryData
GeometryData;
63 typedef typename BroadPhaseManagerPool::BroadPhaseManagerVector BroadPhaseManagerVector;
64 typedef typename BroadPhaseManagerPool::BroadPhaseManager BroadPhaseManager;
65 typedef typename BroadPhaseManager::Manager Manager;
68 template<
class PyClass>
69 void visit(PyClass & cl)
const 71 cl.def(bp::init<
const Model &,
const GeometryModel &, bp::optional<size_t>>(
72 bp::args(
"self",
"model",
"geometry_model",
"size"),
"Default constructor."))
74 bp::init<const BroadPhaseManagerPool &>(bp::args(
"self",
"other"),
"Copy constructor."))
77 "getBroadPhaseManager",
78 (BroadPhaseManager & (BroadPhaseManagerPool::*)(
const size_t))
80 bp::args(
"self",
"index"),
"Return a specific broadphase manager.",
81 bp::return_internal_reference<>())
83 "getBroadPhaseManagers",
84 (BroadPhaseManagerVector & (BroadPhaseManagerPool::*)())
86 bp::arg(
"self"),
"Returns the vector of broadphase managers.",
87 bp::return_internal_reference<>())
92 bp::args(
"self",
"geometry_data"),
93 "Update all the geometry datas with the input geometry data value.")
97 "Check whether the current pool is valid.")
100 "asGeometryPool", downcast, bp::arg(
"self"),
101 "Cast the object as GeometryPool (equivalent to a C++ static_cast).",
102 bp::return_self<>());
105 static PyObject * downcast(BroadPhaseManagerPool & self)
107 bp::type_info
type = bp::type_id<Base>();
108 const bp::converter::registration * registration = bp::converter::registry::query(
type);
110 return registration->to_python(
static_cast<Base *
>(&self));
115 std::string manager_name = boost::typeindex::type_id<Manager>().pretty_name();
116 boost::algorithm::replace_all(manager_name,
"hpp::fcl::",
"");
117 const std::string broadphase_prefix = helper::base_class_name<BroadPhaseManager>::get();
118 const std::string class_name = broadphase_prefix +
"Pool" +
"_" + manager_name;
120 const std::string doc =
"Pool containing a bunch of " + broadphase_prefix +
".";
122 bp::class_<BroadPhaseManagerPool, bp::bases<Base>>(
123 class_name.c_str(), doc.c_str(), bp::no_init)
124 .def(BroadPhaseManagerPoolPythonVisitor())
125 .def(CopyableVisitor<BroadPhaseManagerPool>());
127 const std::string vector_name =
"StdVec_" + broadphase_prefix +
"_" + manager_name;
128 StdVectorPythonVisitor<BroadPhaseManagerVector>::expose(vector_name);
virtual void update(const GeometryData &geometry_data)
const BroadPhaseManager & getBroadPhaseManager(const size_t index) const
const BroadPhaseManagerVector & getBroadPhaseManagers() const
Main pinocchio namespace.