Example #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve crv = null;

            if (!DA.GetData("Curve", ref crv))
            {
                return;
            }

            crv.Domain.MakeIncreasing();

            List <object> r_orientation = new List <object>();

            DA.GetDataList("Orientation", r_orientation);

            object r_data = null;

            DA.GetData("Data", ref r_data);

            CrossSectionOrientation orientation = ParseGlulamOrientation(r_orientation, crv);

            AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, orientation.ToString());

            GlulamData data = ParseGlulamData(r_data);

            AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, data.ToString());

            data.Samples = (int)Math.Ceiling(crv.GetLength() / GlulamData.DefaultSampleDistance);

            Glulam glulam = Glulam.CreateGlulam(crv, orientation, data);


            DA.SetData("Glulam", new GH_Glulam(glulam));
        }
Example #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve        crv    = null;
            List <Plane> planes = new List <Plane>();

            if (!DA.GetData("Curve", ref crv))
            {
                return;
            }

            DA.GetDataList("Frames", planes);

            Lam.GlulamData data  = null;
            object         iData = null;

            DA.GetData("Data", ref iData);
            if (iData is GlulamData)
            {
                data = iData as GlulamData;
            }
            else if (iData is GH_GlulamData)
            {
                data = (iData as GH_GlulamData).Value;
            }
            else
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Failed to get GlulamData.");
            }

            Glulam blank = Glulam.CreateGlulam(crv, planes.ToArray(), data);

            DA.SetData("Glulam", new GH_Glulam(blank));
        }
Example #3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Glulam m_glulam = null;

            if (!DA.GetData <Glulam>("Glulam", ref m_glulam))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not get Glulam.");
                return;
            }

            double x = 0.0, y = 0.0;

            DA.GetData("OffsetX", ref x);
            DA.GetData("OffsetY", ref y);

            Curve crv = m_glulam.CreateOffsetCurve(x, y);


            // GlulamData data = GlulamData.FromCurveLimits(crv,g.Data.NumWidth * g.Data.LamWidth, g.Data.NumHeight * g.Data.LamHeight, g.GetAllPlanes());

            //data.Samples = g.Data.Samples;

            Glulam offset_glulam = Glulam.CreateGlulam(crv, m_glulam.Orientation.Duplicate(), m_glulam.Data.Duplicate());

            DA.SetData("Glulam", new GH_Glulam(offset_glulam));
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve crv  = null;
            Brep  brep = null;
            //double lw = 0, lh = 0;
            double       w = 0, h = 0;
            int          samples = 0;
            List <Plane> planes  = new List <Plane>();

            if (!DA.GetData("Curve", ref crv))
            {
                return;
            }
            if (!DA.GetData("Brep", ref brep))
            {
                return;
            }

            //DA.GetData("LamWidth", ref lw);
            //DA.GetData("LamHeight", ref lh);
            DA.GetData("Width", ref w);
            DA.GetData("Height", ref h);
            DA.GetData("Samples", ref samples);
            samples = Math.Max(samples, 2);

            Plane[] frames = tas.Core.Util.Misc.FramesNormalToSurface(crv, brep);

            GlulamData data = null;

            if (calculate_data)
            {
                data = Lam.GlulamData.FromCurveLimits(crv, w, h, frames);
            }
            else
            {
                data = new Lam.GlulamData(1, 1, w, h, samples);
            }
            //data.LamHeight = lh > 0.001 ? lh : 20.0;
            //data.LamWidth = lw > 0.001 ? lw : 20.0;
            //data.NumHeight = h > 0 ? (int)Math.Ceiling(h / lh) : 4;
            //data.NumWidth = w > 0 ? (int)Math.Ceiling(w / lw) : 4;

            data.InterpolationType = GlulamData.Interpolation.HERMITE;
            Glulam blank = Glulam.CreateGlulam(crv, frames, data);

            //Lam.Glulam blank = Lam.Glulam.CreateGlulamNormalToSurface(crv, brep, 20, null);
            DA.SetData("Glulam", new GH_Glulam(blank));
        }
Example #5
0
        public Glulam GlulamFromCurveMesh(Curve crv, Mesh mesh, GlulamType type = GlulamType.DoubleCurved, Standards.Standard standard = Standards.Standard.None, double tolerance = 10.0)
        {
            double     width, height;
            GlulamData data;
            Plane      xform = new Plane(crv.PointAtStart, crv.PointAtEnd - crv.PointAtStart);
            Polyline   convex_hull;

            if (crv.IsLinear())
            {
                type = GlulamType.Straight;
            }
            else if (crv.IsPlanar())
            {
                type = GlulamType.SingleCurved;
            }

            Beam beam;

            switch (type)
            {
            case GlulamType.Straight:
                var   line_curve = new Line(crv.PointAtStart, crv.PointAtEnd);
                Plane plane      = xform;
                mesh.FitToAxes(plane, out convex_hull, ref xform);

                height = convex_hull.BoundingBox.Max.Y - convex_hull.BoundingBox.Min.Y;
                width  = convex_hull.BoundingBox.Max.X - convex_hull.BoundingBox.Min.X;

                data = new GlulamData(1, 1, width, height);

                var orientation = new VectorOrientation(xform.YAxis);

                return(Glulam.CreateGlulam(line_curve.ToNurbsCurve(), orientation, data));

            case GlulamType.SingleCurved:
                crv.TryGetPlane(out Plane project, tolerance);
                mesh.FitToAxes(project, out convex_hull, ref xform);

                var cbb = crv.GetBoundingBox(project);
                height = (convex_hull.BoundingBox.Max.Y - convex_hull.BoundingBox.Min.Y) - (cbb.Max.Y - cbb.Min.Y);
                width  = (convex_hull.BoundingBox.Max.X - convex_hull.BoundingBox.Min.X) - (cbb.Max.X - cbb.Min.X);

                beam = new Beam {
                    Centreline = crv, Orientation = new PlanarOrientation(project), Width = width, Height = height
                };
                return(Glulam.CreateGlulam(beam, beam.Orientation, standard));

            case GlulamType.DoubleCurved:
            default:
                beam = new Beam {
                    Centreline = crv, Orientation = new RmfOrientation()
                };
                var gmesh = beam.ToBeamSpace(mesh);

                var bb = gmesh.GetBoundingBox(true);
                beam.Height = bb.Max.Y - bb.Min.Y;
                beam.Width  = bb.Max.X - bb.Min.X;

                return(Glulam.CreateGlulam(beam, beam.Orientation, standard));
            }
        }