Esempio n. 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            HM.hMember     member = null;
            List <Point3d> points = new List <Point3d>();
            List <string>  types  = new List <string>();

            if (!DA.GetData(0, ref member))
            {
                return;
            }
            if (!DA.GetDataList(1, points))
            {
                return;
            }
            if (!DA.GetDataList(2, types))
            {
                return;
            }

            if (points.Count != types.Count)
            {
                return;
            }

            var newMember = new HM.hMember(member);

            for (int i = 0; i < points.Count; i++)
            {
                newMember.AddOperationByPointType(HMGHUtil.PointToTriple(points[i]), types[i]);
            }

            DA.SetData(0, newMember);
        }
Esempio n. 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Get names
            var names = new List <string>();

            if (!DA.GetDataList(0, names))
            {
                return;
            }

            // Get normals
            var vectors = new List <Vector3d>();

            if (!DA.GetDataList(1, vectors))
            {
                return;
            }

            // There should be the same number of names and normals
            if (names.Count != vectors.Count)
            {
                return;
            }

            // Create dictionary
            var dictionary = new Dictionary <string, HM.Triple>();

            for (int i = 0; i < names.Count; i++)
            {
                dictionary[names[i]] = HMGHUtil.VectorToTriple(vectors[i]);
            }
            DA.SetData(0, dictionary);
        }
Esempio n. 3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Declare placeholder variables and assign initial invalid data.
            //    This way, if the input parameters fail to supply valid data, we know when to abort.
            HM.hMember member = null;

            // 2. Retrieve input data.
            if (!DA.GetData(0, ref member))
            {
                return;
            }

            var webNormal = member.WebNormal;

            DA.SetData(0, HMGHUtil.TripleToVector(webNormal));
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Declare placeholder variables and assign initial invalid data.
            //    This way, if the input parameters fail to supply valid data, we know when to abort.
            Line     line   = Line.Unset;
            Vector3d vector = Vector3d.Unset;
            string   name   = string.Empty;

            // 2. Retrieve input data.
            if (!DA.GetData(0, ref line))
            {
                return;
            }
            if (!DA.GetData(1, ref vector))
            {
                return;
            }
            if (!DA.GetData(2, ref name))
            {
                name = "<name>";
            }

            // 3. Abort on invalid inputs.
            if (!line.IsValid)
            {
                return;
            }
            if (!vector.IsValid)
            {
                return;
            }

            // 4. Build hMember.
            var mem = new HM.hMember(HMGHUtil.GHLineToHMLine(line), HMGHUtil.VectorToTriple(vector));

            mem.Name = name;

            // 9. Assign output.
            DA.SetData(0, mem);
        }
