/// <summary>
        /// Exports the currently shown mesh to a location chosen by the user.
        /// </summary>
        /// <remarks>
        /// The method supports .obj and .ply file formats.
        /// </remarks>
        public void Export()
        {
            var path = PathChooser.FindSaveLocation();

            if (path == null)
            {
                return;
            }

            var vert = _mainMesh.Positions.Select(p => new Vec3((float)p.X, (float)p.Y, (float)p.Z)).ToArray();
            var tris = new List <int>();

            for (int i = 0; i < _stepcount; i++)
            {
                var step = _steps[i];
                foreach (int[] tri in step.triangles)
                {
                    foreach (int ii in tri)
                    {
                        tris.Add(ii);
                    }
                }
            }

            var polygon = new ExportPolygon(vert, tris.ToArray());

            if (path.EndsWith(".obj"))
            {
                IOhandler.ObjExporter.Export(path, polygon);
            }
            else
            {
                PlyExporter.Export(path, polygon);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Exports all given meshes.
        /// </summary>
        /// <param name="mesh">Meshes to export.</param>
        /// <param name="elapsedTime">Elapsed creation time for each mesh, expected to match mesh in length.</param>
        public static void Export(IPolygon[] mesh, long[] elapsedTime)
        {
            int n             = mesh.Count();
            var paths         = new string[n];
            var exportSuccess = new bool[n];

            PrintTitle("EXPORTING");
            Console.WriteLine();
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine($"Choose location for export {i + 1} of {n}\n");
                paths[i] = PathChooser.FindSaveLocation();
            }

            Parallel.For(0, n, i => {
                if (paths[i] != null)
                {
                    exportSuccess[i] = paths[i].EndsWith("obj") ? ObjExporter.Export(paths[i], mesh[i], elapsedTime[i]) : PlyExporter.Export(paths[i], mesh[i], elapsedTime[i]);
                }
            });

            for (int i = 0; i < n; i++)
            {
                if (paths[i] == null)
                {
                    Console.WriteLine($"\nExporting of file {i + 1} of {n} failed!");
                    continue;
                }

                var s = paths[i].Split('\\');
                Console.WriteLine($"\nOpen generated '{s[s.Length - 1]}' file? Y/N");
                Console.Write("> ");
                if (Console.ReadLine().ToLower().Contains("y"))
                {
                    Process.Start(paths[i]);
                }
            }
        }
        /// <summary>
        /// Exports the mesh to a location chosen by the user.
        /// </summary>
        /// <remarks>
        /// The method supports .obj and .ply file formats.
        /// </remarks>
        public void Export()
        {
            var path = PathChooser.FindSaveLocation();

            if (path == null)
            {
                return;
            }

            var vert = _mainMesh.Positions.Select(p => new Vec3((float)p.X, (float)p.Y, (float)p.Z)).ToArray();
            var tris = _mainMesh.TriangleIndices.ToArray();

            var polygon = new ExportPolygon(vert, tris);

            if (path.EndsWith(".obj"))
            {
                IOhandler.ObjExporter.Export(path, polygon);
            }
            else
            {
                PlyExporter.Export(path, polygon);
            }
        }