public static Parasite_Mesh ToParasiteType(Rhino.Geometry.Mesh mesh, Dictionary <string, Parameter> properties = null) { if (!mesh.IsValid) { throw new ParasiteArgumentException("Please input a valid Rhino Mesh!"); } Rhino.Geometry.Collections.MeshFaceList faces = mesh.Faces; int[][] faceIndexes = new int[faces.Count][]; Parasite_Point3d[] vertices = mesh.Vertices.ToPoint3dArray().Select(a => ToParasiteType(a)).ToArray(); Parasite_Mesh parasiteMesh = null; for (int i = 0; i < faces.Count; i++) { if (faces[i].IsTriangle) { faceIndexes[i] = new int[] { faces[i].A, faces[i].B, faces[i].C } } ; if (faces[i].IsQuad) { faceIndexes[i] = new int[] { faces[i].A, faces[i].B, faces[i].C, faces[i].D } } ; } if (mesh.VertexColors.Count != 0) { Color[] vertexColors = new Color[mesh.VertexColors.Count]; for (int i = 0; i < mesh.VertexColors.Count; i++) { vertexColors[i] = mesh.VertexColors[i]; } parasiteMesh = new Parasite_Mesh(faceIndexes, vertices, vertexColors, properties); } if (mesh.VertexColors.Count == 0) { parasiteMesh = new Parasite_Mesh(faceIndexes, vertices, null, properties); } if (!parasiteMesh.IsValid) { throw new ParasiteConversionExceptions(mesh.GetType(), parasiteMesh.GetType()); } return(parasiteMesh); }