Example #1
0
        //====================================================================//
        public static List <Line> SegmentBounds(Polyline siteBound, ObjectModel.MultiFamily house)
        {
            double   minAmount = house.MinAmount;
            Polyline pline     = house.GardenBound;
            Point3d  pt        = house.AccessPoint;

            //Check if clockwise
            if (!Query.IsClockwise(siteBound, new Vector3d(0, 0, -1)))
            {
                siteBound.Reverse();
            }

            List <double> lengths  = new List <double>();
            List <Line>   segments = new List <Line>();

            double gardenLength = Query.ClosestSegmentToPoint(pt, pline).Length;

            foreach (var segm in siteBound.GetSegments())
            {
                if (segm.Length > gardenLength * minAmount)
                {
                    segments.Add(segm);
                }
            }

            List <Line> shuffledSegments = segments.OrderBy(x => x.Length).ToList();

            return(shuffledSegments);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //Create class instances
            ObjectModel.MultiFamily MFH = new ObjectModel.MultiFamily();

            //Get Data
            if (!DA.GetData(0, ref MFH))
            {
                return;
            }

            //Calculate (shapeFactor = envelopArea/Atemp). Only works for breps with the same floor geometry on every floor.
            double envelopArea = AreaMassProperties.Compute(MFH.HouseGeom).Area;

            Rhino.Geometry.Collections.BrepFaceList faces = MFH.HouseGeom.Faces;
            double floorArea = 0;

            foreach (var face in faces)
            {
                if (face.NormalAt(0.5, 0.5) == new Vector3d(0, 0, -1))
                {
                    floorArea = AreaMassProperties.Compute(face).Area;
                }
                ;
            }

            double shapefactor = envelopArea / (floorArea * MFH.Floors); //Should be the actual number of floors.


            //Set data
            DA.SetData(0, shapefactor);
        }
        //====================================================================//

        public static ObjectModel.MultiFamily Clone(this ObjectModel.MultiFamily house)
        {
            return(new ObjectModel.MultiFamily
            {
                Type = house.Type,
                GardenBound = house.GardenBound.Duplicate(),
                HouseGeom = house.HouseGeom.Clone(),
                Orientation = new Vector3d(house.Orientation),
                AccessPoint = house.AccessPoint.Clone(),
                MinAmount = house.MinAmount,
                MaxAmount = house.MaxAmount,
                Offset = house.Offset,
                MidPoint = house.MidPoint.Clone(),
            });
        }
        //====================================================================//

        public static bool IsInside(ObjectModel.MultiFamily mfh, Curve bound)
        {
            Curve garden = Curve.CreateControlPointCurve(mfh.GardenBound.ToList(), 1);

            return(IsInside(garden, bound));
        }
Example #5
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //Create class instances
            Curve       centreCrv   = new PolylineCurve();
            int         floors      = 1;
            double      thickness   = 1;
            double      levelHeight = 1;
            Rectangle3d garden      = new Rectangle3d();
            Point3d     accessPt    = new Point3d();

            //Get Data
            if (!DA.GetData(0, ref centreCrv))
            {
                return;
            }
            if (!DA.GetData(1, ref floors))
            {
                return;
            }
            if (!DA.GetData(2, ref thickness))
            {
                return;
            }
            if (!DA.GetData(3, ref levelHeight))
            {
                return;
            }
            if (!DA.GetData(4, ref garden))
            {
                return;
            }
            if (!DA.GetData(5, ref accessPt))
            {
                return;
            }


            //Set properties
            PlotPlanning.ObjectModel.MultiFamily house = new ObjectModel.MultiFamily();
            house.Floors      = floors;
            house.Thickness   = thickness;
            house.LevelHeight = levelHeight;
            house.GardenBound = garden.ToPolyline();
            house.AccessPoint = accessPt;

            //Create geometry.
            Brep[] b = Engine.Geometry.Compute.Sweep(centreCrv, thickness, 2);

            //Get and join all brep edges
            Curve[] En    = b[0].DuplicateNakedEdgeCurves(true, true);
            Curve[] bound = Curve.JoinCurves(En);

            // TODO: make sure all the bounding curves are clockwise. This is to ensure extrution in the correct diection
            // For now I used a neg sign before extrution height....
            Extrusion ex = Extrusion.Create(bound[0], -levelHeight * floors, true);

            if (centreCrv.IsClosed)
            {
                //Sort profiles by length. The longer curve will be the outer profile. The shorter the inner.
                Curve     innerCrv = bound.ToList().OrderBy(x => x.GetLength()).First();
                Extrusion exInner  = Extrusion.Create(innerCrv, levelHeight * floors, true);
                Brep[]    diff     = Brep.CreateBooleanDifference(ex.ToBrep(), exInner.ToBrep(), ObjectModel.Tolerance.Distance);
                house.HouseGeom = diff[0];
            }
            else
            {
                house.HouseGeom = ex.ToBrep();
            }


            //Set data
            DA.SetData(0, house);
        }