|
3 | 3 | import platform |
4 | 4 |
|
5 | 5 | import igl |
| 6 | +print("Using igl found at: ",igl.__file__) |
6 | 7 | import igl.triangle |
7 | 8 | import igl.copyleft.cgal |
8 | 9 | import numpy as np |
@@ -38,10 +39,22 @@ def setUp(self): |
38 | 39 | self.v2, self.f2 = igl.read_triangle_mesh( |
39 | 40 | os.path.join(self.test_data_path, "fertility.off")) |
40 | 41 |
|
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 | + |
45 | 58 |
|
46 | 59 | self.default_int = np.array(range(2)).dtype |
47 | 60 | self.default_float = np.zeros((2,2)).dtype |
@@ -443,9 +456,9 @@ def test_circumradius(self): |
443 | 456 | self.assertTrue(r.flags.c_contiguous) |
444 | 457 |
|
445 | 458 | 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]) |
449 | 462 | self.assertTrue(p.flags.c_contiguous) |
450 | 463 |
|
451 | 464 | def test_collapse_small_triangles(self): |
@@ -604,7 +617,7 @@ def test_boundary_loop(self): |
604 | 617 | self.assertTrue(l.flags.c_contiguous) |
605 | 618 |
|
606 | 619 | def test_all_boundary_loop(self): |
607 | | - l = igl.all_boundary_loop(self.f) |
| 620 | + l = igl.all_boundary_loop(self.f3) |
608 | 621 | self.assertEqual(type(l), type([])) |
609 | 622 | self.assertTrue(len(l) > 0) |
610 | 623 |
|
@@ -706,12 +719,11 @@ def test_decimate(self): |
706 | 719 | self.assertTrue(i.flags.c_contiguous) |
707 | 720 |
|
708 | 721 | 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) |
713 | 725 | 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)) |
715 | 727 | self.assertTrue(theta.flags.c_contiguous) |
716 | 728 | self.assertTrue(cos_theta.flags.c_contiguous) |
717 | 729 |
|
@@ -1789,14 +1801,15 @@ def test_normal_derivative(self): |
1789 | 1801 | self.assertTrue(type(d) == csc.csc_matrix) |
1790 | 1802 |
|
1791 | 1803 | 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) |
1794 | 1807 |
|
1795 | 1808 | self.assertTrue(ff.flags.c_contiguous) |
1796 | 1809 | 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]) |
1800 | 1813 | self.assertTrue(ff.shape[1] == 3) |
1801 | 1814 | self.assertTrue(len(i.shape) == 1) |
1802 | 1815 | self.assertTrue(i.shape[0] == np.max(c)+1) |
@@ -2160,7 +2173,7 @@ def test_two_axis_valuator_fixed_up(self): |
2160 | 2173 | def test_triangle_fan(self): |
2161 | 2174 | _, f = igl.read_triangle_mesh( |
2162 | 2175 | os.path.join(self.test_data_path, "camelhead.off")) |
2163 | | - e = igl.exterior_edges(self.f) |
| 2176 | + e = igl.exterior_edges(f) |
2164 | 2177 | cap = igl.triangle_fan(e) |
2165 | 2178 |
|
2166 | 2179 | self.assertTrue(cap.flags.c_contiguous) |
@@ -2293,7 +2306,8 @@ def test_intrinsic_delaunay_cotmatrix(self): |
2293 | 2306 | self.assertTrue(type(l) == csc.csc_matrix) |
2294 | 2307 |
|
2295 | 2308 | 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 |
2297 | 2311 | self.assertTrue(len(cuts) == 9) |
2298 | 2312 |
|
2299 | 2313 | def test_iterative_closest_point(self): |
@@ -2536,7 +2550,7 @@ def test__version(self): |
2536 | 2550 |
|
2537 | 2551 | def test_blue_noise(self): |
2538 | 2552 | 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) |
2540 | 2554 | self.assertTrue(b.shape[0] == fi.shape[0]) |
2541 | 2555 | self.assertTrue(b.shape[0] == p.shape[0]) |
2542 | 2556 | self.assertTrue(self.v.shape[1] == p.shape[1]) |
|
0 commit comments