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); } }
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); } }
private ICurve OrientPolyline(Polyline polyline, bool clockwise) { bool isClockwise = IsClockwise(polyline); if (isClockwise == clockwise) { return(polyline); } return(polyline.Reverse()); }
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); }
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); } } } }
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); }
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); }
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; }