Files
StructureHelper/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionLogic.cs
Evgeny Redikultsev e4a23f5139 Add BeamShearCalculator
2025-02-16 17:24:16 +05:00

84 lines
2.8 KiB
C#

using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.Models.BeamShears
{
public class GetInclinedSectionLogic : IGetInclinedSectionLogic
{
private readonly IBeamShearSection beamShearSection;
private readonly double startCoord;
private readonly double endCoord;
private double width;
private double depth;
private double effectiveDepth;
private InclinedSection? inclinedSection;
public IShiftTraceLogger? TraceLogger { get; set; }
public GetInclinedSectionLogic(
IBeamShearSection beamShearSection,
double startCoord,
double endCoord,
IShiftTraceLogger? traceLogger)
{
this.beamShearSection = beamShearSection;
this.startCoord = startCoord;
this.endCoord = endCoord;
TraceLogger = traceLogger;
Check();
}
public IInclinedSection GetInclinedSection()
{
GetShapeParameters();
GetSection();
return inclinedSection;
}
private void GetSection()
{
effectiveDepth = depth - beamShearSection.CenterCover;
inclinedSection = new()
{
FullDepth = depth,
EffectiveDepth = effectiveDepth,
StartCoord = startCoord,
EndCoord = endCoord,
WebWidth = width
};
}
private void GetShapeParameters()
{
if (beamShearSection.Shape is IRectangleShape rectangle)
{
width = rectangle.Width;
depth = rectangle.Height;
}
else if (beamShearSection.Shape is ICircleShape circle)
{
width = circle.Diameter;
depth = circle.Diameter;
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(beamShearSection.Shape));
}
}
private void Check()
{
if (beamShearSection is null)
{
string errorString = ErrorStrings.ParameterIsNull + ": Beam shear section";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
if (beamShearSection.Shape is null)
{
string errorString = ErrorStrings.ParameterIsNull + ": Beam section shape";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
}
}
}