public Dictionary <string, object> GetProperties() { Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("id", ID); props.Add("centreline", Centreline); props.Add("width", Width); props.Add("height", Height); props.Add("length", Centreline.GetLength()); props.Add("lamella_width", Data.LamWidth); props.Add("lamella_height", Data.LamHeight); props.Add("lamella_count_width", Data.NumWidth); props.Add("lamella_count_height", Data.NumHeight); props.Add("volume", GetVolume()); props.Add("samples", Data.Samples); //props.Add("frames", GetAllPlanes()); double max_kw = 0.0, max_kh = 0.0; props.Add("max_curvature", GetMaxCurvature(ref max_kw, ref max_kh)); props.Add("max_curvature_width", max_kw); props.Add("max_curvature_height", max_kh); props.Add("type", ToString()); props.Add("type_id", (int)Type()); props.Add("orientation", Orientation); return(props); }
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 ArchivableDictionary GetArchivableDictionary() { ArchivableDictionary ad = new ArchivableDictionary(); ad.Set("id", ID); ad.Set("centreline", Centreline); ad.Set("width", Width); ad.Set("height", Height); ad.Set("length", Centreline.GetLength()); ad.Set("lamella_width", Data.LamWidth); ad.Set("lamella_height", Data.LamHeight); ad.Set("lamella_count_width", Data.NumWidth); ad.Set("lamella_count_height", Data.NumHeight); ad.Set("volume", GetVolume()); ad.Set("samples", Data.Samples); //var planes = GetAllPlanes(); //ArchivableDictionary pd = new ArchivableDictionary(); //for (int i = 0; i < planes.Length; ++i) //{ // pd.Set(string.Format("Frame_{0}", i), planes[i]); //} //ad.Set("frames", pd); double max_kw = 0.0, max_kh = 0.0; ad.Set("max_curvature", GetMaxCurvature(ref max_kw, ref max_kh)); ad.Set("max_curvature_width", max_kw); ad.Set("max_curvature_height", max_kh); ad.Set("type", ToString()); ad.Set("type_id", (int)Type()); return(ad); }
public override List <Curve> GetLamellaCurves() { List <Curve> lam_crvs = new List <Curve>(); double hWidth = Data.NumWidth * Data.LamWidth / 2; double hHeight = Data.NumHeight * Data.LamHeight / 2; Plane plane = Misc.PlaneFromNormalAndYAxis( Centreline.PointAtStart, Centreline.TangentAtStart, Orientation.GetOrientation(Centreline, Centreline.Domain.Min)); double hLw = Data.LamWidth / 2; double hLh = Data.LamHeight / 2; Transform xform = Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, plane); for (int i = 0; i < Data.NumHeight; ++i) { for (int j = 0; j < Data.NumWidth; ++j) { Point3d p = new Point3d(j * Data.LamWidth - hWidth + hLw, i * Data.LamHeight - hHeight + hLh, 0.0); Line l = new Line(p, Vector3d.ZAxis * Centreline.GetLength()); l.Transform(xform); lam_crvs.Add(l.ToNurbsCurve()); } } return(lam_crvs); }
public virtual double GetVolume(bool accurate = false) { if (accurate) { Rhino.Geometry.VolumeMassProperties vmp = VolumeMassProperties.Compute(GetBoundingBrep()); return(vmp.Volume); } return(Centreline.GetLength() * Width * Height); }
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 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 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); }
public override List <Brep> GetLamellaBreps() { double Length = Centreline.GetLength(); double hW = Data.NumWidth * Data.LamWidth / 2; double hH = Data.NumHeight * Data.LamHeight / 2; double[] DivParams = new double[] { Centreline.Domain.Min, Centreline.Domain.Max }; List <Curve>[,] LoftCurves = new List <Curve> [Data.NumWidth, Data.NumHeight]; List <Brep> LamellaBreps = new List <Brep>(); // Initialize curve lists for (int i = 0; i < Data.NumWidth; ++i) { for (int j = 0; j < Data.NumHeight; ++j) { LoftCurves[i, j] = new List <Curve>(); } } for (int i = 0; i < DivParams.Length; ++i) { Plane p = GetPlane(DivParams[i]); for (int j = 0; j < Data.NumWidth; ++j) { for (int k = 0; k < Data.NumHeight; ++k) { Rectangle3d rec = new Rectangle3d(p, new Interval(-hW + j * Data.LamWidth, -hW + (j + 1) * Data.LamWidth), new Interval(-hH + k * Data.LamHeight, -hH + (k + 1) * Data.LamHeight)); LoftCurves[j, k].Add(rec.ToNurbsCurve()); } } } for (int i = 0; i < Data.NumWidth; ++i) { for (int j = 0; j < Data.NumHeight; ++j) { Brep[] brep = Brep.CreateFromLoft(LoftCurves[i, j], Point3d.Unset, Point3d.Unset, LoftType.Normal, false); if (brep != null && brep.Length > 0) { LamellaBreps.Add(brep[0].CapPlanarHoles(Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)); } } } return(LamellaBreps); }
// 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 Glulam Trim(Interval domain, double overlap) { double l1 = Centreline.GetLength(new Interval(Centreline.Domain.Min, domain.Min)); double l2 = Centreline.GetLength(new Interval(Centreline.Domain.Min, domain.Max)); double t1, t2; if (!Centreline.LengthParameter(l1 - overlap, out t1)) { t1 = domain.Min; } if (!Centreline.LengthParameter(l2 + overlap, out t2)) { t2 = domain.Max; } domain = new Interval( Math.Max(t1, Centreline.Domain.Min), Math.Min(t2, Centreline.Domain.Max)); double length = Centreline.GetLength(domain); if (domain.IsDecreasing || length < overlap || length < Glulam.OverlapTolerance) { return(null); } double percentage = length / Centreline.GetLength(); GlulamData data = Data.Duplicate(); data.Samples = Math.Max(6, (int)(data.Samples * percentage)); Curve trimmed_curve = Centreline.Trim(domain); GlulamOrientation trimmed_orientation = Orientation.Trim(domain); trimmed_orientation.Remap(Centreline, trimmed_curve); Glulam glulam = CreateGlulam(trimmed_curve, trimmed_orientation, data); return(glulam); }
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 override Curve GetLamellaCurve(int i, int j) { double hWidth = Data.NumWidth * Data.LamWidth / 2; double hHeight = Data.NumHeight * Data.LamHeight / 2; Plane plane = Utility.PlaneFromNormalAndYAxis( Centreline.PointAtStart, Centreline.TangentAtStart, Orientation.GetOrientation(Centreline, Centreline.Domain.Min)); double hLw = Data.LamWidth / 2; double hLh = Data.LamHeight / 2; Transform xform = Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, plane); Point3d p = new Point3d(j * Data.LamWidth - hWidth + hLw, i * Data.LamHeight - hHeight + hLh, 0.0); Line l = new Line(p, Vector3d.ZAxis * Centreline.GetLength()); l.Transform(xform); return(l.ToNurbsCurve()); }
public Brep ToBrep() { var tt = Centreline.DivideByLength((int)(Centreline.GetLength() / 50.0), true); var planes = GetPlanes(tt); var xsections = new List <Curve>(); foreach (Plane plane in planes) { var rec = new Rectangle3d(plane, new Interval(-Width * 0.5, Width * 0.5), new Interval(-Height * 0.5, Height * 0.5)).ToNurbsCurve(); xsections.Add(rec); } var loft = Brep.CreateFromLoft(xsections, Point3d.Unset, Point3d.Unset, LoftType.Normal, false); loft[0] = loft[0].CapPlanarHoles(0.01); loft[0].Flip(); return(loft[0]); }
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 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 override Mesh GetBoundingMesh(double offset = 0.0, GlulamData.Interpolation interpolation = GlulamData.Interpolation.LINEAR) { //Curve CL = Centreline.Extend(CurveEnd.Both, offset, CurveExtensionStyle.Line); Mesh m = new Mesh(); double[] parameters; Plane[] frames; int N = 2; GenerateCrossSectionPlanes(N, out frames, out parameters, interpolation); double hW = Data.NumWidth * Data.LamWidth / 2 + offset; double hH = Data.NumHeight * Data.LamHeight / 2 + offset; Plane pplane; // vertex index and next frame vertex index int i4; int ii4; double Length = Centreline.GetLength() + offset * 2; double MaxT = parameters.Last() - parameters.First(); double Width = Data.NumWidth * Data.LamWidth / 1000; double Height = Data.NumHeight * Data.LamHeight / 1000; for (int i = 0; i < parameters.Length; ++i) { i4 = i * 8; ii4 = i4 - 8; pplane = frames[i]; for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { Point3d v = pplane.Origin + hW * j * pplane.XAxis + hH * k * pplane.YAxis; m.Vertices.Add(v); m.Vertices.Add(v); } } //double DivV = DivParams[i] / MaxT; double DivV = parameters[i] / MaxT * Length / 1000; m.TextureCoordinates.Add(2 * Width + 2 * Height, DivV); m.TextureCoordinates.Add(0.0, DivV); m.TextureCoordinates.Add(Height, DivV); m.TextureCoordinates.Add(Height, DivV); m.TextureCoordinates.Add(2 * Height + Width, DivV); m.TextureCoordinates.Add(2 * Height + Width, DivV); m.TextureCoordinates.Add(Width + Height, DivV); m.TextureCoordinates.Add(Width + Height, DivV); if (i > 0) { m.Faces.AddFace(i4 + 2, ii4 + 2, ii4 + 1, i4 + 1); m.Faces.AddFace(i4 + 6, ii4 + 6, ii4 + 3, i4 + 3); m.Faces.AddFace(i4 + 4, ii4 + 4, ii4 + 7, i4 + 7); m.Faces.AddFace(i4, ii4, ii4 + 5, i4 + 5); } } // Start cap pplane = GetPlane(parameters.First()); Point3d vc = pplane.Origin + hW * -1 * pplane.XAxis + hH * -1 * pplane.YAxis; m.Vertices.Add(vc); vc = pplane.Origin + hW * -1 * pplane.XAxis + hH * 1 * pplane.YAxis; m.Vertices.Add(vc); vc = pplane.Origin + hW * 1 * pplane.XAxis + hH * -1 * pplane.YAxis; m.Vertices.Add(vc); vc = pplane.Origin + hW * 1 * pplane.XAxis + hH * 1 * pplane.YAxis; m.Vertices.Add(vc); m.TextureCoordinates.Add(0, 0); m.TextureCoordinates.Add(0, Height); m.TextureCoordinates.Add(Width, 0); m.TextureCoordinates.Add(Width, Height); m.Faces.AddFace(m.Vertices.Count - 4, m.Vertices.Count - 3, m.Vertices.Count - 1, m.Vertices.Count - 2); // End cap pplane = GetPlane(parameters.Last()); vc = pplane.Origin + hW * -1 * pplane.XAxis + hH * -1 * pplane.YAxis; m.Vertices.Add(vc); vc = pplane.Origin + hW * -1 * pplane.XAxis + hH * 1 * pplane.YAxis; m.Vertices.Add(vc); vc = pplane.Origin + hW * 1 * pplane.XAxis + hH * -1 * pplane.YAxis; m.Vertices.Add(vc); vc = pplane.Origin + hW * 1 * pplane.XAxis + hH * 1 * pplane.YAxis; m.Vertices.Add(vc); m.TextureCoordinates.Add(0, 0); m.TextureCoordinates.Add(0, Height); m.TextureCoordinates.Add(Width, 0); m.TextureCoordinates.Add(Width, Height); m.Faces.AddFace(m.Vertices.Count - 2, m.Vertices.Count - 1, m.Vertices.Count - 3, m.Vertices.Count - 4); m.Vertices.CullUnused(); m.Compact(); //m.UserDictionary.ReplaceContentsWith(GetArchivableDictionary()); //m.UserDictionary.Set("glulam", GetArchivableDictionary()); return(m); }
/// <summary> /// Split glulam into two at parameter t, with an overlap of a certain length. /// </summary> /// <param name="t">Curve parameter to split glulam at.</param> /// <param name="overlap">Amount of overlap.</param> /// <returns>List of new glulams.</returns> public List <Glulam> Split(double t, double overlap) { if (overlap < Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance) { return(Split(t)); } if (!Centreline.Domain.IncludesParameter(t)) { return(null); } double split_length = Centreline.GetLength(new Interval(Centreline.Domain.Min, t)); double t1; double t2; if (!Centreline.LengthParameter(split_length + (overlap / 2), out t1)) { return(null); } if (!Centreline.LengthParameter(split_length - (overlap / 2), out t2)) { return(null); } if (!Centreline.Domain.IncludesParameter(t1) || !Centreline.Domain.IncludesParameter(t2)) { return(null); } Curve[] split_curves; Plane split_plane; double percentage; Glulam Blank1, Blank2; GlulamData Data1, Data2; { percentage = (t1 - Centreline.Domain.Min) / (Centreline.Domain.Max - Centreline.Domain.Min); split_plane = GetPlane(t1); split_curves = Centreline.Split(t1); if (split_curves == null || split_curves.Length != 2) { return(null); } var SplitOrientation = Orientation.Split(new double[] { t1 }); Data1 = Data.Duplicate(); Data1.Samples = Math.Max(2, (int)(Data.Samples * percentage)); Blank1 = CreateGlulam(split_curves[0], SplitOrientation[0], Data1); } { percentage = (t2 - Centreline.Domain.Min) / (Centreline.Domain.Max - Centreline.Domain.Min); split_plane = GetPlane(t2); split_curves = Centreline.Split(t2); if (split_curves == null || split_curves.Length != 2) { return(null); } var SplitOrientation = Orientation.Split(new double[] { t2 }); Data2 = Data.Duplicate(); Data2.Samples = Math.Max(2, (int)(Data.Samples * (1 - percentage))); Blank2 = CreateGlulam(split_curves[1], SplitOrientation[1], Data2); } List <Glulam> blanks = new List <Glulam>() { Blank1, Blank2 }; return(blanks); }
public object GetProperty(string key) { switch (key) { case ("id"): return(Id); case ("centreline"): return(Centreline); case ("width"): return(Width); case ("height"): return(Height); case ("length"): return(Centreline.GetLength()); case ("lamella_width"): return(Data.LamWidth); case ("lamella_height"): return(Data.LamHeight); case ("lamella_count_width"): return(Data.NumWidth); case ("lamella_count_height"): return(Data.NumHeight); case ("volume"): return(GetVolume()); case ("samples"): return(Data.Samples); case ("max_curvature"): double max_kw = 0.0, max_kh = 0.0; return(GetMaxCurvature(ref max_kw, ref max_kh)); case ("max_curvature_width"): max_kw = 0.0; max_kh = 0.0; GetMaxCurvature(ref max_kw, ref max_kh); return(max_kw); case ("max_curvature_height"): max_kw = 0.0; max_kh = 0.0; GetMaxCurvature(ref max_kw, ref max_kh); return(max_kh); case ("type"): return(ToString()); case ("type_id"): return((int)Type()); case ("orientation"): return(Orientation); default: return(null); } }
public override Mesh GetBoundingMesh(double offset = 0.0, GlulamData.Interpolation interpolation = GlulamData.Interpolation.LINEAR) { Mesh m = new Mesh(); int N = Math.Max(Data.Samples, 6); GenerateCrossSectionPlanes(N, out Plane[] frames, out double[] parameters, Data.InterpolationType); GetSectionOffset(out double offsetX, out double offsetY); Point3d[] m_corners = GenerateCorners(); double hW = Data.NumWidth * Data.LamWidth / 2 + offset; double hH = Data.NumHeight * Data.LamHeight / 2 + offset; // vertex index and next frame vertex index int i4; int ii4; //double texLength = (Centreline.GetLength() + offset * 2) / 1000; //double MaxT = parameters.Last() - parameters.First(); double texWidth = Width / 1000.0; // Width in meters double texHeight = Height / 1000.0; // Height in meters for (int i = 0; i < frames.Length; ++i) { i4 = i * 8; ii4 = i4 - 8; double texLength = Centreline.GetLength( new Interval(Centreline.Domain.Min, parameters[i])) / 1000; for (int j = 0; j < m_corners.Length; ++j) { Point3d v = frames[i].PointAt(m_corners[j].X, m_corners[j].Y); m.Vertices.Add(v); m.Vertices.Add(v); } //double DivV = parameters[i] / MaxT * Length / 1000; m.TextureCoordinates.Add(texLength, 2 * texWidth + 2 * texHeight); m.TextureCoordinates.Add(texLength, 0.0); m.TextureCoordinates.Add(texLength, texHeight); m.TextureCoordinates.Add(texLength, texHeight); m.TextureCoordinates.Add(texLength, 2 * texHeight + texWidth); m.TextureCoordinates.Add(texLength, 2 * texHeight + texWidth); m.TextureCoordinates.Add(texLength, texWidth + texHeight); m.TextureCoordinates.Add(texLength, texWidth + texHeight); if (i > 0) { m.Faces.AddFace(i4 + 2, ii4 + 2, ii4 + 1, i4 + 1); m.Faces.AddFace(i4 + 5, ii4 + 5, ii4 + 3, i4 + 3); m.Faces.AddFace(i4 + 7, ii4 + 7, ii4 + 4, i4 + 4); m.Faces.AddFace(i4, ii4, ii4 + 7, i4 + 7); } } Plane pplane; // Start cap pplane = frames.First(); //m_section_corners.Select(x => frames.Select(y => m.Vertices.Add(y.PointAt(x.X, x.Y)))); for (int j = 0; j < m_corners.Length; ++j) { m.Vertices.Add(pplane.PointAt(m_corners[j].X, m_corners[j].Y)); } m.TextureCoordinates.Add(0, 0); m.TextureCoordinates.Add(0, texHeight); m.TextureCoordinates.Add(texWidth, 0); m.TextureCoordinates.Add(texWidth, texHeight); m.Faces.AddFace(m.Vertices.Count - 4, m.Vertices.Count - 3, m.Vertices.Count - 2, m.Vertices.Count - 1); // End cap pplane = frames.Last(); for (int j = 0; j < m_corners.Length; ++j) { m.Vertices.Add(pplane.PointAt(m_corners[j].X, m_corners[j].Y)); } m.TextureCoordinates.Add(0, 0); m.TextureCoordinates.Add(0, texHeight); m.TextureCoordinates.Add(texWidth, 0); m.TextureCoordinates.Add(texWidth, texHeight); m.Faces.AddFace(m.Vertices.Count - 1, m.Vertices.Count - 2, m.Vertices.Count - 3, m.Vertices.Count - 4); //m.UserDictionary.ReplaceContentsWith(GetArchivableDictionary()); //m.UserDictionary.Set("glulam", GetArchivableDictionary()); return(m); }
public override List <Brep> GetLamellaBreps() { double Length = Centreline.GetLength(); double hW = Data.NumWidth * Data.LamWidth / 2; double hH = Data.NumHeight * Data.LamHeight / 2; //double[] DivParams = Centreline.DivideByCount(Data.Samples - 1, true); int N = Math.Max(Data.Samples, 6); GenerateCrossSectionPlanes(N, out Plane[] frames, out double[] parameters, Data.InterpolationType); GetSectionOffset(out double offsetX, out double offsetY); Point3d[,,] AllPoints = new Point3d[Data.NumWidth + 1, Data.NumHeight + 1, parameters.Length]; Point3d[,] CornerPoints = new Point3d[Data.NumWidth + 1, Data.NumHeight + 1]; for (int x = 0; x <= Data.NumWidth; ++x) { for (int y = 0; y <= Data.NumHeight; ++y) { CornerPoints[x, y] = new Point3d( -hW + offsetX + x * Data.LamWidth, -hH + offsetY + y * Data.LamHeight, 0); } } Transform xform; Point3d temp; for (int i = 0; i < frames.Length; ++i) { xform = Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, frames[i]); for (int x = 0; x <= Data.NumWidth; ++x) { for (int y = 0; y <= Data.NumHeight; ++y) { temp = new Point3d(CornerPoints[x, y]); temp.Transform(xform); AllPoints[x, y, i] = temp; } } } Curve[,] EdgeCurves = new Curve[Data.NumWidth + 1, Data.NumHeight + 1]; for (int x = 0; x <= Data.NumWidth; ++x) { for (int y = 0; y <= Data.NumHeight; ++y) { Point3d[] pts = new Point3d[frames.Length]; for (int z = 0; z < frames.Length; ++z) { pts[z] = AllPoints[x, y, z]; } EdgeCurves[x, y] = Curve.CreateInterpolatedCurve(pts, 3, CurveKnotStyle.Chord, frames.First().ZAxis, frames.Last().ZAxis); } } List <Brep> LamellaBreps = new List <Brep>(); for (int x = 0; x < Data.NumWidth; ++x) { for (int y = 0; y < Data.NumHeight; ++y) { Curve[] edges = new Curve[8]; edges[4] = new Line(AllPoints[x, y, 0], AllPoints[x + 1, y, 0]).ToNurbsCurve(); edges[5] = new Line(AllPoints[x, y + 1, 0], AllPoints[x + 1, y + 1, 0]).ToNurbsCurve(); edges[6] = new Line(AllPoints[x, y, frames.Length - 1], AllPoints[x + 1, y, frames.Length - 1]).ToNurbsCurve(); edges[7] = new Line(AllPoints[x, y + 1, frames.Length - 1], AllPoints[x + 1, y + 1, frames.Length - 1]).ToNurbsCurve(); Brep[] sides = new Brep[6]; sides[0] = Brep.CreateFromLoft( new Curve[] { EdgeCurves[x, y], EdgeCurves[x + 1, y] }, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]; sides[1] = Brep.CreateFromLoft( new Curve[] { EdgeCurves[x + 1, y], EdgeCurves[x + 1, y + 1] }, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]; sides[2] = Brep.CreateFromLoft( new Curve[] { EdgeCurves[x + 1, y + 1], EdgeCurves[x, y + 1] }, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]; sides[3] = Brep.CreateFromLoft( new Curve[] { EdgeCurves[x, y + 1], EdgeCurves[x, y] }, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]; sides[4] = Brep.CreateFromLoft( new Curve[] { edges[4], edges[5] }, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]; sides[5] = Brep.CreateFromLoft( new Curve[] { edges[6], edges[7] }, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0]; Brep brep = Brep.JoinBreps( sides, Tolerance )[0]; LamellaBreps.Add(brep); } } return(LamellaBreps); }