Esempio n. 5
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare placeholder variables and assign initial invalid data.
            List <Line>   inputLines           = new List <Line>();
            List <string> names                = new List <string>();
            bool          firstConnectionIsFTF = false;
            Dictionary <string, HM.Triple> webNormalsDictionary = null;
            Dictionary <string, int>       prioritiesDictionary = null;
            Dictionary <string, int>       extensionDictionary  = null;
            double tolerance = 0.001;

            // Retrieve input data.
            if (!DA.GetDataList(0, inputLines))
            {
                return;
            }
            if (!DA.GetDataList(1, names))
            {
                names = null;
            }
            if (!DA.GetData(2, ref firstConnectionIsFTF))
            {
                firstConnectionIsFTF = false;
            }
            if (!DA.GetData(3, ref webNormalsDictionary))
            {
                webNormalsDictionary = null;
            }
            if (!DA.GetData(4, ref prioritiesDictionary))
            {
                prioritiesDictionary = null;
            }
            if (!DA.GetData(5, ref extensionDictionary))
            {
                extensionDictionary = null;
            }
            if (!DA.GetData(6, ref tolerance))
            {
                tolerance = 0.001;
            }

            if (names == null)
            {
                names = new List <string>();
                for (int j = 0; j < inputLines.Count; j++)
                {
                    names.Add(j.ToString());
                }
            }

            if (names.Count < inputLines.Count)
            {
                throw new Exception("You must provide a name for every member.");
            }

            // Convert GH lines to HM lines
            var HMLines = new List <HM.Line>();
            var i       = 0;

            foreach (Line l in inputLines)
            {
                HMLines.Add(HMGHUtil.GHLineToHMLine(l));
            }

            // Create Structure
            var structure = HM.hStructure.StructureFromLines(
                HMLines,
                names,
                webNormalsDict: webNormalsDictionary,
                priorityDict: prioritiesDictionary,
                extensionDict: extensionDictionary,
                firstConnectionIsFTF: firstConnectionIsFTF,
                intersectionTolerance: tolerance,
                planarityTolerance: tolerance);

            DA.SetDataList(0, structure.Members);
            DA.SetDataList(1, structure._solveOrder);
            DA.SetDataList(2, structure._solvedBy);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 1. Declare placeholder variables and assign initial invalid data.
            //    This way, if the input parameters fail to supply valid data, we know when to abort.
            HM.hMember member = null;

            // 2. Retrieve input data.
            if (!DA.GetData(0, ref member))
            {
                return;
            }

            // 3. Abort on invalid inputs.
            //if (!member.IsValid) { return; }

            var webAxisLine = member.WebAxis;
            var webNormal   = member.WebNormal;

            var OP1 = webAxisLine.StartPoint;
            var OP2 = webAxisLine.EndPoint;

            var webAxis = HM.Triple.ByTwoPoints(OP1, OP2);
            var normal  = webNormal;
            var lateral = webAxis.Cross(normal);

            lateral = lateral.Normalized();
            lateral = lateral.Scale(1.75);
            normal  = normal.Normalized();
            normal  = normal.Scale(1.5);
            var lateralR = new HM.Triple(lateral.X * -1, lateral.Y * -1, lateral.Z * -1);
            var webAxisR = new HM.Triple(webAxis.X * -1, webAxis.Y * -1, webAxis.Z * -1);
            var normalR  = new HM.Triple(normal.X * -1, normal.Y * -1, normal.Z * -1);

            var p0 = HMGHUtil.TripleToPoint(OP1.Add(normal.Add(lateral)));
            var p1 = HMGHUtil.TripleToPoint(OP2.Add(normal.Add(lateral)));
            var p2 = HMGHUtil.TripleToPoint(OP1.Add(lateral));
            var p3 = HMGHUtil.TripleToPoint(OP2.Add(lateral));
            var p6 = HMGHUtil.TripleToPoint(OP1.Add(normal.Add(lateralR)));
            var p7 = HMGHUtil.TripleToPoint(OP2.Add(normal.Add(lateralR)));
            var p4 = HMGHUtil.TripleToPoint(OP1.Add(lateralR));
            var p5 = HMGHUtil.TripleToPoint(OP2.Add(lateralR));

            lateral  = lateral.Normalized().Scale(1.25);
            lateralR = lateralR.Normalized().Scale(1.25);
            var p8  = HMGHUtil.TripleToPoint(OP1.Add(lateralR).Add(normal));
            var p9  = HMGHUtil.TripleToPoint(OP2.Add(lateralR).Add(normal));
            var p10 = HMGHUtil.TripleToPoint(OP1.Add(lateral).Add(normal));
            var p11 = HMGHUtil.TripleToPoint(OP2.Add(lateral).Add(normal));


            var flange1 = NurbsSurface.CreateFromCorners(p0, p1, p3, p2);
            var flange2 = NurbsSurface.CreateFromCorners(p4, p5, p7, p6);
            var web     = NurbsSurface.CreateFromCorners(p2, p3, p5, p4);
            var lip1    = NurbsSurface.CreateFromCorners(p0, p1, p11, p10);
            var lip2    = NurbsSurface.CreateFromCorners(p6, p7, p9, p8);

            var memGeo = new List <Brep>()
            {
                Brep.CreateFromSurface(flange1), Brep.CreateFromSurface(flange2), Brep.CreateFromSurface(web), Brep.CreateFromSurface(lip1), Brep.CreateFromSurface(lip2)
            };
            var brep = Brep.JoinBreps(memGeo, 0.001)[0];

            DA.SetData(0, brep);
        }
