// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2026 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "box_cubic.h" #include "../cubic.h" #include "../parallel_for.h" #include template < typename DerivedC, typename DerivedB> IGL_INLINE void igl::cycodebase::box_cubic( const Eigen::MatrixBase& C, Eigen::PlainObjectBase& B1, Eigen::PlainObjectBase& B2) { using Scalar = typename DerivedC::Scalar; typedef Eigen::Matrix VectorS3; typedef Eigen::Matrix VectorSC; // Using the control points is a simple (but not tight) bound B1 = C({0,3},Eigen::all).colwise().minCoeff(); B2 = C({0,3},Eigen::all).colwise().maxCoeff(); // Better to find each of the t values where dC/dt = 0 and evaluate C there for(int d = 0;d(r.data(), coef.data(),0.0,1.0); for(int i = 0;i Cdt; igl::cubic(C.col(d),t,Cdt); B1(d) = std::min(B1(d),Cdt(0)); B2(d) = std::max(B2(d),Cdt(0)); } } } template < typename DerivedP, typename DerivedC, typename DerivedB> IGL_INLINE void igl::cycodebase::box_cubic( const Eigen::MatrixBase& P, const Eigen::MatrixBase& C, Eigen::PlainObjectBase& B1, Eigen::PlainObjectBase& B2) { B1.resize(C.rows(),P.cols()); B2.resize(C.rows(),P.cols()); typedef Eigen::Matrix RowVectorP; igl::parallel_for(C.rows(),[&](const int c) { RowVectorP B1_c, B2_c; // Eval copies, but is it really good to make a template for the non copy? box_cubic(P(C.row(c),Eigen::all).eval(),B1_c,B2_c); B1.row(c) = B1_c; B2.row(c) = B2_c; },1000); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh template void igl::cycodebase::box_cubic, Eigen::Matrix, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::MatrixBase> const&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); template void igl::cycodebase::box_cubic, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); template void igl::cycodebase::box_cubic, Eigen::Matrix, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::MatrixBase> const&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); #endif