public List <Point3d> DiscretizeCentreline(bool adaptive = true) { if (adaptive) { var pCurve = Centreline.ToPolyline(Glulam.Tolerance, Glulam.AngleTolerance, 0.0, 0.0); return(pCurve.ToPolyline().ToList()); } var tt = Centreline.DivideByCount(Data.Samples, true); return(tt.Select(x => Centreline.PointAt(x)).ToList()); }
public Plane[] GetPlanes(IList <Point3d> pts) { var tt = new double[pts.Count]; Parallel.For(0, pts.Count, i => { Centreline.ClosestPoint(pts[i], out tt[i]); }); var orientations = Orientation.GetOrientations(Centreline, tt); var planes = new Plane[tt.Length]; Parallel.For(0, tt.Length, i => { planes[i] = Utility.PlaneFromNormalAndYAxis( Centreline.PointAt(tt[i]), Centreline.TangentAt(tt[i]), orientations[i]); }); return(planes); }
public Brep GetSideSurface(int side, double offset, double width, double extension = 0.0, bool flip = false) { // TODO: Create access for Glulam ends, with offset (either straight or along Centreline). side = side.Modulus(2); double w2 = width / 2; Curve c = Centreline.DuplicateCurve(); if (extension > 0.0) { c = c.Extend(CurveEnd.Both, extension, CurveExtensionStyle.Smooth); } int N = Math.Max(6, Data.Samples); GenerateCrossSectionPlanes(N, out Plane[] planes, out double[] parameters, Data.InterpolationType); Curve[] rules = new Curve[planes.Length]; double offsetX, offsetY; GetSectionOffset(out offsetX, out offsetY); for (int i = 0; i < planes.Length; ++i) { Plane p = planes[i]; if (side == 0) { rules[i] = new Line( p.Origin + p.XAxis * (offset + offsetX) + p.YAxis * (w2 + offsetY), p.Origin + p.XAxis * (offset + offsetX) - p.YAxis * (w2 - offsetY) ).ToNurbsCurve(); } else { rules[i] = new Line( p.Origin + p.YAxis * (offset + offsetY) + p.XAxis * (w2 + offsetX), p.Origin + p.YAxis * (offset + offsetY) - p.XAxis * (w2 - offsetX) ).ToNurbsCurve(); } } Brep[] loft = Brep.CreateFromLoft(rules, Point3d.Unset, Point3d.Unset, LoftType.Normal, false); if (loft == null || loft.Length < 1) { throw new Exception("Glulam::GetSideSurface::Loft failed!"); } Brep brep = loft[0]; Point3d pt = brep.Faces[0].PointAt(brep.Faces[0].Domain(0).Mid, brep.Faces[0].Domain(1).Mid); Vector3d nor = brep.Faces[0].NormalAt(brep.Faces[0].Domain(0).Mid, brep.Faces[0].Domain(1).Mid); double ct; Centreline.ClosestPoint(pt, out ct); Vector3d nor2 = Centreline.PointAt(ct) - pt; nor2.Unitize(); if (nor2 * nor < 0.0) { brep.Flip(); } if (flip) { brep.Flip(); } return(brep); }