Esempio n. 7
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Get member from input
            HM.hMember member = null;
            if (!DA.GetData(0, ref member))
            {
                return;
            }

            // Get member properties as Rhino Geometry
            var webAxisLine      = HMGHUtil.HMLineToGHLine(member.WebAxis);
            var webAxisDirection = HMGHUtil.TripleToVector(member.WebAxis.Direction.Normalized());
            var webNormal        = HMGHUtil.TripleToVector(member.WebNormal.Normalized());
            var flangeNormal     = HMGHUtil.TripleToVector(member.WebNormal.Cross(member.WebAxis.Direction).Normalized());

            // Get operations as curves
            var opCurves = new List <Curve>();

            foreach (HM.hOperation op in member.Operations)
            {
                // Get centerpoints
                var centerTriples = member.GetOperationPunchCenterPoint(op);
                var centerPoints  = new List <Point3d>();
                foreach (HM.Triple t in centerTriples)
                {
                    centerPoints.Add(HMGHUtil.TripleToPoint(t));
                }

                switch (op._type)
                {
                case HM.Operation.BOLT:
                    opCurves.Add(new Circle(new Plane(centerPoints[0], webNormal), 0.25).ToNurbsCurve());
                    break;

                case HM.Operation.SERVICE_HOLE:
                    opCurves.Add(new Circle(new Plane(centerPoints[0], webNormal), 0.5).ToNurbsCurve());
                    break;

                case HM.Operation.WEB:
                    foreach (Point3d p in centerPoints)
                    {
                        opCurves.Add(new Circle(new Plane(p, webNormal), 0.0625).ToNurbsCurve());
                    }
                    break;

                case HM.Operation.DIMPLE:
                    foreach (Point3d p in centerPoints)
                    {
                        opCurves.Add(new Circle(new Plane(p, flangeNormal), 0.0625).ToNurbsCurve());
                    }
                    break;

                case HM.Operation.NOTCH:
                    opCurves.Add(new Rectangle3d(new Plane(centerPoints[0], flangeNormal, webAxisDirection), new Interval(-1.75, 1.75), new Interval(-1.75 / 2, 1.75 / 2)).ToNurbsCurve());
                    break;

                case HM.Operation.END_TRUSS:
                    var midPoint          = member.WebAxis.PointAtParameter(0.5);
                    var endPoint          = member.WebAxis.PointAtParameter(member.WebAxis.ParameterAtPoint(centerTriples[0]));
                    var endTrussDirection = HMGHUtil.TripleToVector(HM.Triple.ByTwoPoints(endPoint, midPoint).Normalized());
                    foreach (Point3d p in centerPoints)
                    {
                        var p1 = Point3d.Add(p, Vector3d.Multiply(0.25, webNormal));
                        var p2 = Point3d.Add(p, Vector3d.Multiply(0.75, webNormal));
                        var p3 = Point3d.Add(p2, Vector3d.Multiply(0.5, endTrussDirection));
                        opCurves.Add(new Polyline(new List <Point3d> {
                            p1, p2, p3, p1
                        }).ToNurbsCurve());

                        var p4 = Point3d.Add(p, Vector3d.Multiply(-0.25, webNormal));
                        var p5 = Point3d.Add(p, Vector3d.Multiply(-0.75, webNormal));
                        var p6 = Point3d.Add(p5, Vector3d.Multiply(0.5, endTrussDirection));
                        opCurves.Add(new Polyline(new List <Point3d> {
                            p4, p5, p6, p4
                        }).ToNurbsCurve());
                    }
                    break;

                case HM.Operation.LIP_CUT:
                    foreach (Point3d p in centerPoints)
                    {
                        opCurves.Add(new Rectangle3d(new Plane(p, flangeNormal, webAxisDirection), new Interval(-0.25, 0.25), new Interval(-1.75 / 2, 1.75 / 2)).ToNurbsCurve());
                    }
                    break;

                case HM.Operation.SWAGE:
                    var left  = Vector3d.Multiply(1.25, flangeNormal);
                    var right = Vector3d.Multiply(-1.25, flangeNormal);
                    var up    = Vector3d.Multiply(0.875, webAxisDirection);
                    var down  = Vector3d.Multiply(-0.875, webAxisDirection);
                    var pt1   = Point3d.Add(Point3d.Add(centerPoints[0], left), up);
                    var pt2   = Point3d.Add(Point3d.Add(centerPoints[0], left), down);
                    var pt3   = Point3d.Add(Point3d.Add(centerPoints[0], right), up);
                    var pt4   = Point3d.Add(Point3d.Add(centerPoints[0], right), down);
                    opCurves.Add(new Line(pt1, pt2).ToNurbsCurve());
                    opCurves.Add(new Line(pt3, pt4).ToNurbsCurve());
                    break;
                }
            }
            DA.SetDataList(0, opCurves);
        }