fromcompas.geometryimportBox,Spherefromcompas.datastructuresimportMeshfromcompas.colorsimportColorfromcompas_view2.appimportAppfromcompas_cgal.booleansimportsplit_mesh_mesh# ==============================================================================# Make a box and a sphere# ==============================================================================box=Box(2)A=box.to_vertices_and_faces(triangulated=True)sphere=Sphere(1,point=[1,1,1])B=sphere.to_vertices_and_faces(u=32,v=32,triangulated=True)# ==============================================================================# Compute the mesh split# ==============================================================================V,F=split_mesh_mesh(A,B)mesh=Mesh.from_vertices_and_faces(V,F)# ==============================================================================# Seperate disjoint faces and visualize# ==============================================================================viewer=App(width=1600,height=900)viewer.view.camera.position=[5,-4,2]viewer.view.camera.look_at([0,0,0])forcolor,verticesinzip([Color.blue(),Color.pink()],mesh.connected_components()):faces=[]forindicesinF:ifall(indexinverticesforindexinindices):faces.append(indices)mesh=Mesh.from_vertices_and_faces(V,faces)mesh.remove_unused_vertices()viewer.add(mesh,facecolor=color)viewer.run()