using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;
using System.Runtime.Versioning;

namespace FeMM.Grasshopper.Components.MeCheck
{
#if NETCOREAPP
    [SupportedOSPlatform("windows")]
#endif
    public class MixedSectionBeamComponent : GH_Component
    {
        /// <summary>
        /// Initializes a new instance of the MixedSectionBeamComponent class.
        /// </summary>
        public MixedSectionBeamComponent()
          : base("Assign Mixed Section", "AMS", "Assign the mixed sections to the beams", CategoryNameConstants.CATEGORY_CHECKS, CategoryNameConstants.SUBCATEGORY_MECHECK)
        {
        }

        /// <summary>
        /// Registers all the input parameters for this component.
        /// </summary>
        protected override void RegisterInputParams(GH_InputParamManager pManager)
        {
            pManager.AddGenericParameter("Beam", "B", "The beam to define the mixed section", GH_ParamAccess.item);
            pManager.AddGenericParameter("Section Start", "SS", "Section on the starting node", GH_ParamAccess.item);
            pManager.AddGenericParameter("Section End", "SE", "Section on the starting node", GH_ParamAccess.item);
            pManager.AddGenericParameter("Auto Loads", "AL", "The auto load of the beam", GH_ParamAccess.tree);
            pManager[3].Optional = true;
        }

        /// <summary>
        /// Registers all the output parameters for this component.
        /// </summary>
        protected override void RegisterOutputParams(GH_OutputParamManager pManager)
        {
            pManager.AddGenericParameter("Beam", "B", "The mixed section beam", 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_Beam beam = null;
            GH_MixedSection startSection = null;
            GH_MixedSection endSection = null;

            if (!DA.GetData(0, ref beam))
                return;
            if (!DA.GetData(1, ref startSection))
                return;
            if (!DA.GetData(2, ref endSection))
                return;

            var ms_beam = new GH_MixedSectionBeam()
            {
                Beam = beam,
                StartSection = startSection,
                EndSection = endSection
            };

            DA.SetData(0, ms_beam);
        }

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

        /// <summary>
        /// Gets the unique ID for this component. Do not change this ID after release.
        /// </summary>
        public override Guid ComponentGuid => new("36e42c93-10dc-450b-8daf-89fd3ceb7d7a");
    }
}
303 files24 directories