Skip to content

Commit ba020a0

Browse files
committed
Merge branch 'main' of github.com:libigl/libigl-python-bindings into alecjacobson/numpyeigen-fork
2 parents e47ad98 + 8b7757f commit ba020a0

1 file changed

Lines changed: 35 additions & 21 deletions

File tree

tests/test_basic.py

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import platform
44

55
import igl
6+
print("Using igl found at: ",igl.__file__)
67
import igl.triangle
78
import igl.copyleft.cgal
89
import numpy as np
@@ -38,10 +39,22 @@ def setUp(self):
3839
self.v2, self.f2 = igl.read_triangle_mesh(
3940
os.path.join(self.test_data_path, "fertility.off"))
4041

41-
self.v = np.random.rand(10, 3).astype(self.v1.dtype)
42-
self.t = np.random.rand(10, 4)
43-
self.f = np.random.randint(0, 10, size=(20, 3), dtype=self.f1.dtype)
44-
self.g = np.random.randint(0, 10, size=(20, 4), dtype="int32")
42+
## Alec: I don't understand why it makes sense to use junk random data
43+
## for the tests. Especially for f and t. These will almost never be
44+
## non-degenerate meshes.
45+
#self.v = np.random.rand(10, 3).astype(self.v1.dtype)
46+
#self.t = np.random.rand(10, 4)
47+
#self.f = np.random.randint(0, 10, size=(20, 3), dtype=self.f1.dtype)
48+
#self.g = np.random.randint(0, 10, size=(20, 4), dtype="int32")
49+
# This model is a quad mesh that's been trivially triangulated
50+
self.v3, self.f3 = igl.read_triangle_mesh(os.path.join(self.test_data_path, "face.obj"))
51+
self.v4, self.t4, self.f4 = igl.read_mesh(os.path.join(self.test_data_path, "decimated-knight.mesh"))
52+
self.q3 = np.concatenate((self.f3[0::2,0:3], self.f3[1::2,2:3]), axis=1)
53+
# Use the bunny rather than random junk. Ideally we'd loop over meshes
54+
# by category like the libigl tests.
55+
self.v = self.v1
56+
self.f = self.f1
57+
4558

4659
self.default_int = np.array(range(2)).dtype
4760
self.default_float = np.zeros((2,2)).dtype
@@ -443,9 +456,9 @@ def test_circumradius(self):
443456
self.assertTrue(r.flags.c_contiguous)
444457

445458
def test_quad_planarity(self):
446-
p = igl.quad_planarity(self.v, self.g)
447-
self.assertTrue(p.dtype == self.v.dtype)
448-
self.assertEqual(p.shape[0], self.g.shape[0])
459+
p = igl.quad_planarity(self.v3, self.q3)
460+
self.assertTrue(p.dtype == self.v3.dtype)
461+
self.assertEqual(p.shape[0], self.q3.shape[0])
449462
self.assertTrue(p.flags.c_contiguous)
450463

451464
def test_collapse_small_triangles(self):
@@ -604,7 +617,7 @@ def test_boundary_loop(self):
604617
self.assertTrue(l.flags.c_contiguous)
605618

606619
def test_all_boundary_loop(self):
607-
l = igl.all_boundary_loop(self.f)
620+
l = igl.all_boundary_loop(self.f3)
608621
self.assertEqual(type(l), type([]))
609622
self.assertTrue(len(l) > 0)
610623

@@ -706,12 +719,11 @@ def test_decimate(self):
706719
self.assertTrue(i.flags.c_contiguous)
707720

708721
def test_dihedral_angles(self):
709-
t = np.random.randint(0, 10, size=(10, 4))
710-
theta, cos_theta = igl.dihedral_angles(self.v, t)
711-
self.assertEqual(theta.dtype, self.v.dtype)
712-
self.assertEqual(cos_theta.dtype, self.v.dtype)
722+
theta, cos_theta = igl.dihedral_angles(self.v4, self.t4)
723+
self.assertEqual(theta.dtype, self.v4.dtype)
724+
self.assertEqual(cos_theta.dtype, self.v4.dtype)
713725
self.assertTrue(
714-
theta.shape == cos_theta.shape and cos_theta.shape == (self.t.shape[0], 6))
726+
theta.shape == cos_theta.shape and cos_theta.shape == (self.t4.shape[0], 6))
715727
self.assertTrue(theta.flags.c_contiguous)
716728
self.assertTrue(cos_theta.flags.c_contiguous)
717729

@@ -1789,14 +1801,15 @@ def test_normal_derivative(self):
17891801
self.assertTrue(type(d) == csc.csc_matrix)
17901802

17911803
def test_orient_outward(self):
1792-
c, _ = igl.orientable_patches(self.f)
1793-
ff, i = igl.orient_outward(self.v, self.f, c)
1804+
v,f = igl.read_triangle_mesh(os.path.join(self.test_data_path, "truck.obj"))
1805+
c, _ = igl.orientable_patches(f)
1806+
ff, i = igl.orient_outward(v, f, c)
17941807

17951808
self.assertTrue(ff.flags.c_contiguous)
17961809
self.assertTrue(i.flags.c_contiguous)
1797-
self.assertTrue(ff.dtype == self.f.dtype)
1798-
self.assertTrue(i.dtype == self.f.dtype)
1799-
self.assertTrue(ff.shape[0] == self.f.shape[0])
1810+
self.assertTrue(ff.dtype == f.dtype)
1811+
self.assertTrue(i.dtype == f.dtype)
1812+
self.assertTrue(ff.shape[0] == f.shape[0])
18001813
self.assertTrue(ff.shape[1] == 3)
18011814
self.assertTrue(len(i.shape) == 1)
18021815
self.assertTrue(i.shape[0] == np.max(c)+1)
@@ -2160,7 +2173,7 @@ def test_two_axis_valuator_fixed_up(self):
21602173
def test_triangle_fan(self):
21612174
_, f = igl.read_triangle_mesh(
21622175
os.path.join(self.test_data_path, "camelhead.off"))
2163-
e = igl.exterior_edges(self.f)
2176+
e = igl.exterior_edges(f)
21642177
cap = igl.triangle_fan(e)
21652178

21662179
self.assertTrue(cap.flags.c_contiguous)
@@ -2293,7 +2306,8 @@ def test_intrinsic_delaunay_cotmatrix(self):
22932306
self.assertTrue(type(l) == csc.csc_matrix)
22942307

22952308
def test_cut_to_disk(self):
2296-
cuts = igl.cut_to_disk(self.f)
2309+
cuts = igl.cut_to_disk(self.f2)
2310+
# This test assumes fertility.off
22972311
self.assertTrue(len(cuts) == 9)
22982312

22992313
def test_iterative_closest_point(self):
@@ -2536,7 +2550,7 @@ def test__version(self):
25362550

25372551
def test_blue_noise(self):
25382552
r = igl.avg_edge_length(self.v, self.f)
2539-
b,fi,p = igl.blue_noise(self.v, self.f, r*0.1)
2553+
b,fi,p = igl.blue_noise(self.v, self.f, r)
25402554
self.assertTrue(b.shape[0] == fi.shape[0])
25412555
self.assertTrue(b.shape[0] == p.shape[0])
25422556
self.assertTrue(self.v.shape[1] == p.shape[1])

0 commit comments

Comments
 (0)