Exemplo n.º 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);
        }
Exemplo n.º 2
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static double LongestSegment(BHG.Polyline pLine)
        {
            List <BHG.Point> pts    = pLine.DiscontinuityPoints();
            double           length = pts.Last().Distance(pts.First());

            for (int x = 0; x < pts.Count - 1; x++)
            {
                double dist = pts[x].Distance(pts[x + 1]);
                length = dist > length ? dist : length;
            }

            return(length);
        }
Exemplo n.º 3
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static double Orientation(IBuildingObject buildingPanel)
        {
            Panel panel = buildingPanel as Panel;

            BHG.Polyline pLine = new BHG.Polyline {
                ControlPoints = panel.PanelCurve.IControlPoints()
            };

            List <BHG.Point> pts = pLine.DiscontinuityPoints();

            BHG.Plane plane = BH.Engine.Geometry.Create.Plane(pts[0], pts[1], pts[2]); //Some protection on this needed maybe?

            BHG.Vector xyNormal = BH.Engine.Geometry.Create.Vector(0, 1, 0);

            return(BH.Engine.Geometry.Query.Angle(plane.Normal, xyNormal) * (180 / Math.PI));
        }