/// <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);
            }
        }
        /// <summary>
        /// Correct vertices reuse is required, which is ensured by using the ExportPolygon builder.
        /// </summary>
        /// <param name="mesh">Any polygon, preferable a ExportPolygon</param>
        private void Import(IPolygon mesh)
        {
            mesh       = ExportPolygon.Convert(mesh);
            _pq        = new StablePriorityQueue <V>(mesh.VertexCount);
            _triangles = new List <T>();

            var verts = new List <V>();

            foreach (Vec3 position in mesh.Vertices)
            {
                verts.Add(new V(position, this));
            }

            int index = 0;
            var t     = mesh.Triangles.ToArray();

            while (index < t.Length)
            {
                _triangles.Add(new T(verts[t[index++]], verts[t[index++]], verts[t[index++]], this));
            }

            foreach (V v in verts)
            {
                v.ComputeEdgeCostAtVertex();
            }
        }
        /// <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);
            }
        }