diff --git a/classes/classes.cpp b/classes/classes.cpp index c80f27c4..7fa80997 100644 --- a/classes/classes.cpp +++ b/classes/classes.cpp @@ -12,7 +12,7 @@ namespace py = pybind11; PYBIND11_MODULE(pyigl_classes, m) { py::class_(m, "ARAP") - .def(py::init([](Eigen::MatrixXd &v, Eigen::MatrixXi &f, int dim, Eigen::MatrixXi &b) { + .def(py::init([](Eigen::MatrixXd &v, Eigen::MatrixXi &f, int dim, Eigen::MatrixXi &b, const int energy_type) { if (dim == 3) { assert_valid_tet_or_tri_mesh(v, f); @@ -25,8 +25,14 @@ PYBIND11_MODULE(pyigl_classes, m) { throw pybind11::value_error("Invalid dimension must be 2 or 3 but got " + std::to_string(dim)); } + if (energy_type >= igl::NUM_ARAP_ENERGY_TYPES) + { + throw pybind11::value_error("Invalid Energy Type. Must be one of igl.ARAP_ENERGY_TYPE_*"); + } std::unique_ptr adata = std::make_unique(); + adata->energy = static_cast(energy_type); + if (b.cols() == 1) igl::arap_precomputation(v, f, dim, b, *adata); else if (b.rows() == 1) @@ -35,7 +41,7 @@ PYBIND11_MODULE(pyigl_classes, m) throw pybind11::value_error("Invalid dimension for b, must be a vector, got " + std::to_string(b.rows()) + "x" + std::to_string(b.cols())); return adata; }), - py::arg("v"), py::arg("f"), py::arg("dim"), py::arg("b")) + py::arg("v"), py::arg("f"), py::arg("dim"), py::arg("b"), py::arg("energy_type") = 3) .def( "solve", [](igl::ARAPData &self, Eigen::MatrixXd &bc, Eigen::MatrixXd &initial_guess) { if (bc.size() > 0) diff --git a/igl/helpers.py b/igl/helpers.py index 9d6a116f..6811f3d0 100644 --- a/igl/helpers.py +++ b/igl/helpers.py @@ -28,11 +28,16 @@ SLIM_ENERGY_TYPE_EXP_CONFORMAL = 4 SLIM_ENERGY_TYPE_EXP_SYMMETRIC_DIRICHLET = 5 -SIGNED_DISTANCE_TYPE_PSEUDONORMAL = 0, +SIGNED_DISTANCE_TYPE_PSEUDONORMAL = 0 SIGNED_DISTANCE_TYPE_WINDING_NUMBER = 1 SIGNED_DISTANCE_TYPE_DEFAULT = 2 SIGNED_DISTANCE_TYPE_UNSIGNED = 3 +ARAP_ENERGY_TYPE_SPOKES = 0 +ARAP_ENERGY_TYPE_SPOKES_AND_RIMS = 1 +ARAP_ENERGY_TYPE_ELEMENTS = 2 +ARAP_ENERGY_TYPE_DEFAULT = 3 + def check_dependencies(deps): import sys diff --git a/tests/test_basic.py b/tests/test_basic.py index 14e36a3b..4a0ea09c 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -914,6 +914,16 @@ def test_arap3(self): arap = igl.ARAP(v, f, 2, np.zeros((0))) uva = arap.solve(np.zeros((0, 0)), uv) + def test_arap4(self): + v, f = igl.read_triangle_mesh(os.path.join(self.test_path, "camelhead.off")) + b = igl.boundary_loop(f) + thetas = np.linspace(0, 2 * np.pi, len(b))[:, np.newaxis] + bc = np.concatenate([np.cos(thetas), np.sin(thetas), np.zeros_like(thetas)], axis=1) + uv_initial_guess = igl.harmonic_weights(v, f, b, bc, 1) + + arap = igl.ARAP(v, f, 3, b, igl.ARAP_ENERGY_TYPE_SPOKES) + uva = arap.solve(bc, uv_initial_guess) + def test_slim(self): v, f, _ = igl.read_off(os.path.join(self.test_path, "camelhead.off")) b = igl.boundary_loop(f)