From 6e8f4bcc58a00bede2d1e5a831fd8f253158a6ad Mon Sep 17 00:00:00 2001 From: RedikultsevEvg Date: Sun, 20 Jul 2025 21:45:07 +0500 Subject: [PATCH] Add circle shape calculation for shear --- .../BeamShearSectionFromDTOConvertStrategy.cs | 2 +- .../BeamShearSectionToDTOConvertStrategy.cs | 2 +- .../CircleShapeFromDTOConvertStrategy.cs | 29 +++++++++++ .../CircleShapeToDTOConvertStrategy.cs | 23 +++++++++ .../Converters/ShapeFromDTOConvertStrategy.cs | 8 +++ .../Converters/ShapeToDTOConvertStrategy.cs | 26 ++++++---- .../BeamShearCalculatorInputDataDTO.cs | 2 +- .../BeamShearDesignRangePropertyDTO.cs | 4 +- .../BeamShears/BeamShearSectionDTO.cs | 4 +- DataAccess/DTOs/DTOEntities/CircleShapeDTO.cs | 23 +++++++++ .../DTOs/DTOEntities/TypeBinderListFactory.cs | 2 + .../UI/Resources/ButtonStyles.xaml | 29 ++++++++++- .../BeamShears/BeamShearActionResultView.xaml | 10 ++++ .../BeamShearActionResultViewModel.cs | 13 +++-- .../BeamShears/BeamShearResultViewModel.cs | 2 +- .../BeamShears/BeamShearSectionsViewModel.cs | 13 +++++ .../Windows/BeamShears/BeamShearView.xaml | 31 +++++++++-- .../Windows/BeamShears/BeamShearViewModel.cs | 24 +++++++-- .../Windows/BeamShears/SectionView.xaml | 3 +- .../Windows/BeamShears/SectionView.xaml.cs | 31 ++++++++++- .../Windows/BeamShears/SectionViewModel.cs | 4 +- .../Windows/BeamShears/ShearDiagramLogic.cs | 13 +++-- .../Shapes/Logics/CircleShapeCloneStrategy.cs | 17 +++++++ .../Logics/CircleShapeUpdateStrategy.cs | 3 ++ .../Logics/RectangleShapeCloneStrategy.cs | 21 ++++++++ .../Shapes/Logics/ShapeCloneStrategy.cs | 33 ++++++++++++ .../BeamShearDesignRangeProperty.cs | 6 +-- .../Models/BeamShears/BeamShearSection.cs | 4 +- .../Factories/BeamShearTemplatesFactory.cs | 32 ++++++++++-- .../Factories/SectionEffectivenessFactory.cs | 2 +- .../Factories/StirrupEffectivenessFactory.cs | 6 ++- .../BeamShears/IStirrupEffectiveness.cs | 4 ++ .../Logics/BeamShearSectionLogic.cs | 22 ++++++-- .../Logics/BeamShearSectionUpdateStrategy.cs | 34 +++++++++---- .../CheckBeamShearSectionLogic.cs | 14 +++++ .../Logics/StirrupByDensityStrengthLogic.cs | 7 +-- .../StirrupByInclinedRebarStrengthLogic.cs | 4 +- .../BeamShears/Logics/StirrupBySearchLogic.cs | 51 +++++++++++-------- .../BeamShears/Logics/StirrupStrengthLogic.cs | 27 +++++++--- .../Models/BeamShears/StirrupEffectiveness.cs | 2 + 40 files changed, 488 insertions(+), 99 deletions(-) create mode 100644 DataAccess/DTOs/Converters/CircleShapeFromDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/CircleShapeToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/DTOEntities/CircleShapeDTO.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/CircleShapeCloneStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/RectangleShapeCloneStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/ShapeCloneStrategy.cs diff --git a/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionFromDTOConvertStrategy.cs index f8b4248..7353ae9 100644 --- a/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionFromDTOConvertStrategy.cs @@ -43,7 +43,7 @@ namespace DataAccess.DTOs private void InitializeStrategies() { - updateStrategy ??= new BeamShearSectionUpdateStrategy(); + updateStrategy ??= new BeamShearSectionUpdateStrategy() { UpdateChildren = false}; shapeConvertStrategy = new DictionaryConvertStrategy (this, new ShapeFromDTOConvertStrategy(this)); concreteConvertStrategy = new ConcreteLibMaterialFromDTOConvertStrategy() diff --git a/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionToDTOConvertStrategy.cs index 1f73c35..1df95bd 100644 --- a/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/BeamShears/BeamShearSectionToDTOConvertStrategy.cs @@ -50,7 +50,7 @@ namespace DataAccess.DTOs private void InitializeStrategies() { - updateStrategy ??= new BeamShearSectionUpdateStrategy(); + updateStrategy ??= new BeamShearSectionUpdateStrategy() { UpdateChildren = false}; shapeConvertStrategy = new DictionaryConvertStrategy (this, new ShapeToDTOConvertStrategy(this)); concreteConvertStrategy = new ConcreteLibMaterialToDTOConvertStrategy() diff --git a/DataAccess/DTOs/Converters/CircleShapeFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CircleShapeFromDTOConvertStrategy.cs new file mode 100644 index 0000000..5be38b4 --- /dev/null +++ b/DataAccess/DTOs/Converters/CircleShapeFromDTOConvertStrategy.cs @@ -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 + { + private IUpdateStrategy 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; + } + } +} diff --git a/DataAccess/DTOs/Converters/CircleShapeToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CircleShapeToDTOConvertStrategy.cs new file mode 100644 index 0000000..baca69c --- /dev/null +++ b/DataAccess/DTOs/Converters/CircleShapeToDTOConvertStrategy.cs @@ -0,0 +1,23 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; + +namespace DataAccess.DTOs +{ + public class CircleShapeToDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy 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; + } + } +} diff --git a/DataAccess/DTOs/Converters/ShapeFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ShapeFromDTOConvertStrategy.cs index d8dbacd..3023148 100644 --- a/DataAccess/DTOs/Converters/ShapeFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/ShapeFromDTOConvertStrategy.cs @@ -7,6 +7,7 @@ namespace DataAccess.DTOs internal class ShapeFromDTOConvertStrategy : ConvertStrategy { private IConvertStrategy rectangleConvertStrategy; + private IConvertStrategy 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 (this, new RectangleShapeFromDTOConvertStrategy(this)); NewItem = rectangleConvertStrategy.Convert(rectangleShapeDTO); } + if (source is CircleShapeDTO circleShapeDTO) + { + circleConvertStrategy ??= new DictionaryConvertStrategy + (this, new CircleShapeFromDTOConvertStrategy(this)); + NewItem = circleConvertStrategy.Convert(circleShapeDTO); + } else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape is unknown"); diff --git a/DataAccess/DTOs/Converters/ShapeToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ShapeToDTOConvertStrategy.cs index 7011323..861c6e6 100644 --- a/DataAccess/DTOs/Converters/ShapeToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/ShapeToDTOConvertStrategy.cs @@ -8,6 +8,7 @@ namespace DataAccess.DTOs public class ShapeToDTOConvertStrategy : ConvertStrategy { private IConvertStrategy rectangleConvertStrategy; + private IConvertStrategy 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 + (this, new CircleShapeToDTOConvertStrategy(this)); + NewItem = circleConvertStrategy.Convert(circle); + } + private void ProcessRectangle(IRectangleShape rectangle) { TraceLogger?.AddMessage($"Shape is rectangle", TraceLogStatuses.Debug); diff --git a/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearCalculatorInputDataDTO.cs b/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearCalculatorInputDataDTO.cs index 4c9333f..5fe8d02 100644 --- a/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearCalculatorInputDataDTO.cs +++ b/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearCalculatorInputDataDTO.cs @@ -14,7 +14,7 @@ namespace DataAccess.DTOs public List Sections { get; } = new(); [JsonProperty("Stirrups")] public List Stirrups { get; } = new(); - public IBeamShearDesignRangeProperty DesignRangeProperty { get; set; } + public IBeamShearDesignRangeProperty DesignRangeProperty { get; set; } = new BeamShearDesignRangePropertyDTO(Guid.NewGuid()); public BeamShearCalculatorInputDataDTO(Guid id) { diff --git a/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearDesignRangePropertyDTO.cs b/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearDesignRangePropertyDTO.cs index 7847b51..8275f86 100644 --- a/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearDesignRangePropertyDTO.cs +++ b/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearDesignRangePropertyDTO.cs @@ -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) { diff --git a/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearSectionDTO.cs b/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearSectionDTO.cs index 489f452..e1c6a78 100644 --- a/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearSectionDTO.cs +++ b/DataAccess/DTOs/DTOEntities/BeamShears/BeamShearSectionDTO.cs @@ -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) { diff --git a/DataAccess/DTOs/DTOEntities/CircleShapeDTO.cs b/DataAccess/DTOs/DTOEntities/CircleShapeDTO.cs new file mode 100644 index 0000000..6a7f22b --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/CircleShapeDTO.cs @@ -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; + } + } +} diff --git a/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs index bd10d60..e7224ca 100644 --- a/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs +++ b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs @@ -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), "ListOfBeamShearActions") }, diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml index c0ad10a..c89fc8c 100644 --- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml @@ -637,6 +637,19 @@ + + + + + + + + + + + + + @@ -646,7 +659,21 @@ - + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/BeamShears/BeamShearActionResultView.xaml b/StructureHelper/Windows/BeamShears/BeamShearActionResultView.xaml index a86d924..2587146 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearActionResultView.xaml +++ b/StructureHelper/Windows/BeamShears/BeamShearActionResultView.xaml @@ -21,6 +21,16 @@ + diff --git a/StructureHelper/Windows/BeamShears/BeamShearActionResultViewModel.cs b/StructureHelper/Windows/BeamShears/BeamShearActionResultViewModel.cs index 66f58a5..1eb7803 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearActionResultViewModel.cs +++ b/StructureHelper/Windows/BeamShears/BeamShearActionResultViewModel.cs @@ -2,11 +2,7 @@ using StructureHelper.Windows.CalculationWindows.CalculatorsViews; using StructureHelper.Windows.CalculationWindows.ProgressViews; using StructureHelperLogics.Models.BeamShears; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Input; namespace StructureHelper.Windows.BeamShears @@ -15,6 +11,7 @@ namespace StructureHelper.Windows.BeamShears { private IBeamShearActionResult result; private RelayCommand showTraceCommand; + private RelayCommand showDiagramCommand; public IBeamShearSectionLogicResult SelectedResult { get; set; } public List SectionResults => result.SectionResults; @@ -27,6 +24,7 @@ namespace StructureHelper.Windows.BeamShears } public ICommand ShowTraceCommand => showTraceCommand ??= new RelayCommand(ShowTrace, o => SelectedResult != null); + public ICommand ShowDiagramCommand => showDiagramCommand ??= new RelayCommand(Show2DDiagram, o => SelectedResult != null); private void ShowTrace(object obj) { @@ -34,5 +32,12 @@ namespace StructureHelper.Windows.BeamShears var traceWindows = new TraceDocumentView(SelectedResult.TraceLogger); traceWindows.ShowDialog(); } + + private void Show2DDiagram(object obj) + { + if (SelectedResult is null) { return; } + var logic = new ShearDiagramLogic(result); + logic.ShowWindow(SelectedResult.InputData.InclinedSection.StartCoord); + } } } diff --git a/StructureHelper/Windows/BeamShears/BeamShearResultViewModel.cs b/StructureHelper/Windows/BeamShears/BeamShearResultViewModel.cs index 3f7aadb..f645c02 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearResultViewModel.cs +++ b/StructureHelper/Windows/BeamShears/BeamShearResultViewModel.cs @@ -48,7 +48,7 @@ namespace StructureHelper.Windows.BeamShears { if (SelectedResult is null) { return; } var logic = new ShearDiagramLogic(SelectedResult); - logic.ShowWindow(); + logic.ShowWindow(0.0); } private void ShowSectionResults(object commandParameter) diff --git a/StructureHelper/Windows/BeamShears/BeamShearSectionsViewModel.cs b/StructureHelper/Windows/BeamShears/BeamShearSectionsViewModel.cs index bead138..763cbf3 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearSectionsViewModel.cs +++ b/StructureHelper/Windows/BeamShears/BeamShearSectionsViewModel.cs @@ -3,6 +3,7 @@ using StructureHelper.Windows.ViewModels; using StructureHelper.Windows.ViewModels.Errors; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.BeamShears; using System; using System.Windows; @@ -50,6 +51,18 @@ namespace StructureHelper.Windows.BeamShears Name = "New rectangle section" }; } + else if (sectionType is PrimitiveType.Circle) + { + NewItem = new BeamShearSection(Guid.NewGuid()) + { + Name = "New circle section", + Shape = new CircleShape(Guid.NewGuid()) { Diameter = 0.6 } + }; + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(sectionType)); + } } private void EditSection() diff --git a/StructureHelper/Windows/BeamShears/BeamShearView.xaml b/StructureHelper/Windows/BeamShears/BeamShearView.xaml index 20748ea..809838d 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearView.xaml +++ b/StructureHelper/Windows/BeamShears/BeamShearView.xaml @@ -37,6 +37,18 @@ + + diff --git a/StructureHelper/Windows/BeamShears/BeamShearViewModel.cs b/StructureHelper/Windows/BeamShears/BeamShearViewModel.cs index 87c9876..3d475fd 100644 --- a/StructureHelper/Windows/BeamShears/BeamShearViewModel.cs +++ b/StructureHelper/Windows/BeamShears/BeamShearViewModel.cs @@ -1,4 +1,6 @@ using StructureHelper.Infrastructure; +using StructureHelper.Infrastructure.Enums; +using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperLogics.Models.Analyses; using StructureHelperLogics.Models.BeamShears; using System; @@ -38,10 +40,24 @@ namespace StructureHelper.Windows.BeamShears private void AddTemplateMethod(object param) { - var templateRepository = BeamShearTemplatesFactory.GetTemplateRepository(ShearSectionTemplateTypes.Rectangle); - var updateStrategy = new BeamShearRepositoryAddUpdateStrategy(); - updateStrategy.Update(repository, templateRepository); - Refresh(); + if (param is PrimitiveType.Rectangle) + { + var templateRepository = BeamShearTemplatesFactory.GetTemplateRepository(ShearSectionTemplateTypes.Rectangle); + var updateStrategy = new BeamShearRepositoryAddUpdateStrategy(); + updateStrategy.Update(repository, templateRepository); + Refresh(); + } + else if (param is PrimitiveType.Circle) + { + var templateRepository = BeamShearTemplatesFactory.GetTemplateRepository(ShearSectionTemplateTypes.Circle); + var updateStrategy = new BeamShearRepositoryAddUpdateStrategy(); + updateStrategy.Update(repository, templateRepository); + Refresh(); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(param)); + } } private void Refresh() diff --git a/StructureHelper/Windows/BeamShears/SectionView.xaml b/StructureHelper/Windows/BeamShears/SectionView.xaml index 95a4fe6..32332ca 100644 --- a/StructureHelper/Windows/BeamShears/SectionView.xaml +++ b/StructureHelper/Windows/BeamShears/SectionView.xaml @@ -17,7 +17,7 @@ - + @@ -31,7 +31,6 @@ - diff --git a/StructureHelper/Windows/BeamShears/SectionView.xaml.cs b/StructureHelper/Windows/BeamShears/SectionView.xaml.cs index dc72a21..493b1c4 100644 --- a/StructureHelper/Windows/BeamShears/SectionView.xaml.cs +++ b/StructureHelper/Windows/BeamShears/SectionView.xaml.cs @@ -1,5 +1,13 @@ -using StructureHelperLogics.Models.BeamShears; +using StructureHelper.Infrastructure.Enums; +using StructureHelper.Infrastructure.UI.DataContexts; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.Models.BeamShears; +using StructureHelperLogics.Models.Primitives; +using System.Collections.Generic; using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; namespace StructureHelper.Windows.BeamShears { @@ -18,7 +26,26 @@ namespace StructureHelper.Windows.BeamShears } public SectionView(IBeamShearSection section) : this(new SectionViewModel(section)) { - + AddPrimitiveProperties(section.Shape, ShapeStackPanel); + } + + private void AddPrimitiveProperties(IShape shape, StackPanel stackPanel) + { + List templateNames = new List(); + if (shape is IRectangleShape) { templateNames.Add("RectangleShapeEdit"); } + else if (shape is ICircleShape) { templateNames.Add("CircleShapeEdit"); } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(shape)); + } + foreach (var name in templateNames) + { + ContentControl contentControl = new ContentControl(); + contentControl.SetResourceReference(ContentTemplateProperty, name); + Binding binding = new Binding { Source = viewModel.Shape }; + contentControl.SetBinding(ContentProperty, binding); + stackPanel.Children.Add(contentControl); + } } } } diff --git a/StructureHelper/Windows/BeamShears/SectionViewModel.cs b/StructureHelper/Windows/BeamShears/SectionViewModel.cs index cd0ad5a..4e4becd 100644 --- a/StructureHelper/Windows/BeamShears/SectionViewModel.cs +++ b/StructureHelper/Windows/BeamShears/SectionViewModel.cs @@ -41,7 +41,7 @@ namespace StructureHelper.Windows.BeamShears beamShearSection.CenterCover = value; } } - public IRectangleShape Shape { get; } + public IShape Shape { get; } public ConcreteViewModel ConcreteMaterial { get; } public ReinforcementViewModel ReinforcementMaterial { get; } @@ -55,7 +55,7 @@ namespace StructureHelper.Windows.BeamShears TensionForSLSVisibility = false, HumidityVisibility = false }; - Shape = beamShearSection.Shape as IRectangleShape; + Shape = beamShearSection.Shape; ReinforcementMaterial = new(beamShearSection.ReinforcementMaterial) { MaterialLogicVisibility = false }; } } diff --git a/StructureHelper/Windows/BeamShears/ShearDiagramLogic.cs b/StructureHelper/Windows/BeamShears/ShearDiagramLogic.cs index 66fca70..96a7b95 100644 --- a/StructureHelper/Windows/BeamShears/ShearDiagramLogic.cs +++ b/StructureHelper/Windows/BeamShears/ShearDiagramLogic.cs @@ -11,8 +11,7 @@ namespace StructureHelper.Windows.BeamShears { public class ShearDiagramLogic { - const string ForceUnitString = "kN"; - + private const string ForceUnitString = "kN"; private IBeamShearActionResult result; private IUnit unitForce; @@ -23,23 +22,23 @@ namespace StructureHelper.Windows.BeamShears unitForce = unitLogic.GetUnit(UnitTypes.Force, ForceUnitString); } - public void ShowWindow() + public void ShowWindow(double sectionsStartCoordinate) { SafetyProcessor.RunSafeProcess(() => { var seriesList = new List(); - var series = new Series(GetParametersByCurveResult()) { Name = "" }; + var series = new Series(GetParametersByCurveResult(sectionsStartCoordinate)) { Name = "" }; seriesList.Add(series); var vm = new GraphViewModel(seriesList); var wnd = new GraphView(vm); wnd.ShowDialog(); }, - "Errors appeared during showing a graph, see detailed information"); + "Errors appeared during showing a chart, see detailed information"); } - private ArrayParameter GetParametersByCurveResult() + private ArrayParameter GetParametersByCurveResult(double sectionsStartCoordinate) { List results = result.SectionResults - .Where(x => x.InputData.InclinedSection.StartCoord == 0) + .Where(x => x.InputData.InclinedSection.StartCoord == sectionsStartCoordinate) .ToList(); var labels = GetLabels(); var arrayParameter = new ArrayParameter(results.Count(), labels.Count(), labels); diff --git a/StructureHelperCommon/Models/Shapes/Logics/CircleShapeCloneStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/CircleShapeCloneStrategy.cs new file mode 100644 index 0000000..2cb7d05 --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/CircleShapeCloneStrategy.cs @@ -0,0 +1,17 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; + +namespace StructureHelperCommon.Models.Shapes +{ + internal class CircleShapeCloneStrategy : ICloneStrategy + { + IUpdateStrategy updateStrategy; + public ICircleShape GetClone(ICircleShape sourceObject) + { + updateStrategy ??= new CircleShapeUpdateStrategy(); + CircleShape clone = new CircleShape(Guid.NewGuid()); + updateStrategy.Update(clone, sourceObject); + return clone; + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/CircleShapeUpdateStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/CircleShapeUpdateStrategy.cs index 7d6d880..d2c480e 100644 --- a/StructureHelperCommon/Models/Shapes/Logics/CircleShapeUpdateStrategy.cs +++ b/StructureHelperCommon/Models/Shapes/Logics/CircleShapeUpdateStrategy.cs @@ -1,4 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; using System; using System.Collections.Generic; using System.Linq; @@ -11,6 +12,8 @@ namespace StructureHelperCommon.Models.Shapes { public void Update(ICircleShape targetObject, ICircleShape sourceObject) { + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.Diameter = sourceObject.Diameter; } diff --git a/StructureHelperCommon/Models/Shapes/Logics/RectangleShapeCloneStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/RectangleShapeCloneStrategy.cs new file mode 100644 index 0000000..d0da4b2 --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/RectangleShapeCloneStrategy.cs @@ -0,0 +1,21 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Shapes +{ + public class RectangleShapeCloneStrategy : ICloneStrategy + { + IUpdateStrategy updateStrategy; + public IRectangleShape GetClone(IRectangleShape sourceObject) + { + RectangleShape clone = new RectangleShape(Guid.NewGuid()); + updateStrategy ??= new RectangleShapeUpdateStrategy(); + updateStrategy.Update(clone, sourceObject); + return clone; + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Logics/ShapeCloneStrategy.cs b/StructureHelperCommon/Models/Shapes/Logics/ShapeCloneStrategy.cs new file mode 100644 index 0000000..0cb01f6 --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/Logics/ShapeCloneStrategy.cs @@ -0,0 +1,33 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Shapes +{ + public class ShapeCloneStrategy : ICloneStrategy + { + private ICloneStrategy rectangleCloneStrategy; + private ICloneStrategy circleCloneStrategy; + public IShape GetClone(IShape sourceObject) + { + if (sourceObject is IRectangleShape rectangleShape) + { + rectangleCloneStrategy ??= new RectangleShapeCloneStrategy(); + return rectangleCloneStrategy.GetClone(rectangleShape); + } + else if (sourceObject is ICircleShape circleShape) + { + circleCloneStrategy ??= new CircleShapeCloneStrategy(); + return circleCloneStrategy.GetClone(circleShape); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(sourceObject)); + } + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearDesignRangeProperty.cs b/StructureHelperLogics/Models/BeamShears/BeamShearDesignRangeProperty.cs index f9e0c6a..4d3b74d 100644 --- a/StructureHelperLogics/Models/BeamShears/BeamShearDesignRangeProperty.cs +++ b/StructureHelperLogics/Models/BeamShears/BeamShearDesignRangeProperty.cs @@ -5,11 +5,11 @@ namespace StructureHelperLogics.Models.BeamShears /// public class BeamShearDesignRangeProperty : IBeamShearDesignRangeProperty { - private const int minStepCount = 0; + private const int minStepCount = 10; private const int maxStepCount = 1000; private double absoluteRangeValue = 0.0; - private double relativeEffectiveDepthRangeValue = 3.0; - private int stepCount = 50; + private double relativeEffectiveDepthRangeValue = 3.3; + private int stepCount = 55; /// public Guid Id { get; } diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearSection.cs b/StructureHelperLogics/Models/BeamShears/BeamShearSection.cs index e4447d0..edd416a 100644 --- a/StructureHelperLogics/Models/BeamShears/BeamShearSection.cs +++ b/StructureHelperLogics/Models/BeamShears/BeamShearSection.cs @@ -28,7 +28,9 @@ namespace StructureHelperLogics.Models.BeamShears public object Clone() { - BeamShearSection newItem = new(Guid.NewGuid()); + var cloneStrategy = new ShapeCloneStrategy(); + IShape shapeClone = cloneStrategy.GetClone(Shape); + BeamShearSection newItem = new(Guid.NewGuid()) { Shape = shapeClone}; updateStrategy ??= new BeamShearSectionUpdateStrategy(); updateStrategy.Update(newItem, this); return newItem; diff --git a/StructureHelperLogics/Models/BeamShears/Factories/BeamShearTemplatesFactory.cs b/StructureHelperLogics/Models/BeamShears/Factories/BeamShearTemplatesFactory.cs index a0842b0..956e7e9 100644 --- a/StructureHelperLogics/Models/BeamShears/Factories/BeamShearTemplatesFactory.cs +++ b/StructureHelperLogics/Models/BeamShears/Factories/BeamShearTemplatesFactory.cs @@ -1,8 +1,10 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces.BeamShearActions; +using StructureHelperCommon.Models.Shapes; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,6 +14,7 @@ namespace StructureHelperLogics.Models.BeamShears public enum ShearSectionTemplateTypes { Rectangle, + Circle } public static class BeamShearTemplatesFactory { @@ -21,23 +24,46 @@ namespace StructureHelperLogics.Models.BeamShears { return GetRectangleSection(); } + if (templateType is ShearSectionTemplateTypes.Circle) + { + return GetCircleSection(); + } else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(templateType)); } } + private static IBeamShearRepository GetCircleSection() + { + BeamShearSection section = new(Guid.NewGuid()) + { + Name = "New circle section", + Shape = new CircleShape(Guid.NewGuid()) { Diameter = 0.6}, + }; + return BuildRepository(section); + } + private static IBeamShearRepository GetRectangleSection() + { + BeamShearSection section = new(Guid.NewGuid()) + { + Name = "New rectangle section", + Shape = new RectangleShape(Guid.NewGuid()) { Height = 0.6, Width = 0.4 }, + }; + return BuildRepository(section); + } + + private static IBeamShearRepository BuildRepository(BeamShearSection section) { BeamShearRepository shearRepository = new(Guid.Empty); IBeamShearAction shearAction = BeamShearActionFactory.GetBeamShearAction(ShearActionTypes.DistributedLoad); shearAction.Name = "New shear action"; shearRepository.Actions.Add(shearAction); - BeamShearSection section = new(Guid.NewGuid()) { Name = "New shear section"}; shearRepository.Sections.Add(section); - StirrupByRebar stirrupByUniformRebar = new(Guid.NewGuid()) { Name = "New uniform stirrup"}; + StirrupByRebar stirrupByUniformRebar = new(Guid.NewGuid()) { Name = "New uniform stirrup" }; shearRepository.Stirrups.Add(stirrupByUniformRebar); - BeamShearCalculator beamShearCalculator = new(Guid.NewGuid()) { Name = "New shear calculator"}; + BeamShearCalculator beamShearCalculator = new(Guid.NewGuid()) { Name = "New shear calculator" }; beamShearCalculator.InputData.Sections.Add(section); beamShearCalculator.InputData.Stirrups.Add(stirrupByUniformRebar); beamShearCalculator.InputData.Actions.Add(shearAction); diff --git a/StructureHelperLogics/Models/BeamShears/Factories/SectionEffectivenessFactory.cs b/StructureHelperLogics/Models/BeamShears/Factories/SectionEffectivenessFactory.cs index 09dc799..33616e2 100644 --- a/StructureHelperLogics/Models/BeamShears/Factories/SectionEffectivenessFactory.cs +++ b/StructureHelperLogics/Models/BeamShears/Factories/SectionEffectivenessFactory.cs @@ -9,7 +9,7 @@ namespace StructureHelperLogics.Models.BeamShears { public static class SectionEffectivenessFactory { - public static ISectionEffectiveness GetSheaEffectiveness(BeamShearSectionType sectionType) + public static ISectionEffectiveness GetShearEffectiveness(BeamShearSectionType sectionType) { if (sectionType == BeamShearSectionType.Rectangle) { diff --git a/StructureHelperLogics/Models/BeamShears/Factories/StirrupEffectivenessFactory.cs b/StructureHelperLogics/Models/BeamShears/Factories/StirrupEffectivenessFactory.cs index 4b541ea..f2494aa 100644 --- a/StructureHelperLogics/Models/BeamShears/Factories/StirrupEffectivenessFactory.cs +++ b/StructureHelperLogics/Models/BeamShears/Factories/StirrupEffectivenessFactory.cs @@ -36,7 +36,8 @@ namespace StructureHelperLogics.Models.BeamShears { MaxCrackLengthRatio = 1.5, StirrupPlacementFactor = 0.75, - StirrupShapeFactor = 0.5 + StirrupShapeFactor = 0.5, + MinimumStirrupRatio = 0.1 }; return stirrupEffectiveness; } @@ -47,7 +48,8 @@ namespace StructureHelperLogics.Models.BeamShears { MaxCrackLengthRatio = 2, StirrupPlacementFactor = 0.75, - StirrupShapeFactor = 1 + StirrupShapeFactor = 1, + MinimumStirrupRatio = 0.25 }; return stirrupEffectiveness; } diff --git a/StructureHelperLogics/Models/BeamShears/IStirrupEffectiveness.cs b/StructureHelperLogics/Models/BeamShears/IStirrupEffectiveness.cs index 11f3802..e0dffe6 100644 --- a/StructureHelperLogics/Models/BeamShears/IStirrupEffectiveness.cs +++ b/StructureHelperLogics/Models/BeamShears/IStirrupEffectiveness.cs @@ -23,5 +23,9 @@ namespace StructureHelperLogics.Models.BeamShears /// Factor of difference between real and uniform distribution /// double StirrupPlacementFactor { get; set; } + /// + /// Minimum ratio of density of stirrup to density of concrete + /// + double MinimumStirrupRatio { get; set; } } } diff --git a/StructureHelperLogics/Models/BeamShears/Logics/BeamShearSectionLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/BeamShearSectionLogic.cs index c57f7f7..637af11 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/BeamShearSectionLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/BeamShearSectionLogic.cs @@ -1,7 +1,9 @@ -using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.BeamShears.Logics; namespace StructureHelperLogics.Models.BeamShears @@ -72,7 +74,8 @@ namespace StructureHelperLogics.Models.BeamShears double concreteStrength = concreteLogic.GetShearStrength(); double stirrupStrength = stirrupLogic.GetShearStrength(); if (stirrupStrength > concreteStrength) - { + { + localTraceLogger?.AddMessage($"Shear reinforcement strength Qsw = {stirrupStrength} is greater than concrete strength for shear Qb = {concreteStrength}, shear reinforcement strength has to be restricted."); stirrupStrength = GetStirrupStrengthBySearch(); } concreteStrength *= factorOfLongitudinalForce; @@ -103,7 +106,7 @@ namespace StructureHelperLogics.Models.BeamShears private double GetStirrupStrengthBySearch() { - var logic = new StirrupBySearchLogic(TraceLogger) + var logic = new StirrupBySearchLogic(localTraceLogger.GetSimilarTraceLogger(100)) { InputData = InputData, SectionEffectiveness = sectionEffectiveness @@ -115,7 +118,18 @@ namespace StructureHelperLogics.Models.BeamShears private void InitializeStrategies() { - sectionEffectiveness = SectionEffectivenessFactory.GetSheaEffectiveness(BeamShearSectionType.Rectangle); + if (InputData.InclinedSection.BeamShearSection.Shape is IRectangleShape) + { + sectionEffectiveness = SectionEffectivenessFactory.GetShearEffectiveness(BeamShearSectionType.Rectangle); + } + else if (InputData.InclinedSection.BeamShearSection.Shape is ICircleShape) + { + sectionEffectiveness = SectionEffectivenessFactory.GetShearEffectiveness(BeamShearSectionType.Circle); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(InputData.InclinedSection.BeamShearSection.Shape)); + } concreteLogic = new(sectionEffectiveness, InputData.InclinedSection, localTraceLogger); stirrupLogic = new(InputData, localTraceLogger); getLongitudinalForceFactorLogic = new GetLongitudinalForceFactorLogic(localTraceLogger?.GetSimilarTraceLogger(100)); diff --git a/StructureHelperLogics/Models/BeamShears/Logics/BeamShearSectionUpdateStrategy.cs b/StructureHelperLogics/Models/BeamShears/Logics/BeamShearSectionUpdateStrategy.cs index bf1da08..fc0406d 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/BeamShearSectionUpdateStrategy.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/BeamShearSectionUpdateStrategy.cs @@ -3,33 +3,45 @@ using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes.Logics; using StructureHelperCommon.Services; using StructureHelperLogics.Models.Materials; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.Models.BeamShears { - public class BeamShearSectionUpdateStrategy : IUpdateStrategy + public class BeamShearSectionUpdateStrategy : IParentUpdateStrategy { private IUpdateStrategy shapeUpdateStrategy; private IUpdateStrategy concreteUpdateStrategy; private IUpdateStrategy reinforcementUpdateStrategy; + + public bool UpdateChildren { get; set; } = true; + public void Update(IBeamShearSection targetObject, IBeamShearSection sourceObject) { CheckObject.IsNull(targetObject); CheckObject.IsNull(sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } + Check(targetObject, sourceObject); InitializeStrategies(); targetObject.Name = sourceObject.Name; targetObject.ReinforcementArea = sourceObject.ReinforcementArea; - shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape); - targetObject.ConcreteMaterial ??= new ConcreteLibMaterial(); - concreteUpdateStrategy.Update(targetObject.ConcreteMaterial, sourceObject.ConcreteMaterial); - targetObject.ReinforcementMaterial ??= new ReinforcementLibMaterial(Guid.NewGuid()); - reinforcementUpdateStrategy.Update(targetObject.ReinforcementMaterial, sourceObject.ReinforcementMaterial); targetObject.CenterCover = sourceObject.CenterCover; + if (UpdateChildren) + { + shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape); + targetObject.ConcreteMaterial ??= new ConcreteLibMaterial(Guid.NewGuid()); + concreteUpdateStrategy.Update(targetObject.ConcreteMaterial, sourceObject.ConcreteMaterial); + targetObject.ReinforcementMaterial ??= new ReinforcementLibMaterial(Guid.NewGuid()); + reinforcementUpdateStrategy.Update(targetObject.ReinforcementMaterial, sourceObject.ReinforcementMaterial); + } + } + + private static void Check(IBeamShearSection targetObject, IBeamShearSection sourceObject) + { + CheckObject.IsNull(sourceObject.Shape, "Source object shape"); + CheckObject.IsNull(targetObject.Shape, "Target object shape"); + CheckObject.IsNull(sourceObject.ConcreteMaterial, "Source concrete material"); + CheckObject.IsNull(targetObject.ConcreteMaterial, "Target concrete material"); + CheckObject.IsNull(sourceObject.ReinforcementMaterial, "Source reinforcement material"); + CheckObject.IsNull(targetObject.ReinforcementMaterial, "Target reinforcement material"); } private void InitializeStrategies() diff --git a/StructureHelperLogics/Models/BeamShears/Logics/CheckStrategies/CheckBeamShearSectionLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/CheckStrategies/CheckBeamShearSectionLogic.cs index d5c1645..b8a3c97 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/CheckStrategies/CheckBeamShearSectionLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/CheckStrategies/CheckBeamShearSectionLogic.cs @@ -9,6 +9,7 @@ namespace StructureHelperLogics.Models.BeamShears.Logics private const double minValueOfCenterCover = 0.01; private const double minValueOfCrossSectionWidth = 0.05; private const double minValueOfCrossSectionHeight = 0.05; + private const double minCircleDiameter = 0.05; private bool result; private string checkResult; @@ -63,6 +64,10 @@ namespace StructureHelperLogics.Models.BeamShears.Logics { CheckRectangleShape(rectangle); } + else if (Entity.Shape is ICircleShape circle) + { + CheckCircleShape(circle); + } else { result = false; @@ -71,6 +76,15 @@ namespace StructureHelperLogics.Models.BeamShears.Logics } } + private void CheckCircleShape(ICircleShape circle) + { + if (circle.Diameter < minCircleDiameter) + { + result = false; + TraceMessage($"\nValue of cross-section diameter D = {circle.Diameter}(m) must not be less than bmin = {minCircleDiameter}(m)"); + } + } + private void CheckRectangleShape(IRectangleShape rectangle) { if (rectangle.Width < minValueOfCrossSectionWidth) diff --git a/StructureHelperLogics/Models/BeamShears/Logics/StirrupByDensityStrengthLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/StirrupByDensityStrengthLogic.cs index 5ae5181..e2a9412 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/StirrupByDensityStrengthLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/StirrupByDensityStrengthLogic.cs @@ -11,7 +11,7 @@ namespace StructureHelperLogics.Models.BeamShears /// public class StirrupByDensityStrengthLogic : IBeamShearStrenghLogic { - private const double minStirrupRatio = 0.25; + //private const double minStirrupRatio = 0.25; private readonly IStirrupEffectiveness stirrupEffectiveness; private readonly IStirrupByDensity stirrupByDensity; private readonly IInclinedSection inclinedSection; @@ -45,9 +45,10 @@ namespace StructureHelperLogics.Models.BeamShears double finalDensity = stirrupEffectiveness.StirrupShapeFactor * stirrupEffectiveness.StirrupPlacementFactor * stirrupByDensity.StirrupDensity; TraceLogger?.AddMessage($"Stirrups design density qsw = {stirrupEffectiveness.StirrupShapeFactor} * {stirrupEffectiveness.StirrupPlacementFactor} * {stirrupByDensity.StirrupDensity} = {finalDensity}(N/m)"); double concreteDensity = inclinedSection.WebWidth * inclinedSection.ConcreteTensionStrength; - if (finalDensity < minStirrupRatio * concreteDensity) + double minFinalDensity = stirrupEffectiveness.MinimumStirrupRatio * concreteDensity; + if (finalDensity < minFinalDensity) { - TraceLogger?.AddMessage($"Since stirrups design density qsw = {finalDensity}(N/m) less than {minStirrupRatio} * {concreteDensity}, final density is equal to zero", TraceLogStatuses.Warning); + TraceLogger?.AddMessage($"Since stirrups design density qsw = {finalDensity}(N/m) less than qsw,min = {stirrupEffectiveness.MinimumStirrupRatio} * {concreteDensity} = {minFinalDensity}(N/m), final density is equal to zero", TraceLogStatuses.Warning); finalDensity = 0; } double strength = finalDensity * finalCrackLength; diff --git a/StructureHelperLogics/Models/BeamShears/Logics/StirrupByInclinedRebarStrengthLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/StirrupByInclinedRebarStrengthLogic.cs index 6e26d9e..b233329 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/StirrupByInclinedRebarStrengthLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/StirrupByInclinedRebarStrengthLogic.cs @@ -35,12 +35,12 @@ namespace StructureHelperLogics.Models.BeamShears GetGeometry(); if (inclinedSection.StartCoord > rebarEndPoint) { - TraceLogger?.AddMessage($"Inclined section start point coordinate X = {inclinedSection.StartCoord} is greater than inclined rebar end point x = {rebarEndPoint}, inclined rebar has been ignored"); + TraceLogger?.AddMessage($"Inclined section start point coordinate X = {inclinedSection.StartCoord} is greater than inclined rebar end point X = {rebarEndPoint}, inclined rebar has been ignored"); return 0.0; } if (inclinedSection.EndCoord < rebarStartPoint) { - TraceLogger?.AddMessage($"Inclined section end point coordinate X = {inclinedSection.EndCoord} is less than inclined rebar start point x = {rebarStartPoint}, inclined rebar has been ignored"); + TraceLogger?.AddMessage($"Inclined section end point coordinate X = {inclinedSection.EndCoord} is less than inclined rebar start point X = {rebarStartPoint}, inclined rebar has been ignored"); return 0.0; } if (inclinedSection.StartCoord > rebarTrueEndPoint & inclinedSection.StartCoord < rebarEndPoint) diff --git a/StructureHelperLogics/Models/BeamShears/Logics/StirrupBySearchLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/StirrupBySearchLogic.cs index c49cf7e..2f3f9d0 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/StirrupBySearchLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/StirrupBySearchLogic.cs @@ -8,29 +8,32 @@ namespace StructureHelperLogics.Models.BeamShears { private ConcreteStrengthLogic concreteLogic; private StirrupStrengthLogic stirrupLogic; - private ShiftTraceLogger? localTraceLogger { get; set; } - + public IShiftTraceLogger? TraceLogger { get; set; } + public IBeamShearSectionLogicInputData InputData { get; internal set; } + public ISectionEffectiveness SectionEffectiveness { get; internal set; } public StirrupBySearchLogic(IShiftTraceLogger? traceLogger) { TraceLogger = traceLogger; } - public IShiftTraceLogger? TraceLogger { get; set; } - public IBeamShearSectionLogicInputData InputData { get; internal set; } - public ISectionEffectiveness SectionEffectiveness { get; internal set; } - public double GetShearStrength() { - double parameter = GetParameter(); - BeamShearSectionLogicInputData newInputData = GetNewInputData(parameter); - stirrupLogic = new(newInputData, localTraceLogger); + double parameter = GetInclinedCrackRatio(); + BeamShearSectionLogicInputData newInputData = GetNewInputDataByCrackLengthRatio(parameter); + TraceLogger?.AddMessage($"New value of dangerous inclinated crack has been obtained: start point Xstart = {newInputData.InclinedSection.StartCoord}(m), end point Xend = {newInputData.InclinedSection.EndCoord}(m)"); + stirrupLogic = new(newInputData, TraceLogger); double stirrupStrength = stirrupLogic.GetShearStrength(); return stirrupStrength; } - public double GetParameter() + /// + /// Calculates ratio of inclined crack length to inclined section length + /// + /// + /// + private double GetInclinedCrackRatio() { - var parameterCalculator = new FindParameterCalculator(TraceLogger); + var parameterCalculator = new FindParameterCalculator(); parameterCalculator.InputData.Predicate = GetPredicate; parameterCalculator.Accuracy.IterationAccuracy = 0.0001d; parameterCalculator.Accuracy.MaxIterationCount = 1000; @@ -40,24 +43,32 @@ namespace StructureHelperLogics.Models.BeamShears throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": predicate error"); } var result = parameterCalculator.Result as FindParameterResult; - var parameter = result.Parameter; - return parameter; + var crackLengthRatio = result.Parameter; + while (GetPredicate(crackLengthRatio) == false) + { + crackLengthRatio += 0.0001; + } + return crackLengthRatio; } - - private bool GetPredicate(double factor) + /// + /// Predicate of comparing of stirrup strength and concrete strength + /// + /// Ratio of inclined crack length and inclined section length + /// Is true when stirrup strength is greate than concrete strength + private bool GetPredicate(double crackLengthRatio) { - BeamShearSectionLogicInputData newInputData = GetNewInputData(factor); - concreteLogic = new(SectionEffectiveness, newInputData.InclinedSection, localTraceLogger); - stirrupLogic = new(newInputData, localTraceLogger); + BeamShearSectionLogicInputData newInputData = GetNewInputDataByCrackLengthRatio(crackLengthRatio); + concreteLogic = new(SectionEffectiveness, newInputData.InclinedSection, null); + stirrupLogic = new(newInputData, null); double concreteStrength = concreteLogic.GetShearStrength(); double stirrupStrength = stirrupLogic.GetShearStrength(); return stirrupStrength > concreteStrength; } - private BeamShearSectionLogicInputData GetNewInputData(double factor) + private BeamShearSectionLogicInputData GetNewInputDataByCrackLengthRatio(double crackLengthRatio) { double sourceCrackLength = InputData.InclinedSection.EndCoord - InputData.InclinedSection.StartCoord; - double newCrackLength = sourceCrackLength * factor; + double newCrackLength = sourceCrackLength * crackLengthRatio; double newStartCoord = InputData.InclinedSection.EndCoord - newCrackLength; InclinedSection newSection = new(); var updateStrategy = new InclinedSectionUpdateStrategy(); diff --git a/StructureHelperLogics/Models/BeamShears/Logics/StirrupStrengthLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/StirrupStrengthLogic.cs index 198e51d..d7a6cf7 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/StirrupStrengthLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/StirrupStrengthLogic.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Shapes; namespace StructureHelperLogics.Models.BeamShears { @@ -11,6 +12,7 @@ namespace StructureHelperLogics.Models.BeamShears private IBeamShearStrenghLogic stirrupByDensityStrengthLogic; private IBeamShearStrenghLogic stirrupGroupStrengthLogic; private IBeamShearStrenghLogic stirrupByInclinedRebarStrengthLogic; + private IStirrupEffectiveness stirrupEffectiveness; public StirrupStrengthLogic(IBeamShearSectionLogicInputData inputData, IShiftTraceLogger? traceLogger) { @@ -22,28 +24,28 @@ namespace StructureHelperLogics.Models.BeamShears public double GetShearStrength() { - var stirrupEffectiveness = StirrupEffectivenessFactory.GetEffectiveness(BeamShearSectionType.Rectangle); + GetStirrupEffectiveness(); if (stirrup is IStirrupByRebar stirrupByRebar) { - TraceLogger?.AddMessage($"Stirrups type is stirrup by rebar {stirrupByRebar.Name}"); + TraceLogger?.AddMessage($"Stirrups type is stirrup by rebar Name = {stirrupByRebar.Name}"); stirrupByDensityStrengthLogic = new StirrupByRebarStrengthLogic(stirrupEffectiveness, stirrupByRebar, inclinedSection, inputData.ForceTuple, TraceLogger); return stirrupByDensityStrengthLogic.GetShearStrength(); } else if (stirrup is IStirrupGroup stirrupGroup) { - TraceLogger?.AddMessage($"Stirrups type is stirrupGroup {stirrupGroup.Name}"); + TraceLogger?.AddMessage($"Stirrups type is stirrup group Name = {stirrupGroup.Name}"); stirrupGroupStrengthLogic ??= new StirrupGroupStrengthLogic(inputData, stirrupGroup, TraceLogger); return stirrupGroupStrengthLogic.GetShearStrength(); } else if (stirrup is IStirrupByDensity stirrupByDensity) { - TraceLogger?.AddMessage($"Stirrups type is stirrup by density {stirrupByDensity.Name}"); - stirrupByDensityStrengthLogic = new StirrupByDensityStrengthLogic(stirrupEffectiveness, stirrupByDensity, inclinedSection,TraceLogger); + TraceLogger?.AddMessage($"Stirrups type is stirrup by density Name = {stirrupByDensity.Name}"); + stirrupByDensityStrengthLogic = new StirrupByDensityStrengthLogic(stirrupEffectiveness, stirrupByDensity, inclinedSection, TraceLogger); return stirrupByDensityStrengthLogic.GetShearStrength(); } else if (stirrup is IStirrupByInclinedRebar inclinedRebar) { - TraceLogger?.AddMessage($"Stirrups type is inclined rebar {inclinedRebar.Name}"); + TraceLogger?.AddMessage($"Stirrups type is inclined rebar Name = {inclinedRebar.Name}"); stirrupByInclinedRebarStrengthLogic ??= new StirrupByInclinedRebarStrengthLogic(inclinedSection, inclinedRebar, TraceLogger); return stirrupByInclinedRebarStrengthLogic.GetShearStrength(); } @@ -53,5 +55,18 @@ namespace StructureHelperLogics.Models.BeamShears } } + + private void GetStirrupEffectiveness() + { + if (inclinedSection.BeamShearSection.Shape is IRectangleShape) + { + stirrupEffectiveness = StirrupEffectivenessFactory.GetEffectiveness(BeamShearSectionType.Rectangle); + } + else if (inclinedSection.BeamShearSection.Shape is ICircleShape) + { + stirrupEffectiveness = StirrupEffectivenessFactory.GetEffectiveness(BeamShearSectionType.Circle); + + } + } } } diff --git a/StructureHelperLogics/Models/BeamShears/StirrupEffectiveness.cs b/StructureHelperLogics/Models/BeamShears/StirrupEffectiveness.cs index 9067466..08f0dd9 100644 --- a/StructureHelperLogics/Models/BeamShears/StirrupEffectiveness.cs +++ b/StructureHelperLogics/Models/BeamShears/StirrupEffectiveness.cs @@ -15,5 +15,7 @@ namespace StructureHelperLogics.Models.BeamShears public double StirrupShapeFactor { get; set; } /// public double StirrupPlacementFactor { get; set; } + /// + public double MinimumStirrupRatio { get; set; } } }