private Curve generatePolyBottomCurve(ObjRef objRef, Point3d origin, double thickness, bool shrinkToDimensions = false) { // First get the section curve (not poly) and use built-in // offset, not a scale transform, to increment Brep brep = objRef.Brep(); Vector3d zNorm = new Vector3d(0, 0, 1); Plane worldXYPlane = new Plane(ORIGIN, zNorm); Curve[] contours = Brep.CreateContourCurves(brep, worldXYPlane); Curve sectionCurve = contours[0]; if (!shrinkToDimensions) { Curve[] offsetCurves = sectionCurve.Offset(worldXYPlane, thickness, 0, CurveOffsetCornerStyle.Sharp); if (offsetCurves.Length != 1) { throw new Exception("Could not properly offset curve."); } sectionCurve = offsetCurves[0]; } // Place our curve to have concentric alignment with a bounding box // anchored at the provided origin, which we first need to offset // from being a bottom corner to "center" BoundingBox boundingBox = sectionCurve.GetBoundingBox(worldXYPlane); double bboxHeight = boundingBox.Max.X - boundingBox.Min.X; double bboxWidth = boundingBox.Max.Y - boundingBox.Min.Y; origin += new Vector3d(bboxHeight / 2, bboxWidth / 2, 0); origin += new Vector3d(thickness, 0, 0); double xDiff = origin.X - boundingBox.Center.X; double yDiff = origin.Y - boundingBox.Center.Y; Transform translation = Transform.Translation(new Vector3d(xDiff, yDiff, 0)); sectionCurve.Transform(translation); return(sectionCurve); }
private Polyline getSectionPolyline(ObjRef objRef) { Brep brep = objRef.Brep(); Vector3d zNorm = new Vector3d(0, 0, 1); Plane worldXYPlane = new Plane(ORIGIN, zNorm); Curve[] contours = Brep.CreateContourCurves(brep, worldXYPlane); Curve sectionCurve = contours[0]; Polyline sectionPolyline; double[] sectionPolylineConversionResults; bool success = sectionCurve.TryGetPolyline(out sectionPolyline, out sectionPolylineConversionResults); if (!success) { throw new Exception("Cannot find section curve of polygon."); } return(sectionPolyline); }
/// <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<double> MP = new List<double>(); MaterialProperties mp = null; List <double> Mu = new List <double>(); Brep BBrep = new Brep(); Curve spCrv = null; //int N = 0; double CC = 0; double selAs = 0; bool fix = false; int code = 0; if (!DA.GetData(0, ref mp)) { return; } if (!DA.GetDataList(1, Mu)) { return; } if (!DA.GetData(2, ref BBrep)) { return; } if (!DA.GetData(3, ref spCrv)) { return; } //if (!DA.GetData(4, ref N)) return; if (!DA.GetData(4, ref CC)) { return; } if (!DA.GetData(5, ref selAs)) { return; } if (!DA.GetData(6, ref fix)) { return; } if (!DA.GetData(7, ref code)) { return; } //MaterialProperties mp = null; //try //{ // mp = (MaterialProperties)mpobj; //} //catch (Exception e) //{ // AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Must provide a valid Material Properties object"); // AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToString()); // return; //} int N = Mu.Count; if (N < 2) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input Mu needs to have at least 2 values"); return; } //if (N > spCrv.GetLength() * 0.5) //{ // AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input n must be less than half of the beam's length"); // return; //} //Copy to each analysis plugin - extracts material properties from MP input //double fc = MP[0]; double Ec = MP[1]; double ec = MP[2]; double rhoc = MP[3]; double EEc = MP[4]; //double fy = MP[5]; double Es = MP[6]; double es = MP[7]; double rhos = MP[8]; double EEs = MP[9]; double fc = mp.fC; double Ec = mp.EC; double ec = mp.eC; double rhoc = mp.rhoC; double EEc = mp.EEC; double fy = mp.fY; double Es = mp.ES; double es = mp.eS; double rhos = mp.rhoS; double EEs = mp.EES; //double fc = mp.FC; //Code limits for design double cdMax, rhoMax, rhoMin = 0; double rhoDes, sConst = 0; if (code == 1) { cdMax = ec / (ec + es); rhoMax = (0.36 * fc / (0.87 * fy)) * cdMax; rhoMin = 0.25 * Math.Sqrt(fc) / fy; //Steel design constants rhoDes = 0.66 * rhoMax; sConst = 0.87 * fy * (1 - 1.005 * rhoDes * (fy / fc)); } else { cdMax = ec / (ec + es); rhoMax = (0.36 * fc / (0.87 * fy)) * cdMax; rhoMin = Math.Max(0.25 * Math.Sqrt(fc) / fy, 1.4 / fy); //Steel design constants rhoDes = 0.66 * rhoMax; sConst = 0.87 * fy * (1 - 1.005 * rhoDes * (fy / fc)); } Console.Write(sConst); //Extract beam sections BoundingBox boundBBrep = BBrep.GetBoundingBox(false); Curve edge0 = spCrv; Double[] edge0div = edge0.DivideByCount(N - 1, true); //Double[] edge0div = edge0.DivideByLength(N, true); Plane[] splitPls = edge0.GetPerpendicularFrames(edge0div); List <Curve> AgCrv = new List <Curve>(); List <Curve> AsCrv = new List <Curve>(); double[] AsCrvArea = new double[splitPls.Length]; List <Point3d> origins = new List <Point3d>(); List <Plane> planesAg = new List <Plane>(); //for testing with single moment at all points double[] newMu = new double[splitPls.Length]; for (int i = 0; i < splitPls.Length; i++) { newMu[i] = Mu[0]; } if (Mu.Count == splitPls.Length) { newMu = Mu.ToArray(); } CurveSimplifyOptions crvSimp = new CurveSimplifyOptions(); for (int i = 0; i < splitPls.Length; i++) { Curve[] ag = Brep.CreateContourCurves(BBrep, splitPls[i]); Brep[] brepAg = Brep.CreatePlanarBreps(ag, DocumentTolerance()); Surface srfAg = brepAg[0].Faces[0]; Curve ag0 = ag[0].Simplify(CurveSimplifyOptions.All, DocumentTolerance(), DocumentAngleTolerance()); AgCrv.Add(ag0); Double uSrfC = srfAg.Domain(0)[1] - srfAg.Domain(0)[0]; Double vSrfC = srfAg.Domain(1)[1] - srfAg.Domain(1)[0]; Curve U = srfAg.IsoCurve(0, 0.5 * vSrfC + srfAg.Domain(1)[0]); Curve V = srfAg.IsoCurve(1, 0.5 * uSrfC + srfAg.Domain(0)[0]); Point3d endPtV = V.PointAtEnd; Point3d startPtV = V.PointAtStart; if (endPtV.Z < startPtV.Z) { V.Reverse(); } if (newMu[i] > DocumentTolerance()) { V.Reverse(); } srfAg.TryGetPlane(out Plane plAg); double d = V.GetLength() - (CC / 1000); double areaAs = 0; if (selAs == 0) { areaAs = (1000000 * Math.Abs(newMu[i])) / (sConst * d * 1000); //As in mm2 } else { areaAs = selAs; } double radAs = Math.Sqrt(areaAs / Math.PI) / 1000; //radius in m if (radAs <= DocumentTolerance()) { radAs = DocumentTolerance(); } //insert correction for when radius is equal to 0 Point3d origin = V.PointAtLength(CC / 1000); origins.Add(origin); planesAg.Add(plAg); Circle crcAs = new Circle(plAg, origin, radAs); Curve crvAs = NurbsCurve.CreateFromCircle(crcAs); AsCrv.Add(crvAs); AsCrvArea[i] = areaAs; } double startAg0 = 0; AgCrv[0].ClosestPoint(new Point3d(0, 0, 0), out startAg0); AgCrv[0].ChangeClosedCurveSeam(startAg0); double startAs0 = 0; AgCrv[0].ClosestPoint(new Point3d(0, 0, 0), out startAs0); AgCrv[0].ChangeClosedCurveSeam(startAs0); double newStartAg = 0; Point3d startAg = new Point3d(); double newStartAs = 0; Point3d startAs = new Point3d(); for (int i = 1; i < AgCrv.Count; i++) { if (AgCrv[i] != null && AgCrv[i - 1] != null) { if (!Curve.DoDirectionsMatch(AgCrv[i], AgCrv[0])) { AgCrv[i].Reverse(); } startAg = AgCrv[i - 1].PointAtStart; AgCrv[i].ClosestPoint(startAg, out newStartAg); AgCrv[i].ChangeClosedCurveSeam(newStartAg); } if (AsCrv[i] != null && AsCrv[i - 1] != null) { if (!Curve.DoDirectionsMatch(AsCrv[i], AsCrv[0])) { AsCrv[i].Reverse(); } startAs = AsCrv[i - 1].PointAtStart; AsCrv[i].ClosestPoint(startAs, out newStartAs); AsCrv[i].ChangeClosedCurveSeam(newStartAs); } } List <Curve> finalAsCrv = new List <Curve>(); Curve[] AsCrvArray = AsCrv.ToArray(); Array.Sort(AsCrvArea, AsCrvArray); double AsCrvAreaMax = AsCrvArea[AsCrvArea.Length - 1]; double radAsMax = Math.Sqrt(AsCrvAreaMax / Math.PI) / 1000; //radius in m Curve AsCrvMax = AsCrvArray[AsCrvArray.Length - 1]; if (fix != false) { for (int i = 0; i < AsCrv.Count; i++) { Circle newCrcAs = new Circle(planesAg[i], origins[i], radAsMax); Curve newCrvAs = NurbsCurve.CreateFromCircle(newCrcAs); finalAsCrv.Add(newCrvAs); } } else { finalAsCrv = AsCrv; } if (finalAsCrv.Count == 0 || AgCrv.Count == 0) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "One or both outputs are empty, check input loads and geometry!"); return; } DA.SetDataList(0, AgCrv); DA.SetDataList(1, finalAsCrv); }
/// <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) { MaterialProperties mp = null; List <double> Mu = new List <double>(); List <double> Vu = new List <double>(); List <double> Vs = new List <double>(); List <Curve> crvAg = new List <Curve>(); List <Curve> crvAs = new List <Curve>(); int M = 0; if (!DA.GetData(0, ref mp)) { return; } if (!DA.GetDataList(1, Mu)) { return; } if (!DA.GetDataList(2, Vu)) { return; } if (!DA.GetDataList(3, Vs)) { return; } if (!DA.GetDataList(4, crvAg)) { return; } if (!DA.GetDataList(5, crvAs)) { return; } if (!DA.GetData(6, ref M)) { return; } if (M <= 2) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input m must be an integer greater than 2"); return; } //Copy to each analysis plugin - extracts material properties from MP input double fc = mp.fC; double Ec = mp.EC; double ec = mp.eC; double rhoc = mp.rhoC; double EEc = mp.EEC; double fy = mp.fY; double Es = mp.ES; double es = mp.eS; double rhos = mp.rhoS; double EEs = mp.EES; //Creates planar Breps from input curves Brep[] brepsAg = Brep.CreatePlanarBreps(crvAg, DocumentTolerance()); Brep[] brepsAs = Brep.CreatePlanarBreps(crvAs, DocumentTolerance()); //Mu correction, for testing with single moment at all points double[] newMu = new double[crvAg.Count]; for (int i = 0; i < crvAg.Count; i++) { newMu[i] = Mu[0]; } if (Mu.Count == crvAg.Count) { newMu = Mu.ToArray(); } //Vu correction, for testing with single moment at all points double[] newVu = new double[crvAg.Count]; for (int i = 0; i < crvAg.Count; i++) { newVu[i] = Vu[0]; } if (Vu.Count == crvAg.Count) { newVu = Vu.ToArray(); } //Vs correction, for testing with single moment at all points double[] newVs = new double[crvAg.Count]; for (int i = 0; i < crvAg.Count; i++) { newVs[i] = Vs[0]; } if (Vs.Count == crvAg.Count) { newVs = Vs.ToArray(); } ////Mn correction, for testing with single moment at all points //double[] newMn = new double[crvAg.Count]; //for (int i = 0; i < crvAg.Count; i++) { newMn[i] = Mn[0]; } //if (Mn.Count == crvAg.Count) { newMn = Mn.ToArray(); } List <Curve> bwCrvs = new List <Curve>(); List <double> sectRho = new List <double>(); List <double> Vn = new List <double>(); List <double> errors = new List <double>(); for (int i = 0; i < crvAg.Count; i++) { Brep brepAg = brepsAg[i]; Brep brepAs = brepsAs[i]; Surface srfAg = brepAg.Surfaces[0]; Double uMidDom = (srfAg.Domain(0)[1] + srfAg.Domain(0)[0]) / 2; Double vMidDom = (srfAg.Domain(1)[1] + srfAg.Domain(1)[0]) / 2; //Correction of U and V curve extraction Curve U0 = srfAg.IsoCurve(0, vMidDom); Curve[] UIntCrv; Point3d[] UIntPt; Rhino.Geometry.Intersect.Intersection.CurveBrep(U0, brepAg, DocumentTolerance(), out UIntCrv, out UIntPt); Curve U = UIntCrv[0]; Curve V0 = srfAg.IsoCurve(1, uMidDom); Curve[] VIntCrv; Point3d[] VIntPt; Rhino.Geometry.Intersect.Intersection.CurveBrep(V0, brepAg, DocumentTolerance(), out VIntCrv, out VIntPt); Curve V = VIntCrv[0]; Point3d endPtV = V.PointAtEnd; Point3d startPtV = V.PointAtStart; if (endPtV.Z > startPtV.Z) { V.Reverse(); } Double[] vDivision = V.DivideByCount(M, false); Plane[] vPlane = V.GetPerpendicularFrames(vDivision); Curve[] vContours = new Curve[vPlane.Length]; double[] vConLen = new double[vPlane.Length]; for (int j = 0; j < vPlane.Length; j++) { Curve[] vContour = Brep.CreateContourCurves(brepAg, vPlane[j]); if (vContour.Length > 0) { vContours[j] = vContour[0]; vConLen[j] = vContour[0].GetLength(); } } Curve bCrv = vContours[0]; Array.Sort(vConLen, vContours); Curve bwCrv = null; //if (vContours[0] == null) { bwCrv = U; } //else { bwCrv = vContours[0]; } bwCrv = vContours[0]; if (bwCrv == null) { bwCrv = U; } bwCrvs.Add(bwCrv); double areaAs = AreaMassProperties.Compute(crvAs[i]).Area; double bw, d, bwd = 0; bw = bwCrv.GetLength(); d = U.GetLength(); bwd = bw * d; double rho = areaAs / bwd; sectRho.Add(rho); //Unit conversions for shear calculations bw *= 1000; d *= 1000; double sectMu = Math.Abs(newMu[i]) * 1000000; double sectVu = Math.Abs(newVu[i] * 1000); //IS456 shear calculation double beta = Math.Max(0.8 * fc / (6.89 * rho * 100), 1); double tauC = 0.85 * Math.Sqrt(0.8 * fc) * (Math.Sqrt(1 + 5 * beta) - 1) / (6 * beta); double sectVcIS = tauC * bw * d / 1000; //ACI shear calculation double Vc1 = (0.16 * Math.Sqrt(fc) + 17 * rho * sectVu * d / sectVu) * bw * d / 1000; double Vc2 = 0.29 * Math.Sqrt(fc) * bw * d / 1000; double sectVcACI = Math.Min(Vc1, Vc2); ////CFP shear calculation, WIP //double avx = Math.Abs(1000 * newMu[i] / newVu[i]); //double Mcx = 0.875 * avx * d * (0.342 * bw + 0.3 * (newMn[i] / (d * d)) * Math.Sqrt(z / avx)) * Math.Pow((16.66 / (rho * fy)), 0.25); //sectVcCFP = Mcx / (avx * 1000); double sectVn = 0; if (Double.IsNaN(sectVn)) { sectVn = 0; } else if (newVs[i] < DocumentTolerance()) { sectVn = Math.Min(sectVcIS, sectVcACI) * 0.5; } else { sectVn = Math.Min(sectVcIS, sectVcACI) + newVs[i]; } Vn.Add(sectVn); double error = ((sectVn - Math.Abs(newVu[i])) / Math.Abs(newVu[i])) * 100; errors.Add(error); } DA.SetDataList(0, Vn); //DA.SetDataList(1, errors); DA.SetDataList(1, bwCrvs); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // 1 - Select a site curve GetObject obj = new GetObject(); obj.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; obj.SetCommandPrompt("Please select a curve representing your site"); GetResult res = obj.Get(); Curve site; if (res != GetResult.Object) { RhinoApp.WriteLine("The user did not select a curve"); return(Result.Failure); // Failed to get a curve } if (obj.ObjectCount == 1) { site = obj.Object(0).Curve(); } else { return(Result.Failure); //Failed to get a curve } // 2 - Extract the border from the precinct surface //Offset for Shop Curve[] offsets = site.Offset(Plane.WorldXY, -2.5, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, CurveOffsetCornerStyle.Chamfer); Curve[] joinedoffset = Curve.JoinCurves(offsets); //join offset curves //Offset for Apartment Curve[] offsetBst = site.Offset(Plane.WorldXY, -4, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, CurveOffsetCornerStyle.Chamfer); Curve[] joinedoffsetBst = Curve.JoinCurves(offsetBst); //join offset curves //Offset for Base Curve[] offsetTop = site.Offset(Plane.WorldXY, -3, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, CurveOffsetCornerStyle.Chamfer); Curve[] joinedoffsetTop = Curve.JoinCurves(offsetTop); //join offset curves //List of offset curves List <Curve> buildingsCrv = new List <Curve>(); buildingsCrv.AddRange(offsets); buildingsCrv.AddRange(offsetBst); buildingsCrv.AddRange(offsetTop); // 3 - Extrude all the offset curves //Extrusions Extrusion Shop = Extrusion.Create(buildingsCrv[0], 3.1, true); Extrusion Apa = Extrusion.Create(buildingsCrv[1], 18.6, true); Extrusion Base = Extrusion.Create(buildingsCrv[2], -3.1, true); //List of extrusions List <Extrusion> buildingsExt = new List <Extrusion>(); buildingsExt.Add(Shop); buildingsExt.Add(Apa); buildingsExt.Add(Base); //Draw all the extrusions foreach (Extrusion itExt in buildingsExt) { RhinoDoc.ActiveDoc.Objects.Add(itExt); } // 4 - Create contour lines on extrusions to represent floors //Define extrusions as Breps for contours Brep ShopBrep = Shop.ToBrep(); Brep BrepApa = Apa.ToBrep(); //List of Breps List <Brep> BuildingBreps = new List <Brep>(); BuildingBreps.Add(ShopBrep); BuildingBreps.Add(BrepApa); //Points to define contours Point3d start = new Point3d(0, 0, 0); Point3d end = new Point3d(0, 0, 30); //Contours Curve[] Shopflr = Brep.CreateContourCurves(ShopBrep as Brep, start, end, 3.1); Curve[] ApaFlr = Brep.CreateContourCurves(BrepApa as Brep, start, end, 3.1); //List of Contour Curves List <Curve> Floors = new List <Curve>(); Floors.AddRange(Shopflr); Floors.AddRange(ApaFlr); //Draw all the Contour curves foreach (Curve itCrv in Floors) { RhinoDoc.ActiveDoc.Objects.Add(itCrv); } RhinoDoc.ActiveDoc.Views.Redraw(); return(Result.Success); }
public static Result ContourCurves(RhinoDoc doc) { var filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Mesh; ObjRef[] obj_refs; var rc = RhinoGet.GetMultipleObjects("Select objects to contour", false, filter, out obj_refs); if (rc != Result.Success) { return(rc); } var gp = new GetPoint(); gp.SetCommandPrompt("Contour plane base point"); gp.Get(); if (gp.CommandResult() != Result.Success) { return(gp.CommandResult()); } var base_point = gp.Point(); gp.DrawLineFromPoint(base_point, true); gp.SetCommandPrompt("Direction perpendicular to contour planes"); gp.Get(); if (gp.CommandResult() != Result.Success) { return(gp.CommandResult()); } var end_point = gp.Point(); if (base_point.DistanceTo(end_point) < RhinoMath.ZeroTolerance) { return(Result.Nothing); } double distance = 1.0; rc = RhinoGet.GetNumber("Distance between contours", false, ref distance); if (rc != Result.Success) { return(rc); } var interval = Math.Abs(distance); Curve[] curves = null; foreach (var obj_ref in obj_refs) { var geometry = obj_ref.Geometry(); if (geometry == null) { return(Result.Failure); } if (geometry is Brep) { curves = Brep.CreateContourCurves(geometry as Brep, base_point, end_point, interval); } else { curves = Mesh.CreateContourCurves(geometry as Mesh, base_point, end_point, interval); } foreach (var curve in curves) { var curve_object_id = doc.Objects.AddCurve(curve); doc.Objects.Select(curve_object_id); } } if (curves != null) { doc.Views.Redraw(); } return(Result.Success); }
/// <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) { MaterialProperties mp = null; List <Curve> crvAg = new List <Curve>(); List <Curve> crvAs = new List <Curve>(); int M = 0; if (!DA.GetData(0, ref mp)) { return; } if (!DA.GetDataList(1, crvAg)) { return; } if (!DA.GetDataList(2, crvAs)) { return; } if (!DA.GetData(3, ref M)) { return; } if (M <= 2) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input m must be an integer greater than 2"); return; } //Copy to each analysis plugin - extracts material properties from MP input double fc = mp.fC; double Ec = mp.EC; double ec = mp.eC; double rhoc = mp.rhoC; double EEc = mp.EEC; double fy = mp.fY; double Es = mp.ES; double es = mp.eS; double rhos = mp.rhoS; double EEs = mp.EES; //Code limits for design double cdMax = ec / (ec + es); double rhoMax = (0.36 * fc / (0.87 * fy)) * cdMax; double rhoMin = 0.25 * Math.Sqrt(fc) / fy; //Creates planar Breps from input curves Brep[] brepsAg = Brep.CreatePlanarBreps(crvAg, DocumentTolerance()); Brep[] brepsAs = Brep.CreatePlanarBreps(crvAs, DocumentTolerance()); List <Curve> bwCrvs = new List <Curve>(); List <double> sectRho = new List <double>(); List <double> maxErrors = new List <double>(); List <double> minErrors = new List <double>(); List <double> rhoMaxs = new List <double>(); List <double> rhoMins = new List <double>(); ////REMOVE WHEN DONE TESTING COMPONENT //maxErrors.Add(rhoMax); //minErrors.Add(rhoMin); for (int i = 0; i < crvAg.Count; i++) { Brep brepAg = brepsAg[i]; Brep brepAs = brepsAs[i]; Surface srfAg = brepAg.Surfaces[0]; Double uSrfC = srfAg.Domain(0)[1] - srfAg.Domain(0)[0]; Double vSrfC = srfAg.Domain(1)[1] - srfAg.Domain(1)[0]; Curve U = srfAg.IsoCurve(0, 0.5 * vSrfC + srfAg.Domain(1)[0]); Curve V = srfAg.IsoCurve(1, 0.5 * uSrfC + srfAg.Domain(0)[0]); Point3d endPtV = V.PointAtEnd; Point3d startPtV = V.PointAtStart; if (endPtV.Z > startPtV.Z) { V.Reverse(); } Double[] vDivision = V.DivideByCount(M, false); Plane[] vPlane = V.GetPerpendicularFrames(vDivision); Curve[] vContours = new Curve[vPlane.Length]; double[] vConLen = new double[vPlane.Length]; for (int j = 0; j < vPlane.Length; j++) { Curve[] vContour = Brep.CreateContourCurves(brepAg, vPlane[j]); if (vContour.Length > 0) { vContours[j] = vContour[0]; vConLen[j] = vContour[0].GetLength(); } } Curve bCrv = vContours[0]; Array.Sort(vConLen, vContours); Curve bwCrv = null; //if (vContours[0] == null) { bwCrv = U; } //else { bwCrv = vContours[0]; } bwCrv = vContours[0]; bwCrvs.Add(bwCrv); double areaAs = AreaMassProperties.Compute(crvAs[i]).Area; double bw = 0; double d = 0; double bwd = 0; if (bwCrv != null) { bw = bwCrv.GetLength(); d = U.GetLength(); bwd = bw * d; } double rho = areaAs / bwd; if (double.IsPositiveInfinity(rho) || double.IsNegativeInfinity(rho)) { //AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Reinforcement ratio is invalid."); //return; rho = 0; } sectRho.Add(rho); double maxError = 100 * ((rhoMax - rho) / rhoMax); maxErrors.Add(maxError); repos double minError = 100 * (rho - rhoMin) / rhoMin; minErrors.Add(minError); rhoMaxs.Add(rhoMax); rhoMins.Add(rhoMin); } DA.SetDataList(0, sectRho); DA.SetDataList(1, maxErrors); DA.SetDataList(2, minErrors); DA.SetDataList(3, bwCrvs); DA.SetDataList(4, rhoMaxs); DA.SetDataList(5, rhoMins); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { MaterialProperties mp = null; List <double> Mu = new List <double>(); List <Curve> crvAg = new List <Curve>(); List <Curve> crvAs = new List <Curve>(); int M = 0; if (!DA.GetData(0, ref mp)) { return; } if (!DA.GetDataList(1, Mu)) { return; } if (!DA.GetDataList(2, crvAg)) { return; } if (!DA.GetDataList(3, crvAs)) { return; } if (!DA.GetData(4, ref M)) { return; } //Copy to each analysis plugin - extracts material properties from MP input double fc = mp.fC; double Ec = mp.EC; double ec = mp.eC; double rhoc = mp.rhoC; double EEc = mp.EEC; double fy = mp.fY; double Es = mp.ES; double es = mp.eS; double rhos = mp.rhoS; double EEs = mp.EES; if (M <= 2) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input m must be an integer greater than 2"); return; } Brep[] brepsAg = Brep.CreatePlanarBreps(crvAg, DocumentTolerance()); //Creates planar Breps from input curves Brep[] brepsAs = Brep.CreatePlanarBreps(crvAs, DocumentTolerance()); List <Brep> allSubSrf = new List <Brep>(); List <Brep> finalSubSrf = new List <Brep>(); List <Double> finalSubSrfArea = new List <Double>(); List <double> Mn = new List <double>(); List <double> errors = new List <double>(); //Code limits for design double cdMax = ec / (ec + es); double rhoMax = (0.36 * fc / (0.87 * fy)) * cdMax; double rhoMin = 0.25 * Math.Sqrt(fc) / fy; //Steel design constants double rhoDes = 0.66 * rhoMax; double sConst = 0.87 * fy * (1 - 1.005 * rhoDes * (fy / fc)); //for testing with single moment at all points double[] newMu = new double[crvAg.Count]; for (int i = 0; i < crvAg.Count; i++) { newMu[i] = Mu[0]; } if (Mu.Count == crvAg.Count) { newMu = Mu.ToArray(); } for (int i = 0; i < crvAg.Count; i++) { Brep brepAg = brepsAg[i]; Brep brepAs = new Brep(); brepAs = brepsAs[i]; BoundingBox bbox = brepAg.GetBoundingBox(true); Surface srfAg = brepAg.Surfaces[0]; Double uSrfC = srfAg.Domain(0)[1] - srfAg.Domain(0)[0]; Double vSrfC = srfAg.Domain(1)[1] - srfAg.Domain(1)[0]; Curve U = srfAg.IsoCurve(0, 0.5 * vSrfC + srfAg.Domain(1)[0]); Curve V = srfAg.IsoCurve(1, 0.5 * uSrfC + srfAg.Domain(0)[0]); Point3d endPtV = V.PointAtEnd; Point3d startPtV = V.PointAtStart; if (endPtV.Z > startPtV.Z) { V.Reverse(); } if (newMu[i] > DocumentTolerance()) { V.Reverse(); } Double[] vDivision = V.DivideByCount(M, false); Plane[] vPlane = V.GetPerpendicularFrames(vDivision); double desiredArea = brepAs.GetArea() * 0.87 * fy / (0.36 * fc); //Adjust to include formula for material properties List <Brep> subSrf = new List <Brep>(); for (int j = 0; j < vPlane.Length; j++) //Needs a fix for when m is 1 or less { Curve[] contour = Brep.CreateContourCurves(brepAg, vPlane[j]); Brep[] splitSrfs = brepAg.Split(contour, DocumentTolerance()); if (splitSrfs.Length > 0 && splitSrfs.Length > 1) { subSrf.Add(splitSrfs[1]); allSubSrf.Add(splitSrfs[1]); } } double subSrfArea = 0; List <Brep> potentialSubSrf = new List <Brep>(); Brep compAg = new Brep(); int check = 0; for (int j = 0; j < subSrf.Count; j++) { Surface subSrf2 = subSrf[j].Surfaces[0]; subSrfArea = AreaMassProperties.Compute(subSrf[j]).Area; if ((subSrfArea > desiredArea) && (check == 0)) { compAg = subSrf[j]; check++; } } finalSubSrf.Add(compAg); finalSubSrfArea.Add(compAg.GetArea()); Point3d centCompAg = new Point3d(); Point3d centBrepAs = new Point3d(); if (compAg.IsValid) { centCompAg = AreaMassProperties.Compute(compAg).Centroid; centBrepAs = AreaMassProperties.Compute(brepAs).Centroid; } double As = brepAs.GetArea(); //double Z = centBrepAs.DistanceTo(centCompAg); double Z = centBrepAs.Z - centCompAg.Z; double T = 0.87 * As * fy * 1000; //ADD NEGATIVE ACCOMODATION... double sectMn = T * Z; Mn.Add(sectMn); double error = ((sectMn - newMu[i]) / newMu[i]) * 100; errors.Add(error); } DA.SetDataList(0, Mn); DA.SetDataList(1, errors); DA.SetDataList(2, finalSubSrf); }
//generate contours private void GenerateContours() { BoundingBox bb = this.land.GetBoundingBox(false); contour.AddRange(Brep.CreateContourCurves(this.land.ToBrep(), bb.GetCorners()[0], bb.GetCorners()[4], 0.5)); }