GCC Code Coverage Report


Directory: ./
File: include/pinocchio/bindings/python/collision/broadphase-manager.hpp
Date: 2025-02-12 21:03:38
Exec Total Coverage
Lines: 28 29 96.6%
Branches: 24 48 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2022-2024 INRIA
3 //
4
5 #ifndef __pinocchio_python_collision_broadphase_manager_hpp__
6 #define __pinocchio_python_collision_broadphase_manager_hpp__
7
8 #include "pinocchio/collision/broadphase-manager.hpp"
9 #include "pinocchio/bindings/python/collision/broadphase-manager-base.hpp"
10
11 #include <eigenpy/eigen-to-python.hpp>
12 #include <boost/algorithm/string/replace.hpp>
13
14 namespace pinocchio
15 {
16 namespace python
17 {
18 namespace bp = boost::python;
19
20 template<typename Derived>
21 struct BroadPhaseManagerPythonVisitor
22 : public bp::def_visitor<BroadPhaseManagerPythonVisitor<Derived>>
23 {
24 public:
25 typedef BroadPhaseManagerTpl<Derived> Self;
26 typedef typename Self::CollisionObjectVector CollisionObjectVector;
27
28 /* --- Exposing C++ API to python through the handler ----------------- */
29 template<class PyClass>
30 780 void visit(PyClass & cl) const
31 {
32 cl
33
3/6
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 390 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 390 times.
✗ Branch 9 not taken.
780 .def(bp::init<const Model *, const GeometryModel *, GeometryData *>(
34 bp::args("self", "model", "geometry_model", "geometry_data"), "Default constructor")
35 [bp::with_custodian_and_ward<1, 2>(), bp::with_custodian_and_ward<1, 3>(),
36 bp::with_custodian_and_ward<1, 4>()])
37
3/6
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 390 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 390 times.
✗ Branch 8 not taken.
2340 .def(bp::init<const Self &>(
38
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 bp::args("self", "other"), "Copy constructor")[bp::with_custodian_and_ward<1, 2>()])
39
40 1560 .def(
41
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 "getCollisionObjectInflation", &Self::getCollisionObjectInflation, bp::arg("self"),
42 "Returns the inflation value related to each collision object.",
43 780 bp::return_internal_reference<>())
44
2/4
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 390 times.
✗ Branch 5 not taken.
1560 .def(
45 "getCollisionObjects",
46
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 (CollisionObjectVector & (Self::*)()) & Self::getCollisionObjects, bp::arg("self"),
47 780 bp::return_internal_reference<>())
48
49
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 .def(
50
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 "getManager", (Derived & (Self::*)()) & Self::getManager, bp::arg("self"),
51 780 "Returns the internal FCL manager", bp::return_internal_reference<>())
52
53 1560 .def(
54
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 "getCollisionObjectStatus", &Self::getCollisionObjectStatus, bp::arg("self"),
55 "Returns the status of the collision object.",
56 780 bp::return_value_policy<bp::copy_const_reference>())
57
58
2/4
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 390 times.
✗ Branch 5 not taken.
780 .def(BroadPhaseManagerBasePythonVisitor<Self>());
59 780 }
60
61 /* --- Expose --------------------------------------------------------- */
62 780 static void expose()
63 {
64
1/2
✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
780 std::string derived_name = boost::typeindex::type_id<Derived>().pretty_name();
65
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 boost::algorithm::replace_all(derived_name, "coal::", "");
66
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 const std::string class_name = "BroadPhaseManager_" + derived_name;
67
68
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 const std::string class_doc = "Broad phase manager associated to coal::" + derived_name;
69
1/2
✓ Branch 3 taken 390 times.
✗ Branch 4 not taken.
780 bp::class_<Self> registered_class(class_name.c_str(), class_doc.c_str(), bp::no_init);
70
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 registered_class.def(BroadPhaseManagerPythonVisitor());
71
72 typedef BroadPhaseManagerBase<Self> Base;
73
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 bp::objects::register_dynamic_id<Base>();
74
1/2
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
780 bp::objects::register_conversion<Self, Base>(false);
75 780 }
76 };
77
78 } // namespace python
79 } // namespace pinocchio
80
81 #endif // ifndef __pinocchio_python_collision_broadphase_manager_hpp__
82