public static void SetGeometry(Brep surface, ref RFOpening rfOpening)
        {
            var myBoundaryLines = new List <NurbsCurve>();

            foreach (var brepEdge in surface.Edges)
            {
                myBoundaryLines.Add(brepEdge.ToNurbsCurve());
            }
            var joinedEdges = Curve.JoinCurves(myBoundaryLines).ToList();

            // In case of openings, countours must be sorted
            if (joinedEdges.Count > 1)
            {
                joinedEdges = joinedEdges.OrderByDescending(x => x.GetLength()).ToList();
            }
            var edges = new List <RFLine>();

            foreach (var e in joinedEdges[0].DuplicateSegments())
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(e, ref myRFLine);
                edges.Add(myRFLine);
            }
            if (!(rfOpening.IsPlanar()))
            {
                return;
            }
            rfOpening.Edges = edges.ToArray();
        }
        public static void SetGeometry(Curve curve, ref RFLine rFLine)
        {
            var inControlPoints = new List <Point3d>();

            rFLine.Order = curve.Degree + 1;
            var myNurbs = curve.ToNurbsCurve();

            foreach (var pt in myNurbs.Points)
            {
                inControlPoints.Add(pt.Location);
            }
            rFLine.ControlPoints = inControlPoints.ToArray();
            if (curve.Degree > 1)
            {
                var inWeights = new double[myNurbs.Points.Count];
                var myKnots   = new double[curve.Degree + myNurbs.Points.Count + 1];
                for (int i = 0; i < myNurbs.Points.Count; i++)
                {
                    inWeights[i] = myNurbs.Points[i].Weight;
                }
                // Knot vector for rfem must have n+p+1 knots between 0.0 and 1.0
                for (int i = 0; i < myNurbs.Knots.Count; i++)
                {
                    myKnots[i + 1] = (myNurbs.Knots[i] - myNurbs.Knots[0]) / (myNurbs.Knots[myNurbs.Knots.Count - 1] - myNurbs.Knots[0]);
                }
                myKnots[0] = myKnots[1];
                myKnots[curve.Degree + myNurbs.Points.Count] = myKnots[curve.Degree + myNurbs.Points.Count - 1];
                rFLine.Weights = inWeights.ToArray();
                rFLine.Knots   = myKnots;
            }


            //inControlPoints.Add(curve.PointAtStart);
            //for (int i = 0; i < curve.SpanCount; i++)
            //{
            //    var t1 = curve.SpanDomain(i).T1;
            //    if (curve.Degree > 1)
            //    {
            //        var t0 = curve.SpanDomain(i).T0;
            //        for (int j = 1; j <= interpolatedPoints; j++)
            //        {
            //            inControlPoints.Add(curve.PointAt(t0 + j * (t1 - t0) / (interpolatedPoints + 1)));
            //        }
            //    }
            //    inControlPoints.Add(curve.PointAt(t1));
            //}
            //rFLine.ControlPoints = inControlPoints.ToArray();
            if (curve.Degree > 1)
            {
                rFLine.Type = LineType.NurbSplineType;
            }
            else
            {
                rFLine.Type = LineType.PolylineType;
            }
            //rFLine.Vertices = null;
        }
        public static void SetGeometry(Brep surface, int interpolatedPoints, ref RFOpening rfOpening)
        {
            var myBoundaryLines = new List <NurbsCurve>();

            foreach (var brepEdge in surface.Edges)
            {
                myBoundaryLines.Add(brepEdge.ToNurbsCurve());
            }
            var joinedEdges = Curve.JoinCurves(myBoundaryLines).ToList();
            // In case of openings, countours must be sorted
            var edges = new List <RFLine>();

            foreach (var e in joinedEdges[0].DuplicateSegments())
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(e, ref myRFLine);
                edges.Add(myRFLine);
            }
            rfOpening.Edges = edges.ToArray();
        }
