Exemplo n.º 1
0
        protected virtual SLExpression VisitPolygonFromLines(PolygonFromLinesExpression polygonFromLinesExpression)
        {
            var lines = polygonFromLinesExpression.Lines.Select(Visit).ToArray();

            if (HasChanged(lines, polygonFromLinesExpression.Lines))
            {
                return(new PolygonFromLinesExpression
                {
                    Lines = lines.Cast <LineExpression>().ToArray(),
                });
            }
            return(polygonFromLinesExpression);
        }
Exemplo n.º 2
0
        public XElement ConvertPolygon(PolygonFromLinesExpression polygon)
        {
            var lines = polygon.Lines.Cast <TwoPointsLineExpression>().ToArray();

            return(new XElement("g",
                                new XAttribute("stroke", "green"),
                                new XAttribute("stroke-width", "0.01"),
                                lines
                                .Select(l => new
            {
                P1 = (CoordinatesPointExpression)l.Point1,
                P2 = (CoordinatesPointExpression)l.Point2,
            })
                                .Select(l => new XElement("line",
                                                          new XAttribute("x1", l.P1.X),
                                                          new XAttribute("y1", l.P1.Y),
                                                          new XAttribute("x2", l.P2.X),
                                                          new XAttribute("y2", l.P2.Y)))
                                .ToArray()));
        }
Exemplo n.º 3
0
        protected override SLExpression VisitPolygonFromLines(PolygonFromLinesExpression polygonFromLinesExpression)
        {
            if (LeavePolygonAsLines)
            {
                return(polygonFromLinesExpression);
            }

            var points = new List <PointExpression>();
            var lines  = polygonFromLinesExpression.Lines.Select(Visit).Cast <TwoPointsLineExpression>().ToArray();

            lines.Aggregate(lines.Last(), (l1, l2) =>
            {
                points.Add(GetIntersectionPoint(l1, l2));
                return(l2);
            });

            return(new PolygonFromPointsExpression
            {
                Points = points.ToArray(),
            });
        }
Exemplo n.º 4
0
 protected override SLExpression VisitPolygonFromLines(PolygonFromLinesExpression polygonFromLinesExpression)
 {
     this.PolygonLines = polygonFromLinesExpression.Lines;
     return(base.VisitPolygonFromLines(polygonFromLinesExpression));
 }
Exemplo n.º 5
0
 protected override SLExpression VisitPolygonFromLines(PolygonFromLinesExpression polygonFromLinesExpression)
 {
     PolygonsFromLines.Add(polygonFromLinesExpression);
     return(polygonFromLinesExpression);
 }