예제 #1
0
        public static bool RhinoMeshToCMesh(
            Mesh mesh,
            ref CMesh outMesh,
            bool flipYZ,
            out String errorMessage)
        {
            outMesh = new CMesh();

            outMesh.n_vertices = mesh.Vertices.Count;
            outMesh.n_faces    = mesh.Faces.Count;

            outMesh.points = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(float)) * outMesh.n_vertices * 3);
            outMesh.faces  = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * outMesh.n_faces * 3);

            float[] points = new float[outMesh.n_vertices * 3];
            for (int id = 0; id < mesh.Vertices.Count; id++)
            {
                points[id * 3] = mesh.Vertices[id].X;
                if (flipYZ)
                {
                    points[id * 3 + 1] = mesh.Vertices[id].Z;
                    points[id * 3 + 2] = -mesh.Vertices[id].Y;
                }
                else
                {
                    points[id * 3 + 1] = mesh.Vertices[id].Y;
                    points[id * 3 + 2] = mesh.Vertices[id].Z;
                }
            }
            Marshal.Copy(points, 0, outMesh.points, outMesh.n_vertices * 3);

            int[] faces = new int[outMesh.n_faces * 3];
            for (int id = 0; id < mesh.Faces.Count; id++)
            {
                if (mesh.Faces[id].IsTriangle)
                {
                    faces[3 * id]     = mesh.Faces[id].A;
                    faces[3 * id + 1] = mesh.Faces[id].B;
                    faces[3 * id + 2] = mesh.Faces[id].C;
                }
                else
                {
                    errorMessage = "Mesh has Quad Faces!";
                    return(false);
                }
            }
            Marshal.Copy(faces, 0, outMesh.faces, outMesh.n_faces * 3);
            errorMessage = "";
            return(true);
        }
예제 #2
0
 internal static extern void addMeshesToContactGraph(IntPtr graphData, [In, Out] ref CMesh mesh, bool brdy);
예제 #3
0
 internal static extern void setReferenceSurface(ref CMesh cmesh, IntPtr topoData);