Example #1
0
        /// <summary>
        /// Export the mesh to EPS format.
        /// </summary>
        /// <param name="mesh">The current mesh.</param>
        /// <param name="filename">The EPS filename.</param>
        /// <param name="width">The desired width of the image (currently ignored).</param>
        public void Export(Mesh mesh, string filename, int width)
        {
            // Check file name
            if (String.IsNullOrWhiteSpace(filename))
            {
                filename = String.Format("mesh-{0}.eps", DateTime.Now.ToString("yyyy-M-d-hh-mm-ss"));
            }

            if (!filename.EndsWith(".eps"))
            {
                filename = Path.ChangeExtension(filename, ".eps");
            }

            UpdateMetrics(mesh.Bounds);

            using (var eps = new EpsDocument(filename, ps))
            {
                int n = mesh.Vertices.Count;

                // Size of the points.
                eps.DefaultPointSize = (n < 100) ? 3 : ((n < 500) ? 2 : 1);

                eps.WriteHeader();

                // Draw a gray border around the page.
                eps.SetColor(ColorBorder);
                eps.DrawRectangle(GetRectangle(ps));

                // Define a clipping polygon.
                eps.SetClip(GetRectangle(clip));

                // Draw edges.
                eps.AddComment("Draw edges.");
                eps.SetStroke(0.4f, ColorLines);

                foreach (var e in EdgeIterator.EnumerateEdges(mesh))
                {
                    eps.DrawLine(Transform(e.GetVertex(0)), Transform(e.GetVertex(1)));
                }

                // Draw Segments.
                eps.AddComment("Draw Segments.");
                eps.SetStroke(0.8f, ColorSegments);

                foreach (var s in mesh.Segments)
                {
                    eps.DrawLine(Transform(s.GetVertex(0)), Transform(s.GetVertex(1)));
                }

                // Draw points.
                eps.AddComment("Draw points.");
                eps.SetColor(ColorPoints);

                foreach (var node in mesh.Vertices)
                {
                    eps.DrawPoint(Transform(node));
                }
            }
        }
Example #2
0
        /// <summary>
        /// Export the mesh to EPS format.
        /// </summary>
        /// <param name="mesh">The current mesh.</param>
        /// <param name="filename">The EPS filename.</param>
        /// <param name="width">The desired width of the image (currently ignored).</param>
        public void Export(Mesh mesh, string filename, int width)
        {
            // Check file name
            if (String.IsNullOrWhiteSpace(filename))
            {
                filename = String.Format("mesh-{0}.eps", DateTime.Now.ToString("yyyy-M-d-hh-mm-ss"));
            }

            if (!filename.EndsWith(".eps"))
            {
                filename = Path.ChangeExtension(filename, ".eps");
            }

            UpdateMetrics(mesh.Bounds);

            using (var eps = new EpsDocument(filename, ps))
            {
                int n = mesh.Vertices.Count;

                // Size of the points.
                eps.DefaultPointSize = (n < 100) ? 3 : ((n < 500) ? 2 : 1);

                eps.WriteHeader();

                // Draw a gray border around the page.
                eps.SetColor(ColorBorder);
                eps.DrawRectangle(GetRectangle(ps));

                // Define a clipping polygon.
                eps.SetClip(GetRectangle(clip));

                // Draw edges.
                eps.AddComment("Draw edges.");
                eps.SetStroke(0.4f, ColorLines);

                foreach (var e in EdgeIterator.EnumerateEdges(mesh))
                {
                    eps.DrawLine(Transform(e.GetVertex(0)), Transform(e.GetVertex(1)));
                }

                // Draw Segments.
                eps.AddComment("Draw Segments.");
                eps.SetStroke(0.8f, ColorSegments);

                foreach (var s in mesh.Segments)
                {
                    eps.DrawLine(Transform(s.GetVertex(0)), Transform(s.GetVertex(1)));
                }

                // Draw points.
                eps.AddComment("Draw points.");
                eps.SetColor(ColorPoints);

                foreach (var node in mesh.Vertices)
                {
                    eps.DrawPoint(Transform(node));
                }
            }
        }