@@ -13,8 +13,8 @@ def test_version():
1313import igl .triangle
1414import igl .copyleft
1515import igl .copyleft .tetgen
16- # import igl.copyleft.cgal
17- # import igl.embree
16+ import igl .copyleft .cgal
17+ import igl .embree
1818
1919
2020#def rand_sparse(n,density):
@@ -449,70 +449,70 @@ def test_bijective():
449449 U = igl .bijective_composite_harmonic_mapping (V ,F ,b ,bc )
450450
451451
452- # def test_copyleft():
453- # V = np.array([[0,0,-1],[2,0,-1],[0,2,-1],[1,1,1]],dtype=np.float64)
454- # T = np.array([[0,1,2,3]],dtype=np.int64)
455- # F,_,_ = igl.boundary_facets(T)
456- # V,F = igl.loop(V,F)
457- #
458- # dV,dF,J = igl.copyleft.progressive_hulls(V,F)
459- #
460- #
461- # def test_cgal():
462- # # tetrahedron
463- # VA = np.array([[0,0,-1],[2,0,-1],[0,2,-1],[1,1,1]],dtype=np.float64)
464- # T = np.array([[0,1,2,3]],dtype=np.int64)
465- # FA,_,_ = igl.boundary_facets(T)
466- # # flip z
467- # VB = np.array([[0,0,1],[2,0,1],[0,2,1],[1,1,-1]],dtype=np.float64)
468- # FB = FA[:,::-1]
469- # IF,_,_,_,_ = igl.copyleft.cgal.intersect_other(VA,FA,VB,FB)
470- # IF,_,_,_,_ = igl.copyleft.cgal.intersect_other(VA,FA,VB,FB,detect_only=True,first_only=True)
471- # VC,FC,J = igl.copyleft.cgal.mesh_boolean(VA,FA,VB,FB,"union")
472- # H = igl.copyleft.cgal.convex_hull(VC)
473- # # concatenate A and B meshes
474- # VC = np.vstack((VA,VB))
475- # FC = np.vstack((FA,FB+VA.shape[0]))
476- # VV,FF,IF,J,IM = igl.copyleft.cgal.remesh_self_intersections(VC,FC)
477- # _,_,IF,_,_ = igl.copyleft.cgal.remesh_self_intersections(VC,FC,detect_only=True,first_only=True)
478- #
479- # p = np.array([0,0,0],dtype=np.float64)
480- # n = np.array([1,1,1],dtype=np.float64)
481- # VV,FF,J = igl.copyleft.cgal.intersect_with_half_space(VC,FC,p,n)
482- # equ = np.hstack((n,-n.dot(p)))
483- # VV,FF,J = igl.copyleft.cgal.intersect_with_half_space(VC,FC,equ)
484- #
485- # P = np.array([[0.5,0.5,0.0],[0.5,0.5,0.5]],dtype=np.float64)
486- # W = igl.copyleft.cgal.fast_winding_number(VA,FA,P)
487- # W = igl.copyleft.cgal.fast_winding_number(VA,FA,P,expansion_order=2,beta=2.0)
488- #
489- # VC,FC,D,J = igl.copyleft.cgal.trim_with_solid(VA,FA,VB,FB)
490- #
491- # _,I,X = igl.random_points_on_mesh(1000,VC,FC)
492- # N = igl.per_face_normals(VC,FC)
493- # N = N[I,:]
494- # point_indices, CH,CN,W = igl.octree(X)
495- # I = igl.knn(X,X,20,point_indices,CH,CN,W)
496- # A,T = igl.copyleft.cgal.point_areas(X,I,N)
497- #
498- # def test_embree():
499- # # octahedron
500- # V = np.array([[1,0,0],[0,1,0],[0,0,1],[-1,0,0],[0,-1,0],[0,0,-1]],dtype=np.float64)
501- # F = np.array([[0,1,2], [0,2,4], [0,4,5], [0,5,1], [1,3,2], [1,5,3], [2,3,4], [3,5,4]],dtype=np.int64)
502- # N = igl.per_vertex_normals(V,F)
503- # ei = igl.embree.EmbreeIntersector();
504- # ei.init(V,F)
505- # S = igl.embree.ambient_occlusion(V,F,V,N,100)
506- # S = igl.embree.ambient_occlusion(ei,V,N,100)
507- # N = -N
508- # S = igl.embree.shape_diameter_function(V,F,V,N,100)
509- # S = igl.embree.shape_diameter_function(ei,V,N,100)
510- # origin = np.array([2,2,2],dtype=np.float64)
511- # direction = np.array([-2,-2,-2],dtype=np.float64)
512- # hit = ei.intersectRay_first(origin,direction)
513- # hits = ei.intersectRay(origin,direction)
514- # hits = ei.intersectRay(origin,direction,tnear=0,tfar=1)
515- # I,C = igl.embree.reorient_facets_raycast(V,F)
452+ def test_copyleft ():
453+ V = np .array ([[0 ,0 ,- 1 ],[2 ,0 ,- 1 ],[0 ,2 ,- 1 ],[1 ,1 ,1 ]],dtype = np .float64 )
454+ T = np .array ([[0 ,1 ,2 ,3 ]],dtype = np .int64 )
455+ F ,_ ,_ = igl .boundary_facets (T )
456+ V ,F = igl .loop (V ,F )
457+
458+ dV ,dF ,J = igl .copyleft .progressive_hulls (V ,F )
459+
460+
461+ def test_cgal ():
462+ # tetrahedron
463+ VA = np .array ([[0 ,0 ,- 1 ],[2 ,0 ,- 1 ],[0 ,2 ,- 1 ],[1 ,1 ,1 ]],dtype = np .float64 )
464+ T = np .array ([[0 ,1 ,2 ,3 ]],dtype = np .int64 )
465+ FA ,_ ,_ = igl .boundary_facets (T )
466+ # flip z
467+ VB = np .array ([[0 ,0 ,1 ],[2 ,0 ,1 ],[0 ,2 ,1 ],[1 ,1 ,- 1 ]],dtype = np .float64 )
468+ FB = FA [:,::- 1 ]
469+ IF ,_ ,_ ,_ ,_ = igl .copyleft .cgal .intersect_other (VA ,FA ,VB ,FB )
470+ IF ,_ ,_ ,_ ,_ = igl .copyleft .cgal .intersect_other (VA ,FA ,VB ,FB ,detect_only = True ,first_only = True )
471+ VC ,FC ,J = igl .copyleft .cgal .mesh_boolean (VA ,FA ,VB ,FB ,"union" )
472+ H = igl .copyleft .cgal .convex_hull (VC )
473+ # concatenate A and B meshes
474+ VC = np .vstack ((VA ,VB ))
475+ FC = np .vstack ((FA ,FB + VA .shape [0 ]))
476+ VV ,FF ,IF ,J ,IM = igl .copyleft .cgal .remesh_self_intersections (VC ,FC )
477+ _ ,_ ,IF ,_ ,_ = igl .copyleft .cgal .remesh_self_intersections (VC ,FC ,detect_only = True ,first_only = True )
478+
479+ p = np .array ([0 ,0 ,0 ],dtype = np .float64 )
480+ n = np .array ([1 ,1 ,1 ],dtype = np .float64 )
481+ VV ,FF ,J = igl .copyleft .cgal .intersect_with_half_space (VC ,FC ,p ,n )
482+ equ = np .hstack ((n ,- n .dot (p )))
483+ VV ,FF ,J = igl .copyleft .cgal .intersect_with_half_space (VC ,FC ,equ )
484+
485+ P = np .array ([[0.5 ,0.5 ,0.0 ],[0.5 ,0.5 ,0.5 ]],dtype = np .float64 )
486+ W = igl .copyleft .cgal .fast_winding_number (VA ,FA ,P )
487+ W = igl .copyleft .cgal .fast_winding_number (VA ,FA ,P ,expansion_order = 2 ,beta = 2.0 )
488+
489+ VC ,FC ,D ,J = igl .copyleft .cgal .trim_with_solid (VA ,FA ,VB ,FB )
490+
491+ _ ,I ,X = igl .random_points_on_mesh (1000 ,VC ,FC )
492+ N = igl .per_face_normals (VC ,FC )
493+ N = N [I ,:]
494+ point_indices , CH ,CN ,W = igl .octree (X )
495+ I = igl .knn (X ,X ,20 ,point_indices ,CH ,CN ,W )
496+ A ,T = igl .copyleft .cgal .point_areas (X ,I ,N )
497+
498+ def test_embree ():
499+ # octahedron
500+ V = np .array ([[1 ,0 ,0 ],[0 ,1 ,0 ],[0 ,0 ,1 ],[- 1 ,0 ,0 ],[0 ,- 1 ,0 ],[0 ,0 ,- 1 ]],dtype = np .float64 )
501+ F = np .array ([[0 ,1 ,2 ], [0 ,2 ,4 ], [0 ,4 ,5 ], [0 ,5 ,1 ], [1 ,3 ,2 ], [1 ,5 ,3 ], [2 ,3 ,4 ], [3 ,5 ,4 ]],dtype = np .int64 )
502+ N = igl .per_vertex_normals (V ,F )
503+ ei = igl .embree .EmbreeIntersector ();
504+ ei .init (V ,F )
505+ S = igl .embree .ambient_occlusion (V ,F ,V ,N ,100 )
506+ S = igl .embree .ambient_occlusion (ei ,V ,N ,100 )
507+ N = - N
508+ S = igl .embree .shape_diameter_function (V ,F ,V ,N ,100 )
509+ S = igl .embree .shape_diameter_function (ei ,V ,N ,100 )
510+ origin = np .array ([2 ,2 ,2 ],dtype = np .float64 )
511+ direction = np .array ([- 2 ,- 2 ,- 2 ],dtype = np .float64 )
512+ hit = ei .intersectRay_first (origin ,direction )
513+ hits = ei .intersectRay (origin ,direction )
514+ hits = ei .intersectRay (origin ,direction ,tnear = 0 ,tfar = 1 )
515+ I ,C = igl .embree .reorient_facets_raycast (V ,F )
516516
517517def test_tetgen ():
518518 # octahedron
0 commit comments