using FeMM.Common.Models;
using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;

namespace FeMM.Grasshopper.Components.Definitions
{
    public class PlateModifiersNameComponent : GH_Component
    {
        /// <summary>
        /// Initializes a new instance of the BeamReleasesComponent class.
        /// </summary>
        public PlateModifiersNameComponent()
          : base("Plate Modifier Named", "PMN", "Plate modifier Named (only for SAP/ETABS)", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_DEFINITIONS)
        {
        }

        /// <summary>
        /// Registers all the input parameters for this component.
        /// </summary>
        protected override void RegisterInputParams(GH_InputParamManager pManager)
        {
            pManager.AddTextParameter("Name", "N", "The beam modifiers name", GH_ParamAccess.item);
            int[] idx =
            [
                pManager.AddNumberParameter("Membrane F11", "F11", "Membrane F11 Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Membrane F22", "F22", "Membrane F22 Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Membrane F12", "F12", "Membrane F12 Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Bending M11", "M11", "Bending M11 Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Bending M22", "M22", "Bending M22 Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Bending M12", "M12", "Bending M12 Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Shear V13", "V13", "Shear V13 Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Shear V23", "V23", "Shear V23 Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Mass", "M", "Mass Modifier", GH_ParamAccess.item, 1.0),
                pManager.AddNumberParameter("Weight", "W", "Weight Modifier", GH_ParamAccess.item, 1.0),
            ];
            foreach (int i in idx)
                pManager[i].Optional = true;
        }

        /// <summary>
        /// Registers all the output parameters for this component.
        /// </summary>
        protected override void RegisterOutputParams(GH_OutputParamManager pManager)
        {
            pManager.AddGenericParameter("Plate Modifier", "PM", "The plate modifier", 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)
        {
            string name = null;
            double f11 = 1.0;
            double f22 = 1.0;
            double f12 = 1.0;
            double m11 = 1.0;
            double m22 = 1.0;
            double m12 = 1.0;
            double v13 = 1.0;
            double v23 = 1.0;
            double m = 1.0;
            double w = 1.0;

            if (!DA.GetData(0, ref name))
                return;

            DA.GetData(1, ref f11);
            DA.GetData(2, ref f22);
            DA.GetData(3, ref f12);
            DA.GetData(4, ref m11);
            DA.GetData(5, ref m22);
            DA.GetData(6, ref m12);
            DA.GetData(7, ref v13);
            DA.GetData(8, ref v23);
            DA.GetData(9, ref m);
            DA.GetData(10, ref w);

            var data = new PlateModifierNamedModel(name, f11, f22, f12, m11, m22, m12, v13, v23, m, w);

            var set = new GH_FunctionDefinition(data);
            DA.SetData(0, name);
        }

        public override GH_Exposure Exposure => GH_Exposure.quinary;

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

        /// <summary>
        /// Gets the unique ID for this component. Do not change this ID after release.
        /// </summary>
        public override Guid ComponentGuid => new("bcaf6eb6-e195-458a-9233-9d0119145da2");
    }
}
303 files24 directories