// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2025 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 "lipschitz_octree.h" #include "lipschitz_octree_prune.h" #include "find.h" #include "matlab_format.h" #include #include template < bool batched, typename Derivedorigin, typename Func, typename Derivedijk > IGL_INLINE void igl::lipschitz_octree( const Eigen::MatrixBase & origin, const typename Derivedorigin::Scalar h0, const int max_depth, const Func & udf, Eigen::PlainObjectBase & ijk_out) { using Scalar = typename Derivedorigin::Scalar; using RowVectorS3 = Eigen::Matrix; using MatrixSX8R = Eigen::Matrix; using MatrixiX3R = Eigen::Matrix; // static assert to ensure that Derivedorigin is a vector and the // non-singleton dimension is 3 or Eigen::Dynamic static_assert( (Derivedorigin::RowsAtCompileTime == 1 && ( Derivedorigin::ColsAtCompileTime == 3 || Derivedorigin::ColsAtCompileTime == Eigen::Dynamic)) || (Derivedorigin::ColsAtCompileTime == 1 && ( Derivedorigin::RowsAtCompileTime == 3 || Derivedorigin::RowsAtCompileTime == Eigen::Dynamic)), "Derivedorigin must be a vector with 3 or Eigen::Dynamic dimensions"); // dynamic assert that the origin is a 3D vector assert((origin.rows() == 3 || origin.cols() == 3) && origin.size() == 3 && "origin must be a 3D vector"); MatrixiX3R ijk(1,3); ijk<<0,0,0; for(int depth = 0;depth<=max_depth;depth++) { if(ijk.rows() == 0) { // no more cells to refine break; } const Scalar h = h0 / (1 << depth); MatrixiX3R ijk_next; MatrixiX3R ijk_maybe; igl::lipschitz_octree_prune(origin,h0,depth,udf,ijk,ijk_maybe); if(depth == max_depth) { // sad copy ijk_out = ijk_maybe.template cast(); return; }else { const MatrixiX3R ijk_maybe_2 = ijk_maybe * 2; ijk_next.resize(ijk_maybe_2.rows()*8,3); for(int c = 0;c, std::function const&)>, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::Matrix::Scalar, int, std::function const&)> const&, Eigen::PlainObjectBase>&); template void igl::lipschitz_octree, std::function (Eigen::Matrix const&)>, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::Matrix::Scalar, int, std::function (Eigen::Matrix const&)> const&, Eigen::PlainObjectBase>&); #endif