Ejemplo n.º 1
0
        public void SaveMesh3()
        {
            // Mesh Points
            System.Diagnostics.Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew();
            MeshPointData mpd = new MeshPointData(m.points);

            using (FileStream fs = new FileStream(Path.Combine(Application.dataPath,
                                                               "scimesh/tests/vtk_to_unity/Resources/m_points_" + name + ".bytes"), FileMode.Create))
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fs, mpd);
            }
            stopwatch.Stop();
            Debug.Log(string.Format("M Points serializing time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks));
            // Mesh Edges
            stopwatch = System.Diagnostics.Stopwatch.StartNew();
            MeshEdgeData med = new MeshEdgeData(m.edges);

            using (FileStream fs = new FileStream(Path.Combine(Application.dataPath,
                                                               "scimesh/tests/vtk_to_unity/Resources/m_edges_" + name + ".bytes"), FileMode.Create))
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fs, med);
            }
            stopwatch.Stop();
            Debug.Log(string.Format("M Edges serializing time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks));
            // Mesh Faces
            stopwatch = System.Diagnostics.Stopwatch.StartNew();
            MeshFaceData mfd = new MeshFaceData(m.faces);

            using (FileStream fs = new FileStream(Path.Combine(Application.dataPath,
                                                               "scimesh/tests/vtk_to_unity/Resources/m_faces_" + name + ".bytes"), FileMode.Create))
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fs, mfd);
            }
            stopwatch.Stop();
            Debug.Log(string.Format("M Faces serializing time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks));
            // Mesh Cells
            stopwatch = System.Diagnostics.Stopwatch.StartNew();
            MeshCellData mcd = new MeshCellData(m.cells);

            using (FileStream fs = new FileStream(Path.Combine(Application.dataPath,
                                                               "scimesh/tests/vtk_to_unity/Resources/m_cells_" + name + ".bytes"), FileMode.Create))
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(fs, mcd);
            }
            stopwatch.Stop();
            Debug.Log(string.Format("M Cells serializing time: {0} ms, {1} ticks", stopwatch.ElapsedMilliseconds, stopwatch.ElapsedTicks));
        }
Ejemplo n.º 2
0
        public void SaveMesh2()
        {
            // Mesh Points
            System.Diagnostics.Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew();
            MeshPointData mpd = new MeshPointData(m.points);

            using (FileStream fs = new FileStream(Path.Combine(Application.dataPath,
                                                               "scimesh/tests/vtk_to_unity/Resources/m_points.bytes"), FileMode.Create))
            {
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Compress))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(gs, mpd);
                }
            }
            stopwatch.Stop();
            Debug.Log("M Points serializing time: " + stopwatch.ElapsedMilliseconds + " ms");
            // Mesh Edges
            stopwatch = System.Diagnostics.Stopwatch.StartNew();
            MeshEdgeData med = new MeshEdgeData(m.edges);

            using (FileStream fs = new FileStream(Path.Combine(Application.dataPath,
                                                               "scimesh/tests/vtk_to_unity/Resources/m_edges.bytes"), FileMode.Create))
            {
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Compress))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(gs, med);
                }
            }
            stopwatch.Stop();
            Debug.Log("M Edges serializing time: " + stopwatch.ElapsedMilliseconds + " ms");
            // Mesh Faces
            stopwatch = System.Diagnostics.Stopwatch.StartNew();
            MeshFaceData mfd = new MeshFaceData(m.faces);

            using (FileStream fs = new FileStream(Path.Combine(Application.dataPath,
                                                               "scimesh/tests/vtk_to_unity/Resources/m_faces.bytes"), FileMode.Create))
            {
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Compress))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(gs, mfd);
                }
            }
            stopwatch.Stop();
            Debug.Log("M Faces serializing time: " + stopwatch.ElapsedMilliseconds + " ms");
            // Mesh Cells
            stopwatch = System.Diagnostics.Stopwatch.StartNew();
            MeshCellData mcd = new MeshCellData(m.cells);

            using (FileStream fs = new FileStream(Path.Combine(Application.dataPath,
                                                               "scimesh/tests/vtk_to_unity/Resources/m_cells.bytes"), FileMode.Create))
            {
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Compress))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(gs, mcd);
                }
            }
            stopwatch.Stop();
            Debug.Log("M Cells serializing time: " + stopwatch.ElapsedMilliseconds + " ms");
        }