public static BHX.Polyloop ToGBXML(this BHG.Polyline pLine, double tolerance = BHG.Tolerance.Distance) { BHX.Polyloop polyloop = new BHX.Polyloop(); pLine = pLine.CleanPolyline(); List <BHG.Point> pts = pLine.DiscontinuityPoints(); if (pts.Count == 0) { return(polyloop); } int count = ((pts.First().SquareDistance(pts.Last()) < (tolerance * tolerance)) ? pts.Count - 1 : pts.Count); List <BHX.CartesianPoint> cartpoint = new List <BHX.CartesianPoint>(); for (int i = 0; i < count; i++) { BHX.CartesianPoint cpt = pts[i].ToGBXML(); List <string> coord = new List <string>(); cartpoint.Add(cpt); } polyloop.CartesianPoint = cartpoint.ToArray(); return(polyloop); }
public static BHG.Polyline ToBHoM(this BHX.Polyloop pLoop, double tolerance = BHG.Tolerance.Distance) { BHG.Polyline pLine = new BHG.Polyline(); List <BHX.CartesianPoint> pts = pLoop.CartesianPoint.ToList(); List <BHG.Point> bhomPts = new List <BHG.Point>(); for (int x = 0; x < pts.Count; x++) { bhomPts.Add(pts[x].ToBHoM()); } if (bhomPts.First().SquareDistance(bhomPts.Last()) > (tolerance * tolerance)) { bhomPts.Add(bhomPts.First()); } pLine.ControlPoints = bhomPts; return(pLine); }