Ejemplo n.º 1
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
            Rectangle3d gardenBound = new Rectangle3d();
            Brep        carportGeom = new Brep();
            Point3d     accessPoint = new Point3d();

            //Get Data
            if (!DA.GetData(0, ref gardenBound))
            {
                return;
            }
            if (!DA.GetData(1, ref carportGeom))
            {
                return;
            }
            if (!DA.GetData(2, ref accessPoint))
            {
                return;
            }


            //Set properties
            PlotPlanning.ObjectModel.Carport carport = new ObjectModel.Carport();
            carport.AccessPoint = accessPoint;
            carport.CarportGeom = carportGeom;
            carport.GardenBound = gardenBound.ToPolyline();

            //Set data
            DA.SetData(0, carport);
        }
Ejemplo n.º 2
0
        //====================================================================//

        public static ObjectModel.Carport Clone(this ObjectModel.Carport carport)
        {
            return(new ObjectModel.Carport
            {
                AccessPoint = carport.AccessPoint,
                GardenBound = carport.GardenBound.Duplicate(),
                CarportGeom = carport.CarportGeom.Clone(),
            });
        }
        //====================================================================//

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

            return(IsInside(garden, bound));
        }
Ejemplo n.º 4
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)
        {
            //List<SingleFamily> houses = new List<SingleFamily>();
            List <IHouse> houses    = new List <IHouse>();
            Curve         bound     = new PolylineCurve();
            int           itts      = 1;
            int           seed      = 1;
            int           methodIdx = 1;
            List <Curve>  roads     = new List <Curve>();

            ObjectModel.Carport carport = new ObjectModel.Carport();

            //Get Data
            if (!DA.GetDataList(0, houses))
            {
                return;
            }
            if (!DA.GetData(1, ref bound))
            {
                return;
            }
            if (!DA.GetData(2, ref itts))
            {
                return;
            }
            if (!DA.GetData(3, ref seed))
            {
                return;
            }
            if (!DA.GetData(4, ref methodIdx))
            {
                return;
            }
            if (!DA.GetDataList(5, roads))
            {
                return;
            }
            if (!DA.GetData(6, ref carport))
            {
                return;
            }

            //set the method to the correct string
            string method = "";

            if (methodIdx == 0)
            {
                method = "random";
            }
            else if (methodIdx == 1)
            {
                method = "roads";
            }
            else if (methodIdx == 2)
            {
                method = "boundary";
            }
            else if (methodIdx == 3)
            {
                method = "shortest";
            }
            else if (methodIdx == 4)
            {
                method = "longest";
            }
            else if (methodIdx == 5)
            {
                method = "boundary first";
            }
            else
            {
                method = "random";
            }


            List <IHouse> houseList             = new List <IHouse>();
            List <ObjectModel.Carport> carports = new List <ObjectModel.Carport>();
            Random random        = new Random(seed);
            Curve  originalBound = bound;


            List <Curve> boundList = new List <Curve>()
            {
                bound
            };


            for (int i = 0; i < itts; i++)
            {
                int   idx = random.Next(boundList.Count);
                Curve c   = boundList[idx];
                boundList.RemoveAt(idx);

                (List <IHouse>, List <PolylineCurve>, List <ObjectModel.Carport>)objectTuple = Methods.Generate.IPlaceHouseRow(houses, c, originalBound, roads, random, method, carport);

                houseList.AddRange(objectTuple.Item1);
                boundList.AddRange(objectTuple.Item2);
                carports.AddRange(objectTuple.Item3);
                if (boundList.Count == 0)
                {
                    break;
                }
            }

            List <Curve> newRegions = boundList;

            //Set data for the outputs
            DA.SetDataList(0, houseList);
            DA.SetDataList(1, newRegions);
            DA.SetDataList(2, carports);
        }