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 BeamSectionTComponent : GH_Component
{
/// <summary>
/// Initializes a new instance of the BeamSectionTComponent class.
/// </summary>
public BeamSectionTComponent()
: base("T Section", "T", "Defines a T 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("Flange width", "FW", "The flange width", GH_ParamAccess.item);
pManager.AddNumberParameter("Flange thickness", "FT", "The flange thickness", GH_ParamAccess.item);
pManager.AddNumberParameter("Height", "H", "The total section height", GH_ParamAccess.item);
pManager.AddNumberParameter("Web thickness", "WT", "The web thickness", GH_ParamAccess.item);
pManager.AddNumberParameter("Radius", "R", "The fillet radius", GH_ParamAccess.item, 0);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Section", "S", "The T 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 b = 0, d = 0, t1 = 0, t2 = 0;
double r = 0;
if (!DA.GetData(0, ref b))
return;
if (!DA.GetData(1, ref t1))
return;
if (!DA.GetData(2, ref d))
return;
if (!DA.GetData(3, ref t2))
return;
if (!DA.GetData(4, ref r))
return;
var sectionModel = new SectionModel()
{
SectionType = SectionModel.SectionTypes.T,
D = d,
B = b,
T1 = t1,
T2 = t2,
R = r
};
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.TBeamSectionIcon;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new("2a2a2c2f-c079-4ad1-b298-5ba8a53e0003");
}
}