def explodeMesh(mesh): meshList = [] for i in range(len(mesh.Faces)): new_mesh = rg.Mesh() v1 = mesh.Vertices[mesh.Faces[i][0]] v2 = mesh.Vertices[mesh.Faces[i][1]] v3 = mesh.Vertices[mesh.Faces[i][2]] new_mesh.Vertices.Add(v1.X, v1.Y, v1.Z) new_mesh.Vertices.Add(v2.X, v2.Y, v2.Z) new_mesh.Vertices.Add(v3.X, v3.Y, v3.Z) if mesh.Faces[0][-1] != mesh.Faces[0][-2]: v4 = mesh.Vertices[mesh.Faces[i][3]] new_mesh.Vertices.Add(v4.X, v4.Y, v4.Z) new_mesh.Faces.AddFace(0, 1, 2, 3) else: new_mesh.Faces.AddFace(0, 1, 2) meshList.append(new_mesh) return meshList
def rhino_mesh_from_meshpy(mesh): rmesh = rhino.Mesh() for p in mesh.points: rmesh.Vertices.Add(p[0], p[1], 0.0) for e in mesh.elements: rmesh.Faces.AddFace(e[0], e[1], e[2]) return rmesh
def makeSampleMesh(U, V): #creating a simple mesh from a grid of points mesh = rg.Mesh() for i in range(U): for j in range(V): p = rg.Point3d(i, j, 0) mesh.Vertices.Add(p.X, p.Y, p.Z) for i in range(len(mesh.Vertices) - (V)): if (i % V != V - 1): mesh.Faces.AddFace(i, i + 1, i + V + 1, i + V) return mesh