Ejemplo n.º 4
0
        public override void SolveInstance(IGH_DataAccess DA, out string msg, out GH_RuntimeMessageLevel level)
        {
            msg   = "";
            level = GH_RuntimeMessageLevel.Blank;

            Curve inCurve  = null;
            var   noIndex  = 0;
            var   comment  = "";
            var   rfSup    = new RFSupportL();
            var   inRFEM   = new GH_RFEM();
            var   mod      = false;
            var   del      = false;
            var   tx       = 0.0;
            var   ty       = 0.0;
            var   tz       = 0.0;
            var   rx       = 0.0;
            var   ry       = 0.0;
            var   rz       = 0.0;
            var   lineList = "";
            var   refSys   = 0;


            if (DA.GetData(11, ref inRFEM))
            {
                rfSup = new RFSupportL((RFSupportL)inRFEM.Value);
                if (DA.GetData(0, ref inCurve))
                {
                    var myRFLine = new RFLine();
                    Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                    var myRFLines = new List <RFLine>()
                    {
                        myRFLine
                    };
                    rfSup = new RFSupportL(rfSup, myRFLines);
                }
            }
            else if (DA.GetData(0, ref inCurve))
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                var myRFLines = new List <RFLine>()
                {
                    myRFLine
                };
                rfSup = new RFSupportL(new LineSupport(), myRFLines);
            }
            else if (DA.GetData(9, ref lineList))
            {
                rfSup          = new RFSupportL();
                rfSup.LineList = lineList;
            }
            else
            {
                msg   = "Insufficient input parameters. Provide either Input Curve or Line List or existing RFSupportL Object. ";
                level = GH_RuntimeMessageLevel.Warning;
                return;
            }
            if (DA.GetData(12, ref mod))
            {
                rfSup.ToModify = mod;
            }
            if (DA.GetData(13, ref del))
            {
                rfSup.ToDelete = del;
            }
            if (DA.GetData(1, ref noIndex))
            {
                rfSup.No = noIndex;
            }
            if (DA.GetData(8, ref comment))
            {
                rfSup.Comment = comment;
            }
            if (DA.GetData(2, ref tx))
            {
                rfSup.Tx = tx;
            }
            if (DA.GetData(3, ref ty))
            {
                rfSup.Ty = ty;
            }
            if (DA.GetData(4, ref tz))
            {
                rfSup.Tz = tz;
            }
            if (DA.GetData(5, ref rx))
            {
                rfSup.Rx = rx;
            }
            if (DA.GetData(6, ref ry))
            {
                rfSup.Ry = ry;
            }
            if (DA.GetData(7, ref rz))
            {
                rfSup.Rz = rz;
            }
            if (DA.GetData(9, ref lineList))
            {
                rfSup.LineList = lineList;
            }
            if (DA.GetData(10, ref refSys))
            {
                rfSup.RSType = (ReferenceSystemType)refSys;
                if (rfSup.RSType == ReferenceSystemType.UnknownReferenceSystemType)
                {
                    msg   = "Reference System Type not supported. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
            }

            DA.SetData(0, rfSup);
        }
        public static void SetGeometry(Brep surface, ref RFSurface rfSurface)
        {
            var myBoundaryLines = new List <NurbsCurve>();

            foreach (var brepEdge in surface.Edges)
            {
                myBoundaryLines.Add(brepEdge.ToNurbsCurve());
            }
            var joinedEdges = Curve.JoinCurves(myBoundaryLines).ToList();

            // In case of openings, countours must be sorted
            if (joinedEdges.Count > 1)
            {
                joinedEdges = joinedEdges.OrderByDescending(x => x.GetLength()).ToList();
            }
            var edges = new List <RFLine>();

            foreach (var e in joinedEdges[0].DuplicateSegments())
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(e, ref myRFLine);
                edges.Add(myRFLine);
            }
            rfSurface.Edges = edges.ToArray();
            // Openings
            if (joinedEdges.Count > 1)
            {
                var openings = new List <RFOpening>();
                for (int i = 1; i < joinedEdges.Count; i++)
                {
                    var myOpening = new Opening();
                    myOpening.InSurfaceNo = rfSurface.No;
                    var opEdges = new List <RFLine>();
                    foreach (var e in joinedEdges[i].DuplicateSegments())
                    {
                        var myRFLine = new RFLine();
                        Component_RFLine.SetGeometry(e, ref myRFLine);
                        opEdges.Add(myRFLine);
                    }
                    openings.Add(new RFOpening(myOpening, opEdges.ToArray()));
                }
                rfSurface.Openings = openings.ToArray();
            }
            // Check if surface is Planar to assign type
            if (rfSurface.IsPlanar())
            {
                rfSurface.GeometryType = SurfaceGeometryType.PlaneSurfaceType;
            }
            else
            {
                rfSurface.GeometryType = SurfaceGeometryType.QuadrangleSurfaceType;
                //var interpolatedPoints = 4;
                //// Assign control points
                //var myControlPoints = new Point3d[interpolatedPoints + 2, interpolatedPoints + 2];
                //var srfc = surface.Faces[0];
                //var uDomain = srfc.Domain(0);
                //var vDomain = srfc.Domain(1);
                //var derivatives = new Vector3d[0];
                //for (int i = 0; i < interpolatedPoints + 2; i++)
                //{
                //    var u = uDomain.T0 + i * (uDomain.T1 - uDomain.T0) / (interpolatedPoints + 1);
                //    for (int j = 0; j < interpolatedPoints + 2; j++)
                //    {
                //        var v = vDomain.T0 + j * (vDomain.T1 - vDomain.T0) / (interpolatedPoints + 1);
                //        srfc.Evaluate(u, v, 0, out myControlPoints[i, j], out derivatives);
                //    }
                //}
                //rfSurface.ControlPoints = myControlPoints;

                //SetGeometryNURBS(surface, ref rfSurface);
            }
        }
        public override void SolveInstance(IGH_DataAccess DA, out string msg, out GH_RuntimeMessageLevel level)
        {
            msg   = "";
            level = GH_RuntimeMessageLevel.Blank;
            //var line = new LineCurve();
            Curve inCurve = null;
            var   noIndex = 0;
            var   comment = "";
            var   rfHinge = new RFLineHinge();
            var   inRFEM  = new GH_RFEM();
            var   mod     = false;
            var   del     = false;
            var   tx      = 0.0;
            var   ty      = 0.0;
            var   tz      = 0.0;
            var   rx      = 0.0;
            var   ry      = 0.0;
            var   rz      = 0.0;
            var   lineNo  = 0;
            var   sfcNo   = 0;
            var   side    = 0;

            //int newNo = 0;


            if (DA.GetData(12, ref inRFEM))
            {
                rfHinge = new RFLineHinge((RFLineHinge)inRFEM.Value);
                if (DA.GetData(0, ref inCurve))
                {
                    var myRFLine = new RFLine();
                    Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                    rfHinge = new RFLineHinge(rfHinge, myRFLine);
                }
                if (DA.GetData(10, ref lineNo))
                {
                    rfHinge.LineNo = lineNo;
                }
            }
            else if (DA.GetData(0, ref inCurve))
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                rfHinge = new RFLineHinge(new RFLineHinge(), myRFLine);
            }
            else if (DA.GetData(10, ref lineNo))
            {
                rfHinge.LineNo = lineNo;
            }
            else
            {
                msg   = "Insufficient input parameters. Provide either Input Curve or Line Number or existing RFLineHinge Object. ";
                level = GH_RuntimeMessageLevel.Warning;
                return;
            }
            if (DA.GetData(13, ref mod))
            {
                rfHinge.ToModify = mod;
            }
            if (DA.GetData(14, ref del))
            {
                rfHinge.ToDelete = del;
            }
            if (DA.GetData(1, ref noIndex))
            {
                rfHinge.No = noIndex;
            }
            if (DA.GetData(2, ref sfcNo))
            {
                rfHinge.SfcNo = sfcNo;
            }
            if (DA.GetData(9, ref comment))
            {
                rfHinge.Comment = comment;
            }
            if (DA.GetData(3, ref tx))
            {
                rfHinge.Tx = tx;
            }
            if (DA.GetData(4, ref ty))
            {
                rfHinge.Ty = ty;
            }
            if (DA.GetData(5, ref tz))
            {
                rfHinge.Tz = tz;
            }
            if (DA.GetData(6, ref rx))
            {
                rfHinge.Rx = rx;
            }
            if (DA.GetData(7, ref ry))
            {
                rfHinge.Ry = ry;
            }
            if (DA.GetData(8, ref rz))
            {
                rfHinge.Rz = rz;
            }

            if (DA.GetData(11, ref side))
            {
                rfHinge.Side = (HingeSideType)side;
                if (rfHinge.Side == HingeSideType.UnknownSideType)
                {
                    msg   = "Hinge Side Type not supported. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
            }

            DA.SetData(0, rfHinge);
        }
        public override void SolveInstance(IGH_DataAccess DA, out string msg, out GH_RuntimeMessageLevel level)
        {
            msg   = "";
            level = GH_RuntimeMessageLevel.Blank;
            //var line = new LineCurve();
            Curve inCurve    = null;
            var   noIndex    = 0;
            var   comment    = "";
            var   rFMember   = new RFMember();
            var   inRFEM     = new GH_RFEM();
            var   mod        = false;
            var   del        = false;
            var   lineNo     = 0;
            var   memberType = 0;
            var   taperType  = 0;
            var   rotAngle   = 0.0;
            //var intPoints = 4;
            var sCS  = 0;
            var eCS  = 0;
            var sH   = 0;
            var eH   = 0;
            var ecc  = 0;
            var div  = 0;
            var kcry = 1.0;
            var kcrz = 1.0;

            //int newNo = 0;

            if (DA.GetData(15, ref inRFEM))
            {
                rFMember = new RFMember((RFMember)inRFEM.Value);
                if (DA.GetData(1, ref sCS))
                {
                    rFMember.StartCrossSectionNo = sCS;
                }
                if (DA.GetData(0, ref inCurve))
                {
                    var myRFLine = new RFLine();
                    Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                    rFMember.SetFrames();
                }
                if (DA.GetData(1, ref sCS))
                {
                    rFMember.StartCrossSectionNo = sCS;
                }
            }
            else if (DA.GetData(0, ref inCurve) && DA.GetData(1, ref sCS))
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                rFMember.BaseLine = myRFLine;
                rFMember.SetFrames();
                rFMember.StartCrossSectionNo = sCS;
            }
            else if (DA.GetData(4, ref lineNo) && DA.GetData(1, ref sCS))
            {
                rFMember.LineNo              = lineNo;
                rFMember.BaseLine            = null;
                rFMember.StartCrossSectionNo = sCS;
            }
            else
            {
                msg   = "Insufficient input parameters. Provide either Input Curve and Start Cross Section or existing RFMember Object. ";
                level = GH_RuntimeMessageLevel.Warning;
                return;
            }
            // Check line length
            if (rFMember.BaseLine != null && rFMember.BaseLine.ToCurve().GetLength() <= 0.001)
            {
                level = GH_RuntimeMessageLevel.Warning;
                msg   = "Line is too short. It may cause import errors.";
            }
            if (DA.GetData(16, ref mod))
            {
                rFMember.ToModify = mod;
            }
            if (DA.GetData(17, ref del))
            {
                rFMember.ToDelete = del;
            }
            if (DA.GetData(2, ref noIndex))
            {
                rFMember.No = noIndex;
            }
            if (DA.GetData(3, ref comment))
            {
                rFMember.Comment = comment;
            }
            //if (DA.GetData(4, ref lineNo))
            //{
            //    rFMember.LineNo = lineNo;
            //}
            if (DA.GetData(5, ref memberType))
            {
                rFMember.Type = (MemberType)memberType;
                if (rFMember.Type == MemberType.UnknownMemberType)
                {
                    msg   = "Member Type not supported. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
            }
            if (DA.GetData(6, ref rotAngle))
            {
                rFMember.RotationType  = RotationType.Angle;
                rFMember.RotationAngle = rotAngle;
            }
            if (DA.GetData(7, ref eCS))
            {
                rFMember.EndCrossSectionNo = eCS;
            }
            if (DA.GetData(8, ref sH))
            {
                rFMember.StartHingeNo = sH;
            }
            if (DA.GetData(9, ref eH))
            {
                rFMember.EndHingeNo = eH;
            }
            if (DA.GetData(10, ref ecc))
            {
                rFMember.EccentricityNo = ecc;
            }
            if (DA.GetData(11, ref div))
            {
                rFMember.DivisionNo = div;
            }
            if (DA.GetData(12, ref taperType))
            {
                rFMember.TaperShape = (TaperShapeType)taperType;
                if (rFMember.TaperShape == TaperShapeType.UnknownTaperShape)
                {
                    msg   = "Taper Shape Type not supported. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
            }
            if (DA.GetData(13, ref kcry))
            {
                if (kcry < 0 || kcry > 1000)
                {
                    msg   = "Effective length factor Kcr,y out of range. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
                rFMember.Kcry = kcry;
            }
            if (DA.GetData(14, ref kcrz))
            {
                if (kcrz < 0 || kcrz > 1000)
                {
                    msg   = "Effective length factor Kcr,z out of range. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
                rFMember.Kcrz = kcrz;
            }
            DA.SetData(0, rFMember);
        }
Ejemplo n.º 8
0
        public override void SolveInstance(IGH_DataAccess DA, out string msg, out GH_RuntimeMessageLevel level)
        {
            msg   = "";
            level = GH_RuntimeMessageLevel.Blank;
            //var line = new LineCurve();
            Curve inCurve  = null;
            var   noIndex  = 0;
            var   comment  = "";
            var   rFLine   = new RFLine();
            var   inRFEM   = new GH_RFEM();
            var   mod      = false;
            var   del      = false;
            var   nodeList = "";
            var   lineType = 0;
            var   rotAngle = 0.0;

            //int intPoints = 4;
            //int newNo = 0;

            if (DA.GetData(6, ref inRFEM))
            {
                rFLine = new RFLine((RFLine)inRFEM.Value);
            }
            else if (DA.GetData(0, ref inCurve))
            {
                Component_RFLine.SetGeometry(inCurve, ref rFLine);
            }
            else if (DA.GetData(3, ref nodeList))
            {
                rFLine.NodeList = nodeList;
            }
            else
            {
                msg   = "Insufficient input parameters. Provide either Input Curve, node list or existing RFLine Object. ";
                level = GH_RuntimeMessageLevel.Warning;
                return;
            }
            // Check line length
            if (rFLine.ControlPoints != null && rFLine.ControlPoints.Length > 0 && rFLine.ToCurve().GetLength() <= 0.001)
            {
                level = GH_RuntimeMessageLevel.Warning;
                msg   = "Line is too short. It may cause import errors.";
            }
            if (DA.GetData(7, ref mod))
            {
                rFLine.ToModify = mod;
            }
            if (DA.GetData(8, ref del))
            {
                rFLine.ToDelete = del;
            }
            if (DA.GetData(1, ref noIndex))
            {
                rFLine.No = noIndex;
            }
            if (DA.GetData(2, ref comment))
            {
                rFLine.Comment = comment;
            }
            if (DA.GetData(3, ref nodeList))
            {
                rFLine.NodeList = nodeList;
            }
            if (DA.GetData(4, ref lineType))
            {
                rFLine.Type = (LineType)lineType;
                if (rFLine.Type == LineType.UnknownLineType || rFLine.Type == LineType.ParabolaType || rFLine.Type == LineType.TrajectoryType ||
                    rFLine.Type == LineType.OnSurfaceType || (nodeList != "" && rFLine.Type == LineType.NurbSplineType))
                {
                    msg   = "Line Type not supported. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
            }
            if (DA.GetData(5, ref rotAngle))
            {
                rFLine.RotationType  = RotationType.Angle;
                rFLine.RotationAngle = rotAngle;
            }

            DA.SetData(0, rFLine);
        }
        /// <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, EvaluationUnit unit)
        {
            //var line = new LineCurve();
            Curve inCurve = null;
            var   noIndex = 0;
            var   comment = "";
            var   rfHinge = new RFLineHinge();
            var   inRFEM  = new GH_RFEM();
            var   mod     = false;
            var   del     = false;
            var   tx      = 0.0;
            var   ty      = 0.0;
            var   tz      = 0.0;
            var   rx      = 0.0;
            var   ry      = 0.0;
            var   rz      = 0.0;
            var   lineNo  = 0;
            var   sfcNo   = 0;
            var   side    = "";

            //int newNo = 0;


            if (DA.GetData(12, ref inRFEM))
            {
                rfHinge = new RFLineHinge((RFLineHinge)inRFEM.Value);
            }
            else if (DA.GetData(0, ref inCurve))
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                rfHinge = new RFLineHinge(new RFLineHinge(), myRFLine);
            }
            else if (DA.GetData(10, ref lineNo))
            {
                rfHinge.LineNo = lineNo;
            }
            else
            {
                return;
            }
            if (DA.GetData(13, ref mod))
            {
                rfHinge.ToModify = mod;
            }
            if (DA.GetData(14, ref del))
            {
                rfHinge.ToDelete = del;
            }
            if (DA.GetData(1, ref noIndex))
            {
                rfHinge.No = noIndex;
            }
            if (DA.GetData(2, ref sfcNo))
            {
                rfHinge.SfcNo = sfcNo;
            }
            if (DA.GetData(9, ref comment))
            {
                rfHinge.Comment = comment;
            }
            if (DA.GetData(3, ref tx))
            {
                rfHinge.Tx = tx;
            }
            if (DA.GetData(4, ref ty))
            {
                rfHinge.Ty = ty;
            }
            if (DA.GetData(5, ref tz))
            {
                rfHinge.Tz = tz;
            }
            if (DA.GetData(6, ref rx))
            {
                rfHinge.Rx = rx;
            }
            if (DA.GetData(7, ref ry))
            {
                rfHinge.Ry = ry;
            }
            if (DA.GetData(8, ref rz))
            {
                rfHinge.Rz = rz;
            }

            if (DA.GetData(11, ref side))
            {
                Enum.TryParse(side, out HingeSideType mySide);
                rfHinge.Side = mySide;
            }

            DA.SetData(0, rfHinge);
        }
        /// <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, EvaluationUnit unit)
        {
            //var line = new LineCurve();
            Curve inCurve    = null;
            var   noIndex    = 0;
            var   comment    = "";
            var   rFMember   = new RFMember();
            var   inRFEM     = new GH_RFEM();
            var   mod        = false;
            var   del        = false;
            var   lineNo     = 0;
            var   memberType = "";
            var   taperType  = "";
            var   rotAngle   = 0.0;
            //var intPoints = 4;
            var sCS = 0;
            var eCS = 0;
            var sH  = 0;
            var eH  = 0;
            var ecc = 0;
            var div = 0;

            //int newNo = 0;

            if (DA.GetData(13, ref inRFEM))
            {
                rFMember = new RFMember((RFMember)inRFEM.Value);
                if (DA.GetData(1, ref sCS))
                {
                    rFMember.StartCrossSectionNo = sCS;
                }
            }
            else if (DA.GetData(0, ref inCurve) && DA.GetData(1, ref sCS))
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                rFMember.BaseLine            = myRFLine;
                rFMember.StartCrossSectionNo = sCS;
            }
            else
            {
                return;
            }
            if (DA.GetData(14, ref mod))
            {
                rFMember.ToModify = mod;
            }
            if (DA.GetData(15, ref del))
            {
                rFMember.ToDelete = del;
            }
            if (DA.GetData(2, ref noIndex))
            {
                rFMember.No = noIndex;
            }
            if (DA.GetData(3, ref comment))
            {
                rFMember.Comment = comment;
            }
            if (DA.GetData(4, ref lineNo))
            {
                rFMember.LineNo = lineNo;
            }
            if (DA.GetData(5, ref memberType))
            {
                Enum.TryParse(memberType, out MemberType myMemberType);
                rFMember.Type = myMemberType;
            }
            if (DA.GetData(6, ref rotAngle))
            {
                rFMember.RotationType  = RotationType.Angle;
                rFMember.RotationAngle = rotAngle;
            }
            if (DA.GetData(7, ref eCS))
            {
                rFMember.EndCrossSectionNo = eCS;
            }
            if (DA.GetData(8, ref sH))
            {
                rFMember.StartHingeNo = sH;
            }
            if (DA.GetData(9, ref eH))
            {
                rFMember.EndHingeNo = eH;
            }
            if (DA.GetData(10, ref ecc))
            {
                rFMember.EccentricityNo = ecc;
            }
            if (DA.GetData(11, ref div))
            {
                rFMember.DivisionNo = div;
            }
            if (DA.GetData(12, ref taperType))
            {
                Enum.TryParse(taperType, out TaperShapeType myTaperType);
                rFMember.TaperShape = myTaperType;
            }
            DA.SetData(0, rFMember);
        }
Ejemplo n.º 11
0
        /// <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, EvaluationUnit unit)
        {
            //var line = new LineCurve();
            Curve inCurve  = null;
            var   noIndex  = 0;
            var   comment  = "";
            var   rfSup    = new RFSupportL();
            var   inRFEM   = new GH_RFEM();
            var   mod      = false;
            var   del      = false;
            var   tx       = 0.0;
            var   ty       = 0.0;
            var   tz       = 0.0;
            var   rx       = 0.0;
            var   ry       = 0.0;
            var   rz       = 0.0;
            var   lineList = "";
            var   refSys   = "";

            //int newNo = 0;


            if (DA.GetData(11, ref inRFEM))
            {
                rfSup = new RFSupportL((RFSupportL)inRFEM.Value);
            }
            else if (DA.GetData(0, ref inCurve))
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                var myRFLines = new List <RFLine>()
                {
                    myRFLine
                };
                rfSup = new RFSupportL(new LineSupport(), myRFLines);
            }
            else
            {
                return;
            }
            if (DA.GetData(12, ref mod))
            {
                rfSup.ToModify = mod;
            }
            if (DA.GetData(13, ref del))
            {
                rfSup.ToDelete = del;
            }
            if (DA.GetData(1, ref noIndex))
            {
                rfSup.No = noIndex;
            }
            if (DA.GetData(8, ref comment))
            {
                rfSup.Comment = comment;
            }
            if (DA.GetData(2, ref tx))
            {
                rfSup.Tx = tx;
            }
            if (DA.GetData(3, ref ty))
            {
                rfSup.Ty = ty;
            }
            if (DA.GetData(4, ref tz))
            {
                rfSup.Tz = tz;
            }
            if (DA.GetData(5, ref rx))
            {
                rfSup.Rx = rx;
            }
            if (DA.GetData(6, ref ry))
            {
                rfSup.Ry = ry;
            }
            if (DA.GetData(7, ref rz))
            {
                rfSup.Rz = rz;
            }
            if (DA.GetData(9, ref lineList))
            {
                rfSup.LineList = lineList;
            }
            if (DA.GetData(10, ref refSys))
            {
                Enum.TryParse(refSys, out ReferenceSystemType myrefSys);
                rfSup.RSType = myrefSys;
            }

            DA.SetData(0, rfSup);
        }
        public static void SetGeometryNURBS(Brep surface, ref RFSurface rfSurface)
        {
            var myNurbsSurface = surface.Faces[0].ToNurbsSurface();
            var edgesNURBS     = new NurbsCurve[4];
            // Get boundary Lines - UNTRIMMED!!!
            var edge1 = new NurbsCurve(myNurbsSurface.OrderU - 1, myNurbsSurface.Points.CountU);

            for (int i = 0; i < myNurbsSurface.Points.CountU; i++)
            {
                edge1.Points[i] = myNurbsSurface.Points.GetControlPoint(i, 0);
            }
            for (int i = 0; i < myNurbsSurface.KnotsU.Count; i++)
            {
                edge1.Knots[i] = myNurbsSurface.KnotsU[i];
            }
            var edge2 = new NurbsCurve(myNurbsSurface.OrderV - 1, myNurbsSurface.Points.CountV);

            for (int i = 0; i < myNurbsSurface.Points.CountV; i++)
            {
                edge2.Points[i] = myNurbsSurface.Points.GetControlPoint(0, i);
            }
            for (int i = 0; i < myNurbsSurface.KnotsV.Count; i++)
            {
                edge2.Knots[i] = myNurbsSurface.KnotsV[i];
            }
            var edge3 = new NurbsCurve(myNurbsSurface.OrderU - 1, myNurbsSurface.Points.CountU);

            for (int i = 0; i < myNurbsSurface.Points.CountU; i++)
            {
                edge3.Points[i] = myNurbsSurface.Points.GetControlPoint(i, myNurbsSurface.Points.CountV - 1);
            }
            for (int i = 0; i < myNurbsSurface.KnotsU.Count; i++)
            {
                edge3.Knots[i] = myNurbsSurface.KnotsU[i];
            }
            var edge4 = new NurbsCurve(myNurbsSurface.OrderV - 1, myNurbsSurface.Points.CountV);

            for (int i = 0; i < myNurbsSurface.Points.CountV; i++)
            {
                edge4.Points[i] = myNurbsSurface.Points.GetControlPoint(myNurbsSurface.Points.CountU - 1, i);
            }
            for (int i = 0; i < myNurbsSurface.KnotsV.Count; i++)
            {
                edge4.Knots[i] = myNurbsSurface.KnotsV[i];
            }
            edgesNURBS[0] = edge1;
            edgesNURBS[1] = edge2;
            edgesNURBS[2] = edge3;
            edgesNURBS[3] = edge4;

            //var myBoundaryLines = new List<NurbsCurve>();
            ////Untrim surface
            //var unTrimmed = surface.Faces[0].DuplicateSurface().ToBrep();
            //foreach (var brepEdge in unTrimmed.Edges)
            //{
            //    myBoundaryLines.Add(brepEdge.ToNurbsCurve());
            //}
            //var joinedEdges = Curve.JoinCurves(myBoundaryLines).ToList();
            //// In case of openings, countours must be sorted
            //if (joinedEdges.Count > 1)
            //{
            //    joinedEdges = joinedEdges.OrderByDescending(x => x.GetLength()).ToList();
            //}
            var edges = new List <RFLine>();

            //foreach (var e in joinedEdges[0].DuplicateSegments())
            foreach (var e in edgesNURBS)
            {
                var myRFLine = new RFLine();
                // If line has just 2 points - insert additional one (otherwise it doesnw work in RFEM)
                //var eNURBS = e.ToNurbsCurve();
                if (e.Points.Count <= 2)
                {
                    var splitted = e.Rebuild(3, e.Degree, true);
                }
                Component_RFLine.SetGeometry(e, ref myRFLine);
                edges.Add(myRFLine);
            }
            rfSurface.Edges = edges.ToArray();
            //// Openings
            //if (joinedEdges.Count > 1)
            //{
            //    var openings = new List<RFOpening>();
            //    for (int i = 1; i < joinedEdges.Count; i++)
            //    {
            //        var myOpening = new Opening();
            //        myOpening.InSurfaceNo = rfSurface.No;
            //        var opEdges = new List<RFLine>();
            //        foreach (var e in joinedEdges[i].DuplicateSegments())
            //        {
            //            var myRFLine = new RFLine();
            //            Component_RFLine.SetGeometry(e, ref myRFLine);
            //            opEdges.Add(myRFLine);
            //        }
            //        openings.Add(new RFOpening(myOpening, opEdges.ToArray()));
            //    }
            //    rfSurface.Openings = openings.ToArray();
            //}
            // Check if surface is Planar to assign type
            rfSurface.GeometryType = SurfaceGeometryType.NurbsSurfaceType;
            // Assign Nurbsurface data
            var utNURBS         = surface.Faces[0].DuplicateSurface().ToNurbsSurface();
            var myControlPoints = new Point3d[utNURBS.Points.CountU, utNURBS.Points.CountV];
            var myWeights       = new double[utNURBS.Points.CountU, utNURBS.Points.CountV];

            for (int i = 0; i < utNURBS.Points.CountU; i++)
            {
                for (int j = 0; j < utNURBS.Points.CountV; j++)
                {
                    var myPt = new Point3d();
                    utNURBS.Points.GetPoint(i, j, out myPt);
                    myControlPoints[i, j] = myPt;
                    myWeights[i, j]       = utNURBS.Points.GetWeight(i, j);
                }
            }

            // modify formulation -see curve knots!!!!!!!!!!!

            var countKnotsX = utNURBS.Points.CountU + utNURBS.OrderU;
            var myKnotX     = new double[countKnotsX];

            for (int i = 0; i < countKnotsX - 2; i++)
            {
                myKnotX[i + 1] = utNURBS.KnotsU[i] / utNURBS.KnotsU[countKnotsX - 3];
            }
            myKnotX[0] = myKnotX[1];
            myKnotX[countKnotsX - 1] = myKnotX[countKnotsX - 2];
            var countKnotsY = utNURBS.Points.CountV + utNURBS.OrderV;
            var myKnotY     = new double[countKnotsY];

            for (int i = 0; i < countKnotsY - 2; i++)
            {
                myKnotY[i + 1] = utNURBS.KnotsV[i] / utNURBS.KnotsV[countKnotsY - 3];
            }
            myKnotY[0] = myKnotY[1];
            myKnotY[countKnotsY - 1] = myKnotY[countKnotsY - 2];
            // Assign nurbs values
            rfSurface.ControlPoints = myControlPoints;
            rfSurface.Weights       = myWeights;
            rfSurface.KnotsX        = myKnotX;
            rfSurface.KnotsY        = myKnotY;
            rfSurface.OrderX        = utNURBS.OrderU;
            rfSurface.OrderY        = utNURBS.OrderV;
        }
        public override void SolveInstance(IGH_DataAccess DA, out string msg, out GH_RuntimeMessageLevel level)
        {
            msg   = "";
            level = GH_RuntimeMessageLevel.Blank;

            Curve inCurve      = null;
            var   noIndex      = 0;
            var   loadCase     = 0;
            var   comment      = "";
            var   rfLineLoad   = new RFLineLoad();
            var   inRFEM       = new GH_RFEM();
            var   mod          = false;
            var   del          = false;
            var   lineList     = "";
            var   type         = 0;
            var   dir          = 0;
            var   dist         = 0;
            var   reference    = 0;
            var   f1           = 0.0;
            var   f2           = 0.0;
            var   f3           = 0.0;
            var   t1           = 0.0;
            var   t2           = 0.0;
            var   loads        = new List <double>();
            var   distances    = new List <double>();
            var   totallength  = true;
            var   reldistances = true;


            if (DA.GetData(18, ref inRFEM))
            {
                rfLineLoad = new RFLineLoad((RFLineLoad)inRFEM.Value);
                if (DA.GetData(0, ref inCurve))
                {
                    var myRFLine = new RFLine();
                    Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                    var myRFLines = new List <RFLine>()
                    {
                        myRFLine
                    };
                    rfLineLoad = new RFLineLoad(rfLineLoad, myRFLines, rfLineLoad.LoadCase);
                }
                if (DA.GetData(1, ref loadCase))
                {
                    rfLineLoad.LoadCase = loadCase;
                }
                if (DA.GetData(5, ref lineList))
                {
                    rfLineLoad.LineList = lineList;
                }
            }
            else if ((DA.GetData(0, ref inCurve)) && (DA.GetData(1, ref loadCase)))
            {
                var myRFLine = new RFLine();
                Component_RFLine.SetGeometry(inCurve, ref myRFLine);
                var myRFLines = new List <RFLine>()
                {
                    myRFLine
                };
                rfLineLoad                   = new RFLineLoad(new LineLoad(), myRFLines, loadCase);
                rfLineLoad.LoadType          = LoadType.ForceType;
                rfLineLoad.LoadDirType       = LoadDirectionType.LocalZType;
                rfLineLoad.LoadDistType      = LoadDistributionType.UniformType;
                rfLineLoad.LoadRefType       = LineLoadReferenceType.LinesType;
                rfLineLoad.OverTotalLength   = true;
                rfLineLoad.RelativeDistances = true;
            }
            else if (DA.GetData(5, ref lineList) && (DA.GetData(1, ref loadCase)))
            {
                rfLineLoad                   = new RFLineLoad();
                rfLineLoad.LoadCase          = loadCase;
                rfLineLoad.LineList          = lineList;
                rfLineLoad.LoadType          = LoadType.ForceType;
                rfLineLoad.LoadDirType       = LoadDirectionType.LocalZType;
                rfLineLoad.LoadDistType      = LoadDistributionType.UniformType;
                rfLineLoad.LoadRefType       = LineLoadReferenceType.LinesType;
                rfLineLoad.OverTotalLength   = true;
                rfLineLoad.RelativeDistances = true;
            }
            else
            {
                msg   = "Insufficient input parameters. Provide either base line and load case or line list and load case or existing RFLineLoad Object. ";
                level = GH_RuntimeMessageLevel.Warning;
                return;
            }
            if (DA.GetData(19, ref mod))
            {
                rfLineLoad.ToModify = mod;
            }
            if (DA.GetData(20, ref del))
            {
                rfLineLoad.ToDelete = del;
            }
            if (DA.GetData(3, ref noIndex))
            {
                rfLineLoad.No = noIndex;
            }
            if (DA.GetData(4, ref comment))
            {
                rfLineLoad.Comment = comment;
            }
            if (DA.GetDataList(10, loads) && DA.GetDataList(11, distances))
            {
                if (loads.Count != distances.Count)
                {
                    msg   = "Null forces will result in an error in RFEM. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
                var loadsarray = new double[loads.Count, 2];
                for (int i = 0; i < loads.Count; i++)
                {
                    loadsarray[i, 0] = distances[i] * 100;
                    loadsarray[i, 1] = loads[i];
                }
                rfLineLoad.LoadArray = loadsarray;
            }
            if (DA.GetData(2, ref f1))
            {
                rfLineLoad.Magnitude1 = f1;
            }
            if (DA.GetData(6, ref f2))
            {
                rfLineLoad.Magnitude2 = f2;
            }
            if (DA.GetData(7, ref f3))
            {
                rfLineLoad.Magnitude3 = f3;
            }
            // Add warning in case of null forces
            if ((rfLineLoad.Magnitude1 == 0.0) && (rfLineLoad.Magnitude2 == 0.0) && (rfLineLoad.Magnitude3 == 0.0) && (loads.Count == 0))
            {
                msg   = "Null forces will result in an error in RFEM. ";
                level = GH_RuntimeMessageLevel.Warning;
                return;
            }
            if (DA.GetData(8, ref t1) && DA.GetData(9, ref t2))
            {
                rfLineLoad.DistanceA       = t1;
                rfLineLoad.DistanceB       = t2;
                rfLineLoad.OverTotalLength = false;
                if ((t1 < 0.0) || (t1 > 1.0) || (t2 < 0.0) || (t2 > 1.0))
                {
                    msg   = "Invalid interval. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
            }
            if (DA.GetData(13, ref dir))
            {
                rfLineLoad.LoadDirType = (LoadDirectionType)dir;
            }
            if (DA.GetData(14, ref dist))
            {
                rfLineLoad.LoadDistType = (LoadDistributionType)dist;
                if (rfLineLoad.LoadDistType == LoadDistributionType.UnknownLoadDistributionType)
                {
                    msg   = "Load Distribution not supported. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
            }
            if (DA.GetData(12, ref type))
            {
                var myType = (LoadType)type;
                // Check Load Orientation
                switch (myType)
                {
                case LoadType.ForceType:
                    if (rfLineLoad.LoadDirType == LoadDirectionType.LocalUType || rfLineLoad.LoadDirType == LoadDirectionType.LocalVType || rfLineLoad.LoadDirType == LoadDirectionType.UnknownLoadDirectionType || rfLineLoad.LoadDirType == LoadDirectionType.PerpendicularZType)
                    {
                        msg   = "Load Direction Type not supported for this Loading Type. ";
                        level = GH_RuntimeMessageLevel.Warning;
                        return;
                    }
                    break;

                case LoadType.MomentType:
                    if (rfLineLoad.LoadDirType == LoadDirectionType.LocalUType || rfLineLoad.LoadDirType == LoadDirectionType.LocalVType || rfLineLoad.LoadDirType == LoadDirectionType.ProjectXType || rfLineLoad.LoadDirType == LoadDirectionType.ProjectYType || rfLineLoad.LoadDirType == LoadDirectionType.ProjectZType || rfLineLoad.LoadDirType == LoadDirectionType.UnknownLoadDirectionType || rfLineLoad.LoadDirType == LoadDirectionType.PerpendicularZType)
                    {
                        msg   = "Load Direction Type not supported for this Loading Type. ";
                        level = GH_RuntimeMessageLevel.Warning;
                        return;
                    }
                    break;

                default:
                {
                    msg   = "Load Type not supported. ";
                    level = GH_RuntimeMessageLevel.Warning;
                    return;
                }
                }
                rfLineLoad.LoadType = myType;
            }
            if (DA.GetData(15, ref reference))
            {
                rfLineLoad.LoadRefType = (LineLoadReferenceType)reference;
            }
            if (DA.GetData(16, ref totallength))
            {
                rfLineLoad.OverTotalLength = totallength;
            }
            if (DA.GetData(17, ref reldistances))
            {
                rfLineLoad.RelativeDistances = reldistances;
            }
            DA.SetData(0, rfLineLoad);
        }
Ejemplo n.º 14
0
        /// <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, EvaluationUnit unit)
        {
            //var line = new LineCurve();
            Curve inCurve  = null;
            var   noIndex  = 0;
            var   comment  = "";
            var   rFLine   = new RFLine();
            var   inRFEM   = new GH_RFEM();
            var   mod      = false;
            var   del      = false;
            var   nodeList = "";
            var   lineType = "";
            var   rotAngle = 0.0;

            //int intPoints = 4;
            //int newNo = 0;

            if (DA.GetData(6, ref inRFEM))
            {
                rFLine = new RFLine((RFLine)inRFEM.Value);
            }
            else if (DA.GetData(0, ref inCurve))
            {
                Component_RFLine.SetGeometry(inCurve, ref rFLine);
            }
            else
            {
                return;
            }
            if (DA.GetData(7, ref mod))
            {
                rFLine.ToModify = mod;
            }
            if (DA.GetData(8, ref del))
            {
                rFLine.ToDelete = del;
            }
            if (DA.GetData(1, ref noIndex))
            {
                rFLine.No = noIndex;
            }
            if (DA.GetData(2, ref comment))
            {
                rFLine.Comment = comment;
            }
            if (DA.GetData(3, ref nodeList))
            {
                rFLine.NodeList = nodeList;
            }
            if (DA.GetData(4, ref lineType))
            {
                Enum.TryParse(lineType, out LineType myLineType);
                rFLine.Type = myLineType;
            }
            if (DA.GetData(5, ref rotAngle))
            {
                rFLine.RotationType  = RotationType.Angle;
                rFLine.RotationAngle = rotAngle;
            }

            DA.SetData(0, rFLine);
        }