|
| 1 | +#include "default_types.h" |
| 2 | +#include <igl/cycodebase/box_cubic.h> |
| 3 | +#include <nanobind/nanobind.h> |
| 4 | +#include <nanobind/eigen/dense.h> |
| 5 | +#include <nanobind/stl/tuple.h> |
| 6 | +#include <tuple> |
| 7 | + |
| 8 | +namespace nb = nanobind; |
| 9 | +using namespace nb::literals; |
| 10 | + |
| 11 | +namespace pyigl |
| 12 | +{ |
| 13 | + // Bounding box of a single cubic Bézier curve. |
| 14 | + auto box_cubic_C( |
| 15 | + const nb::DRef<const Eigen::MatrixXN> &C) |
| 16 | + { |
| 17 | + Eigen::RowVectorXN B1, B2; |
| 18 | + igl::cycodebase::box_cubic(C, B1, B2); |
| 19 | + return std::make_tuple(B1, B2); |
| 20 | + } |
| 21 | + // Bounding boxes of many indexed cubic Bézier curves. |
| 22 | + auto box_cubic_PC( |
| 23 | + const nb::DRef<const Eigen::MatrixXN> &P, |
| 24 | + const nb::DRef<const Eigen::MatrixXI> &C) |
| 25 | + { |
| 26 | + Eigen::MatrixXN B1, B2; |
| 27 | + igl::cycodebase::box_cubic(P, C, B1, B2); |
| 28 | + return std::make_tuple(B1, B2); |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +void bind_box_cubic(nb::module_ &m) |
| 33 | +{ |
| 34 | + m.def("box_cubic", &pyigl::box_cubic_C, "C"_a, |
| 35 | + R"(Compute the min/max box corners tightly containing a cubic Bézier curve. |
| 36 | +
|
| 37 | +@param[in] C 4 by dim matrix of control points defining the cubic Bézier curve |
| 38 | +@return Tuple (B1, B2) where |
| 39 | + B1 1 by dim min corner of the bounding box |
| 40 | + B2 1 by dim max corner of the bounding box)"); |
| 41 | + |
| 42 | + m.def("box_cubic", &pyigl::box_cubic_PC, "P"_a, "C"_a, |
| 43 | + R"(Compute bounding boxes for a collection of indexed cubic Bézier curves. |
| 44 | +
|
| 45 | +@param[in] P #P by dim matrix of control point locations |
| 46 | +@param[in] C #C by 4 matrix of indices into P defining the cubics |
| 47 | +@return Tuple (B1, B2) where |
| 48 | + B1 #C by dim matrix of min corners of the bounding boxes |
| 49 | + B2 #C by dim matrix of max corners of the bounding boxes)"); |
| 50 | +} |
0 commit comments