public static List <Brep> OptimalFloorSpaceConfiguration(List <Brep> validFloorRegions, TestFitPackage tf) { Curve perimeterCurve = tf.FloorPlanPackage.FloorProfile; Curve coreCurve = tf.FloorPlanPackage.CoreProfile; List <Brep> zonesToSlice = new List <Brep>(); List <Brep> optimizedZones = new List <Brep>(); //Identify zones with irregular proximity or shape. foreach (Brep region in validFloorRegions) { bool intersectsPerimeter = Confirm.CurveRegionIntersection(perimeterCurve, region); bool intersectsCore = Confirm.CurveRegionIntersection(coreCurve, region); if (intersectsPerimeter && intersectsCore) { zonesToSlice.Add(region); } else { optimizedZones.Add(region); } } //Cut them into more manageable pieces. List <Curve> splitterCurves = Select.BestSplitterCurves(zonesToSlice, tf.FloorPlanPackage.CirculationAxisCurves, tf.FloorPlanPackage.CoreProfile); for (int i = 0; i < zonesToSlice.Count; i++) { List <Brep> splitBreps = Breps.SplitByCurve(zonesToSlice[i], splitterCurves[i]); foreach (Brep zone in splitBreps) { optimizedZones.Add(zone); } } //Identify donut zones (zones with a hole in the middle). for (int i = optimizedZones.Count - 1; i >= 0; i--) { bool isNotDonut = Confirm.RegionIsNotDonut(optimizedZones[i]); //Cut up the donuts. if (!isNotDonut) { List <Curve> donutSplitCurves = Select.DonutSplittingCurves(optimizedZones[i]); foreach (Curve crv in donutSplitCurves) { //RhinoDoc.ActiveDoc.Objects.AddCurve(crv); } List <Brep> unDonutZones = Breps.SplitByCurves(optimizedZones[i], donutSplitCurves); optimizedZones.RemoveAt(i); foreach (Brep newZone in unDonutZones) { optimizedZones.Add(newZone); } } } return(optimizedZones); }