@@ -2468,5 +2468,40 @@ def test_flip_edge(self):
2468
2468
emap .dtype == self .f1 .dtype )
2469
2469
self .assertTrue (np .array (ue2e ).dtype == self .f1 .dtype )
2470
2470
2471
+ def test_AABB (self ):
2472
+ tree = igl .AABB_f64_3 ()
2473
+ tree .init (self .v1 ,self .f1 )
2474
+ bc = igl .barycenter (self .v1 ,self .f1 )
2475
+ sqrD = tree .squared_distance (self .v1 ,self .f1 ,bc )
2476
+ self .assertTrue (sqrD .shape [0 ] == bc .shape [0 ])
2477
+ self .assertTrue (np .max (sqrD ) <= 1e-16 )
2478
+ sqrD ,I ,C = tree .squared_distance (self .v1 ,self .f1 ,bc ,return_index = True ,return_closest_point = True )
2479
+ self .assertTrue (sqrD .shape [0 ] == bc .shape [0 ])
2480
+ self .assertTrue (I .shape [0 ] == bc .shape [0 ])
2481
+ self .assertTrue (C .shape == bc .shape )
2482
+
2483
+ def test_in_element_3 (self ):
2484
+ V = np .array ([ [0. ,0 ,0 ], [1 ,0 ,0 ], [0 ,1 ,0 ], [0 ,0 ,1 ], [1 ,1 ,1 ]],dtype = 'float64' )
2485
+ T = np .array ([[0 ,1 ,2 ,3 ],[4 ,3 ,2 ,1 ]],dtype = 'int32' )
2486
+ Q = np .array ([[0.1 ,0.1 ,0.1 ],[0.9 ,0.9 ,0.9 ]],dtype = 'float64' )
2487
+ tree = igl .AABB_f64_3 ()
2488
+ tree .init (V ,T )
2489
+ I = igl .in_element_3 (V ,T ,Q ,tree )
2490
+ self .assertTrue (I .shape [0 ] == Q .shape [0 ])
2491
+ self .assertTrue (I [0 ] == 0 )
2492
+ self .assertTrue (I [1 ] == 1 )
2493
+
2494
+ def test_in_element_2 (self ):
2495
+ V = np .array ([ [0. ,0 ], [1 ,0 ], [0 ,1 ], [1 ,1 ]],dtype = 'float64' )
2496
+ F = np .array ([[0 ,1 ,2 ],[2 ,1 ,3 ]],'int32' )
2497
+ Q = np .array ([[0.1 ,0.1 ],[0.9 ,0.9 ]],dtype = 'float64' )
2498
+ tree = igl .AABB_f64_2 ()
2499
+ tree .init (V ,F )
2500
+ I = igl .in_element_2 (V ,F ,Q ,tree )
2501
+ self .assertTrue (I .shape [0 ] == Q .shape [0 ])
2502
+ self .assertTrue (I [0 ] == 0 )
2503
+ self .assertTrue (I [1 ] == 1 )
2504
+
2505
+
2471
2506
if __name__ == '__main__' :
2472
2507
unittest .main ()
0 commit comments