示例#1
0
        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);
        }
示例#2
0
        public static BHG.Point ToBHoM(this BHX.CartesianPoint pt)
        {
            BHG.Point bhomPt = new BHG.Point();
            try
            {
                bhomPt.X = (pt.Coordinate.Length >= 1 ? System.Convert.ToDouble(pt.Coordinate[0]) : 0);
                bhomPt.Y = (pt.Coordinate.Length >= 2 ? System.Convert.ToDouble(pt.Coordinate[1]) : 0);
                bhomPt.Z = (pt.Coordinate.Length >= 3 ? System.Convert.ToDouble(pt.Coordinate[2]) : 0);
            }
            catch { }

            return(bhomPt);
        }
示例#3
0
        public static BHX.CartesianPoint ToGBXML(this BHG.Point pt)
        {
            BHX.CartesianPoint cartPoint = new BHX.CartesianPoint();
            List <string>      coord     = new List <string>();

            coord.Add(Math.Round(pt.X, 4).ToString());
            coord.Add(Math.Round(pt.Y, 4).ToString());
            coord.Add(Math.Round(pt.Z, 4).ToString());

            cartPoint.Coordinate = coord.ToArray();

            return(cartPoint);
        }