示例#1
0
文件: VEdge.cs 项目: KOpenMOS/Mos
 static void FillContexForPolyline(WStreamGeometryContext context, MPolyline poly)
 {
     for (PolylinePoint pp = poly.StartPoint.Next; pp != null; pp = pp.Next)
     {
         context.LineTo(Common.WpfPoint(pp.Point), true, false);
     }
 }
示例#2
0
 private static void FillContexForPolyline(StreamGeometryContext context, GeometryPolyline poly)
 {
     for (PolylinePoint pp = poly.StartPoint.Next; pp != null; pp = pp.Next)
     {
         context.LineTo(pp.Point.ToWpf(), true, false);
     }
 }
示例#3
0
        private ICurve OrientPolyline(Polyline polyline, bool clockwise)
        {
            bool isClockwise = IsClockwise(polyline);

            if (isClockwise == clockwise)
            {
                return(polyline);
            }
            return(polyline.Reverse());
        }
示例#4
0
        static void FillContexForPolyline(PathGeometry path, Polyline poly)
        {
            PathFigure polylineFigure = new PathFigure();

            for (PolylinePoint pp = poly.StartPoint.Next; pp != null; pp = pp.Next)
            {
                polylineFigure.Segments.Add(new Windows.UI.Xaml.Media.LineSegment()
                {
                    Point = Common.UwpPoint(pp.Point)
                });
            }

            path.Figures.Add(polylineFigure);
        }
示例#5
0
        private void SubdividePolyline(Polyline polyline, double minLength)
        {
            var q = new Queue <PolylinePoint>();

            foreach (var pp in polyline.PolylinePoints)
            {
                var ppn = pp.NextOnPolyline;
                if ((pp.Point - ppn.Point).Length > minLength)
                {
                    q.Enqueue(pp);
                }
            }

            while (q.Count > 0)
            {
                var pp  = q.Dequeue();
                var ppn = pp.NextOnPolyline;
                var p   = new PolylinePoint(0.5 * (pp.Point + ppn.Point))
                {
                    Polyline = polyline
                };
                bool tooBig = (p.Point - pp.Point).Length > minLength;
                if (pp.Next != null)
                {
                    p.Prev   = pp;
                    p.Next   = ppn;
                    pp.Next  = p;
                    ppn.Prev = p;
                    if (tooBig)
                    {
                        q.Enqueue(pp);
                        q.Enqueue(p);
                    }
                }
                else
                {
                    polyline.AddPoint(p.Point);
                    if (tooBig)
                    {
                        q.Enqueue(polyline.EndPoint);
                        q.Enqueue(polyline.EndPoint.Prev);
                    }
                }
            }
        }
示例#6
0
        private static PolylinePoint FindConvexHullPolyPoint(Polyline polyline)
        {
            PolylinePoint convexHullPolyPoint = polyline.StartPoint;

            for (var p = polyline.StartPoint.Next; p != null; p = p.Next)
            {
                if (p.Point.Y < convexHullPolyPoint.Point.Y)
                {
                    convexHullPolyPoint = p;
                }
                else if (p.Point.Y > convexHullPolyPoint.Point.Y)
                {
                    continue;
                }

                if (p.Point.X < convexHullPolyPoint.Point.X)
                {
                    convexHullPolyPoint = p;
                }
            }
            return(convexHullPolyPoint);
        }
示例#7
0
        private bool IsClockwise(Polyline polyline)
        {
            PolylinePoint convexHullPolyPoint = FindConvexHullPolyPoint(polyline);

            return(Point.GetTriangleOrientation(convexHullPolyPoint.PrevOnPolyline.Point, convexHullPolyPoint.Point, convexHullPolyPoint.NextOnPolyline.Point) == TriangleOrientation.Clockwise);
        }
 static void FillContexForPolyline(StreamGeometryContext context,Polyline poly) {
     for(PolylinePoint pp = poly.StartPoint.Next;pp != null;pp = pp.Next)
         context.LineTo(Common.WpfPoint(pp.Point),true,false);
 }
示例#9
0
 private static MsaglPolyline PolylineFromCurve(Curve curve)
 {
     var ret = new MsaglPolyline();
     ret.AddPoint(curve.Start);
     foreach (var ls in curve.Segments)
         ret.AddPoint(ls.End);
     ret.Closed = curve.Start == curve.End;
     return ret;
 }
        private static PolylinePoint FindConvexHullPolyPoint(Polyline polyline) {
            PolylinePoint convexHullPolyPoint = polyline.StartPoint;

            for (var p = polyline.StartPoint.Next; p != null; p = p.Next) {
                if (p.Point.Y < convexHullPolyPoint.Point.Y)
                    convexHullPolyPoint = p;
                else if (p.Point.Y > convexHullPolyPoint.Point.Y) continue;

                if (p.Point.X < convexHullPolyPoint.Point.X)
                    convexHullPolyPoint = p;
            }
            return convexHullPolyPoint;
        }
 private bool IsClockwise(Polyline polyline) {
     PolylinePoint convexHullPolyPoint = FindConvexHullPolyPoint(polyline);
     return Point.GetTriangleOrientation(convexHullPolyPoint.PrevOnPolyline.Point, convexHullPolyPoint.Point, convexHullPolyPoint.NextOnPolyline.Point) == TriangleOrientation.Clockwise;
 }
 private ICurve OrientPolyline(Polyline polyline, bool clockwise) {
     bool isClockwise = IsClockwise(polyline);
     if (isClockwise == clockwise)
         return polyline;
     return polyline.Reverse();
 }
        private void SubdividePolyline(Polyline polyline, double minLength) {
            var q = new Queue<PolylinePoint>();
            foreach (var pp in polyline.PolylinePoints) {
                var ppn = pp.NextOnPolyline; 
                if ((pp.Point - ppn.Point).Length > minLength)
                    q.Enqueue(pp);
            }

            while (q.Count > 0) {
                var pp = q.Dequeue();
                var ppn = pp.NextOnPolyline;
                var p = new PolylinePoint(0.5 * (pp.Point + ppn.Point)) { Polyline = polyline };                 
                bool tooBig=(p.Point-pp.Point).Length>minLength;
                if (pp.Next != null) {
                    p.Prev = pp;
                    p.Next = ppn;
                    pp.Next = p;
                    ppn.Prev = p;
                    if(tooBig){
                        q.Enqueue(pp);
                        q.Enqueue(p);
                    }
                } else {
                    polyline.AddPoint(p.Point);
                    if(tooBig){
                        q.Enqueue(polyline.EndPoint);
                        q.Enqueue(polyline.EndPoint.Prev);
                    }

                }
                                    
            }
   
        }
 internal PolylineIterator(Polyline poly)
 {
     this.polyline = poly;
 }