private void SliceElements() { List <string> meshLayers = new List <string>() { "HANG", "WALL-N", "WALL-S", "WALL-E", "WALL-W" }; Orientation orientation = Orientation.Ceiling; foreach (string layer in meshLayers) { List <Mesh> meshes = SelectMeshes(layer, ReferencePlane); meshes = NearFragments(meshes); switch (layer) { case "HANG": orientation = Orientation.Ceiling; break; case "WALL-N": orientation = Orientation.SideNorth; break; case "WALL-S": orientation = Orientation.SideSouth; break; case "WALL-E": orientation = Orientation.SideEast; break; case "WALL-W": orientation = Orientation.SideWest; break; default: orientation = Orientation.Ceiling; break; } if (layer == "WALL-E" || layer == "WALL-W") { List <Mesh> splits = new List <Mesh>(); foreach (Mesh m in meshes) { if (m.Faces.Count == 0) { continue; } List <Mesh> refFrags = SelectMeshes("columnRef", ReferencePlane); Mesh refMesh = new Mesh(); refMesh.Append(m); refMesh.Append(refFrags); OrientedBox oBox = CaveTools.FindOrientedBox(ReferencePlane, refMesh, parameters.yCell); splits.AddRange(WallSplit3(oBox, m, refFrags)); } meshes = splits; } foreach (Mesh m in meshes) { if (m.Faces.Count == 0) { continue; } CaveElement element = new CaveElement(m, ReferencePlane, orientation, parameters); caveElements.Add(element); } } }
private void MeshToPanels() { double cellSize = parameters.zCell; double boxDim = orientedBox.zDim; if (orientation == Orientation.Ceiling) { cellSize = parameters.xCell; boxDim = orientedBox.xDim; } int panelNum = 0; double cumulativeDim = 0; Point3d p1 = orientationPlane.Origin; Point3d p2 = orientationPlane.Origin + orientationPlane.XAxis * cellSize; double xPanel = cellSize; double yPanel = parameters.yCell; if (orientation == Orientation.SideWest || orientation == Orientation.SideEast) { yPanel = orientedBox.xDim; } bool lastPanel = false; Mesh panel = new Mesh(); while (cumulativeDim < boxDim) { Plane cut1 = new Plane(p1, orientationPlane.XAxis); Plane cut2 = new Plane(p2, orientationPlane.XAxis * -1); Plane local = new Plane(p1, orientationPlane.XAxis, orientationPlane.YAxis); //area check double panelArea = 0; panel = FindPanelByArea(cut1, ref cut2, xPanel, ref panelArea); //RhinoDoc.ActiveDoc.Objects.AddMesh(panel); if (lastPanel) { AreaMassProperties amp = AreaMassProperties.Compute(panel); panelArea = amp.Area; xPanel = boxDim - orientationPlane.Origin.DistanceTo(p1); if (xPanel < parameters.cellMin) { //try and combine with previous if (panelFrames[panelNum - 1].panelArea + panelArea < 9e6 && xPanel + panelFrames[panelNum - 1].xdim < parameters.xCell + parameters.cellMin) { p1 = panelFrames[panelNum - 1].refPlane.Origin; local = new Plane(p1, orientationPlane.XAxis, orientationPlane.YAxis); cut1 = new Plane(p1, orientationPlane.XAxis); cut2 = new Plane(p2, orientationPlane.XAxis * -1); panel = FindPanelByArea(cut1, ref cut2, xPanel, ref panelArea); OrientedBox panelBox = CaveTools.FindOrientedBox(BayXY, panel, parameters.yCell); xPanel = panelBox.zDim; if (orientation == Orientation.Ceiling) { xPanel = panelBox.xDim; } // panelFrames.RemoveAt(panelNum - 1); } else { //split last two panels equally xPanel = (panelFrames[panelNum - 1].xdim + xPanel) / 2; p1 = panelFrames[panelNum - 1].refPlane.Origin; local = new Plane(p1, orientationPlane.XAxis, orientationPlane.YAxis); cut1 = new Plane(p1, orientationPlane.XAxis); p2 = p1 + orientationPlane.XAxis * xPanel; cut2 = new Plane(p2, orientationPlane.XAxis * -1); panel = SelectClosestPanel(CaveTools.splitTwoPlanes(cut1, cut2, mesh), orientationPlane); cumulativeDim -= panelFrames[panelNum - 1].xdim; panelFrames.RemoveAt(panelNum - 1); lastPanel = false; } } } else { xPanel = cut1.Origin.DistanceTo(cut2.Origin); } cumulativeDim += xPanel; panelFrames.Add(new PanelFrame(local, xPanel, parameters, panel, panelNum, yPanel)); if (lastPanel) { break; } //set p1 and p2 for next panel p1 = cut2.Origin; p2 = p1 + orientationPlane.XAxis * cellSize; if (orientationPlane.Origin.DistanceTo(p2) >= boxDim) { lastPanel = true; } panelNum++; } }