GCC Code Coverage Report


Directory: ./
File: include/ndcurves/python/python_definitions.h
Date: 2025-03-05 17:18:30
Exec Total Coverage
Lines: 17 17 100.0%
Branches: 14 22 63.6%

Line Branch Exec Source
1 #include <vector>
2
3 #include "ndcurves/bezier_curve.h"
4 #include "ndcurves/fwd.h"
5 #include "ndcurves/linear_variable.h"
6 #include "ndcurves/polynomial.h"
7 #include "ndcurves/quadratic_variable.h"
8
9 #ifndef _DEFINITION_PYTHON_BINDINGS
10 #define _DEFINITION_PYTHON_BINDINGS
11
12 namespace ndcurves {
13 /*** TEMPLATE SPECIALIZATION FOR PYTHON ****/
14 typedef double real;
15 typedef std::vector<real> t_time_t;
16 typedef Eigen::VectorXd time_waypoints_t;
17
18 typedef Eigen::Matrix<double, Eigen::Dynamic, 1, 0, Eigen::Dynamic, 1>
19 ret_pointX_t;
20 typedef std::pair<pointX_t, pointX_t> pair_pointX_tangent_t;
21 typedef Eigen::MatrixXd pointX_list_t;
22 typedef std::vector<pair_pointX_tangent_t,
23 Eigen::aligned_allocator<pair_pointX_tangent_t> >
24 t_pair_pointX_tangent_t;
25 typedef ndcurves::curve_constraints<pointX_t> curve_constraints_t;
26 typedef ndcurves::curve_constraints<point3_t> curve_constraints3_t;
27 typedef std::pair<real, pointX_t> waypoint_t;
28 typedef std::vector<waypoint_t> t_waypoint_t;
29 typedef Eigen::Matrix<real, Eigen::Dynamic, Eigen::Dynamic> point_listX_t;
30 typedef Eigen::Matrix<real, 3, Eigen::Dynamic> point_list3_t;
31 typedef Eigen::Matrix<real, 6, Eigen::Dynamic> point_list6_t;
32 typedef polynomial_t::coeff_t coeff_t;
33
34 typedef ndcurves::Bern<double> bernstein_t;
35
36 template <typename PointList, typename T_Point>
37 94 T_Point vectorFromEigenArray(const PointList& array) {
38 94 T_Point res;
39
2/2
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 47 times.
504 for (int i = 0; i < array.cols(); ++i) {
40
3/6
✓ Branch 1 taken 205 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 205 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 205 times.
✗ Branch 8 not taken.
410 res.push_back(array.col(i));
41 }
42 94 return res;
43 }
44 template <typename PointList, typename T_Point>
45 7 T_Point vectorFromEigenVector(const PointList& vector) {
46 7 T_Point res;
47
2/2
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 7 times.
56 for (int i = 0; i < vector.rows(); ++i) {
48
2/4
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
49 res.push_back(vector[i]);
49 }
50 7 return res;
51 }
52
53 template <typename T_point, typename PointList>
54 12 PointList vectorToEigenArray(const T_point& vect) {
55 12 const size_t nCols = vect.size();
56 12 const size_t nRows = vect[0].rows();
57
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 PointList res(nRows, nCols);
58
2/2
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 6 times.
72 for (size_t i = 0; i < vect.size(); ++i) {
59
2/4
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 30 times.
✗ Branch 6 not taken.
60 res.block(0, i, nRows, 1) = vect[i];
60 }
61 24 return res;
62 }
63 } // namespace ndcurves
64 #endif //_DEFINITION_PYTHON_BINDINGS
65