예제 #1
0
        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);
                    }
                }

            }
        }
예제 #2
0
        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);

                    }
                    }

            }
        }
예제 #3
0
 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");
 }
예제 #4
0
        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());
        }