예제 #1
0
        private void DrawEdges(StreamWriter svg, Mesh mesh)
        {
            svg.Write("\t<path d=\"");

            StringBuilder labels = new StringBuilder();

            Vertex v1, v2;
            double x1, y1, x2, y2;

            int i = 1;

            foreach (var e in EdgeIterator.EnumerateEdges(mesh))
            {
                v1 = e.GetVertex(0);
                v2 = e.GetVertex(1);

                x1 = scale * v1.X;
                y1 = scale * v1.Y;
                x2 = scale * v2.X;
                y2 = scale * v2.Y;

                svg.Write("M {0:0.#},{1:0.#} L {2:0.#},{3:0.#} ",
                          x1, y1, x2, y2);

                if (i % LINEBREAK_COUNT == 0)
                {
                    svg.WriteLine();
                    svg.Write("\t");
                }

                i++;
            }

            svg.WriteLine("\" style=\"stroke:#c2c2c2; fill:none; stroke-linejoin:bevel;\"/>");
        }
예제 #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));
                }
            }
        }