private void setInnerBound() { centroid = MeshTools.meshCentroid(boundary); Mesh offset = MeshTools.makeCuboid(cellPlane, xDim - memberSize, yDim - memberSize, zDim - memberSize); innerBoundary = Brep.CreateFromMesh(offset, false); foreach (BrepVertex p in innerBoundary.Vertices) { nodeGrid.Add(p.Location); } nodeGrid.Add(new Line(nodeGrid[0], nodeGrid[2]).PointAt(0.5)); nodeGrid.Add(new Line(nodeGrid[1], nodeGrid[3]).PointAt(0.5)); nodeGrid.Add(new Line(nodeGrid[6], nodeGrid[4]).PointAt(0.5)); nodeGrid.Add(new Line(nodeGrid[7], nodeGrid[5]).PointAt(0.5)); setCentreLines(); //foreach(BrepEdge be in innerBoundary.Edges) //{ // untrimmedCentreLines.Add(be.DuplicateCurve()); //} ////add diagonals for (int d = 0; d < 11; d++) { diagonalMembers.Add(new DiagonalMember(d, nodeGrid)); } //set the faceboundaries setBoundaryGeometry(); }
private void setupSpans(int end) { for (int y = 0; y < end; y++)//unitsY { Vector3d shiftY = gridPlane.YAxis * y * parameters.yCell; Point3d basePt = new Point3d(gridPlane.OriginX, gridPlane.OriginY, gridPlane.OriginZ); Point3d origin = basePt + shiftY; Plane p1 = new Plane(origin, gridPlane.YAxis); Plane p2 = new Plane(origin + gridPlane.YAxis * parameters.yCell, gridPlane.YAxis * -1); //try and slice the mesh Mesh slice = MeshTools.splitTwoPlanes(p1, p2, meshesToVoxelise[0]); if (slice != null && slice.Faces.Count > 0) { Plane boxPln = new Plane(origin, gridPlane.XAxis, gridPlane.YAxis); //containing box with allowance in x and z directions Box box = new Box(boxPln, new Interval(-parameters.xCell / 10, parameters.width + parameters.xCell / 10), new Interval(0, parameters.yCell), new Interval(-parameters.zCell / 10, parameters.height + parameters.zCell / 10)); Mesh sectionVolume = Mesh.CreateFromBox(box, 1, 1, 1); spanBoxes.Add(sectionVolume); foreach (Brep b in parameters.wall) { var boundVol = Brep.CreateBooleanIntersection(box.ToBrep(), b, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance); if (boundVol != null) { structuralSpans.Add(new StructuralSpan(parameters, slice, boxPln, y, boundVol[0])); } } } } }
private void defineSkinCells() { foreach (List <StructuralCell> sc in voxels) { foreach (StructuralCell c in sc) { if (c.id == cellDebugId) { int g = 0; } Mesh extendSplitter = MeshTools.makeCuboid(c.cellPlane, c.xDim, c.yDim, c.zDim); var intersectCurve = Rhino.Geometry.Intersect.Intersection.MeshMeshAccurate(slice, extendSplitter, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance); if (intersectCurve != null) { if (intersectCurve.Length > 0) { //we know there is defintely an intersection if we have result from MeshMesh Mesh caveface = MeshTools.findIntersection(slice, c); if (caveface == null) { return; } MeshTools.matchOrientation(slice, ref caveface); c.setSkinCell(caveface); } } } } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <Mesh> meshes = new List <Mesh>(); List <Box> boxes = new List <Box>(); if (!DA.GetDataList(0, meshes)) { return; } foreach (Mesh m in meshes) { boxes.Add(MeshTools.findBBox(m)); } DA.SetDataList(0, boxes); }
private void boundaryChecks() { Curve[] cInter; Point3d[] pInter; Plane insidePlane = new Plane(); foreach (List <StructuralCell> sc in voxels) { for (int i = 0; i < sc.Count; i++) { if (sc[i].id == cellDebugId) { int g = 0; } StructuralCell c = sc[i]; foreach (Brep w in parameters.wall) { bool inter = Rhino.Geometry.Intersect.Intersection.BrepBrep(c.outerBoundary, w, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, out cInter, out pInter); if (cInter.Length > 0) { //which cell end is inside bool end0 = MeshTools.curveInBrep(c.boundCurve0, w); bool end1 = MeshTools.curveInBrep(c.boundCurve1, w); if (!end0 && !end1) { // both ends intersect, we won't use it, move to next cell sc[i] = null; break; } if (end0) { insidePlane = c.boundPlane0; } if (end1) { insidePlane = c.boundPlane1; } reduceModuleYDirection(ref c, insidePlane, cInter[0]); sc[i] = c; break;//move to next cell } } } } }
public StructuralCell(Plane cellplane, double xdim, double ydim, double zdim, double memberDim, string ID, bool filler, Color c) { cellPlane = cellplane; xDim = xdim; yDim = ydim; zDim = zdim; boundary = MeshTools.makeCuboid(cellPlane, xDim, yDim, zDim); boundary.FaceNormals.ComputeFaceNormals(); memberSize = memberDim; cellType = CellType.Undefined; id = ID; setPositionFromID(); fillerCell = filler; displayColor = c; setInnerBound(); centreLines = untrimmedCentreLines; storeDiagonals(); }
private void setMidPlane() { List <Point3d> facePts = new List <Point3d>(); //plane normals follow caveface foreach (Point3d p in caveFace.Vertices) { facePts.Add(p); } foreach (Vector3d mf in caveFace.FaceNormals) { toOutside += mf; } Point3d planeOrigin = MeshTools.averagePoint(facePts); toOutside.Unitize(); Plane.FitPlaneToPoints(facePts, out midPlane); midPlane.Origin = planeOrigin; if (Vector3d.VectorAngle(midPlane.Normal, toOutside) > Math.PI / 2) { midPlane.Flip(); } }