@@ -76,6 +76,13 @@ def test_cotmatrix(self):
7676 self .assertTrue (l .shape == (self .v .shape [0 ], self .v .shape [0 ]))
7777 self .assertTrue (l .dtype == self .v .dtype )
7878 self .assertTrue (type (l ) == csc .csc_matrix )
79+
80+ def test_cotmatrix_intrinsic (self ):
81+ el = igl .edge_lengths (self .v , self .f )
82+ l = igl .cotmatrix_intrinsic (el , self .f )
83+ self .assertTrue (l .shape == (self .v .shape [0 ], self .v .shape [0 ]))
84+ self .assertTrue (l .dtype == el .dtype )
85+ self .assertTrue (type (l ) == csc .csc_matrix )
7986
8087 def test_ears (self ):
8188 ears , ears_opp = igl .ears (self .f1 )
@@ -93,6 +100,12 @@ def test_gaussian_curvature(self):
93100 self .assertTrue (g .flags .c_contiguous )
94101
95102 # sparse matrix, no flag attribute
103+ def test_grad_intrinsic (self ):
104+ el = igl .edge_lengths (self .v , self .f )
105+ g = igl .grad_intrinsic (el , self .f )
106+ self .assertTrue (g .shape == (self .f .shape [0 ] * 2 , self .v .shape [0 ]))
107+ self .assertTrue (type (g ) == csc .csc_matrix )
108+
96109 def test_grad (self ):
97110 g = igl .grad (self .v , self .f )
98111 h = igl .grad (self .v , self .f , uniform = True )
@@ -110,6 +123,16 @@ def test_massmatrix(self):
110123 self .assertTrue (a .dtype == np .float64 )
111124 self .assertTrue (type (a ) == type (b ) == csc .csc_matrix )
112125
126+ def test_massmatrix_intrinsic (self ):
127+ el = igl .edge_lengths (self .v , self .f )
128+ a = igl .massmatrix_intrinsic (el , self .f )
129+ b = igl .massmatrix_intrinsic (el , self .f , type = igl .MASSMATRIX_TYPE_BARYCENTRIC )
130+ self .assertTrue (a .shape == (self .v .shape [0 ], self .v .shape [0 ]))
131+ self .assertTrue (b .shape == (self .v .shape [0 ], self .v .shape [0 ]))
132+ self .assertTrue (b .dtype == np .float64 )
133+ self .assertTrue (a .dtype == np .float64 )
134+ self .assertTrue (type (a ) == type (b ) == csc .csc_matrix )
135+
113136 def test_principal_curvature (self ):
114137 pd1 , pd2 , pv1 , pv2 = igl .principal_curvature (self .v , self .f )
115138 qd1 , qd2 , qv1 , qv2 = igl .principal_curvature (self .v , self .f , radius = 7 , use_k_ring = False )
@@ -373,14 +396,6 @@ def test_quad_planarity(self):
373396 self .assertEqual (p .shape [0 ], self .g .shape [0 ])
374397 self .assertTrue (p .flags .c_contiguous )
375398
376- # def test_circulation(self):
377- # difficult data
378- # _, e, emap = igl.crouzeix_raviart_cotmatrix(self.v1, self.f1)
379- # ret = igl.circulation(0, False, emap, e, e)
380- # self.assertTrue(type(ret) == list)
381- # self.assertTrue(type(ret[0]) == int)
382-
383-
384399 def test_collapse_small_triangles (self ):
385400 ff = igl .collapse_small_triangles (self .v , self .f , 0.5 )
386401 self .assertEqual (ff .shape [1 ], self .f .shape [1 ])
@@ -1017,6 +1032,13 @@ def test_exact_geodesic(self):
10171032 self .assertEqual (d .dtype , self .v1 .dtype )
10181033 self .assertTrue (d .flags .c_contiguous )
10191034
1035+ def test_heat_geodesic (self ):
1036+ vs = np .array ([0 ])
1037+ d = igl .heat_geodesic (self .v1 , self .f1 , 1.0 , vs )
1038+ # TODO: Should this not return distances for all sources?
1039+ self .assertEqual (d .dtype , self .v1 .dtype )
1040+ self .assertTrue (d .flags .c_contiguous )
1041+
10201042 def test_cut_mesh (self ):
10211043 cuts = np .random .randint (0 , 2 , size = self .f1 .shape , dtype = self .f1 .dtype )
10221044 vcut , fcut = igl .cut_mesh (self .v1 , self .f1 , cuts )
@@ -1556,6 +1578,49 @@ def test_delaunay_triangulation(self):
15561578 self .assertTrue (f .flags .c_contiguous )
15571579 self .assertTrue (f .dtype == self .f .dtype )
15581580 self .assertTrue (f .shape [1 ] == 3 )
1581+
1582+ def test_is_delaunay (self ):
1583+ v = np .array ([[0.0 , 0.0 ], [1.0 , 0.0 ], [1.0 , 1.0 ], [0 , 0 ], [0 , - 1 ]])
1584+ f = igl .delaunay_triangulation (v )
1585+ d = igl .is_delaunay (v , f )
1586+ self .assertTrue (d .flags .c_contiguous )
1587+ self .assertTrue (d .dtype == np .bool )
1588+ self .assertTrue (d .shape == f .shape )
1589+ self .assertTrue (np .all (d ))
1590+
1591+ d1 = igl .is_delaunay (self .v1 , self .f1 )
1592+ self .assertTrue (d1 .flags .c_contiguous )
1593+ self .assertTrue (d1 .dtype == np .bool )
1594+ self .assertTrue (d1 .shape == self .f1 .shape )
1595+ self .assertFalse (np .all (d1 ))
1596+
1597+
1598+ v = np .hstack ([v , np .zeros ((v .shape [0 ], 1 ))])
1599+ el = igl .edge_lengths (v , f )
1600+ d2 = igl .is_intrinsic_delaunay (el , f )
1601+ self .assertTrue (d2 .flags .c_contiguous )
1602+ self .assertTrue (d2 .dtype == np .bool )
1603+ self .assertTrue (d2 .shape == f .shape )
1604+ #self.assertTrue(np.all(d2)) #TODO: Why?
1605+
1606+ def test_is_intrinsic_delaunay (self ):
1607+ # Tested above
1608+ pass
1609+
1610+ def test_intrinsic_delaunay_triangulation (self ):
1611+ el = igl .edge_lengths (self .v , self .f )
1612+ l , f = igl .intrinsic_delaunay_triangulation (el , self .f )
1613+ print (l , f )
1614+ self .assertTrue (f .flags .c_contiguous )
1615+ self .assertTrue (f .dtype == self .f .dtype )
1616+ self .assertTrue (f .shape [1 ] == 3 )
1617+
1618+ def test_intrinsic_delaunay_triangulation_edges (self ):
1619+ el = igl .edge_lengths (self .v , self .f )
1620+ l , f , e , u_e , emap , ue2e = igl .intrinsic_delaunay_triangulation_edges (el , self .f )
1621+ #self.assertTrue(f.flags.c_contiguous)
1622+ #self.assertTrue(f.dtype == self.f.dtype)
1623+ #self.assertTrue(f.shape[1] == 3)
15591624
15601625 def test_edges_to_path (self ):
15611626 e = igl .edges (self .f1 )
@@ -1569,6 +1634,17 @@ def test_edges_to_path(self):
15691634 self .assertTrue (i .dtype == e .dtype )
15701635 self .assertTrue (j .dtype == e .dtype )
15711636 self .assertTrue (k .dtype == e .dtype )
1637+
1638+ def test_path_to_edges (self ):
1639+ e1 = igl .path_to_edges (np .array (range (20 )), False )
1640+ e2 = igl .path_to_edges (np .array (range (20 )), True )
1641+ r2 = np .vstack ([np .array (range (20 )), np .array (range (1 ,21 ))]).T
1642+ r2 [19 , 1 ] = 0
1643+ self .assertTrue (np .allclose (e2 , r2 ))
1644+ self .assertTrue (e1 .flags .c_contiguous )
1645+ self .assertTrue (e2 .flags .c_contiguous )
1646+ self .assertTrue (e1 .dtype == np .int )
1647+ self .assertTrue (e2 .dtype == np .int )
15721648
15731649 def test_exterior_edges (self ):
15741650 e = igl .exterior_edges (self .f1 )
@@ -2105,12 +2181,67 @@ def test_extract_non_manifold_edge_curves(self):
21052181 self .assertTrue (len (curves ) == 1 )
21062182 self .assertTrue (curves [0 ][0 ] == 0 )
21072183
2184+ def test_intrinsic_delaunay_cotmatrix (self ):
2185+ l , l_int , f_int = igl .intrinsic_delaunay_cotmatrix (self .v , self .f )
2186+ print (l .shape , l_lint .shape , f_int .shape )
2187+ self .assertTrue (l .shape == (self .v .shape [0 ], self .v .shape [0 ]))
2188+ self .assertTrue (l .dtype == self .v .dtype )
2189+ self .assertTrue (type (l ) == csc .csc_matrix )
2190+
2191+ def test_cut_to_disk (self ):
2192+ cuts = igl .cut_to_disk (self .f )
2193+ self .assertTrue (len (cuts ) == 9 )
2194+
2195+ def test_iterative_closest_point (self ):
2196+ # This crashes in libigl
2197+ #r, t = igl.iterative_closest_point(self.v, self.f, self.v1, self.f1, 10, 20)
2198+ r , t = igl .iterative_closest_point (self .v , self .f , self .v1 , self .f1 , 3 , 20 )
2199+ self .assertEqual (r .shape , (3 , 3 ))
2200+ self .assertEqual (t .shape , (3 ,))
2201+ self .assertTrue (r .flags .c_contiguous )
2202+ self .assertTrue (t .flags .c_contiguous )
2203+ self .assertTrue (r .dtype == t .dtype == self .v .dtype )
2204+
2205+ def test_rigid_alignment (self ):
2206+ n = igl .per_vertex_normals (self .v , self .f )
2207+ r , t = igl .rigid_alignment (self .v , self .v + 1 , n )
2208+ self .assertTrue (np .allclose (r , np .eye (3 )))
2209+ self .assertTrue (np .allclose (t , np .ones (3 )))
2210+ self .assertEqual (r .shape , (3 , 3 ))
2211+ self .assertEqual (t .shape , (3 ,))
2212+ self .assertTrue (r .flags .c_contiguous )
2213+ self .assertTrue (t .flags .c_contiguous )
2214+ self .assertTrue (r .dtype == t .dtype == self .v .dtype )
2215+
2216+ def test_quad_grid (self ):
2217+ v , q , e = igl .quad_grid (3 , 3 )
2218+ self .assertTrue (v .shape == (3 * 3 , 2 )) # TODO: IGL Function has wrong arguments, fix in igl
2219+ self .assertTrue (q .shape == (2 * 2 , 4 ))
2220+ print (v , q , e )
2221+ self .assertTrue (v .flags .c_contiguous )
2222+ self .assertTrue (q .flags .c_contiguous )
2223+ self .assertTrue (v .dtype == np .float )
2224+ self .assertTrue (q .dtype == np .int )
2225+ self .assertTrue (e .dtype == np .int )
2226+
21082227 def test_flip_avoiding_line_search (self ):
21092228 #def fun(v):
21102229 # return 0.5
21112230 #energy, vr = igl.flip_avoiding_line_search(self.f1, self.v1, -self.v1, fun, 10.0)
21122231 # TODO: fix function assertion fail
21132232 pass
2233+
2234+ def test_circulation (self ):
2235+ pass
2236+ # difficult data
2237+ # _, e, emap = igl.crouzeix_raviart_cotmatrix(self.v1, self.f1)
2238+ # ret = igl.circulation(0, False, emap, e, e)
2239+ # self.assertTrue(type(ret) == list)
2240+ # self.assertTrue(type(ret[0]) == int)
2241+
2242+ def test_edge_collapse_is_valid (self ):
2243+ # Dummy test
2244+ pass
21142245
21152246
21162247if __name__ == '__main__' :
0 commit comments