GCC Code Coverage Report


Directory: ./
File: include/pinocchio/bindings/python/collision/tree-broadphase-manager.hpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 19 20 95.0%
Branches: 18 36 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2022 INRIA
3 //
4
5 #ifndef __pinocchio_python_collision_tree_broadphase_manager_hpp__
6 #define __pinocchio_python_collision_tree_broadphase_manager_hpp__
7
8 #include "pinocchio/collision/tree-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 TreeBroadPhaseManagerPythonVisitor
22 : public bp::def_visitor<TreeBroadPhaseManagerPythonVisitor<Derived>>
23 {
24 public:
25 typedef TreeBroadPhaseManagerTpl<Derived> Self;
26 typedef typename Self::BroadPhaseManagerVector BroadPhaseManagerVector;
27
28 /* --- Exposing C++ API to python through the handler ----------------- */
29 template<class PyClass>
30 240 void visit(PyClass & cl) const
31 {
32 cl
33
3/6
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 120 times.
✗ Branch 9 not taken.
240 .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 120 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 120 times.
✗ Branch 8 not taken.
720 .def(bp::init<const Self &>(
38
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 bp::args("self", "other"), "Copy constructor")[bp::with_custodian_and_ward<1, 2>()])
39
40
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 .def(
41 "getBroadPhaseManagers",
42
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 (BroadPhaseManagerVector & (Self::*)()) & Self::getBroadPhaseManagers, bp::arg("self"),
43 240 "Returns the internal broad phase managers", bp::return_internal_reference<>())
44
45
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 .def(BroadPhaseManagerBasePythonVisitor<Self>());
46 240 }
47
48 /* --- Expose --------------------------------------------------------- */
49 240 static void expose()
50 {
51
1/2
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
240 std::string derived_name = boost::typeindex::type_id<Derived>().pretty_name();
52
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 boost::algorithm::replace_all(derived_name, "hpp::fcl::", "");
53
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 const std::string class_name = "TreeBroadPhaseManager_" + derived_name;
54
55
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 const std::string class_doc =
56 "Tree-based broad phase manager associated to hpp::fcl::" + derived_name;
57
1/2
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
240 bp::class_<Self> registered_class(class_name.c_str(), class_doc.c_str(), bp::no_init);
58
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 registered_class.def(TreeBroadPhaseManagerPythonVisitor());
59
60 typedef BroadPhaseManagerBase<Self> Base;
61
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 bp::objects::register_dynamic_id<Base>();
62
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
240 bp::objects::register_conversion<Self, Base>(false);
63 240 }
64 };
65
66 } // namespace python
67 } // namespace pinocchio
68
69 #endif // ifndef __pinocchio_python_collision_tree_broadphase_manager_hpp__
70