Add circle shape calculation for shear

This commit is contained in:
RedikultsevEvg
2025-07-20 21:45:07 +05:00
parent ddf075bffd
commit 6e8f4bcc58
40 changed files with 488 additions and 99 deletions

View File

@@ -43,7 +43,7 @@ namespace DataAccess.DTOs
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearSectionUpdateStrategy();
updateStrategy ??= new BeamShearSectionUpdateStrategy() { UpdateChildren = false};
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>
(this, new ShapeFromDTOConvertStrategy(this));
concreteConvertStrategy = new ConcreteLibMaterialFromDTOConvertStrategy()

View File

@@ -50,7 +50,7 @@ namespace DataAccess.DTOs
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearSectionUpdateStrategy();
updateStrategy ??= new BeamShearSectionUpdateStrategy() { UpdateChildren = false};
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>
(this, new ShapeToDTOConvertStrategy(this));
concreteConvertStrategy = new ConcreteLibMaterialToDTOConvertStrategy()

View File

@@ -0,0 +1,29 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class CircleShapeFromDTOConvertStrategy : ConvertStrategy<CircleShape, CircleShapeDTO>
{
private IUpdateStrategy<ICircleShape> updateStrategy;
public CircleShapeFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override CircleShape GetNewItem(CircleShapeDTO source)
{
ChildClass = this;
ChildClass = this;
updateStrategy ??= new CircleShapeUpdateStrategy();
NewItem = new CircleShape(source.Id);
updateStrategy.Update(NewItem, source);
return NewItem;
}
}
}

View File

@@ -0,0 +1,23 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
namespace DataAccess.DTOs
{
public class CircleShapeToDTOConvertStrategy : ConvertStrategy<CircleShapeDTO, ICircleShape>
{
private IUpdateStrategy<ICircleShape> updateStrategy;
public CircleShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override CircleShapeDTO GetNewItem(ICircleShape source)
{
ChildClass = this;
updateStrategy ??= new CircleShapeUpdateStrategy();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
return NewItem;
}
}
}

View File

