GCC Code Coverage Report


Directory: ./
File: include/multicontact-api/bindings/python/geometry/ellipsoid.hpp
Date: 2025-03-10 16:17:01
Exec Total Coverage
Lines: 15 22 68.2%
Branches: 13 32 40.6%

Line Branch Exec Source
1 // Copyright (c) 2015-2018, CNRS
2 // Authors: Justin Carpentier <jcarpent@laas.fr>
3
4 #ifndef __multicontact_api_python_geometry_ellipsoid_hpp__
5 #define __multicontact_api_python_geometry_ellipsoid_hpp__
6
7 #include <pinocchio/fwd.hpp>
8
9 #include "multicontact-api/bindings/python/fwd.hpp"
10 #include "multicontact-api/geometry/ellipsoid.hpp"
11
12 namespace multicontact_api {
13 namespace python {
14
15 namespace bp = boost::python;
16
17 template <typename Ellipsoid>
18 struct EllipsoidPythonVisitor
19 : public boost::python::def_visitor<EllipsoidPythonVisitor<Ellipsoid> > {
20 typedef typename Ellipsoid::Matrix Matrix;
21 typedef typename Ellipsoid::Vector Vector;
22
23 template <class PyClass>
24 3 void visit(PyClass& cl) const {
25
4/8
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
6 cl.def(bp::init<Matrix, Vector>((bp::arg("A"), bp::arg("center"))))
26
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 .def("__str__", &toString)
27
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 .def("lhsValue", &Ellipsoid::lhsValue, bp::arg("point"),
28 "Returns the value of norm(A*(x-c)).")
29
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 .add_property("center", &get_center, &set_center,
30 "Accessor to the center property.")
31
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 .add_property("A", &get_A, &set_A, "Accessor to the A property.");
32 3 }
33
34 static void set_center(Ellipsoid& e, const Vector& center) {
35 e.center() = center;
36 }
37 1 static Vector get_center(const Ellipsoid& e) { return e.center(); }
38
39 static void set_A(Ellipsoid& e, const Matrix& A) { e.A() = A; }
40 1 static Matrix get_A(const Ellipsoid& e) { return e.A(); }
41
42 3 static void expose(const std::string& class_name) {
43
1/2
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 std::string doc = "Ellipsoid of dimension " + Ellipsoid::dim;
44
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 doc += " defined by its matrix A and its center.";
45
1/2
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
3 bp::class_<Ellipsoid>(class_name.c_str(), doc.c_str(), bp::no_init)
46
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 .def(EllipsoidPythonVisitor<Ellipsoid>());
47 3 }
48
49 protected:
50 static std::string toString(const Ellipsoid& e) {
51 std::ostringstream s;
52 s << e;
53 return s.str();
54 }
55 };
56
57 } // namespace python
58 } // namespace multicontact_api
59
60 #endif // ifnef __multicontact_api_python_geometry_ellipsoid_hpp__
61