public Glulam Generate() { GlulamData data = new GlulamData(Centreline, Width, Height, Frames.ToArray(), CrossSectionSamples, 100); Glulam g = Glulam.CreateGlulam(Centreline, Frames.ToArray(), data); return(g); }
static public Glulam CreateGlulamFromBeamGeometry2(Curve curve, Mesh beam, out double true_width, out double true_height, out double true_length, double extra = 0.0) { Mesh mm = curve.MapToCurveSpace(beam); BoundingBox bb = mm.GetBoundingBox(true); double x = bb.Center.X; double y = bb.Center.Y; double tmin, tmax; curve.LengthParameter(bb.Min.Z, out tmin); curve.LengthParameter(bb.Max.Z, out tmax); Plane twist = Plane.WorldXY; Polyline ch; mm = mm.FitToAxes(Plane.WorldXY, out ch, ref twist); bb = mm.GetBoundingBox(true); double dx = bb.Max.X - bb.Min.X; double dy = bb.Max.Y - bb.Min.Y; Plane cp; curve.PerpendicularFrameAt(tmin, out cp); double angle = Vector3d.VectorAngle(Vector3d.XAxis, twist.XAxis); int sign = Math.Sign(twist.YAxis * Vector3d.XAxis); Curve[] segments = curve.Split(new double[] { tmin, tmax }); if (segments.Length == 3) { curve = segments[1]; } else { curve = segments[0]; } Beam b = new Beam(curve, null, new Plane[] { cp }); //curve = b.CreateOffsetCurve(-x, -y); curve = b.CreateOffsetCurve(x, y); curve = curve.Extend(CurveEnd.Both, extra, CurveExtensionStyle.Smooth); cp.Transform(Rhino.Geometry.Transform.Rotation(angle * sign, cp.ZAxis, cp.Origin)); GlulamData data = GlulamData.FromCurveLimits(curve, dx + extra * 2, dy + extra * 2, new Plane[] { cp }); true_length = curve.GetLength(); true_width = dx + extra * 2; true_height = dy + extra * 2; return(Glulam.CreateGlulam(curve, new Plane[] { cp }, data)); }
/// <summary> /// Create glulam with frames that are aligned with a Surface. The input curve does not /// necessarily have to lie on the Surface. /// </summary> /// <param name="curve">Input centreline of the Glulam.</param> /// <param name="srf">Surface to align the Glulam orientation to.</param> /// <param name="num_samples">Number of orientation frames to use for alignment.</param> /// <returns>New Glulam oriented to the Surface.</returns> static public Glulam CreateGlulamNormalToSurface_old(Curve curve, Brep brep, int num_samples = 20, GlulamData data = null) { double[] t = curve.DivideByCount(num_samples, true); List <Plane> planes = new List <Plane>(); double u, v; Vector3d xaxis, yaxis, zaxis; ComponentIndex ci; Point3d pt; for (int i = 0; i < t.Length; ++i) { brep.ClosestPoint(curve.PointAt(t[i]), out pt, out ci, out u, out v, 0, out yaxis); zaxis = curve.TangentAt(t[i]); xaxis = Vector3d.CrossProduct(zaxis, yaxis); planes.Add(new Plane(curve.PointAt(t[i]), xaxis, yaxis)); } return(Glulam.CreateGlulam(curve, planes.ToArray(), data)); }
/// <summary> /// Create glulam with frames that are aligned with a Brep. The input curve does not /// necessarily have to lie on the Brep. /// </summary> /// <param name="curve">Input centreline of the glulam.</param> /// <param name="brep">Brep to align the glulam orientation to.</param> /// <param name="num_samples">Number of orientation frames to use for alignment.</param> /// <returns>New Glulam oriented to the brep.</returns> static public Glulam CreateGlulamNormalToSurface(Curve curve, Brep brep, int num_samples = 20, GlulamData data = null) { Plane[] frames = tas.Core.Util.Misc.FramesNormalToSurface(curve, brep, num_samples); return(Glulam.CreateGlulam(curve, frames, data)); }