Пример #1
0
        public static void Distribute(ref Apartment apartment /*ref ParkingLotOnEarth onEarth, ref ParkingLotUnderGround underGround*/)
        {
            int legalPark = apartment.GetLegalParkingLotofHousing();
            int tempPark  = apartment.ParkingLotOnEarth.ParkingLines[0].Count();

            if (tempPark < legalPark)
            {
                int required = legalPark - tempPark;
                //최소 10대 규모
                if (required < 10)
                {
                    required = 10;
                }
                UnderGroundParkingModule upm = new UnderGroundParkingModule(apartment.Plot.Boundary, required);
                bool canUnderGroundParking   = upm.CheckPrecondition();
                if (canUnderGroundParking)
                {
                    upm.Calculate();
                    ParkingLotUnderGround plug = new ParkingLotUnderGround((int)upm.EachFloorParkingCount * upm.Floors, upm.EachFloorArea * upm.Floors, upm.Floors);
                    apartment.ParkingLotUnderGround = plug;
                }
                else
                {
                    //beforeUnderGround;
                }
            }
            else
            {
                //beforeUnderGround;
            }
        }
Пример #2
0
        public Apartment Finilize()
        {
            //WriteLine("[{0}]Start Finalize",depth);
            ////far check
            //WriteLine("[{0}]FAR Check...", depth);
            if (IsSuitable())
            {
                //WriteLine("[{0}]FAR Enough...", depth);

                //WriteLine("[{0}]GP Check...", depth);
                //suit
                //ground parking enough
                //generate ground parking

                if (ParkingsEnough())
                {
                    //WriteLine("[{0}]GP Enough...", depth);
                    //WriteLine("[{0}]return value", depth);
                    return(apt);
                }
                else
                {
                    if (apt.AGtype == "PT-4")
                    {
                        return(Reduce(apt));
                    }

                    //WriteLine("[{0}]GP Lack...", depth);
                    ////can make undergroundparking
                    //WriteLine("[{0}]UGP Check...", depth);
                    UnderGroundParkingModule ugpm = new UnderGroundParkingModule(apt.Plot.Boundary, (int)ugpRequired);
                    bool canUGP = ugpm.CheckPrecondition();
                    bool isNull = (apt.AptLines.Count == 0) ? true : false;
                    if (canUGP && !isNull)
                    {
                        //UnderGroundParkingModule ...
                        //WriteLine("[{0}]UGP Creating", depth);
                        //WriteLine("[{0}]return value", depth);
                        bool ugpResult = ugpm.Calculate();
                        if (ugpResult)
                        {
                            Vector3d aptdir = Vector3d.Unset;
                            if (apt.AptLines.Count > 0)
                            {
                                for (int i = 0; i < apt.AptLines.Count; i++)
                                {
                                    aptdir = apt.AptLines[0].TangentAtStart;
                                    if (aptdir != Vector3d.Zero)
                                    {
                                        break;
                                    }
                                }
                            }
                            if (aptdir == Vector3d.Zero)
                            {
                                aptdir = Vector3d.Unset;
                            }

                            List <Curve> obstacles = new List <Curve>();
                            obstacles.AddRange(apt.Core[0].Select(n => n.DrawOutline()));
                            List <Curve> householdOutlines = new List <Curve>();
                            for (int i = 0; i < apt.Household[0].Count; i++)
                            {
                                for (int j = 0; j < apt.Household[0][i].Count; j++)
                                {
                                    Curve tempOutline = apt.Household[0][i][j].GetOutline();
                                    tempOutline.Translate(-Vector3d.ZAxis * tempOutline.PointAtStart.Z);
                                    householdOutlines.Add(tempOutline);
                                }
                            }
                            obstacles.AddRange(householdOutlines);
                            Curve ramp = ugpm.DrawRamp(apt.Plot, aptdir, obstacles);
                            if (ramp == null)
                            {
                                return(Reduce(apt));
                            }


                            apt.ParkingLotUnderGround      = new ParkingLotUnderGround((int)ugpm.EachFloorParkingCount * ugpm.Floors, ugpm.EachFloorArea * ugpm.Floors, ugpm.Floors);
                            apt.ParkingLotUnderGround.Ramp = ramp;

                            //overlap check & replace parkings (ref)
                            while (true)
                            {
                                bool overlapResult = ugpm.OverlapCheck(ref apt);
                                if (overlapResult)
                                {
                                    ramp = ugpm.DrawRamp(apt.Plot, aptdir, obstacles);
                                    apt.ParkingLotUnderGround.Ramp = ramp;
                                    //something changed
                                    //re finalize
                                }
                                else
                                {
                                    return(apt);//with new ugp
                                }
                            }
                        }
                        else
                        {
                            return(Reduce(apt));
                        }
                    }
                    else
                    {
                        //WriteLine("[{0}]UGP Impossible", depth);
                        //WriteLine("[{0}]return Reduced value", depth);
                        return(Reduce(apt));
                    }
                }
            }
            else
            {
                //WriteLine("[{0}]FAR Lack...", depth);
                //WriteLine("[{0}]Check SetBack...", depth);
                if (apt.AGtype == "PT-4")
                {
                    return(Reduce(apt));
                }

                if (setBacked)
                {
                    //WriteLine("[{0}]Can Set Back...", depth);
                    //WriteLine("[{0}]Set Back...", depth);
                    Apartment setBacked = SetBack(apt);
                    Finalizer fnz       = new Finalizer(setBacked, depth);
                    fnz.setBacked = true;
                    //set back and Recursive
                    //WriteLine("[{0}]return SetBack...", depth);
                    return(fnz.Finilize());
                }

                //if (!setBacked && !using1f)
                else if (using1f)
                {
                    ////WriteLine("[{0}]Can't Set Back...", depth);
                    ////WriteLine("[{0}]Check Using1F...", depth);
                    //if (!using1f)
                    //{
                    //WriteLine("[{0}]Can Using1F...", depth);
                    //WriteLine("[{0}]Using 1F...", depth);
                    //지상주차 계산도 다시 해야함.
                    Apartment using1f = Add1F(apt);
                    Finalizer fnz     = new Finalizer(using1f, depth);
                    fnz.using1f = true;
                    //use1f and Recursive
                    //WriteLine("[{0}]return Using 1F...", depth);
                    return(fnz.Finilize());
                    //}
                    //else
                    //{
                    //    //WriteLine("[{0}]can't do anything , return basic value", depth);
                    //    return apt;
                    //}
                }
            }

            Reduce(apt);
            return(apt);
        }