public SilkwormSegment(Curve curve, int mainSegmentCount, int subSegmentCount, double maxAngleRadians, double maxChordLengthRatio, double maxAspectRatio, double tolerance, double minEdgeLength, double maxEdgeLength, bool keepStartPoint) { if (curve != null) { //See if curve can be represented as a polyline already if (curve.TryGetPolyline(out Pline)) { PolylineCurve plinecurve = new PolylineCurve(Pline); //Segments = plinecurve.DuplicateSegments().ToList(); Segments = DuplicateSegments(plinecurve); } //Try to see if conversion will work if (curve.ToPolyline(mainSegmentCount, subSegmentCount, maxAngleRadians, maxChordLengthRatio, maxAspectRatio, tolerance, minEdgeLength, maxEdgeLength, keepStartPoint) != null) { //Convert PolylineCurve plinec = curve.ToPolyline(mainSegmentCount, subSegmentCount, maxAngleRadians, maxChordLengthRatio, maxAspectRatio, tolerance, minEdgeLength, maxEdgeLength, keepStartPoint); if (plinec.TryGetPolyline(out Pline)) { PolylineCurve plinecurve = new PolylineCurve(Pline); //Segments = plinecurve.DuplicateSegments().ToList(); Segments = DuplicateSegments(plinecurve); } } } }
public SilkwormSegment(Curve curve) { if (curve != null) { //See if curve can be represented as a polyline already if (curve.TryGetPolyline(out Pline)) { PolylineCurve plinecurve = new PolylineCurve(Pline); //Segments = plinecurve.DuplicateSegments().ToList(); Segments = DuplicateSegments(plinecurve); } //Try to see if conversion will work if (curve.ToPolyline(0, 0, 0.05, 0.1, 0, 0, 0.1, 0, true) != null) { //Convert PolylineCurve plinec = curve.ToPolyline(0, 0, 0.05, 0.1, 0, 0, 0.1, 0, true); if (plinec.TryGetPolyline(out Pline)) { PolylineCurve plinecurve = new PolylineCurve(Pline); //Segments = plinecurve.DuplicateSegments().ToList(); Segments = DuplicateSegments(plinecurve); } } } }
public static Polygon ToPolygon(this rg.Curve curve) { if (curve.IsPolyline() && curve is rg.PolylineCurve pcrv) { return(pcrv.ToPolyline().ToPolygon()); } return(curve.ToPolyline(0.01, 0.1, 0.1, 100).ToPolyline().ToPolygon()); // throw new ArgumentException("This curve is not a polygon, conversion will not continue"); }
public static Polyline ToPolyline(this rg.Curve curve) { if (curve.IsPolyline() && curve is rg.PolylineCurve pcrv) { return(pcrv.ToPolyline().ToPolyline()); } if (curve.TryGetPolyline(out rg.Polyline polyline)) { return(polyline.ToPolyline()); } return(curve.ToPolyline(0.01, 0.1, 0.1, 100).ToPolyline().ToPolyline()); }