|
| 1 | +#include <common.h> |
| 2 | +#include <npe.h> |
| 3 | +#include <typedefs.h> |
| 4 | + |
| 5 | + |
| 6 | +#include <igl/signed_distance.h> |
| 7 | + |
| 8 | +const char *ds_signed_distance = R"igl_Qu8mg5v7( |
| 9 | +SIGNED_DISTANCE computes signed distance to a mesh |
| 10 | +
|
| 11 | +
|
| 12 | +Parameters |
| 13 | +---------- |
| 14 | + P #P by 3 list of query point positions |
| 15 | + V #V by 3 list of vertex positions |
| 16 | + F #F by ss list of triangle indices, ss should be 3 unless sign_type |
| 17 | + return_normals (Optional, defaults to False) If set to True, will return pseudonormals of |
| 18 | + closest points to each query point in P |
| 19 | +Returns |
| 20 | +------- |
| 21 | + S #P list of smallest signed distances |
| 22 | + I #P list of facet indices corresponding to smallest distances |
| 23 | + C #P by 3 list of closest points |
| 24 | +
|
| 25 | +See also |
| 26 | +-------- |
| 27 | +
|
| 28 | +
|
| 29 | +Notes |
| 30 | +----- |
| 31 | + Known issue: This only computes distances to triangles. So unreferenced |
| 32 | + vertices and degenerate triangles are ignored. |
| 33 | +
|
| 34 | +Examples |
| 35 | +-------- |
| 36 | +>>> S, I, C = signed_distance(P, V, F, return_normals=False) |
| 37 | +
|
| 38 | +)igl_Qu8mg5v7"; |
| 39 | + |
| 40 | +npe_function(signed_distance) |
| 41 | +npe_doc(ds_signed_distance) |
| 42 | + |
| 43 | +npe_arg(p, dense_float, dense_double) |
| 44 | +npe_arg(v, dense_float, dense_double) |
| 45 | +npe_arg(f, dense_int, dense_long, dense_longlong) |
| 46 | +npe_default_arg(return_normals, bool, false) |
| 47 | + |
| 48 | +npe_begin_code() |
| 49 | + assert_cols_equals(p, 3, "p"); |
| 50 | + assert_nonzero_rows(p, "p"); |
| 51 | + assert_valid_3d_tri_mesh(v, f, "v", "f"); |
| 52 | + |
| 53 | + Eigen::MatrixXd V = v.template cast<double>(); |
| 54 | + Eigen::MatrixXd P = p.template cast<double>(); |
| 55 | + Eigen::MatrixXi F = f.template cast<int>(); |
| 56 | + |
| 57 | + EigenDenseLike<npe_Matrix_p> S; |
| 58 | + EigenDenseLike<npe_Matrix_f> I; |
| 59 | + EigenDenseLike<npe_Matrix_v> C; |
| 60 | + EigenDenseLike<npe_Matrix_v> N; |
| 61 | + |
| 62 | + if (return_normals) { |
| 63 | + igl::signed_distance(P, V, F, igl::SIGNED_DISTANCE_TYPE_PSEUDONORMAL, S, I, C, N); |
| 64 | + return pybind11::make_tuple(npe::move(S), npe::move(I), npe::move(C), npe::move(N)); |
| 65 | + } else { |
| 66 | + igl::signed_distance(P, V, F, igl::SIGNED_DISTANCE_TYPE_DEFAULT, S, I, C, N); |
| 67 | + return pybind11::make_tuple(npe::move(S), npe::move(I), npe::move(C)); |
| 68 | + } |
| 69 | + |
| 70 | +npe_end_code() |
| 71 | + |
| 72 | + |
| 73 | + |
0 commit comments