private static bool CheckRoadCenterMeetStreet(Apartment agOutput) { if (agOutput.AGtype == "PT-4") { return(true); } List <Curve> roadCenterCurve = new List <Curve>(); List <ParkingLineMaker.ParkingLotType> parkingLotTypes = new List <ParkingLineMaker.ParkingLotType>(); double Angle; Curve centerCurve = new LineCurve(Point3d.Origin, Point3d.Origin); if (agOutput.AptLines.Count() != 0) { centerCurve = agOutput.AptLines[0]; } ParkingLineMaker.parkingLineMaker(agOutput.AGtype, agOutput.Core, agOutput.Plot, agOutput.ParameterSet.Parameters[2], centerCurve, out parkingLotTypes, out roadCenterCurve, out Angle); Polyline plotBoundaryPolyline; agOutput.Plot.Boundary.TryGetPolyline(out plotBoundaryPolyline); plotBoundaryPolyline = new Polyline(new List <Point3d>(plotBoundaryPolyline)); for (int i = 0; i < roadCenterCurve.Count(); i++) { var tempIntersection = Rhino.Geometry.Intersect.Intersection.CurveCurve(plotBoundaryPolyline.ToNurbsCurve(), roadCenterCurve[i], 0, 0); if (tempIntersection.Count() != 0) { bool tempIsMeetStreet = false; for (int j = 0; j < tempIntersection.Count(); j++) { if (agOutput.Plot.Surroundings[(int)tempIntersection[j].ParameterA] >= 4) { tempIsMeetStreet = true; } } if (tempIsMeetStreet == false) { return(false); } } } return(true); }
public static List <Apartment> finalizeAGoutput(Apartment agOutput, double LegalFloorAreaRatio, double LegalBuildingCoverage, bool onlyCreateUnderGround) { Apartment tempBasicAgOutput = agOutput; /* * if(IsRoadCenterMeetStreet(agOutput)) * agOutput.Plot.Boundary = OffsetBoundaryToMakeRoad(agOutput.Plot.Boundary, agOutput.Plot.Surroundings); */ if (agOutput.Plot.GetArea() / 1000000 / 3.3 >= 300 || onlyCreateUnderGround == true) { List <double> reducePercentage = new List <double>(new double[] { 0, 5, 10 }); List <Curve> roadCenterCurve = new List <Curve>(); List <ParkingLineMaker.ParkingLotType> parkingLotTypes = new List <ParkingLineMaker.ParkingLotType>(); double Angle; Curve centerCurve = new LineCurve(Point3d.Origin, Point3d.Origin); if (agOutput.AptLines.Count() != 0) { centerCurve = agOutput.AptLines[0]; } ParkingLineMaker.parkingLineMaker(agOutput.AGtype, agOutput.Core, agOutput.Plot, agOutput.ParameterSet.Parameters[2], centerCurve, out parkingLotTypes, out roadCenterCurve, out Angle); bool IsRoadCenterMeetStreet = CheckRoadCenterMeetStreet(agOutput); Curve Boundary = agOutput.Plot.Boundary; if (IsRoadCenterMeetStreet == false && agOutput.AGtype != "PT-4") { Curve tempBoundary = Boundary; Polyline tempBoundaryPolyline; tempBoundary.TryGetPolyline(out tempBoundaryPolyline); Boundary = CreateRoadClass.createRoad(tempBoundaryPolyline, Angle).ToNurbsCurve(); } List <Apartment> tempApartmentSet = duplicateAndReduceAGoutput(agOutput, reducePercentage); List <Apartment> outputApartmentSet = new List <Apartment>(); for (int i = 0; i < tempApartmentSet.Count(); i++) { List <Curve> tempRoadCenterCurve = new List <Curve>(); List <ParkingLineMaker.ParkingLotType> tempParkingLotTypes = new List <ParkingLineMaker.ParkingLotType>(); double tempAngle; Curve tempCenterCurve = new LineCurve(Point3d.Origin, Point3d.Origin); if (tempApartmentSet[i].AptLines.Count() != 0) { tempCenterCurve = tempApartmentSet[i].AptLines[0]; } List <List <ParkingLine> > tempParkingLines = ParkingLineMaker.parkingLineMaker(tempApartmentSet[i].AGtype, tempApartmentSet[i].Core, new Plot(Boundary, agOutput.Plot.Surroundings), agOutput.ParameterSet.Parameters[2], tempCenterCurve, out tempParkingLotTypes, out tempRoadCenterCurve, out tempAngle); int tempParkingLotCount = 0; foreach (List <ParkingLine> j in tempParkingLines) { tempParkingLotCount += j.Count(); } List <List <ParkingLine> > tempParkingLineCopy = new List <List <ParkingLine> >(tempParkingLines); Curve tempRamp = (new Rectangle3d()).ToNurbsCurve(); bool IsRampAvailable = CreateUnderGroundParking_Ramp(ref tempParkingLines, ref tempParkingLotTypes, ref tempRamp); int tempMaxParkingLotOnEarth = 0; for (int j = 0; j < tempParkingLineCopy.Count(); j++) { tempMaxParkingLotOnEarth += tempParkingLineCopy[j].Count(); } if (IsRampAvailable == true) { tempParkingLines = tempParkingLineCopy; List <Household> tempHouseholdOnSecondFloor = new List <Household>(); for (int j = 0; j < tempApartmentSet[i].Household.Count(); j++) { if (tempApartmentSet[i].Household[j].Count != 0) { tempHouseholdOnSecondFloor.AddRange(tempApartmentSet[i].Household[j][0]); } } double tempGrossAreaRemain = tempApartmentSet[i].Plot.GetArea() * (LegalFloorAreaRatio / 100) - tempApartmentSet[i].GetGrossArea(); double tempBuildingAreaRemain = tempApartmentSet[i].Plot.GetArea() * (LegalBuildingCoverage / 100) - tempApartmentSet[i].GetBuildingArea(); List <NonResidential> tempCommercials = new List <NonResidential>(); if (i != 0) { tempCommercials = CreateCommercial(ref tempParkingLines, tempHouseholdOnSecondFloor, ref tempGrossAreaRemain, ref tempBuildingAreaRemain); } int tempParkingLinesCount = 0; for (int j = 0; j < tempParkingLines.Count(); j++) { tempParkingLinesCount += tempParkingLines[j].Count(); } tempApartmentSet[i].ParkingLotOnEarth = new ParkingLotOnEarth(tempParkingLines); tempApartmentSet[i].Commercial = tempCommercials; int tempNeededParkingLotUnderGround = tempApartmentSet[i].GetLegalParkingLotofHousing(); tempNeededParkingLotUnderGround += tempApartmentSet[i].GetLegalParkingLotOfCommercial(); tempNeededParkingLotUnderGround -= tempApartmentSet[i].ParkingLotOnEarth.GetCount(); double UnderGroundFloor = (double)tempNeededParkingLotUnderGround / (double)tempMaxParkingLotOnEarth; double UnderGroundArea = agOutput.Plot.GetArea() * UnderGroundFloor; if (UnderGroundFloor % 1 != 0) { UnderGroundFloor = (int)UnderGroundFloor + 1; } if (tempNeededParkingLotUnderGround > tempParkingLinesCount) { tempApartmentSet[i].ParkingLotUnderGround = new ParkingLotUnderGround(tempNeededParkingLotUnderGround, UnderGroundArea, (int)UnderGroundFloor); } else { tempApartmentSet[i].ParkingLotUnderGround = new ParkingLotUnderGround(); } outputApartmentSet.Add(tempApartmentSet[i]); } else { List <List <ParkingLine> > tempParkingline = ParkingLineMaker.parkingLineMaker(tempApartmentSet[i].AGtype, tempApartmentSet[i].Core, new Plot(Boundary, agOutput.Plot.Surroundings), agOutput.ParameterSet.Parameters[2], tempCenterCurve, out tempParkingLotTypes, out tempRoadCenterCurve, out tempAngle); List <Household> tempHouseholdOnSecondFloor = new List <Household>(); for (int j = 0; j < tempApartmentSet[i].Household.Count(); j++) { if (tempApartmentSet[i].Household[j].Count != 0) { tempHouseholdOnSecondFloor.AddRange(tempApartmentSet[i].Household[j][0]); } } double tempGrossAreaRemain = tempApartmentSet[i].Plot.GetArea() * (LegalFloorAreaRatio / 100) - tempApartmentSet[i].GetGrossArea(); double tempBuildingAreaRemain = tempApartmentSet[i].Plot.GetArea() * (LegalBuildingCoverage / 100) - tempApartmentSet[i].GetBuildingArea(); List <NonResidential> tempCommercials = new List <NonResidential>(); if (i != 0) { tempCommercials = CreateCommercial(ref tempParkingline, tempHouseholdOnSecondFloor, ref tempGrossAreaRemain, ref tempBuildingAreaRemain); } int tempParkingLinesCount = 0; for (int j = 0; j < tempParkingline.Count(); j++) { tempParkingLinesCount += tempParkingline[j].Count(); } tempApartmentSet[i].ParkingLotOnEarth = new ParkingLotOnEarth(tempParkingline); tempApartmentSet[i].Commercial = tempCommercials; int tempNeededParkingLot = tempApartmentSet[i].GetLegalParkingLotofHousing(); tempNeededParkingLot += tempApartmentSet[i].GetLegalParkingLotOfCommercial(); outputApartmentSet.Add(tempApartmentSet[i]); } } return(outputApartmentSet); } else { List <double> reducePercentage = new List <double>(new double[] { 0, 5 }); List <Curve> roadCenterCurve = new List <Curve>(); List <ParkingLineMaker.ParkingLotType> parkingLotTypes = new List <ParkingLineMaker.ParkingLotType>(); double Angle; Curve centerCurve = new LineCurve(Point3d.Origin, Point3d.Origin); if (agOutput.AptLines.Count() != 0) { centerCurve = agOutput.AptLines[0]; } ParkingLineMaker.parkingLineMaker(agOutput.AGtype, agOutput.Core, agOutput.Plot, agOutput.ParameterSet.Parameters[2], centerCurve, out parkingLotTypes, out roadCenterCurve, out Angle); bool IsRoadCenterMeetStreet = CheckRoadCenterMeetStreet(agOutput); Curve Boundary = agOutput.Plot.Boundary; if (IsRoadCenterMeetStreet == false) { Curve tempBoundary = Boundary; Polyline tempBoundaryPolyline; tempBoundary.TryGetPolyline(out tempBoundaryPolyline); Boundary = CreateRoadClass.createRoad(tempBoundaryPolyline, Angle).ToNurbsCurve(); } List <Apartment> tempApartmentSet = duplicateAndReduceAGoutput(agOutput, reducePercentage); List <Apartment> outputApartmentSet = new List <Apartment>(); List <ParkingLineMaker.ParkingLotType> tempParkingLotTypes; List <Curve> tempRoadCenterCurve; double tempAngle; tempApartmentSet[0].ParkingLotOnEarth = new ParkingLotOnEarth(ParkingLineMaker.parkingLineMaker(agOutput.AGtype, agOutput.Core, agOutput.Plot, agOutput.ParameterSet.Parameters[2], centerCurve, out tempParkingLotTypes, out tempRoadCenterCurve, out tempAngle)); outputApartmentSet.Add(tempApartmentSet[0]); for (int i = 1; i < tempApartmentSet.Count(); i++) { List <List <ParkingLine> > tempParkingline = ParkingLineMaker.parkingLineMaker(agOutput.AGtype, agOutput.Core, agOutput.Plot, agOutput.ParameterSet.Parameters[2], centerCurve, out tempParkingLotTypes, out tempRoadCenterCurve, out tempAngle); List <Household> tempHouseholdOnSecondFloor = new List <Household>(); for (int j = 0; j < tempApartmentSet[i].Household.Count(); j++) { if (tempApartmentSet[i].Household[j].Count != 0) { tempHouseholdOnSecondFloor.AddRange(tempApartmentSet[i].Household[j][0]); } } double tempGrossAreaRemain = tempApartmentSet[i].Plot.GetArea() * (LegalFloorAreaRatio / 100) - tempApartmentSet[i].GetGrossArea(); double tempBuildingAreaRemain = tempApartmentSet[i].Plot.GetArea() * (LegalBuildingCoverage / 100) - tempApartmentSet[i].GetBuildingArea(); List <NonResidential> tempCommercials = new List <NonResidential>(); if (i != 0) { tempCommercials = CreateCommercial(ref tempParkingline, tempHouseholdOnSecondFloor, ref tempGrossAreaRemain, ref tempBuildingAreaRemain); } int tempParkingLinesCount = 0; for (int j = 0; j < tempParkingline.Count(); j++) { tempParkingLinesCount += tempParkingline[j].Count(); } tempApartmentSet[i].ParkingLotOnEarth = new ParkingLotOnEarth(tempParkingline); tempApartmentSet[i].Commercial = tempCommercials; outputApartmentSet.Add(tempApartmentSet[i]); } return(outputApartmentSet); } }