Skip to content

Commit 4d80ed8

Browse files
author
Teseo Schneider
committed
added all_boundary_loop
1 parent b3f94f7 commit 4d80ed8

2 files changed

Lines changed: 52 additions & 7 deletions

File tree

src/boundary_loop.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <npe.h>
33
#include <typedefs.h>
44
#include <igl/boundary_loop.h>
5+
#include <pybind11/stl.h>
56

67
const char* ds_boundary_loop = R"igl_Qu8mg5v7(
78
Compute ordered boundary loops for a manifold mesh and return the longest loop in terms of vertices.
@@ -40,3 +41,41 @@ npe_begin_code()
4041

4142
npe_end_code()
4243

44+
45+
46+
const char* ds_all_boundary_loop = R"igl_Qu8mg5v7xx(
47+
Compute ordered boundary loops for a manifold mesh
48+
49+
Parameters
50+
----------
51+
f : #v by dim array of mesh faces
52+
53+
Returns
54+
-------
55+
l : list of loops where l[i] = ordered list of boundary vertices in loop i
56+
57+
See also
58+
--------
59+
60+
61+
Notes
62+
-----
63+
None
64+
65+
Examples
66+
--------
67+
# Mesh in (v, f)
68+
>>>l = all_boundary_loop(f)
69+
)igl_Qu8mg5v7xx";
70+
71+
npe_function(all_boundary_loop)
72+
npe_doc(ds_all_boundary_loop)
73+
npe_arg(f, dense_int, dense_long, dense_longlong)
74+
npe_begin_code()
75+
assert_valid_tri_mesh_faces(f);
76+
std::vector<std::vector<typename EigenDenseI64::Scalar>> l;
77+
igl::boundary_loop(f, l);
78+
return l;
79+
80+
npe_end_code()
81+

tests/test_basic.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,12 @@ def test_boundary_loop(self):
551551
self.assertEqual(l.dtype, self.f.dtype)
552552
self.assertTrue(l.flags.c_contiguous)
553553

554+
def test_all_boundary_loop(self):
555+
l = igl.all_boundary_loop(self.f)
556+
self.assertEqual(type(l), type([]))
557+
self.assertTrue(len(l) > 0)
558+
559+
554560
def test_bounding_box_diagonal(self):
555561
length = igl.bounding_box_diagonal(self.v1)
556562
self.assertEqual(type(length), float)
@@ -2253,7 +2259,7 @@ def sphere1(point):
22532259
self.assertTrue(ci.flags.c_contiguous)
22542260
self.assertTrue(ci.dtype == np.int)
22552261
self.assertTrue(ci.shape[1] == 8)
2256-
2262+
22572263
def test_topological_hole_fill(self):
22582264
f = self.f1
22592265
b = np.array(range(10))
@@ -2278,9 +2284,9 @@ def test_unproject_on_line(self):
22782284
eye = np.eye(4)
22792285
viewport = np.array([0., 0., 100., 100.])
22802286
p = np.array([15.0, 20.0, 13.0])
2281-
d = np.array([0.1, 0.2, 1.0])
2287+
d = np.array([0.1, 0.2, 1.0])
22822288
t, z = igl.unproject_on_line(pos, eye, viewport, p, d)
2283-
2289+
22842290
self.assertTrue(z.flags.c_contiguous)
22852291
self.assertTrue(z.shape == (3, ))
22862292
self.assertTrue(z.dtype == np.float)
@@ -2291,18 +2297,18 @@ def test_unproject_on_plane(self):
22912297
viewport = np.array([0., 0., 100., 100.])
22922298
p = np.array([1.0, 2.0, 3.0, 2.0])
22932299
z = igl.unproject_on_plane(pos, eye, viewport, p)
2294-
2300+
22952301
self.assertTrue(z.flags.c_contiguous)
22962302
self.assertTrue(z.shape == (3, ))
22972303
self.assertTrue(z.dtype == np.float)
22982304

2299-
def test_fast_winding_number_for_points(self):
2305+
def test_fast_winding_number_for_points(self):
23002306
xs = np.linspace(-5.0, 5.0, 10)
23012307
grid = np.meshgrid(xs, xs, xs, indexing='ij')
23022308
grid = np.stack(grid).reshape(3, -1, order='F').T
23032309
n = igl.per_vertex_normals(self.v1, self.f1)
23042310
a = np.ones((n.shape[0], )) / n.shape[0]
2305-
2311+
23062312
wn = igl.fast_winding_number_for_points(self.v1, n, a, grid)
23072313
self.assertTrue(wn.flags.c_contiguous)
23082314
self.assertTrue(wn.shape == (grid.shape[0], ))
@@ -2312,7 +2318,7 @@ def test_fast_winding_number_for_meshes(self):
23122318
xs = np.linspace(-5.0, 5.0, 10)
23132319
grid = np.meshgrid(xs, xs, xs, indexing='ij')
23142320
grid = np.stack(grid).reshape(3, -1, order='F').T
2315-
2321+
23162322
wn = igl.fast_winding_number_for_meshes(self.v1, self.f1, grid)
23172323
self.assertTrue(wn.flags.c_contiguous)
23182324
self.assertTrue(wn.shape == (grid.shape[0], ))

0 commit comments

Comments
 (0)