using FeMM.Common.Models;
using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;
using System.Runtime.Versioning;
namespace FeMM.Grasshopper.Components.Attributes
{
#if NETCOREAPP
[SupportedOSPlatform("windows")]
#endif
public class BeamOutputStationsComponent : GH_Component
{
/// <summary>
/// Initializes a new instance of the BeamReleasesComponent class.
/// </summary>
public BeamOutputStationsComponent()
: base("Beam Output Stations", "BOS", "Beam Output Stations", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_ATTRIBUTES)
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Beam", "B", "The beam where to define the output stations", GH_ParamAccess.item);
pManager.AddIntegerParameter("OutputStations", "O", "The minimum number of stations", GH_ParamAccess.item);
int[] idx =
[
pManager.AddBooleanParameter("At Intersections with other elements", "I", "If this item is True, no additional output stations are added at the ends " +
"of line elements when the frame object is internally meshed. (Only for SAP)", GH_ParamAccess.item, true),
pManager.AddBooleanParameter("At concentrated load locations", "PL", "If this item is True, no additional output stations are added at point load " +
"locations (only for SAP)", GH_ParamAccess.item, true),
];
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("Beam", "B", "The modified 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;
int stations = 0;
bool atIntersections = true;
bool atPointLoad = true;
if (!DA.GetData(0, ref beam))
return;
if (!DA.GetData(1, ref stations))
return;
DA.GetData(2, ref atIntersections);
DA.GetData(3, ref atPointLoad);
var newBeam = new GH_Beam(beam);
var attributeData = new BeamOutputStationsModel.AttributeData()
{
MinimumNumberOfStations = stations,
NoOutPutAndDesignAtElementEnds = atIntersections,
NoOutPutAndDesignAtPointLoads = atPointLoad,
};
var attr = new BeamOutputStationsModel(attributeData);
newBeam.Value.Attributes.Add(attr);
DA.SetData("Beam", newBeam);
}
public override GH_Exposure Exposure => GH_Exposure.secondary;
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon => Properties.Resources.BeamOutputStationsIcon;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new("6fde7eae-8abb-40d6-9a53-49dd678a22ad");
}
}