MeshExplorer.IO.EpsImage.DrawSegments C# (CSharp) Method

DrawSegments() private method

private DrawSegments ( StreamWriter eps, Mesh mesh ) : void
eps System.IO.StreamWriter
mesh TriangleNet.Mesh
return void
        private void DrawSegments(StreamWriter eps, Mesh mesh)
        {
            eps.WriteLine("%");
            eps.WriteLine("%  Set the triangle line color and width.");
            eps.WriteLine("%");
            eps.WriteLine("0.27  0.5  0.7 setrgbcolor");
            eps.WriteLine("0.75 setlinewidth");
            eps.WriteLine("%");
            eps.WriteLine("%  Draw the triangles.");
            eps.WriteLine("%");

            StringBuilder labels = new StringBuilder();

            double x1, y1, x2, y2;
            int x_ps, y_ps;

            foreach (var seg in mesh.Segments)
            {
                eps.WriteLine("newpath");

                x1 = seg.GetVertex(0).X; y1 = seg.GetVertex(0).Y;
                x2 = seg.GetVertex(1).X; y2 = seg.GetVertex(1).Y;

                x_ps = (int)Math.Floor(((x_max - x1) * x_ps_min + (x1 - x_min) * x_ps_max) / (x_max - x_min));
                y_ps = (int)Math.Floor(((y_max - y1) * y_ps_min + (y1 - y_min) * y_ps_max) / (y_max - y_min));
                eps.WriteLine("  {0}  {1}  moveto", x_ps, y_ps);

                x_ps = (int)Math.Floor(((x_max - x2) * x_ps_min + (x2 - x_min) * x_ps_max) / (x_max - x_min));
                y_ps = (int)Math.Floor(((y_max - y2) * y_ps_min + (y2 - y_min) * y_ps_max) / (y_max - y_min));
                eps.WriteLine("  {0}  {1}  lineto", x_ps, y_ps);

                eps.WriteLine("stroke");
            }
        }