fromcompas.colorsimportColorfromcompas.datastructuresimportMeshfromcompas.geometryimportBoxfromcompas.geometryimportSpherefromcompas_cgal.booleansimportsplit_mesh_meshfromcompas_viewerimportViewer# ==============================================================================# 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=Viewer()viewer.renderer.camera.target=[0,0,0]viewer.renderer.camera.position=[4,-6,3]forcolor,verticesinzip([Color.blue(),Color.pink()],mesh.connected_vertices()):faces=[]forindicesinF:ifall(indexinverticesforindexinindices):faces.append(indices)mesh=Mesh.from_vertices_and_faces(V,faces)mesh.remove_unused_vertices()viewer.scene.add(mesh,facecolor=color,show_points=False)viewer.show()