@@ -7,6 +7,7 @@ namespace DataAccess.DTOs
internal class ShapeFromDTOConvertStrategy : ConvertStrategy<IShape, IShape>
{
private IConvertStrategy<RectangleShape, RectangleShapeDTO> rectangleConvertStrategy;
private IConvertStrategy<CircleShape, CircleShapeDTO> circleConvertStrategy;
public ShapeFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
@@ -14,12 +15,19 @@ namespace DataAccess.DTOs
public override IShape GetNewItem(IShape source)
{
ChildClass = this;
if (source is RectangleShapeDTO rectangleShapeDTO)
{
rectangleConvertStrategy ??= new DictionaryConvertStrategy<RectangleShape, RectangleShapeDTO>
(this, new RectangleShapeFromDTOConvertStrategy(this));
NewItem = rectangleConvertStrategy.Convert(rectangleShapeDTO);
}
if (source is CircleShapeDTO circleShapeDTO)
{
circleConvertStrategy ??= new DictionaryConvertStrategy<CircleShape, CircleShapeDTO>
(this, new CircleShapeFromDTOConvertStrategy(this));
NewItem = circleConvertStrategy.Convert(circleShapeDTO);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape is unknown");

View File

@@ -8,6 +8,7 @@ namespace DataAccess.DTOs
public class ShapeToDTOConvertStrategy : ConvertStrategy<IShape, IShape>
{
private IConvertStrategy<RectangleShapeDTO, IRectangleShape> rectangleConvertStrategy;
private IConvertStrategy<CircleShapeDTO, ICircleShape> circleConvertStrategy;
public ShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
@@ -15,16 +16,9 @@ namespace DataAccess.DTOs
public override IShape GetNewItem(IShape source)
{
try
{
GetNewShape(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
ChildClass = this;
GetNewShape(source);
return NewItem;
}
private void GetNewShape(IShape source)
@@ -34,6 +28,10 @@ namespace DataAccess.DTOs
{
ProcessRectangle(rectangle);
}
else if (source is ICircleShape circle)
{
ProcessCircle(circle);
}
else
{
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape type";
@@ -42,6 +40,14 @@ namespace DataAccess.DTOs
TraceLogger?.AddMessage($"Shape converting Id = {NewItem.Id} has been has been finished successfully", TraceLogStatuses.Debug);
}
private void ProcessCircle(ICircleShape circle)
{
TraceLogger?.AddMessage($"Shape is circle", TraceLogStatuses.Debug);
circleConvertStrategy = new DictionaryConvertStrategy<CircleShapeDTO, ICircleShape>
(this, new CircleShapeToDTOConvertStrategy(this));
NewItem = circleConvertStrategy.Convert(circle);
}
private void ProcessRectangle(IRectangleShape rectangle)
{
TraceLogger?.AddMessage($"Shape is rectangle", TraceLogStatuses.Debug);

View File

@@ -14,7 +14,7 @@ namespace DataAccess.DTOs
public List<IBeamShearSection> Sections { get; } = new();
[JsonProperty("Stirrups")]
public List<IStirrup> Stirrups { get; } = new();
public IBeamShearDesignRangeProperty DesignRangeProperty { get; set; }
public IBeamShearDesignRangeProperty DesignRangeProperty { get; set; } = new BeamShearDesignRangePropertyDTO(Guid.NewGuid());
public BeamShearCalculatorInputDataDTO(Guid id)
{

View File

@@ -10,9 +10,9 @@ namespace DataAccess.DTOs
[JsonProperty("AbsoluteRangeValue")]
public double AbsoluteRangeValue { get; set; } = 0.0;
[JsonProperty("RelativeEffectiveDepthRangeValue")]
public double RelativeEffectiveDepthRangeValue { get; set; } = 3.0;
public double RelativeEffectiveDepthRangeValue { get; set; } = 3.3;
[JsonProperty("StepCount")]
public int StepCount { get; set; } = 50;
public int StepCount { get; set; } = 55;
public BeamShearDesignRangePropertyDTO(Guid id)
{

View File

@@ -17,13 +17,13 @@ namespace DataAccess.DTOs
[JsonProperty("Shape")]
public IShape Shape { get; set; } = new RectangleShapeDTO(Guid.Empty);
[JsonProperty("ConcreteMaterial")]
public IConcreteLibMaterial ConcreteMaterial { get; set; }
public IConcreteLibMaterial ConcreteMaterial { get; set; } = new ConcreteLibMaterial(Guid.NewGuid());
[JsonProperty("CenterCover")]
public double CenterCover { get; set; }
[JsonProperty("ReinforcementArea")]
public double ReinforcementArea { get; set; }
[JsonProperty("ReinforcementMaterial")]
public IReinforcementLibMaterial ReinforcementMaterial { get; set; }
public IReinforcementLibMaterial ReinforcementMaterial { get; set; } = new ReinforcementLibMaterial(Guid.NewGuid());
public BeamShearSectionDTO(Guid id)
{

View File

@@ -0,0 +1,23 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class CircleShapeDTO : ICircleShape
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Diameter")]
public double Diameter { get; set; }
public CircleShapeDTO(Guid id)
{
Id = id;
}
}
}

View File

@@ -34,6 +34,7 @@ namespace DataAccess.DTOs
List<(Type type, string name)> newList = new List<(Type type, string name)>
{
{ (typeof(AccuracyDTO), "Accuracy") },
{ (typeof(CircleShapeDTO), "CircleShape") },
{ (typeof(ConcreteLibMaterialDTO), "ConcreteLibMaterial") },
{ (typeof(ColumnFilePropertyDTO), "ColumnFileProperty") },
{ (typeof(ColumnedFilePropertyDTO), "ColumnedFileProperty") },
@@ -119,6 +120,7 @@ namespace DataAccess.DTOs
{ (typeof(BeamShearAnalysisDTO), "BeamShearAnalysis") },
{ (typeof(BeamShearCalculatorDTO), "BeamShearCalculator") },
{ (typeof(BeamShearCalculatorInputDataDTO), "BeamShearCalculatorInputData") },
{ (typeof(BeamShearDesignRangePropertyDTO), "BeamShearDesignRangeProperty") },
{ (typeof(BeamShearRepositoryDTO), "BeamShearRepository") },
{ (typeof(BeamShearSectionDTO), "BeamShearSection") },
{ (typeof(List<IBeamShearAction>), "ListOfBeamShearActions") },