예제 #1
0
        public static BHX.Polyloop ToGBXML(this BHG.Polyline pLine, GBXMLSettings settings, double tolerance = BHG.Tolerance.Distance)
        {
            BHX.Polyloop polyloop = new BHX.Polyloop();

            pLine = pLine.CleanPolyline(minimumSegmentLength: tolerance);

            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(settings);
                List <string>      coord = new List <string>();
                cartpoint.Add(cpt);
            }
            polyloop.CartesianPoint = cartpoint.ToArray();
            return(polyloop);
        }
예제 #2
0
        public static BHG.Polyline FromGBXML(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].FromGBXML());
            }

            if (bhomPts.First().SquareDistance(bhomPts.Last()) > (tolerance * tolerance))
            {
                bhomPts.Add(bhomPts.First());
            }

            pLine.ControlPoints = bhomPts;
            return(pLine);
        }