using FeMM.Common.Models;
using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;
namespace FeMM.Grasshopper.Components.Sections
{
    public class BeamSectionHollowCircleComponent : GH_Component
    {
        /// <summary>
        /// Initializes a new instance of the BeamSectionHollowCircleComponent class.
        /// </summary>
        public BeamSectionHollowCircleComponent()
          : base("Hollow Circle", "HC", "Hollow circle beam section", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_SECTIONS)
        {
        }

        /// <summary>
        /// Registers all the input parameters for this component.
        /// </summary>
        protected override void RegisterInputParams(GH_InputParamManager pManager)
        {
            pManager.AddNumberParameter("Diameter", "D", "The section diameter", GH_ParamAccess.item);
            pManager.AddNumberParameter("Thickness", "T", "The section thickness", GH_ParamAccess.item);
        }

        /// <summary>
        /// Registers all the output parameters for this component.
        /// </summary>
        protected override void RegisterOutputParams(GH_OutputParamManager pManager)
        {
            pManager.AddGenericParameter("Section", "S", "The hollow circular section", 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)
        {
            double d = 0, t = 0;
            if (!DA.GetData(0, ref d))
                return;
            if (!DA.GetData(1, ref t))
                return;

            var sectionModel = new SectionModel()
            {
                SectionType = SectionModel.SectionTypes.HollowCircle,
                D = d,
                T = t
            };
            sectionModel.CalculateSection();

            var section = new GH_BeamSection(sectionModel);
            DA.SetData(0, section);
        }

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

        /// <summary>
        /// Gets the unique ID for this component. Do not change this ID after release.
        /// </summary>
        public override Guid ComponentGuid => new("b4e99212-ddb6-4e61-88df-071156cb83b6");
    }
}
303 files24 directories