From b566373f16713b62b99831845d89f1bdf2911f44 Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Sat, 19 Nov 2022 21:12:55 +0500 Subject: [PATCH] LinePrimitive and RectanglePrimitive was added --- .../UI/DataContexts/LinePrimitive.cs | 27 ++++++++ Infrastructure/UI/DataContexts/Point.cs | 2 +- Infrastructure/UI/DataContexts/Rectangle.cs | 2 +- StructureHelper.csproj | 1 + .../Infrastructures/Interfaces/ISaveable.cs | 14 ++++ .../Models/Shapes/ICenter.cs | 4 +- .../Models/Shapes/ILineShape.cs | 15 +++++ .../{IRectangle.cs => IRectangleShape.cs} | 8 +-- .../Models/Shapes/LineShape.cs | 26 ++++++++ .../Models/Shapes/{Point.cs => PointShape.cs} | 2 +- .../{Rectangle.cs => RectangleShape.cs} | 2 +- .../Services/ShapeServices/ShapeService.cs | 27 ++++++++ .../StructureHelperCommon.csproj | 10 ++- .../Models/Materials/ElasticMaterial.cs | 13 +++- .../Models/Materials/IElasticMaterial.cs | 2 + .../Models/Primitives/IPrimitive.cs | 20 ++++++ .../Models/Primitives/LinePrimitive.cs | 37 +++++++++++ .../Templates/RCs/RectangleBeamTemplate.cs | 4 +- .../Primitives/IHasDivisionSize.cs | 14 ++++ .../Primitives/INdmPrimitive.cs | 11 +++- .../Primitives/LinePrimitive.cs | 64 +++++++++++++++++++ .../Primitives/NdmPrimitive.cs | 32 ++++++++-- .../Primitives/RectanglePrimitive.cs | 53 +++++++++++++++ .../IRectangleTriangulationLogicOptions.cs | 2 +- .../RectangleTriangulationLogicOptions.cs | 16 +++-- .../Triangulations/Triangulation.cs | 2 +- .../NdmPrimitives/NdmPrimitivesService.cs | 28 ++++++++ .../Ndms/RCSections/RCSectionTest.cs | 6 +- .../Ndms/SteelSections/ReinforcementTest.cs | 2 +- .../RectangleTriangulationTest.cs | 2 +- Windows/MainWindow/MainView.xaml | 22 ++++++- Windows/MainWindow/MainViewModel.cs | 13 +++- .../Materials/HeadMaterialsView.xaml | 60 +++++++++++++---- .../Materials/HeadMaterialsView.xaml.cs | 38 +++++++++-- .../PrimitivePropertiesView.xaml.cs | 7 +- .../Materials/HeadMaterialsViewModel.cs | 23 ++++++- .../RCs/RectangleBeamViewModel.cs | 2 +- 37 files changed, 544 insertions(+), 69 deletions(-) create mode 100644 Infrastructure/UI/DataContexts/LinePrimitive.cs create mode 100644 StructureHelperCommon/Infrastructures/Interfaces/ISaveable.cs create mode 100644 StructureHelperCommon/Models/Shapes/ILineShape.cs rename StructureHelperCommon/Models/Shapes/{IRectangle.cs => IRectangleShape.cs} (67%) create mode 100644 StructureHelperCommon/Models/Shapes/LineShape.cs rename StructureHelperCommon/Models/Shapes/{Point.cs => PointShape.cs} (74%) rename StructureHelperCommon/Models/Shapes/{Rectangle.cs => RectangleShape.cs} (85%) create mode 100644 StructureHelperCommon/Services/ShapeServices/ShapeService.cs create mode 100644 StructureHelperLogics/Models/Primitives/IPrimitive.cs create mode 100644 StructureHelperLogics/Models/Primitives/LinePrimitive.cs create mode 100644 StructureHelperLogics/NdmCalculations/Primitives/IHasDivisionSize.cs create mode 100644 StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs create mode 100644 StructureHelperLogics/NdmCalculations/Primitives/RectanglePrimitive.cs create mode 100644 StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs diff --git a/Infrastructure/UI/DataContexts/LinePrimitive.cs b/Infrastructure/UI/DataContexts/LinePrimitive.cs new file mode 100644 index 0000000..c45f5bd --- /dev/null +++ b/Infrastructure/UI/DataContexts/LinePrimitive.cs @@ -0,0 +1,27 @@ +using StructureHelper.Infrastructure.Enums; +using StructureHelper.Services.Primitives; +using StructureHelper.UnitSystem.Systems; +using StructureHelper.Windows.MainWindow; +using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.Models.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Infrastructure.UI.DataContexts +{ + internal class LinePrimitive : PrimitiveBase + { + private ILineShape lineShape; + public LinePrimitive(PrimitiveType type, double x, double y, MainViewModel ownerVM) : base(type, x, y, ownerVM) + { + } + + public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem) + { + throw new NotImplementedException(); + } + } +} diff --git a/Infrastructure/UI/DataContexts/Point.cs b/Infrastructure/UI/DataContexts/Point.cs index 2936a88..315f3f9 100644 --- a/Infrastructure/UI/DataContexts/Point.cs +++ b/Infrastructure/UI/DataContexts/Point.cs @@ -52,7 +52,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts { string materialName = MaterialName; ICenter center = new Center { X = CenterX, Y = CenterY }; - IShape shape = new StructureHelperCommon.Models.Shapes.Point { Area = this.Area }; + IShape shape = new StructureHelperCommon.Models.Shapes.PointShape { Area = this.Area }; INdmPrimitive ndmPrimitive = new NdmPrimitive(HeadMaterial) { Center = center, Shape = shape, PrestrainKx = PrestrainKx, diff --git a/Infrastructure/UI/DataContexts/Rectangle.cs b/Infrastructure/UI/DataContexts/Rectangle.cs index d90682d..4e67679 100644 --- a/Infrastructure/UI/DataContexts/Rectangle.cs +++ b/Infrastructure/UI/DataContexts/Rectangle.cs @@ -48,7 +48,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts double centerX = CenterX; double centerY = CenterY; ICenter center = new Center { X = centerX, Y = centerY }; - IShape shape = new StructureHelperCommon.Models.Shapes.Rectangle { Height = height, Width = width, Angle = 0 }; + IShape shape = new StructureHelperCommon.Models.Shapes.RectangleShape { Height = height, Width = width, Angle = 0 }; INdmPrimitive ndmPrimitive = new NdmPrimitive(HeadMaterial) { Center = center, Shape = shape, NdmMaxSize = MaxElementSize, NdmMinDivision = MinElementDivision, diff --git a/StructureHelper.csproj b/StructureHelper.csproj index dfc1102..e00d112 100644 --- a/StructureHelper.csproj +++ b/StructureHelper.csproj @@ -140,6 +140,7 @@ + PrimitivePopup.xaml diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ISaveable.cs b/StructureHelperCommon/Infrastructures/Interfaces/ISaveable.cs new file mode 100644 index 0000000..a1020e2 --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/ISaveable.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + public interface ISaveable + { + int Id { get; set; } + void Save(); + } +} diff --git a/StructureHelperCommon/Models/Shapes/ICenter.cs b/StructureHelperCommon/Models/Shapes/ICenter.cs index 2fb9f90..de2b176 100644 --- a/StructureHelperCommon/Models/Shapes/ICenter.cs +++ b/StructureHelperCommon/Models/Shapes/ICenter.cs @@ -10,11 +10,11 @@ /// Coordinate of center of rectangle by local axis X, m /// Координата центра вдоль локальной оси X, м /// - double X { get;} + double X { get; set; } /// /// Coordinate of center of rectangle by local axis Y, m /// Координата центра вдоль локальной оси Y, м /// - double Y { get;} + double Y { get; set; } } } diff --git a/StructureHelperCommon/Models/Shapes/ILineShape.cs b/StructureHelperCommon/Models/Shapes/ILineShape.cs new file mode 100644 index 0000000..253472d --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/ILineShape.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Shapes +{ + public interface ILineShape : IShape + { + ICenter StartPoint { get; set; } + ICenter EndPoint { get; set; } + double Thickness { get; set; } + } +} diff --git a/StructureHelperCommon/Models/Shapes/IRectangle.cs b/StructureHelperCommon/Models/Shapes/IRectangleShape.cs similarity index 67% rename from StructureHelperCommon/Models/Shapes/IRectangle.cs rename to StructureHelperCommon/Models/Shapes/IRectangleShape.cs index 5ecbad3..d98dd10 100644 --- a/StructureHelperCommon/Models/Shapes/IRectangle.cs +++ b/StructureHelperCommon/Models/Shapes/IRectangleShape.cs @@ -1,18 +1,18 @@ namespace StructureHelperCommon.Models.Shapes { - public interface IRectangle : IShape + public interface IRectangleShape : IShape { /// /// Width of rectangle, m /// - double Width { get; } + double Width { get; set; } /// /// Height of rectangle, m /// - double Height { get; } + double Height { get; set; } /// /// Angle of rotating rectangle, rad /// - double Angle { get; } + double Angle { get; set; } } } diff --git a/StructureHelperCommon/Models/Shapes/LineShape.cs b/StructureHelperCommon/Models/Shapes/LineShape.cs new file mode 100644 index 0000000..c55c472 --- /dev/null +++ b/StructureHelperCommon/Models/Shapes/LineShape.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Shapes +{ + /// + public class LineShape : ILineShape + { + /// + public ICenter StartPoint { get; set; } + /// + public ICenter EndPoint { get; set; } + /// + public double Thickness { get; set; } + + public LineShape() + { + StartPoint = new Center(); + EndPoint = new Center(); + Thickness = 0; + } + } +} diff --git a/StructureHelperCommon/Models/Shapes/Point.cs b/StructureHelperCommon/Models/Shapes/PointShape.cs similarity index 74% rename from StructureHelperCommon/Models/Shapes/Point.cs rename to StructureHelperCommon/Models/Shapes/PointShape.cs index 2bbf5a4..31bdd6b 100644 --- a/StructureHelperCommon/Models/Shapes/Point.cs +++ b/StructureHelperCommon/Models/Shapes/PointShape.cs @@ -1,6 +1,6 @@ namespace StructureHelperCommon.Models.Shapes { - public class Point : IPoint + public class PointShape : IPoint { public double Area { get; set; } } diff --git a/StructureHelperCommon/Models/Shapes/Rectangle.cs b/StructureHelperCommon/Models/Shapes/RectangleShape.cs similarity index 85% rename from StructureHelperCommon/Models/Shapes/Rectangle.cs rename to StructureHelperCommon/Models/Shapes/RectangleShape.cs index be9d236..12f0a64 100644 --- a/StructureHelperCommon/Models/Shapes/Rectangle.cs +++ b/StructureHelperCommon/Models/Shapes/RectangleShape.cs @@ -1,7 +1,7 @@ namespace StructureHelperCommon.Models.Shapes { /// - public class Rectangle : IRectangle + public class RectangleShape : IRectangleShape { /// public double Width { get; set; } diff --git a/StructureHelperCommon/Services/ShapeServices/ShapeService.cs b/StructureHelperCommon/Services/ShapeServices/ShapeService.cs new file mode 100644 index 0000000..7c75825 --- /dev/null +++ b/StructureHelperCommon/Services/ShapeServices/ShapeService.cs @@ -0,0 +1,27 @@ +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Services.ShapeServices +{ + public static class ShapeService + { + public static void CopyLineProperties(ILineShape source, ILineShape target) + { + target.StartPoint.X = source.StartPoint.X; + target.StartPoint.Y = source.StartPoint.Y; + target.EndPoint.X = source.EndPoint.X; + target.EndPoint.Y = source.EndPoint.Y; + } + + public static void CopyRectangleProperties(IRectangleShape source, IRectangleShape target) + { + target.Width = source.Width; + target.Height = source.Height; + target.Angle = source.Angle; + } + } +} diff --git a/StructureHelperCommon/StructureHelperCommon.csproj b/StructureHelperCommon/StructureHelperCommon.csproj index 7c57c3a..ce92dbd 100644 --- a/StructureHelperCommon/StructureHelperCommon.csproj +++ b/StructureHelperCommon/StructureHelperCommon.csproj @@ -51,19 +51,23 @@ + + - + - - + + + + \ No newline at end of file diff --git a/StructureHelperLogics/Models/Materials/ElasticMaterial.cs b/StructureHelperLogics/Models/Materials/ElasticMaterial.cs index 9a6b509..0d47185 100644 --- a/StructureHelperLogics/Models/Materials/ElasticMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ElasticMaterial.cs @@ -12,12 +12,14 @@ namespace StructureHelperLogics.Models.Materials public class ElasticMaterial : IElasticMaterial { public double Modulus { get; set; } + public double CompressiveStrength { get; set; } + public double TensileStrength { get; set; } public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) { IMaterial material = new Material(); material.InitModulus = Modulus; - IEnumerable parameters = new List() { Modulus}; + IEnumerable parameters = new List() { Modulus, CompressiveStrength, TensileStrength}; material.DiagramParameters = parameters; material.Diagram = GetStress; return material; @@ -25,12 +27,17 @@ namespace StructureHelperLogics.Models.Materials private double GetStress (IEnumerable parameters, double strain) { - return parameters.First() * strain; + double modulus = parameters.First(); + double stress = modulus * strain; + double compressiveStrength = (-1d) * parameters.ElementAt(1); + double tensileStrength = parameters.ElementAt(2); + if (stress > tensileStrength || stress < compressiveStrength) { return 0d; } + else { return stress; } } public object Clone() { - return new ElasticMaterial() { Modulus = Modulus }; + return new ElasticMaterial() { Modulus = Modulus, CompressiveStrength = CompressiveStrength, TensileStrength = TensileStrength }; } } } diff --git a/StructureHelperLogics/Models/Materials/IElasticMaterial.cs b/StructureHelperLogics/Models/Materials/IElasticMaterial.cs index d9e34be..9974916 100644 --- a/StructureHelperLogics/Models/Materials/IElasticMaterial.cs +++ b/StructureHelperLogics/Models/Materials/IElasticMaterial.cs @@ -9,5 +9,7 @@ namespace StructureHelperLogics.Models.Materials public interface IElasticMaterial : IHelperMaterial { double Modulus { get; set; } + double CompressiveStrength { get; set; } + double TensileStrength { get; set; } } } diff --git a/StructureHelperLogics/Models/Primitives/IPrimitive.cs b/StructureHelperLogics/Models/Primitives/IPrimitive.cs new file mode 100644 index 0000000..f1cfaff --- /dev/null +++ b/StructureHelperLogics/Models/Primitives/IPrimitive.cs @@ -0,0 +1,20 @@ +using LoaderCalculator.Data.Ndms; +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 StructureHelperLogics.Models.Primitives +{ + public interface IPrimitive : ISaveable, ICloneable + { + string Name { get; set; } + ICenter Center { get; } + IShape Shape { get; } + + IEnumerable GetNdmPrimitives(); + } +} diff --git a/StructureHelperLogics/Models/Primitives/LinePrimitive.cs b/StructureHelperLogics/Models/Primitives/LinePrimitive.cs new file mode 100644 index 0000000..956c634 --- /dev/null +++ b/StructureHelperLogics/Models/Primitives/LinePrimitive.cs @@ -0,0 +1,37 @@ +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.Primitives +{ + public class LinePrimitive : IPrimitive + { + public int Id { get; set; } + public string Name { get; set; } + public ICenter Center { get; set; } + public IShape Shape { get; } + + public LinePrimitive() + { + + } + + public IEnumerable GetNdmPrimitives() + { + throw new NotImplementedException(); + } + + public object Clone() + { + throw new NotImplementedException(); + } + + public void Save() + { + throw new NotImplementedException(); + } + } +} diff --git a/StructureHelperLogics/Models/Templates/RCs/RectangleBeamTemplate.cs b/StructureHelperLogics/Models/Templates/RCs/RectangleBeamTemplate.cs index dd79568..fdd60af 100644 --- a/StructureHelperLogics/Models/Templates/RCs/RectangleBeamTemplate.cs +++ b/StructureHelperLogics/Models/Templates/RCs/RectangleBeamTemplate.cs @@ -18,7 +18,7 @@ namespace StructureHelperLogics.Models.Templates.RCs public RectangleBeamTemplate() { - Shape = new Rectangle() { Width = 0.4d, Height = 0.6d }; + Shape = new RectangleShape() { Width = 0.4d, Height = 0.6d }; CoverGap = 0.05d; TopDiameter = 0.016d; BottomDiameter = 0.025d; @@ -28,7 +28,7 @@ namespace StructureHelperLogics.Models.Templates.RCs public RectangleBeamTemplate(double width, double height) { - Shape = new Rectangle() { Width = width, Height = height }; + Shape = new RectangleShape() { Width = width, Height = height }; CoverGap = 0.05d; TopDiameter = 0.016d; BottomDiameter = 0.025d; diff --git a/StructureHelperLogics/NdmCalculations/Primitives/IHasDivisionSize.cs b/StructureHelperLogics/NdmCalculations/Primitives/IHasDivisionSize.cs new file mode 100644 index 0000000..8ca8bfb --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Primitives/IHasDivisionSize.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.NdmCalculations.Primitives +{ + internal interface IHasDivisionSize + { + double NdmMaxSize { get; set; } + int NdmMinDivision { get; set; } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Primitives/INdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/INdmPrimitive.cs index 2e92450..4c723c9 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/INdmPrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/INdmPrimitive.cs @@ -1,18 +1,23 @@ using StructureHelperLogics.Models.Materials; using StructureHelperCommon.Models.Shapes; using StructureHelper.Models.Materials; +using System.Collections; +using LoaderCalculator.Data.Ndms; +using LoaderCalculator.Data.Materials; +using System.Collections.Generic; namespace StructureHelperLogics.Models.Primitives { public interface INdmPrimitive { + string Name { get; set; } ICenter Center { get; set; } IShape Shape { get; set; } - IHeadMaterial HeadMaterial { get; } - double NdmMaxSize { get; set; } - int NdmMinDivision { get; set; } + IHeadMaterial HeadMaterial { get; set; } double PrestrainKx { get; set; } double PrestrainKy { get; set; } double PrestrainEpsZ { get; set; } + + IEnumerable GetNdms(IMaterial material); } } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs new file mode 100644 index 0000000..72b61a7 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Primitives/LinePrimitive.cs @@ -0,0 +1,64 @@ +using LoaderCalculator.Data.Materials; +using LoaderCalculator.Data.Ndms; +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Services.ShapeServices; +using StructureHelperLogics.Models.Primitives; +using StructureHelperLogics.Services.NdmPrimitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.NdmCalculations.Primitives +{ + public class LinePrimitive : INdmPrimitive, ILineShape, IHasDivisionSize, ISaveable, ICloneable + { + public ICenter Center { get; set; } + public IShape Shape { get; set; } + + public int Id { get; set; } + public string Name { get; set; } + public double NdmMaxSize { get; set; } + public int NdmMinDivision { get; set; } + public IHeadMaterial HeadMaterial { get; set; } + public double PrestrainKx { get; set; } + public double PrestrainKy { get; set; } + public double PrestrainEpsZ { get; set; } + + public ICenter StartPoint { get; set; } + public ICenter EndPoint { get; set; } + public double Thickness { get; set; } + + public LinePrimitive() + { + StartPoint = new Center(); + EndPoint = new Center(); + + Name = "New Line"; + NdmMaxSize = 0.01d; + NdmMinDivision = 10; + } + + public object Clone() + { + LinePrimitive primitive = new LinePrimitive(); + NdmPrimitivesService.CopyNdmProperties(this, primitive); + NdmPrimitivesService.CopyDivisionProperties(this, primitive); + ShapeService.CopyLineProperties(this, primitive); + return primitive; + } + + public IEnumerable GetNdms(IMaterial material) + { + throw new NotImplementedException(); + } + + public void Save() + { + throw new NotImplementedException(); + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Primitives/NdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/NdmPrimitive.cs index 61a42f2..a67e9d2 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/NdmPrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/NdmPrimitive.cs @@ -1,25 +1,47 @@ using StructureHelperLogics.Models.Materials; using StructureHelperCommon.Models.Shapes; using StructureHelper.Models.Materials; +using System.Collections.Generic; +using LoaderCalculator.Data.Ndms; +using LoaderCalculator.Data.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; +using System; namespace StructureHelperLogics.Models.Primitives { - public class NdmPrimitive : INdmPrimitive + public class NdmPrimitive : INdmPrimitive, ISaveable, ICloneable { - private IHeadMaterial headMaterial; - public ICenter Center { get; set; } public IShape Shape { get; set; } - public IHeadMaterial HeadMaterial { get => headMaterial; } + + public int Id { get; set; } + public string Name { get; set; } + public IHeadMaterial HeadMaterial { get; private set; } public double NdmMaxSize { get; set; } public int NdmMinDivision { get; set; } public double PrestrainKx { get; set; } public double PrestrainKy { get; set; } public double PrestrainEpsZ { get; set; } + public NdmPrimitive(IHeadMaterial material) { - headMaterial = material; + HeadMaterial = material; + } + + public IEnumerable GetNdms(IMaterial material) + { + throw new System.NotImplementedException(); + } + + public void Save() + { + throw new System.NotImplementedException(); + } + + public object Clone() + { + throw new NotImplementedException(); } } } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/RectanglePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/RectanglePrimitive.cs new file mode 100644 index 0000000..ad7721d --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Primitives/RectanglePrimitive.cs @@ -0,0 +1,53 @@ +using LoaderCalculator.Data.Materials; +using LoaderCalculator.Data.Ndms; +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Services.ShapeServices; +using StructureHelperLogics.Models.Primitives; +using StructureHelperLogics.Services.NdmPrimitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.NdmCalculations.Primitives +{ + public class RectanglePrimitive : INdmPrimitive, IRectangleShape, IHasDivisionSize, ISaveable, ICloneable + { + public string Name { get; set; } + public ICenter Center { get; set; } + public IShape Shape { get; set; } + public IHeadMaterial HeadMaterial { get; set; } + public double PrestrainKx { get; set; } + public double PrestrainKy { get; set; } + public double PrestrainEpsZ { get; set; } + public double NdmMaxSize { get; set; } + public int NdmMinDivision { get; set; } + public int Id { get; set; } + + public double Width { get; set; } + public double Height { get; set; } + public double Angle { get; set; } + + public object Clone() + { + RectanglePrimitive primitive = new RectanglePrimitive(); + NdmPrimitivesService.CopyNdmProperties(this, primitive); + NdmPrimitivesService.CopyDivisionProperties(this, primitive); + ShapeService.CopyRectangleProperties(this, primitive); + return primitive; + } + + public IEnumerable GetNdms(IMaterial material) + { + throw new NotImplementedException(); + } + + public void Save() + { + throw new NotImplementedException(); + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/IRectangleTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/IRectangleTriangulationLogicOptions.cs index ddfd6a8..1c689bc 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/IRectangleTriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/IRectangleTriangulationLogicOptions.cs @@ -15,7 +15,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations /// /// /// - IRectangle Rectangle { get; } + IRectangleShape Rectangle { get; } /// /// Maximum size (width or height) of ndm part after triangulation /// diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs index 540942d..16aafbf 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs @@ -3,6 +3,7 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Strings; using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.Primitives; +using StructureHelperLogics.NdmCalculations.Primitives; namespace StructureHelperLogics.NdmCalculations.Triangulations { @@ -12,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations /// public ICenter Center { get; } /// - public IRectangle Rectangle { get; } + public IRectangleShape Rectangle { get; } /// public double NdmMaxSize { get; } /// @@ -24,7 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations /// public double PrestrainEpsZ { get;} - public RectangleTriangulationLogicOptions(ICenter center, IRectangle rectangle, double ndmMaxSize, int ndmMinDivision) + public RectangleTriangulationLogicOptions(ICenter center, IRectangleShape rectangle, double ndmMaxSize, int ndmMinDivision) { Center = center; Rectangle = rectangle; @@ -34,11 +35,14 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations public RectangleTriangulationLogicOptions(INdmPrimitive primitive) { - if (! (primitive.Shape is IRectangle)) { throw new StructureHelperException(ErrorStrings.ShapeIsNotCorrect); } + if (! (primitive.Shape is IRectangleShape)) { throw new StructureHelperException(ErrorStrings.ShapeIsNotCorrect); } Center = primitive.Center; - Rectangle = primitive.Shape as IRectangle; - NdmMaxSize = primitive.NdmMaxSize; - NdmMinDivision = primitive.NdmMinDivision; + Rectangle = primitive.Shape as IRectangleShape; + if (primitive is IHasDivisionSize) + { + NdmMaxSize = (primitive as IHasDivisionSize).NdmMaxSize; + NdmMinDivision = (primitive as IHasDivisionSize).NdmMinDivision; + } PrestrainKx = primitive.PrestrainKx; PrestrainKy = primitive.PrestrainKy; PrestrainEpsZ = primitive.PrestrainEpsZ; diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs b/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs index 5fd161d..c643b18 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/Triangulation.cs @@ -73,7 +73,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations ITriangulationLogicOptions options; ICenter center = primitive.Center; IShape shape = primitive.Shape; - if (shape is IRectangle) + if (shape is IRectangleShape) { options = new RectangleTriangulationLogicOptions(primitive); ITriangulationLogic logic = new RectangleTriangulationLogic(options); diff --git a/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs b/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs new file mode 100644 index 0000000..73a7847 --- /dev/null +++ b/StructureHelperLogics/Services/NdmPrimitives/NdmPrimitivesService.cs @@ -0,0 +1,28 @@ +using StructureHelperLogics.Models.Primitives; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Services.NdmPrimitives +{ + internal static class NdmPrimitivesService + { + public static void CopyNdmProperties (INdmPrimitive source, INdmPrimitive target) + { + target.Name = source.Name + " - copy" ; + target.HeadMaterial = source.HeadMaterial; + target.PrestrainKx = source.PrestrainKx; + target.PrestrainKy = source.PrestrainKy; + target.PrestrainEpsZ = source.PrestrainEpsZ; + } + + public static void CopyDivisionProperties(IHasDivisionSize source, IHasDivisionSize target) + { + target.NdmMaxSize = source.NdmMaxSize; + target.NdmMinDivision = source.NdmMinDivision; + } + } +} diff --git a/StructureHelperTests/FunctionalTests/Ndms/RCSections/RCSectionTest.cs b/StructureHelperTests/FunctionalTests/Ndms/RCSections/RCSectionTest.cs index 25028ca..e437871 100644 --- a/StructureHelperTests/FunctionalTests/Ndms/RCSections/RCSectionTest.cs +++ b/StructureHelperTests/FunctionalTests/Ndms/RCSections/RCSectionTest.cs @@ -62,7 +62,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections { double strength = 40e6; ICenter center = new Center { X = 0, Y = 0 }; - IRectangle rectangle = new Rectangle { Width = width, Height = height, Angle = 0 }; + IRectangleShape rectangle = new RectangleShape { Width = width, Height = height, Angle = 0 }; IPrimitiveMaterial material = new PrimitiveMaterial { MaterialType = MaterialTypes.Concrete, ClassName = "С40", Strength = strength }; //ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm }; INdmPrimitive primitive = new NdmPrimitive { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 20 }; @@ -74,8 +74,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections { double gap = 0.05d; double strength = 4e8; - IShape topReinforcement = new Point { Area = topArea }; - IShape bottomReinforcement = new Point { Area = bottomArea }; + IShape topReinforcement = new PointShape { Area = topArea }; + IShape bottomReinforcement = new PointShape { Area = bottomArea }; IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength }; //ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm }; ICenter centerRT = new Center { X = width / 2 - gap, Y = height / 2 - gap }; diff --git a/StructureHelperTests/FunctionalTests/Ndms/SteelSections/ReinforcementTest.cs b/StructureHelperTests/FunctionalTests/Ndms/SteelSections/ReinforcementTest.cs index fcc62eb..edcaf53 100644 --- a/StructureHelperTests/FunctionalTests/Ndms/SteelSections/ReinforcementTest.cs +++ b/StructureHelperTests/FunctionalTests/Ndms/SteelSections/ReinforcementTest.cs @@ -22,7 +22,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.SteelSections { //Arrange ICenter center = new Center { X = 0, Y = 0 }; - IRectangle rectangle = new Rectangle { Width = width, Height = height, Angle = 0 }; + IRectangleShape rectangle = new RectangleShape { Width = width, Height = height, Angle = 0 }; IPrimitiveMaterial material = new PrimitiveMaterial { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength }; ITriangulationOptions options = new TriangulationOptions { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm }; INdmPrimitive primitive = new NdmPrimitive { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 100 }; diff --git a/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs b/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs index 079f4e0..caecc93 100644 --- a/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs +++ b/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs @@ -22,7 +22,7 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations //Arrange IMaterial material = new Material(); ICenter center = new Center { X = centerX, Y = centerY }; - IRectangle rectangle = new Rectangle { Width = width, Height = height, Angle = angle }; + IRectangleShape rectangle = new RectangleShape { Width = width, Height = height, Angle = angle }; IRectangleTriangulationLogicOptions options = new StructureHelperLogics.NdmCalculations.Triangulations.RectangleTriangulationLogicOptions(center, rectangle, ndmMaxSize, ndmMinDivision); IRectangleTriangulationLogic logic = new StructureHelperLogics.NdmCalculations.Triangulations.RectangleTriangulationLogic(options); //Act diff --git a/Windows/MainWindow/MainView.xaml b/Windows/MainWindow/MainView.xaml index 6725caa..b393f97 100644 --- a/Windows/MainWindow/MainView.xaml +++ b/Windows/MainWindow/MainView.xaml @@ -65,7 +65,12 @@ - + + + +