Ejemplo n.º 1
0
        private JsonLine makeJsonLine(ICurve curve3D)
        {
            ICurve path = curve3D.Approximate(true, precision);

            if (path is Polyline)
            {
                JsonLine pl = new JsonLine();
                pl.vertices = new List <JsonPoint>();
                for (int i = 0; i < (path as Polyline).Vertices.Length; i++)
                {
                    pl.vertices.Add(new JsonPoint((path as Polyline).Vertices[i]));
                }
                pl.color = 0; // all edges are black
                return(pl);
            }
            else if (path is GeoObject.Path)
            {
                JsonLine pl = new JsonLine();
                pl.vertices = new List <JsonPoint>();
                for (int i = 0; i < (path as GeoObject.Path).CurveCount; i++)
                {
                    pl.vertices.Add(new JsonPoint((path as GeoObject.Path).Curves[i].StartPoint));
                }
                pl.vertices.Add(new JsonPoint((path as GeoObject.Path).Curves.Last().EndPoint));
                pl.color = 0;
                return(pl);
            }
            else if (path is Line)
            {
                JsonLine pl = new JsonLine();
                pl.vertices = new List <JsonPoint>();
                pl.vertices.Add(new JsonPoint(curve3D.StartPoint));
                pl.vertices.Add(new JsonPoint(curve3D.EndPoint));
                pl.color = 0;
                return(pl);
            }
            return(new JsonLine
            {
                vertices = new List <JsonPoint>(),
                color = 0
            });
        }