internal static Polyline PolylineFromCurve(Curve curve) { var ret = new Polyline(); ret.AddPoint(curve.Start); foreach (var ls in curve.Segments) { ret.AddPoint(ls.End); } ret.Closed = curve.Start == curve.End; return(ret); }
internal Polyline ReversePolyline() { var ret = new Polyline(); PolylinePoint pp = EndPoint; while (pp.Prev != null) { ret.AddPoint(pp.Point); pp = pp.Prev; } ret.AddPoint(StartPoint.Point); ret.Closed = Closed; return(ret); }
/// <summary> /// clones the curve. /// </summary> /// <returns>the cloned curve</returns> ICurve ICurve.Clone() { var ret = new Polyline(); foreach (Point p in this) { ret.AddPoint(p); } ret.Closed = Closed; return(ret); }
static Polyline FlipPolyline(Polyline poly) { Polyline ret = new Polyline(); for (PolylinePoint pp = poly.StartPoint; pp != null; pp = pp.Next) { ret.AddPoint(-pp.Point); } ret.Closed = true; return(ret); }
/// <summary> /// Returns the curved with all points scaled from the original by x and y /// </summary> /// <param name="xScale"></param> /// <param name="yScale"></param> /// <returns></returns> public ICurve ScaleFromOrigin(double xScale, double yScale) { var ret = new Polyline(); PolylinePoint polyPoint = StartPoint; while (polyPoint != null) { ret.AddPoint(Point.Scale(xScale, yScale, polyPoint.Point)); polyPoint = polyPoint.Next; } ret.Closed = Closed; return(ret); }
public static Polyline PolylineAroundClosedCurve(ICurve curve) { Polyline poly = new Polyline(); foreach (Point point in PointsOnAroundPolyline(curve)) { poly.AddPoint(point); } if (Point.GetTriangleOrientation(poly.StartPoint.Point, poly.StartPoint.Next.Point, poly.StartPoint.Next.Next.Point) == TriangleOrientation.Counterclockwise) { poly = (Polyline)poly.Reverse(); } poly.Closed = true; return(poly); }
/// <summary> /// returns the transformed polyline /// </summary> /// <param name="transformation"></param> /// <returns></returns> public ICurve Transform(PlaneTransformation transformation) { if (transformation == null) { return(this); } var poly = new Polyline { Closed = Closed }; foreach (var p in this) { poly.AddPoint(transformation * p); } return(poly); }
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); } } } }
static Polyline Merge(PolylinePoint p0, PolylinePoint p1) { PolylinePoint s0 = p0; PolylinePoint s1 = p1; Polyline ret = new Polyline(); while (true) { ret.AddPoint(p0.Point + p1.Point); PickNextVertex(ref p0, ref p1); if (p0 == s0 && p1 == s1) { break; } } ret.Closed = true; return(ret); }
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 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); } } } }