using FeMM.Grasshopper.Components.Parameters;
using FeMM.Grasshopper.DataTypes.MeCheck2;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;

namespace FeMM.Grasshopper.Components.MeCheck2
{
    public class CompositeBeamTensionResultComponent : GH_Component
    {
        /// <summary>
        /// Initializes a new instance of the MeshRemap class.
        /// </summary>
        public CompositeBeamTensionResultComponent()
          : base("Composite Section Linear Tension Results", "CSLTR", "Results for Composite Section Linear Tension analysis", CategoryNameConstants.CATEGORY_CHECKS, CategoryNameConstants.SUBCATEGORY_MECHECK2)
        {
        }

        /// <summary>
        /// Registers all the input parameters for this component.
        /// </summary>
        protected override void RegisterInputParams(GH_InputParamManager pManager)
        {
            pManager.AddParameter(new StressAnalysisResultMeCheckParam(), "Linear Tension Results", "LTR", "The Linear Tension Results", GH_ParamAccess.item);
        }

        /// <summary>
        /// Registers all the output parameters for this component.
        /// </summary>
        protected override void RegisterOutputParams(GH_OutputParamManager pManager)
        {
            pManager.AddNumberParameter("Point1_ConcreteEpsilon", "P1_CE", "Point1_ConcreteEpsilon", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point1_ConcreteSigma", "P1_CS", "Point1_ConcreteSigma", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point2_RebarSigma", "P2_RS", "Point2_RebarSigma", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point3_RebarSigma", "P3_RS", "Point3_RebarSigma", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point4_ConcreteSigma", "P4_CS", "Point4_ConcreteSigma", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point5_SteelSigma", "P5_SS", "Point5_SteelSigma", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point6_SteelSigma", "P6_SS", "Point6_SteelSigma", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point6_SteelTau ", "P6_ST", "Point6_SteelTau ", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point6_SigmaId ", "P6_Id", "Point6_SigmaId ", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point7_SteelSigma", "P7_SS", "Point7_SteelSigma", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point7_SteelTau ", "P7_ST", "Point7_SteelTau ", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point7_SigmaId ", "P7_Id", "Point7_SigmaId ", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point8_SteelSigma", "P8_SS", "Point8_SteelSigma", GH_ParamAccess.item);
            pManager.AddNumberParameter("Point8_SteelEpsilon", "P8_SE", "Point8_SteelEpsilon", GH_ParamAccess.item);
        }

        /// <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)
        {
            GH_StressAnalysisResultMeCheck result = null;

            int count = 0;
            if (!DA.GetData(count++, ref result))
                return;

            if (result.IsValid)
            {
                var v = result.Value;
                int index = 0;
                DA.SetData(index++, v.Point1_ConcreteEpsilon);
                DA.SetData(index++, v.Point1_ConcreteSigma);
                DA.SetData(index++, v.Point2_RebarSigma);
                DA.SetData(index++, v.Point3_RebarSigma);
                DA.SetData(index++, v.Point4_ConcreteSigma);
                DA.SetData(index++, v.Point5_SteelSigma);
                DA.SetData(index++, v.Point6_SteelSigma);
                DA.SetData(index++, v.Point6_SteelTau);
                DA.SetData(index++, v.Point6_SteelSigmaId);
                DA.SetData(index++, v.Point7_SteelSigma);
                DA.SetData(index++, v.Point7_SteelTau);
                DA.SetData(index++, v.Point7_SteelSigmaId);
                DA.SetData(index++, v.Point8_SteelSigma);
                DA.SetData(index++, v.Point8_SteelEpsilon);
            }
        }

        public override GH_Exposure Exposure => GH_Exposure.tertiary;

        /// <summary>
        /// Provides an Icon for the component.
        /// </summary>
        protected override System.Drawing.Bitmap Icon => Properties.Resources.MixedSectionBeamCheckIcon;

        /// <summary>
        /// Gets the unique ID for this component. Do not change this ID after release.
        /// </summary>
        public override Guid ComponentGuid => new("d5038a4c-1473-4e4b-8a21-a9a2c433fe6b");
    }
}
303 files24 directories