public override Mesh MapToCurveSpace(Mesh m) { Plane cp, cpp = Plane.Unset; if (!Centreline.TryGetPlane(out cp, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)) { throw new Exception("SingleCurvedGlulam: Centreline is not planar!"); } double t, l; Mesh mesh = new Mesh(); for (int i = 0; i < m.Vertices.Count; ++i) { Point3d p = new Point3d(m.Vertices[i]); Centreline.ClosestPoint(p, out t); l = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); //Vector3d xaxis = Vector3d.CrossProduct(cp.ZAxis, Centreline.TangentAt(t)); //cpp = new Plane(Centreline.PointAt(t), xaxis, cp.ZAxis); cpp = GetPlane(t); p.Transform(Rhino.Geometry.Transform.PlaneToPlane(cpp, Plane.WorldXY)); p.Z = l; mesh.Vertices.Add(p); } mesh.Faces.AddFaces(m.Faces); mesh.FaceNormals.ComputeFaceNormals(); return(mesh); }
public Plane ToBeamSpace(Plane plane) { Centreline.ClosestPoint(plane.Origin, out double t); Plane m_plane = GetPlane(t); plane.Transform(Rhino.Geometry.Transform.PlaneToPlane(m_plane, Plane.WorldXY)); plane.OriginZ = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); return(plane); }
public Point3d MapToGlulamSpace(Point3d pt) { Centreline.ClosestPoint(pt, out double t); Plane m_plane = GetPlane(t); pt.Transform(Rhino.Geometry.Transform.PlaneToPlane(m_plane, Plane.WorldXY)); pt.Z = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); return(pt); }
public override Mesh MapToCurveSpace(Mesh m) { Plane cp; double t, l; Mesh mesh = new Mesh(); List <Point3d> verts = new List <Point3d>(m.Vertices.Count); object m_lock = new object(); Parallel.For(0, m.Vertices.Count, i => //for (int i = 0; i < m.Vertices.Count; ++i) { Point3d temp1, temp2; temp1 = m.Vertices[i]; Centreline.ClosestPoint(temp1, out t); l = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); cp = GetPlane(t); //Centreline.PerpendicularFrameAt(t, out cp); //p.Transform(Rhino.Geometry.Transform.PlaneToPlane(cp, Plane.WorldXY)); cp.RemapToPlaneSpace(temp1, out temp2); temp2.Z = l; //lock(m_lock) //{ verts[i] = temp2; //} //} }); /* * for (int i = 0; i < m.Vertices.Count; ++i) * { * Point3d p = new Point3d(m.Vertices[i]); * Centreline.ClosestPoint(p, out t); * l = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); * cp = GetPlane(t); * //Centreline.PerpendicularFrameAt(t, out cp); * p.Transform(Rhino.Geometry.Transform.PlaneToPlane(cp, Plane.WorldXY)); * p.Z = l; * * } */ mesh.Vertices.AddVertices(verts); mesh.Faces.AddFaces(m.Faces); mesh.FaceNormals.ComputeFaceNormals(); return(mesh); }
// MAPPING METHODS public Point3d ToBeamSpace(Point3d pt) { Plane m_plane; Point3d m_temp; double t; Centreline.ClosestPoint(pt, out t); m_plane = GetPlane(t); m_plane.RemapToPlaneSpace(pt, out m_temp); if (t > Centreline.Domain.Max) { m_temp.Z = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); } return(m_temp); }
public Point3d[] MapToGlulamSpace(IList <Point3d> pts) { Point3d[] m_output_pts = new Point3d[pts.Count]; Plane m_plane; Point3d m_temp; double t; for (int i = 0; i < pts.Count; ++i) { Centreline.ClosestPoint(pts[i], out t); m_plane = GetPlane(t); m_plane.RemapToPlaneSpace(pts[i], out m_temp); m_temp.Z = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); m_output_pts[i] = m_temp; } return(m_output_pts); }
public Plane[] MapToGlulamSpace(IList <Plane> planes) { Plane[] m_output_planes = new Plane[planes.Count]; Plane m_plane; Plane m_temp; double t; for (int i = 0; i < planes.Count; ++i) { Centreline.ClosestPoint(planes[i].Origin, out t); m_plane = GetPlane(t); m_temp = planes[i]; m_temp.Transform(Rhino.Geometry.Transform.PlaneToPlane(m_plane, Plane.WorldXY)); m_temp.OriginZ = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); m_output_planes[i] = m_temp; } return(m_output_planes); }
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); }
public Point3d[] ToBeamSpace(IList <Point3d> pts, bool approximate = false, int num_samples = 100) { Point3d[] m_output_pts = new Point3d[pts.Count]; Plane m_plane; Point3d m_temp; double t; if (approximate) { double mu; var tt = Centreline.DivideByCount(num_samples, true); var lengths = tt.Select(x => Centreline.GetLength(new Interval(Centreline.Domain.Min, x))).ToArray(); //for (int i = 0; i < pts.Count; ++i) Parallel.For(0, pts.Count, i => { Centreline.ClosestPoint(pts[i], out t); m_plane = GetPlane(t); m_plane.RemapToPlaneSpace(pts[i], out m_temp); var res = Array.BinarySearch(tt, t); if (res < 0) { res = ~res; res--; } if (res >= 0 && res < tt.Length - 1) { mu = (t - tt[res]) / (tt[res + 1] - tt[res]); m_temp.Z = Interpolation.Lerp(lengths[res], lengths[res + 1], mu); } else if (res < 0) { m_temp.Z = lengths.First(); } else if (res >= (tt.Length - 1)) { m_temp.Z = lengths.Last(); } m_output_pts[i] = m_temp; } ); } else { //for (int i = 0; i < pts.Count; ++i) Parallel.For(0, pts.Count, i => { Centreline.ClosestPoint(pts[i], out t); m_plane = GetPlane(t); m_plane.RemapToPlaneSpace(pts[i], out m_temp); m_temp.Z = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); m_output_pts[i] = m_temp; } ); } return(m_output_pts); }
public Plane GetPlane(Point3d pt) { Centreline.ClosestPoint(pt, out double t); return(GetPlane(t)); }