//====================================================================// public static ObjectModel.Carport Move(Carport carport, Vector3d vector) { Carport movedCarport = carport.Clone(); Transform t = Transform.Translation(vector); movedCarport.GardenBound.Transform(t); movedCarport.CarportGeom.Transform(t); movedCarport.AccessPoint += new Point3d(vector); return(movedCarport); }
//====================================================================// public static ObjectModel.Carport Translate(Carport carport, Point3d boundPt, Vector3d tan) { Point3d basePt = carport.AccessPoint; Line accessLine = Query.ClosestSegmentToPoint(basePt, carport.GardenBound); Vector3d accessVec = Compute.CreateVector(accessLine.To, accessLine.From); Carport movedCarport = carport.Clone(); Transform t = Transform.Translation(Compute.CreateVector(basePt, boundPt)); Transform r = Transform.Rotation(accessVec, tan, boundPt); movedCarport.GardenBound.Transform(t); movedCarport.GardenBound.Transform(r); movedCarport.CarportGeom.Transform(t); movedCarport.CarportGeom.Transform(r); movedCarport.AccessPoint = boundPt; return(movedCarport); }
//====================================================================// public static List <Point3d> PossiblePoints(Line line, MultiFamily house, Random random, Carport carport) //we want to have carport as an optional parameter later { Polyline houseGardenBoundary = house.GardenBound; Point3d houseAccessPt = house.AccessPoint; double lineLength = line.Length; double houseWidth = Query.ClosestSegmentToPoint(houseAccessPt, houseGardenBoundary).Length; Point3d startPt = line.From; Vector3d vec = (line.Direction) / lineLength; Vector3d husVec = vec * houseWidth; List <Point3d> pointPos = new List <Point3d>(); Point3d currPt = startPt; double currLength = houseWidth; Line currLine = new Line(); int i = 0; while (currLength < lineLength) { currLine = new Line(currPt, husVec); currPt = currLine.To; pointPos.Add(currPt); currLength += houseWidth; i++; if (i == house.MaxAmount) { break; } } Vector3d move_vec = random.NextDouble() * (lineLength - currLength) * vec.Normalise(); List <Point3d> move_pts = new List <Point3d>(); foreach (Point3d p in pointPos) { move_pts.Add(Point3d.Add(p, move_vec)); } return(move_pts); }
//====================================================================// public static (List <IHouse>, List <PolylineCurve>, List <Carport>) PlaceHouseRow(List <MultiFamily> baseHouses, Curve bound, Curve originalBound, List <Curve> roads, Random random, string method, Carport carport) { List <MultiFamily> houseList = new List <MultiFamily>(); List <Carport> carportList = new List <Carport>(); List <PolylineCurve> cutBound = new List <PolylineCurve>(); MultiFamily baseHouse = baseHouses[random.Next(baseHouses.Count)]; //1. pick house type to place //2. Get boundaries. bound.TryGetPolyline(out Polyline boundPL); List <Line> lines = SegmentBounds(boundPL.ClosePolyline(), baseHouse); if (lines.Count == 0) { goto end; } Line currLine = lines.PickLine(method, random, roads, originalBound); currLine.Extend(-Tolerance.FilletOffset, -Tolerance.FilletOffset); List <Point3d> possiblePts = PossiblePoints(currLine, baseHouse, random, carport); //3. Place houses for each position for (int i = 0; i < possiblePts.Count; i++) { MultiFamily movedHouse = Adjust.Translate(baseHouse, possiblePts[i], currLine.Direction); if (Query.IsInside(movedHouse, bound)) { houseList.Add(movedHouse); } else if (houseList.Count != 0) //already places houses { break; } } end: if (houseList.Count >= baseHouse.MinAmount) { cutBound = UpdateBoundaries(houseList, baseHouse, bound); //TODO: Include carport } else { cutBound = new List <PolylineCurve>() { bound.ToPolylineCurve() }; houseList = new List <MultiFamily>(); carportList = new List <Carport>(); } List <IHouse> IHouseList = houseList.Cast <IHouse>().ToList(); return(IHouseList, cutBound, carportList); }
public static (List <IHouse>, List <PolylineCurve>, List <Carport>) IPlaceHouseRow(List <IHouse> baseHouses, Curve bound, Curve originalBound, List <Curve> roads, Random random, string method, Carport carport) { if (baseHouses[0].GetType() == new SingleFamily().GetType()) //TODO: Replace this if statement with interface method { return(PlaceHouseRow(baseHouses.Cast <SingleFamily>().ToList(), bound, originalBound, roads, random, method, carport)); } else { return(PlaceHouseRow(baseHouses.Cast <MultiFamily>().ToList(), bound, originalBound, roads, random, method, carport)); } }
public CarRepository() { _carport = new Carport(); }