public void AddStalactiteSupport(CaveElement caveElement) { //find points in bay Plane pln1 = new Plane(caveElement.BayXY.Origin - caveElement.BayXY.YAxis, caveElement.BayXY.YAxis); Plane pln2 = new Plane(caveElement.BayXY.Origin + caveElement.BayXY.YAxis * 3000, caveElement.BayXY.YAxis * -1); List <Point3d> bayMinima = CaveTools.PointsInsidePlane(minima, pln1, pln2); foreach (PanelFrame panelFrame in caveElement.panelFrames) { SetHangers(panelFrame, bayMinima); } }
private Mesh midSection() { Plane plane1 = OrientedBox.FaceOffsetPlane(bayBoundary.SideXmax, 2500); plane1.Flip(); Plane plane2 = OrientedBox.FaceOffsetPlane(bayBoundary.SideXmin, 2000); plane2.Flip(); Mesh ceiling = CaveTools.splitTwoPlanes(plane1, plane2, slice); //RhinoDoc.ActiveDoc.Objects.AddMesh(ceiling); return(ceiling); }
private void RemoveCloseIntersects() { //compare to each other and keep those within min spacing List <Point3d> cleaned = new List <Point3d>(); cleaned.Add(interpts[0]); for (int i = 1; i < interpts.Count; i++) { Point3d closest = CaveTools.ClosestPoint(interpts[i], cleaned); if (closest.DistanceTo(interpts[i]) > parameters.cellGap / 4) { cleaned.Add(interpts[i]); } } interpts = cleaned; }
private Point3d FindConnectionPoint(Point3d refPoint) { Point3d connection = new Point3d(); if (orientation == Orientation.Ceiling) { connection = CaveTools.ClosestProjected(breps, refPoint, orientationPlane.Normal * -1); } else { connection = CaveTools.ClosestPoint(centreLines, refPoint, orientationPlane); //Plane testPlane = new Plane(connection, orientationPlane.Normal); //double dist1 = refPoint.DistanceTo(testPlane.ClosestPoint(refPoint)); //connection = refPoint - orientationPlane.Normal * dist1; } return(connection); }
public void ConnectToEnvelope(List <PanelFrame> panelFrames) { for (int i = 0; i < panelFrames.Count; i++) { if (i < panelFrames.Count - 1) { if (!panelFrames[i + 1].FailedFrame) { Line b1 = SetHangerAssembly(panelFrames[i].cornerStub[2].stubEnd, panelFrames[i + 1].cornerStub[0].stubEnd, ref hangerA); UpdateStubs(panelFrames[i].cornerStub[2], panelFrames[i + 1].cornerStub[0], b1); Line b2 = SetHangerAssembly(panelFrames[i].cornerStub[3].stubEnd, panelFrames[i + 1].cornerStub[1].stubEnd, ref hangerB); UpdateStubs(panelFrames[i].cornerStub[3], panelFrames[i + 1].cornerStub[1], b2); } if (i > 0) { if (panelFrames[i - 1].FailedFrame) { SimpleHanger(panelFrames[i].cornerStub[0].stubEnd, ref hangerA); SimpleHanger(panelFrames[i].cornerStub[1].stubEnd, ref hangerB); } } } if (i == 0) { SimpleHanger(panelFrames[i].cornerStub[0].stubEnd, ref hangerA); SimpleHanger(panelFrames[i].cornerStub[1].stubEnd, ref hangerB); } if (i == panelFrames.Count - 1) { SimpleHanger(panelFrames[i].cornerStub[2].stubEnd, ref hangerA); SimpleHanger(panelFrames[i].cornerStub[3].stubEnd, ref hangerB); } CaveTools.CheckLines(panelFrames[i].cornerStub.Select(x => x.Stub).ToList()); } CaveTools.CheckLines(hangerA); CaveTools.CheckLines(hangerB); CaveTools.CheckLines(connection); if (orientation != Orientation.Ceiling) { HangerBrace(hangerA); HangerBrace(hangerB); } CaveTools.CheckLines(brace); }
private void FindIntersectsToKeep() { //compare to point grid to remove if too close for (int i = 0; i < interpts.Count; i++) { Point3d closest = CaveTools.ClosestPoint(interpts[i], planarPointGrid.SelectMany(x => x).ToList()); if (closest.DistanceTo(interpts[i]) > parameters.cellGap / 4) { Ray3d ray = new Ray3d(interpts[i], panelFrame.localPlane.ZAxis); double t = Rhino.Geometry.Intersect.Intersection.MeshRay(panelFrame.CavePanels, ray); if (t >= 0) { meshpts.Add(ray.PointAt(t)); } } } }
private List <Mesh> WallSplit3(OrientedBox orientedBox, Mesh mesh, List <Mesh> meshes) { Plane orientationPlane = orientedBox.SideZmaxPlane; List <Mesh> parts = new List <Mesh>(); foreach (Mesh refmesh in meshes) { OrientedBox refBox = CaveTools.FindRefOrientedBox(orientationPlane, refmesh); //OrientedBox.CheckPlane(refBox.SideXmaxPlane); Mesh panel = CaveTools.splitTwoPlanes(refBox.SideXmaxPlane, refBox.SideXminPlane, mesh); parts.Add(panel); } foreach (Mesh m in parts) { RhinoDoc.ActiveDoc.Objects.AddMesh(m); } return(parts); }
private void Slice() { Plane p1 = new Plane(gridPlane.Origin, gridPlane.YAxis); Plane p2 = new Plane(gridPlane.Origin + gridPlane.YAxis * parameters.yCell, gridPlane.YAxis * -1); //try and slice the mesh Mesh slice = CaveTools.splitTwoPlanes(p1, p2, meshToVoxelise); bool normals = slice.FaceNormals.ComputeFaceNormals(); Plane boxPln = new Plane(gridPlane.Origin, gridPlane.XAxis, gridPlane.YAxis); if (slice != null && slice.Faces.Count > 0) { //Brep minVol = CaveTools.findBBoxGivenPlane(boxPln, slice); //OrientedBox oBox = CaveTools.FindOrientedBox(boxPln, slice); //brepBBoxes.Add(oBox.BoundingBox); //caveSlices.Add(slice); //bayControllers.Add(new BayController(gridPlane, parameters)); } }
private void FrameGridToExtraSupportPos(PanelFrame panelFrame, Line frameline, int i, int j, Point3d closestExtra) { Point3d start = panelFrame.localPlane.ClosestPoint(frameline.From); Point3d end = panelFrame.localPlane.ClosestPoint(frameline.To); Point3d endToMove = new Point3d(start); Point3d endFixed = new Point3d(end); if (panelFrame.frameGrid[i][j].DistanceTo(end) < panelFrame.frameGrid[i][j].DistanceTo(start)) { endToMove = new Point3d(end); endFixed = new Point3d(start); } Point3d extra = panelFrame.localPlane.ClosestPoint(closestExtra); Point3d ptOnLn = new Point3d(); if (extra.DistanceTo(endFixed) < 500) { //move to frame 500mmm Vector3d move = endToMove - endFixed; move.Unitize(); endToMove = endFixed + move * 500; Line drop = new Line(endToMove, panelFrame.localPlane.ZAxis * 10000); double a = 0; double b = 0; Rhino.Geometry.Intersect.Intersection.LineLine(frameline, drop, out a, out b); ptOnLn = frameline.PointAt(a); UpdateStubs(panelFrame, panelFrame.frameGrid[i][j], ptOnLn, ptOnLn); } else { //move to closest extra ptOnLn = frameline.ClosestPoint(closestExtra, true); Point3d meshpt = CaveTools.ClosestPoint(panelFrame.frameGrid[i][j], panelFrame.meshExtraSupport.Stubs.Select(x => x.To).ToList()); UpdateStubs(panelFrame, panelFrame.frameGrid[i][j], meshpt, ptOnLn); //remove extra support RemoveExtraSupport(panelFrame, closestExtra); } panelFrame.frameGrid[i][j] = ptOnLn; }
public CaveElement(Mesh imesh, Plane bayPlane, Orientation iorientation, Parameters iparameters) { parameters = iparameters; orientation = iorientation; mesh = imesh; BayXY = bayPlane; if (mesh == null) { return; } orientedBox = CaveTools.FindOrientedBox(bayPlane, imesh, parameters.yCell); //RhinoDoc.ActiveDoc.Objects.AddBrep(orientedBox.BoundingBox); orientationPlane = orientedBox.PlaneSelection(orientation); //OrientedBox.CheckPlane(orientationPlane); supportAssembly = new SupportAssembly(parameters, orientation, orientationPlane); MeshToPanels(); }
private Mesh SelectClosestPanel(Mesh m, Plane plane) { if (m.DisjointMeshCount > 1) { double minDist = double.MaxValue; Mesh closest = new Mesh(); foreach (Mesh d in m.SplitDisjointPieces()) { Point3d centroid = CaveTools.averagePoint(d); if (centroid.DistanceTo(plane.ClosestPoint(centroid)) < minDist) { minDist = centroid.DistanceTo(plane.ClosestPoint(centroid)); closest = d; } } return(closest); } else { return(m); } }
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++; } }
public void TrySnapGhosts(PanelFrame panelFrame, int rowToAdjust) { //only apply to edge near clash if (panelFrame.clashFixAttempted) { return; } panelFrame.clashFixAttempted = true; for (int i = 0; i < panelFrame.meshnodes.Count; i++) { //skip middle row if (panelFrame.meshnodes.Count == 3 && i == 1) { continue; } if (i != rowToAdjust) { continue; } for (int j = 0; j < panelFrame.meshnodes[i].Count; j++) { if (panelFrame.meshnodes[i][j].isGhost) { bool replaceSupport = false; Point3d closestExtra = CaveTools.ClosestPoint(panelFrame.frameGrid[i][j], panelFrame.meshExtraSupport.Stubs.Select(x => x.From).ToList()); Line frameline = new Line(); Vector3d test = panelFrame.frameGrid[i][j] - closestExtra; foreach (Line line in panelFrame.frameLinesX) { if (panelFrame.frameGrid[i][j].DistanceTo(line.ClosestPoint(panelFrame.frameGrid[i][j], true)) < 5) { frameline = line; } // angle should be small a and dist on line double angle = Vector3d.VectorAngle(test, line.Direction); if (Math.Abs(angle - Math.PI) < 0.05 || angle < 0.05) { //the extra stub is on the same frame line Point3d ptOnLn = line.ClosestPoint(closestExtra, true); if (panelFrame.frameGrid[i][j].DistanceTo(ptOnLn) < line.Length && closestExtra.DistanceTo(ptOnLn) < 5) { replaceSupport = true; break; } } } if (replaceSupport) { FrameGridToExtraSupportPos(panelFrame, frameline, i, j, closestExtra); } else { FrameGridToLineCentre(panelFrame, frameline, i, j); } } } } //now re set frame panelFrame.frameLinesX = new List <Line>(); panelFrame.frameLinesY = new List <Line>(); panelFrame.SetFrameLines(ref panelFrame.frameGrid, ref panelFrame.frameLinesX, ref panelFrame.frameLinesY); }