diff --git a/python/curves_python.cpp b/python/curves_python.cpp index df77c4cf31abcd4957961fba522e7dc6fb621ff5..087157ddf8cfeb3543b6165b0d6121801d1017c4 100644 --- a/python/curves_python.cpp +++ b/python/curves_python.cpp @@ -4,8 +4,6 @@ #include <vector> - - namespace curves { using namespace boost::python; @@ -20,6 +18,17 @@ namespace curves real max() { return this->get_override("max")();} }; + + struct Curve3Wrapper : curve_3_t, wrapper<curve_3_t> + { + point_t operator()(const real) { return this->get_override("operator()")();} + point_t derivate(const real, const std::size_t) { return this->get_override("derivate")();} + std::size_t dim() { return this->get_override("dim")();} + real min() { return this->get_override("min")();} + real max() { return this->get_override("max")();} + + }; + /* end base wrap of curve_abc */ /* Template constructor bezier */ @@ -339,8 +348,17 @@ namespace curves .def("loadFromBinary",pure_virtual(&curve_abc_t::loadFromBinary<curve_abc_t>),bp::args("filename"),"Loads *this from a binary file.") ; + class_<Curve3Wrapper,boost::noncopyable, bases<curve_abc_t> >("curve3",no_init) + .def("__call__", pure_virtual(&curve_3_t::operator()),"Evaluate the curve at the given time.",args("self","t")) + .def("derivate", pure_virtual(&curve_3_t::derivate),"Evaluate the derivative of order N of curve at time t.",args("self","t","N")) + .def("min", pure_virtual(&curve_3_t::min), "Get the LOWER bound on interval definition of the curve.") + .def("max", pure_virtual(&curve_3_t::max),"Get the HIGHER bound on interval definition of the curve.") + .def("dim", pure_virtual(&curve_3_t::dim),"Get the dimension of the curve.") + ; + + /** BEGIN bezier3 curve**/ - class_<bezier3_t, bases<curve_abc_t> >("bezier3", init<>()) + class_<bezier3_t, bases<curve_3_t> >("bezier3", init<>()) .def("__init__", make_constructor(&wrapBezier3Constructor)) .def("__init__", make_constructor(&wrapBezier3ConstructorBounds)) .def("__init__", make_constructor(&wrapBezier3ConstructorConstraints)) diff --git a/python/python_variables.h b/python/python_variables.h index fdcb62fcb5da8a6e818b121cf8423bdbf26001c1..bbb496d7fb27a9c5b6cfbd42e5d763d7a28ba5f1 100644 --- a/python/python_variables.h +++ b/python/python_variables.h @@ -96,6 +96,7 @@ namespace curves // Curves typedef curve_abc<real, real, true, pointX_t> curve_abc_t; // generic class of curve + typedef curve_abc<real, real, true, point3_t> curve_3_t; // generic class of curve of size 3 typedef curves::cubic_hermite_spline <real, real, true, pointX_t> cubic_hermite_spline_t; typedef curves::bezier_curve <real, real, true, pointX_t> bezier_t; typedef curves::polynomial <real, real, true, pointX_t, t_pointX_t> polynomial_t;