Skip to content

Commit d209694

Browse files
author
Teseo Schneider
committed
added energy typo to arap
1 parent bfe4ded commit d209694

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

classes/classes.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace py = pybind11;
1212
PYBIND11_MODULE(pyigl_classes, m)
1313
{
1414
py::class_<igl::ARAPData>(m, "ARAP")
15-
.def(py::init([](Eigen::MatrixXd &v, Eigen::MatrixXi &f, int dim, Eigen::MatrixXi &b) {
15+
.def(py::init([](Eigen::MatrixXd &v, Eigen::MatrixXi &f, int dim, Eigen::MatrixXi &b, const int energy_type) {
1616
if (dim == 3)
1717
{
1818
assert_valid_tet_or_tri_mesh(v, f);
@@ -25,8 +25,14 @@ PYBIND11_MODULE(pyigl_classes, m)
2525
{
2626
throw pybind11::value_error("Invalid dimension must be 2 or 3 but got " + std::to_string(dim));
2727
}
28+
if (energy_type >= igl::NUM_ARAP_ENERGY_TYPES)
29+
{
30+
throw pybind11::value_error("Invalid Energy Type. Must be one of igl.ARAP_ENERGY_TYPE_*");
31+
}
2832

2933
std::unique_ptr<igl::ARAPData> adata = std::make_unique<igl::ARAPData>();
34+
adata->energy = static_cast<igl::ARAPEnergyType>(energy_type);
35+
3036
if (b.cols() == 1)
3137
igl::arap_precomputation(v, f, dim, b, *adata);
3238
else if (b.rows() == 1)
@@ -35,7 +41,7 @@ PYBIND11_MODULE(pyigl_classes, m)
3541
throw pybind11::value_error("Invalid dimension for b, must be a vector, got " + std::to_string(b.rows()) + "x" + std::to_string(b.cols()));
3642
return adata;
3743
}),
38-
py::arg("v"), py::arg("f"), py::arg("dim"), py::arg("b"))
44+
py::arg("v"), py::arg("f"), py::arg("dim"), py::arg("b"), py::arg("energy_type") = 3)
3945
.def(
4046
"solve", [](igl::ARAPData &self, Eigen::MatrixXd &bc, Eigen::MatrixXd &initial_guess) {
4147
if (bc.size() > 0)

igl/helpers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@
2828
SLIM_ENERGY_TYPE_EXP_CONFORMAL = 4
2929
SLIM_ENERGY_TYPE_EXP_SYMMETRIC_DIRICHLET = 5
3030

31-
SIGNED_DISTANCE_TYPE_PSEUDONORMAL = 0,
31+
SIGNED_DISTANCE_TYPE_PSEUDONORMAL = 0
3232
SIGNED_DISTANCE_TYPE_WINDING_NUMBER = 1
3333
SIGNED_DISTANCE_TYPE_DEFAULT = 2
3434
SIGNED_DISTANCE_TYPE_UNSIGNED = 3
3535

36+
ARAP_ENERGY_TYPE_SPOKES = 0
37+
ARAP_ENERGY_TYPE_SPOKES_AND_RIMS = 1
38+
ARAP_ENERGY_TYPE_ELEMENTS = 2
39+
ARAP_ENERGY_TYPE_DEFAULT = 3
40+
3641

3742
def check_dependencies(deps):
3843
import sys

tests/test_basic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,16 @@ def test_arap3(self):
914914
arap = igl.ARAP(v, f, 2, np.zeros((0)))
915915
uva = arap.solve(np.zeros((0, 0)), uv)
916916

917+
def test_arap4(self):
918+
v, f = igl.read_triangle_mesh(os.path.join(self.test_path, "camelhead.off"))
919+
b = igl.boundary_loop(f)
920+
thetas = np.linspace(0, 2 * np.pi, len(b))[:, np.newaxis]
921+
bc = np.concatenate([np.cos(thetas), np.sin(thetas), np.zeros_like(thetas)], axis=1)
922+
uv_initial_guess = igl.harmonic_weights(v, f, b, bc, 1)
923+
924+
arap = igl.ARAP(v, f, 3, b, igl.ARAP_ENERGY_TYPE_SPOKES)
925+
uva = arap.solve(bc, uv_initial_guess)
926+
917927
def test_slim(self):
918928
v, f, _ = igl.read_off(os.path.join(self.test_path, "camelhead.off"))
919929
b = igl.boundary_loop(f)

0 commit comments

Comments
 (0)