diff --git a/DataAccess/DTOs/Converters/DivisionSizeFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/DivisionSizeFromDTOConvertStrategy.cs new file mode 100644 index 0000000..053ebbb --- /dev/null +++ b/DataAccess/DTOs/Converters/DivisionSizeFromDTOConvertStrategy.cs @@ -0,0 +1,32 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperLogics.NdmCalculations.Primitives; + +namespace DataAccess.DTOs +{ + public class DivisionSizeFromDTOConvertStrategy : ConvertStrategy + { + IUpdateStrategy updateStrategy; + + public DivisionSizeFromDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public DivisionSizeFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + updateStrategy = new DivisionSizeUpdateStrategy(); + } + + public override IDivisionSize GetNewItem(IDivisionSize source) + { + if (source is not DivisionSizeDTO sourceDTO) + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source)); + } + NewItem = new DivisionSize(source.Id); + updateStrategy.Update(NewItem, sourceDTO); + return NewItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/Forces/ForceCombinationFromFileFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Forces/ForceCombinationFromFileFromDTOConvertStrategy.cs index c85c7d7..700de3d 100644 --- a/DataAccess/DTOs/Converters/Forces/ForceCombinationFromFileFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Forces/ForceCombinationFromFileFromDTOConvertStrategy.cs @@ -104,7 +104,7 @@ namespace DataAccess.DTOs private void InitializeStrategies() { updateStrategy ??= new ForceCombinationFromFileUpdateStrategy(); - pointConvertStrategy = new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger}; + pointConvertStrategy = new Point2DFromDTOConvertStrategy(this); combinationPropertyConvertStrategy = new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger); fileConvertStrategy ??= new ColumnedFilePropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; } diff --git a/DataAccess/DTOs/Converters/Forces/ForceCombinationListFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Forces/ForceCombinationListFromDTOConvertStrategy.cs index 56dd934..e532cd4 100644 --- a/DataAccess/DTOs/Converters/Forces/ForceCombinationListFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Forces/ForceCombinationListFromDTOConvertStrategy.cs @@ -72,7 +72,7 @@ namespace DataAccess.DTOs { baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy(); updateStrategy ??= new ForceCombinationListUpdateStrategy(); - pointConvertStrategy ??= new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger}; + pointConvertStrategy ??= new Point2DFromDTOConvertStrategy(this); designTupleConvertStrategy ??= new DesignForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; } } diff --git a/DataAccess/DTOs/Converters/Forces/ForceFactoredListFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Forces/ForceFactoredListFromDTOConvertStrategy.cs index 4bd8a3b..e2792fd 100644 --- a/DataAccess/DTOs/Converters/Forces/ForceFactoredListFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Forces/ForceFactoredListFromDTOConvertStrategy.cs @@ -85,7 +85,7 @@ namespace DataAccess.DTOs { baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy(); updateStrategy ??= new ForceFactoredListUpdateStrategy(); - pointConvertStrategy ??= new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger}; + pointConvertStrategy ??= new Point2DFromDTOConvertStrategy(this); forceTupleConvertStrategy ??= new ForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger); } diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/EllipseNdmPrimitiveFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/EllipseNdmPrimitiveFromDTOConvertStrategy.cs index a8a328e..8a6b69f 100644 --- a/DataAccess/DTOs/Converters/NdmCrossSections/EllipseNdmPrimitiveFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/NdmCrossSections/EllipseNdmPrimitiveFromDTOConvertStrategy.cs @@ -1,10 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperLogics.NdmCalculations.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DataAccess.DTOs { diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/HasPrimitivesFromDTOUpdateStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/HasPrimitivesFromDTOUpdateStrategy.cs index 6d9b1b7..2126812 100644 --- a/DataAccess/DTOs/Converters/NdmCrossSections/HasPrimitivesFromDTOUpdateStrategy.cs +++ b/DataAccess/DTOs/Converters/NdmCrossSections/HasPrimitivesFromDTOUpdateStrategy.cs @@ -1,11 +1,6 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Services; using StructureHelperLogics.NdmCalculations.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DataAccess.DTOs.Converters { diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementFromDTOConvertStrategy.cs new file mode 100644 index 0000000..97e6542 --- /dev/null +++ b/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementFromDTOConvertStrategy.cs @@ -0,0 +1,36 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces; +using StructureHelperLogics.NdmCalculations.Primitives; +using StructureHelperLogics.NdmCalculations.Primitives.Logics; + +namespace DataAccess.DTOs +{ + public class NdmElementFromDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IUpdateStrategy forceUpdateStrategy = new ForceTupleUpdateStrategy(); + private NdmElement newItem; + + public NdmElementFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + } + + public override INdmElement GetNewItem(INdmElement source) + { + if (source is not NdmElementDTO sourceDTO) + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source)); + } + newItem = new NdmElement(sourceDTO.Id); + updateStrategy = new NdmElementUpdateStrategy() { UpdateChildren = false}; + updateStrategy.Update(newItem, sourceDTO); + forceUpdateStrategy.Update(newItem.UsersPrestrain, source.UsersPrestrain); + //newItem.UsersPrestrain.Id = source.UsersPrestrain.Id; + //forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain); + //(newItem.AutoPrestrain as ForceTupleDTO).Id = source.AutoPrestrain.Id; + NewItem = newItem; + return NewItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementToDTOConvertStrategy.cs index 29895ec..83fd7b4 100644 --- a/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/NdmCrossSections/NdmElementToDTOConvertStrategy.cs @@ -54,16 +54,20 @@ namespace DataAccess.DTOs updateStrategy.Update(newItem, source); headMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary; headMaterialConvertStrategy.TraceLogger = TraceLogger; - var convertLogic = new DictionaryConvertStrategy(this, headMaterialConvertStrategy); + var headMaterialLogic = new DictionaryConvertStrategy(this, headMaterialConvertStrategy); if (source.HeadMaterial != null) { - var headMaterial = convertLogic.Convert(source.HeadMaterial); + var headMaterial = headMaterialLogic.Convert(source.HeadMaterial); newItem.HeadMaterial = headMaterial; - } + } + else + { + newItem.HeadMaterial = null; + } forceUpdateStrategy.Update(newItem.UsersPrestrain, source.UsersPrestrain); (newItem.UsersPrestrain as ForceTupleDTO).Id = source.UsersPrestrain.Id; - forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain); - (newItem.AutoPrestrain as ForceTupleDTO).Id = source.AutoPrestrain.Id; + //forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain); + //(newItem.AutoPrestrain as ForceTupleDTO).Id = source.AutoPrestrain.Id; return newItem; } diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/NdmPrimitiveFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/NdmPrimitiveFromDTOConvertStrategy.cs index 7fc126f..f9d56e3 100644 --- a/DataAccess/DTOs/Converters/NdmCrossSections/NdmPrimitiveFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/NdmCrossSections/NdmPrimitiveFromDTOConvertStrategy.cs @@ -45,9 +45,12 @@ namespace DataAccess.DTOs public override INdmPrimitive GetNewItem(INdmPrimitive source) { - GetMaterial(source.NdmElement.HeadMaterial); INdmPrimitive newItem = GetNewPrimitive(source); - newItem.NdmElement.HeadMaterial = headMaterial; + if (source.NdmElement.HeadMaterial != null) + { + GetMaterial(source.NdmElement.HeadMaterial); + newItem.NdmElement.HeadMaterial = headMaterial; + } return newItem; } @@ -69,11 +72,23 @@ namespace DataAccess.DTOs { return GetRectangle(rectangle); } + if (source is ShapeNdmPrimitiveDTO shape) + { + return GetShape(shape); + } string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source); TraceLogger.AddMessage(errorString, TraceLogStatuses.Error); throw new StructureHelperException(errorString); } + private INdmPrimitive GetShape(ShapeNdmPrimitiveDTO shape) + { + TraceLogger?.AddMessage($"{PrimitiveIs} shape ndm primitive"); + ShapeNdmPrimitiveFromDTOConvertStrategy convertStrategy = new(this); + IShapeNdmPrimitive shapeNdmPrimitive = convertStrategy.Convert(shape); + return shapeNdmPrimitive; + } + private void GetMaterial(IHeadMaterial source) { HeadMaterialFromDTOConvertStrategy convertStrategy = new() diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/RebarNdmPrimitiveFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/RebarNdmPrimitiveFromDTOConvertStrategy.cs index 2a46a4f..f51f571 100644 --- a/DataAccess/DTOs/Converters/NdmCrossSections/RebarNdmPrimitiveFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/NdmCrossSections/RebarNdmPrimitiveFromDTOConvertStrategy.cs @@ -1,10 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperLogics.NdmCalculations.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DataAccess.DTOs { diff --git a/DataAccess/DTOs/Converters/NdmCrossSections/ShapeNdmPrimitiveFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/NdmCrossSections/ShapeNdmPrimitiveFromDTOConvertStrategy.cs new file mode 100644 index 0000000..fe508bd --- /dev/null +++ b/DataAccess/DTOs/Converters/NdmCrossSections/ShapeNdmPrimitiveFromDTOConvertStrategy.cs @@ -0,0 +1,52 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.NdmCalculations.Primitives; + +namespace DataAccess.DTOs +{ + public class ShapeNdmPrimitiveFromDTOConvertStrategy : ConvertStrategy + { + IUpdateStrategy updateStrategy; + private IConvertStrategy shapeConvertStrategy; + private IConvertStrategy ndmElementConvertStrategy; + private IConvertStrategy pointConvertStrategy; + private IConvertStrategy visualPropsConvertStrategy; + private IConvertStrategy divisionConvertStrategy; + + private ShapeNdmPrimitive newItem; + + public ShapeNdmPrimitiveFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + updateStrategy = new ShapeNdmPrimitiveUpdateStrategy() { UpdateChildren = false }; + shapeConvertStrategy = new ShapeFromDTOConvertStrategy(this); + ndmElementConvertStrategy = new NdmElementFromDTOConvertStrategy(this); + pointConvertStrategy = new Point2DFromDTOConvertStrategy(this); + visualPropsConvertStrategy = new VisualPropertyFromDTOConvertStrategy(this); + divisionConvertStrategy = new DivisionSizeFromDTOConvertStrategy(this); + } + + public override IShapeNdmPrimitive GetNewItem(IShapeNdmPrimitive source) + { + ChildClass = this; + if (source is not ShapeNdmPrimitiveDTO sourceDTO) + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": source shape is not DTO object"); + } + newItem = new(source.Id); + updateStrategy.Update(newItem, sourceDTO); + updateChildProperties(sourceDTO); + NewItem = newItem; + return NewItem; + } + private void updateChildProperties(ShapeNdmPrimitiveDTO source) + { + newItem.SetShape(shapeConvertStrategy.Convert(source.Shape)); + newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement); + newItem.Center = pointConvertStrategy.Convert(source.Center as Point2DDTO); + newItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty as VisualPropertyDTO); + newItem.DivisionSize = divisionConvertStrategy.Convert(source.DivisionSize); + } + + } +} diff --git a/DataAccess/DTOs/Converters/Shapes/LinePolygonFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/LinePolygonFromDTOConvertStrategy.cs new file mode 100644 index 0000000..6e04304 --- /dev/null +++ b/DataAccess/DTOs/Converters/Shapes/LinePolygonFromDTOConvertStrategy.cs @@ -0,0 +1,43 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; + +namespace DataAccess.DTOs +{ + public class LinePolygonFromDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy vertexConvertStrategy; + private LinePolygonShape newItem; + + public LinePolygonFromDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public LinePolygonFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + updateStrategy = new LinePolygonShapeUpdateStrategy() { UpdateChildren = false }; + vertexConvertStrategy = new VertexFtomDTOConvertStrategy(this); + } + + public override ILinePolygonShape GetNewItem(ILinePolygonShape source) + { + ChildClass = this; + if (source is not LinePolygonShapeDTO sourceDTO) + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": source line polygon is not DTO object"); + } + newItem = new(sourceDTO.Id); + updateStrategy.Update(newItem, sourceDTO); + newItem.Clear(); + foreach (var item in source.Vertices) + { + IVertex newVertex = vertexConvertStrategy.Convert(item); + newItem.AddVertex(newVertex); + } + NewItem = newItem; + return NewItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/Shapes/LinePolygonToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/LinePolygonToDTOConvertStrategy.cs index 8a773c7..e3b1f7d 100644 --- a/DataAccess/DTOs/Converters/Shapes/LinePolygonToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Shapes/LinePolygonToDTOConvertStrategy.cs @@ -12,24 +12,26 @@ namespace DataAccess.DTOs { private IUpdateStrategy updateStrategy; private IConvertStrategy vertexConvertStrategy; + private LinePolygonShapeDTO newItem; public LinePolygonToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) { + updateStrategy = new LinePolygonShapeUpdateStrategy() { UpdateChildren = false }; + vertexConvertStrategy = new VertexToDTOConvertStrategy(this); } public override LinePolygonShapeDTO GetNewItem(ILinePolygonShape source) { ChildClass = this; - NewItem = new(source.Id); - updateStrategy = new LinePolygonShapeUpdateStrategy() { UpdateChildren = false }; - vertexConvertStrategy = new VertexToDTOConvertStrategy(this); - updateStrategy.Update(NewItem, source); - NewItem.Clear(); + newItem = new(source.Id); + updateStrategy.Update(newItem, source); + newItem.Clear(); foreach (var item in source.Vertices) { VertexDTO newVertex = vertexConvertStrategy.Convert(item); - NewItem.AddVertex(newVertex); + newItem.AddVertex(newVertex); } + NewItem = newItem; return NewItem; } } diff --git a/DataAccess/DTOs/Converters/Shapes/Point2DFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/Point2DFromDTOConvertStrategy.cs index 0569170..f2d7787 100644 --- a/DataAccess/DTOs/Converters/Shapes/Point2DFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Shapes/Point2DFromDTOConvertStrategy.cs @@ -1,12 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; -using StructureHelperCommon.Models.Loggers; -using StructureHelperCommon.Models; using StructureHelperCommon.Models.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DataAccess.DTOs { @@ -24,27 +17,16 @@ namespace DataAccess.DTOs } - public override Point2D GetNewItem(Point2DDTO source) + public Point2DFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) { - TraceLogger?.AddMessage("Point 2D converting has been started"); - try - { - Point2D newItem = GetNewItemBySource(source); - TraceLogger?.AddMessage("Point 2D converting has been finished"); - return newItem; - } - catch (Exception ex) - { - TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(this)} made error: {ex.Message}", TraceLogStatuses.Error); - throw; - } + updateStrategy = new Point2DUpdateStrategy(); } - private Point2D GetNewItemBySource(Point2DDTO source) + public override Point2D GetNewItem(Point2DDTO source) { - Point2D newItem = new(source.Id); - updateStrategy.Update(newItem, source); - return newItem; + NewItem = new(source.Id); + updateStrategy.Update(NewItem, source); + return NewItem; } } } diff --git a/DataAccess/DTOs/Converters/Shapes/ShapeFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/ShapeFromDTOConvertStrategy.cs index df50109..69b0052 100644 --- a/DataAccess/DTOs/Converters/Shapes/ShapeFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Shapes/ShapeFromDTOConvertStrategy.cs @@ -28,6 +28,12 @@ namespace DataAccess.DTOs (this, new CircleShapeFromDTOConvertStrategy(this)); NewItem = circleConvertStrategy.Convert(circleShapeDTO); } + else if (source is LinePolygonShapeDTO linePolygonDTO) + { + var polygonConvertStrategy = new DictionaryConvertStrategy + (this, new LinePolygonFromDTOConvertStrategy(this)); + NewItem = polygonConvertStrategy.Convert(linePolygonDTO); + } else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape is unknown"); diff --git a/DataAccess/DTOs/Converters/Shapes/VertexFtomDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Shapes/VertexFtomDTOConvertStrategy.cs new file mode 100644 index 0000000..6b2ce03 --- /dev/null +++ b/DataAccess/DTOs/Converters/Shapes/VertexFtomDTOConvertStrategy.cs @@ -0,0 +1,33 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; + +namespace DataAccess.DTOs +{ + public class VertexFtomDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy pointConvertStrategy; + private Vertex newItem; + + public VertexFtomDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + updateStrategy = new VertexUpdateStrategy() { UpdateChildren = false }; + pointConvertStrategy = new Point2DFromDTOConvertStrategy(this); + } + + public override IVertex GetNewItem(IVertex source) + { + ChildClass = this; + if (source is not VertexDTO sourceDTO) + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": source vertex is not DTO object"); + } + newItem = new(sourceDTO.Id); + updateStrategy.Update(newItem, sourceDTO); + newItem.Point = pointConvertStrategy.Convert(sourceDTO.Point as Point2DDTO); + NewItem = newItem; + return NewItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/VisualPropertyFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VisualPropertyFromDTOConvertStrategy.cs new file mode 100644 index 0000000..d4f6038 --- /dev/null +++ b/DataAccess/DTOs/Converters/VisualPropertyFromDTOConvertStrategy.cs @@ -0,0 +1,27 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperLogics.NdmCalculations.Primitives; + +namespace DataAccess.DTOs +{ + public class VisualPropertyFromDTOConvertStrategy : ConvertStrategy + { + IUpdateStrategy updateStrategy; + + public VisualPropertyFromDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public VisualPropertyFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) + { + updateStrategy = new VisualPropsUpdateStrategy(); + } + + public override IVisualProperty GetNewItem(VisualPropertyDTO source) + { + NewItem = new VisualProperty(source.Id); + updateStrategy.Update(NewItem, source); + return NewItem; + } + } +} diff --git a/DataAccess/DTOs/DTOEntities/NdmCrossSections/NdmElementDTO.cs b/DataAccess/DTOs/DTOEntities/NdmCrossSections/NdmElementDTO.cs index 7e6db12..f9b2170 100644 --- a/DataAccess/DTOs/DTOEntities/NdmCrossSections/NdmElementDTO.cs +++ b/DataAccess/DTOs/DTOEntities/NdmCrossSections/NdmElementDTO.cs @@ -15,7 +15,7 @@ namespace DataAccess.DTOs public bool Triangulate { get; set; } [JsonProperty("UsersPrestrain")] public IForceTuple UsersPrestrain { get; set; } = new ForceTupleDTO(Guid.NewGuid()); - [JsonProperty("AutoPrestrain")] + [JsonIgnore] public IForceTuple AutoPrestrain { get; set; } = new ForceTupleDTO(Guid.NewGuid()); public NdmElementDTO(Guid id) diff --git a/DataAccess/DTOs/DTOEntities/NdmCrossSections/ShapeNdmPrimitiveDTO.cs b/DataAccess/DTOs/DTOEntities/NdmCrossSections/ShapeNdmPrimitiveDTO.cs index 6c7c2eb..aa03473 100644 --- a/DataAccess/DTOs/DTOEntities/NdmCrossSections/ShapeNdmPrimitiveDTO.cs +++ b/DataAccess/DTOs/DTOEntities/NdmCrossSections/ShapeNdmPrimitiveDTO.cs @@ -21,7 +21,7 @@ namespace DataAccess.DTOs [JsonProperty("Name")] public string? Name { get; set; } [JsonProperty("Shape")] - public IShape Shape => shape; + public IShape Shape { get => shape; set => shape = value; } [JsonProperty("NdmElement")] public INdmElement NdmElement { get; set; } [JsonProperty("Center")] diff --git a/DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs b/DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs index 3d8255e..02f43d4 100644 --- a/DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs +++ b/DataAccess/DTOs/DTOEntities/Shapes/LinePolygonShapeDTO.cs @@ -9,10 +9,11 @@ namespace DataAccess.DTOs [JsonProperty("Id")] public Guid Id { get; } [JsonProperty("Vertices")] - public IReadOnlyList Vertices => _vertices; + public List VerticesList {get => _vertices;} [JsonProperty("IsClosed")] public bool IsClosed { get; set; } - + [JsonIgnore] + public IReadOnlyList Vertices => _vertices; public LinePolygonShapeDTO(Guid id) { diff --git a/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs index d93c2b8..0612a3a 100644 --- a/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs +++ b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs @@ -5,6 +5,7 @@ using StructureHelperCommon.Models.Analyses; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Materials.Libraries; +using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.NdmCalculations.Primitives; @@ -34,70 +35,117 @@ 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") }, { (typeof(CompressedMemberDTO), "CompressedMember") }, - { (typeof(CrackCalculatorDTO), "CrackCalculator") }, - { (typeof(CrackCalculatorInputDataDTO), "CrackCalculatorInputData") }, - { (typeof(CrossSectionDTO), "CrossSection") }, - { (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") }, - { (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") }, - { (typeof(DateVersionDTO), "DateVersion") }, - { (typeof(DesignForceTupleDTO), "DesignForceTuple") }, { (typeof(DivisionSizeDTO), "DivisionSize") }, - { (typeof(ElasticMaterialDTO), "ElasticMaterial") }, - { (typeof(EllipseNdmPrimitiveDTO), "EllipseNdmPrimitive") }, - { (typeof(FileVersionDTO), "FileVersion") }, - { (typeof(ForceCalculatorDTO), "ForceCalculator") }, - { (typeof(ForceCalculatorInputDataDTO), "ForceCalculatorInputData") }, - { (typeof(FRMaterialDTO), "FRMaterial") }, - { (typeof(HeadMaterialDTO), "HeadMaterial") }, - { (typeof(MaterialSafetyFactorDTO), "MaterialSafetyFactor") }, - { (typeof(NdmElementDTO), "NdmElement") }, - { (typeof(IVisualAnalysis), "IVisualAnalysis") }, { (typeof(List), "ListOfCalcTerms") }, { (typeof(List), "ColumnFileProperties") }, { (typeof(List), "ColumnedFileProperties") }, - { (typeof(List), "ListOfICalculator") }, - { (typeof(List), "ListOfIDateVersion") }, - { (typeof(List), "ListOfIDesignForceTuple") }, - { (typeof(List), "ListOfIForceAction") }, - { (typeof(List), "ListOfIForceTuple") }, - { (typeof(List), "ListOfIHeadMaterial") }, { (typeof(List), "ListOfLimitState") }, - { (typeof(List), "ListOfMaterialSafetyFactor") }, - { (typeof(List), "ListOfMaterialPartialFactor") }, - { (typeof(List), "ListOfINdmPrimitive") }, { (typeof(List), "ListOfPartialFactor") }, - { (typeof(List), "ListOfIVisualAnalysis") }, - { (typeof(Point2DDTO), "Point2D") }, - { (typeof(PointNdmPrimitiveDTO), "PointNdmPrimitive") }, - { (typeof(PrimitiveVisualPropertyDTO), "PrimitiveVisualProperty") }, - { (typeof(ProjectDTO), "Project") }, - { (typeof(RebarNdmPrimitiveDTO), "RebarNdmPrimitive") }, { (typeof(RebarSectionDTO), "RebarSection") }, - { (typeof(RectangleNdmPrimitiveDTO), "RectangleNdmPrimitive") }, - { (typeof(RectangleShapeDTO), "RectangleShape") }, - { (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") }, - { (typeof(RootObjectDTO), "RootObject") }, - { (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") }, - { (typeof(VersionProcessorDTO), "VersionProcessor") }, - { (typeof(VisualAnalysisDTO), "VisualAnalysis") }, { (typeof(VisualPropertyDTO), "VisualProperty") }, - { (typeof(UserCrackInputDataDTO), "UserCrackInputData") }, { (typeof(WorkPlanePropertyDTO), "WorkPlanePropertyDTO") }, }; + newList.AddRange(GetProjectList()); + newList.AddRange(GetGeometryShapeList()); newList.AddRange(GetForceList()); - newList.AddRange(GetListForBeamShear()); + newList.AddRange(GetMaterialList()); + newList.AddRange(GetCalculatorList()); + newList.AddRange(GetNdmPrimitiveList()); + newList.AddRange(GetBeamShearList()); return newList; } + private static List<(Type type, string name)> GetProjectList() + { + List<(Type type, string name)> newList = new() + { + { (typeof(List), "ListOfIVisualAnalysis") }, + { (typeof(List), "ListOfIDateVersion") }, + { (typeof(RootObjectDTO), "RootObject") }, + { (typeof(ProjectDTO), "Project") }, + { (typeof(VersionProcessorDTO), "VersionProcessor") }, + { (typeof(DateVersionDTO), "DateVersion") }, + { (typeof(IVisualAnalysis), "IVisualAnalysis") }, + { (typeof(VisualAnalysisDTO), "VisualAnalysis") }, + { (typeof(FileVersionDTO), "FileVersion") }, + + }; + return newList; + } + private static List<(Type type, string name)> GetMaterialList() + { + List<(Type type, string name)> newList = new() + { + { (typeof(List), "ListOfMaterialPartialFactor") }, + { (typeof(ConcreteLibMaterialDTO), "ConcreteLibMaterial") }, + { (typeof(ElasticMaterialDTO), "ElasticMaterial") }, + { (typeof(FRMaterialDTO), "FRMaterial") }, + { (typeof(HeadMaterialDTO), "HeadMaterial") }, + { (typeof(List), "ListOfIHeadMaterial") }, + { (typeof(MaterialSafetyFactorDTO), "MaterialSafetyFactor") }, + { (typeof(List), "ListOfMaterialSafetyFactor") }, + { (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") }, + { (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") }, + }; + return newList; + } + private static List<(Type type, string name)> GetCalculatorList() + { + List<(Type type, string name)> newList = new() + { + { (typeof(List), "ListOfICalculator") }, + { (typeof(ForceCalculatorDTO), "ForceCalculator") }, + { (typeof(ForceCalculatorInputDataDTO), "ForceCalculatorInputData") }, + { (typeof(CrackCalculatorDTO), "CrackCalculator") }, + { (typeof(CrackCalculatorInputDataDTO), "CrackCalculatorInputData") }, + { (typeof(UserCrackInputDataDTO), "UserCrackInputData") }, + + }; + return newList; + } + private static List<(Type type, string name)> GetNdmPrimitiveList() + { + List<(Type type, string name)> newList = new() + { + { (typeof(List), "ListOfINdmPrimitive") }, + { (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") }, + { (typeof(CrossSectionDTO), "CrossSection") }, + { (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") }, + { (typeof(NdmElementDTO), "NdmElement") }, + { (typeof(PointNdmPrimitiveDTO), "PointNdmPrimitive") }, + { (typeof(RebarNdmPrimitiveDTO), "RebarNdmPrimitive") }, + { (typeof(RectangleNdmPrimitiveDTO), "RectangleNdmPrimitive") }, + { (typeof(EllipseNdmPrimitiveDTO), "EllipseNdmPrimitive") }, + { (typeof(ShapeNdmPrimitiveDTO), "ShapeNdmPrimitive") }, + { (typeof(PrimitiveVisualPropertyDTO), "PrimitiveVisualProperty") }, + + }; + return newList; + } + private static List<(Type type, string name)> GetGeometryShapeList() + { + List<(Type type, string name)> newList = new() + { + { (typeof(List), "ListOfVertex2D") }, + { (typeof(Point2DDTO), "Point2D") }, + { (typeof(VertexDTO), "Vertex2D") }, + { (typeof(RectangleShapeDTO), "RectangleShape") }, + { (typeof(CircleShapeDTO), "CircleShape") }, + { (typeof(LinePolygonShapeDTO), "LinePolygonShape") }, + }; + return newList; + } private static List<(Type type, string name)> GetForceList() { List<(Type type, string name)> newList = new() { + { (typeof(List), "ListOfIForceAction") }, + { (typeof(List), "ListOfIDesignForceTuple") }, + { (typeof(List), "ListOfIForceTuple") }, + { (typeof(DesignForceTupleDTO), "DesignForceTuple") }, { (typeof(ConcentratedForceDTO), "ConcentratedForce") }, { (typeof(DistributedLoadDTO), "DistributedLoad") }, { (typeof(FactoredForceTupleDTO), "FactoredForceTuple") }, @@ -110,8 +158,7 @@ namespace DataAccess.DTOs }; return newList; } - - private static List<(Type type, string name)> GetListForBeamShear() + private static List<(Type type, string name)> GetBeamShearList() { List<(Type type, string name)> newList = new() { diff --git a/FieldVisualizer/Entities/Values/Primitives/ITrianglePrimitive.cs b/FieldVisualizer/Entities/Values/Primitives/ITrianglePrimitive.cs new file mode 100644 index 0000000..f800c68 --- /dev/null +++ b/FieldVisualizer/Entities/Values/Primitives/ITrianglePrimitive.cs @@ -0,0 +1,16 @@ +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FieldVisualizer.Entities.Values.Primitives +{ + public interface ITrianglePrimitive : IValuePrimitive + { + IPoint2D Point1 { get; set; } + IPoint2D Point2 { get; set; } + IPoint2D Point3 { get; set; } + } +} diff --git a/FieldVisualizer/Entities/Values/Primitives/TrianglePrimitive.cs b/FieldVisualizer/Entities/Values/Primitives/TrianglePrimitive.cs new file mode 100644 index 0000000..c377fe0 --- /dev/null +++ b/FieldVisualizer/Entities/Values/Primitives/TrianglePrimitive.cs @@ -0,0 +1,31 @@ +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FieldVisualizer.Entities.Values.Primitives +{ + public class TrianglePrimitive : ITrianglePrimitive + { + public double Value { get; set; } + + public IPoint2D Point1 { get; set; } + public IPoint2D Point2 { get; set; } + public IPoint2D Point3 { get; set; } + + // --- Computed properties --- + + // Centroid (geometric center) + public double CenterX => (Point1.X + Point2.X + Point3.X) / 3.0; + public double CenterY => (Point1.Y + Point2.Y + Point3.Y) / 3.0; + + // Triangle area using determinant formula + public double Area => + 0.5 * Math.Abs( + (Point2.X - Point1.X) * (Point3.Y - Point1.Y) - + (Point3.X - Point1.X) * (Point2.Y - Point1.Y) + ); + } +} diff --git a/FieldVisualizer/Services/PrimitiveServices/PrimitiveOperations.cs b/FieldVisualizer/Services/PrimitiveServices/PrimitiveOperations.cs index c043a8c..cb1913a 100644 --- a/FieldVisualizer/Services/PrimitiveServices/PrimitiveOperations.cs +++ b/FieldVisualizer/Services/PrimitiveServices/PrimitiveOperations.cs @@ -53,19 +53,23 @@ namespace FieldVisualizer.Services.PrimitiveServices List coords = new List(); foreach (var primitive in valuePrimitives) { - if (primitive is IRectanglePrimitive) + if (primitive is IRectanglePrimitive rectanglePrimitive) { - IRectanglePrimitive rectanglePrimitive = primitive as IRectanglePrimitive; coords.Add(rectanglePrimitive.CenterX + rectanglePrimitive.Width / 2); coords.Add(rectanglePrimitive.CenterX - rectanglePrimitive.Width / 2); } - else if (primitive is ICirclePrimitive) + else if (primitive is ICirclePrimitive circlePrimitive) { - ICirclePrimitive circlePrimitive = primitive as ICirclePrimitive; coords.Add(circlePrimitive.CenterX + circlePrimitive.Diameter / 2); coords.Add(circlePrimitive.CenterX - circlePrimitive.Diameter / 2); } - else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown);} + else if (primitive is ITrianglePrimitive triangle) + { + coords.Add(triangle.Point1.X); + coords.Add(triangle.Point2.X); + coords.Add(triangle.Point3.X); + } + else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown); } } return coords; } @@ -87,6 +91,12 @@ namespace FieldVisualizer.Services.PrimitiveServices coords.Add(circlePrimitive.CenterY + circlePrimitive.Diameter / 2); coords.Add(circlePrimitive.CenterY - circlePrimitive.Diameter / 2); } + else if (primitive is ITrianglePrimitive triangle) + { + coords.Add(triangle.Point1.Y); + coords.Add(triangle.Point2.Y); + coords.Add(triangle.Point3.Y); + } else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown); } } return coords; diff --git a/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs b/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs index ca3b3a0..10c1708 100644 --- a/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs +++ b/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs @@ -14,7 +14,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Windows; using System.Windows.Controls; +using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Shapes; @@ -50,20 +52,20 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels set { primitiveSet = value; - OnPropertyChanged(nameof(PrimitiveSet)); AreaTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Area); - OnPropertyChanged(nameof(AreaTotal)); AreaNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0d).Sum(x => x.Area); - OnPropertyChanged(nameof(AreaNeg)); AreaZero = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value == 0d).Sum(x => x.Area); - OnPropertyChanged(nameof(AreaZero)); AreaPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0d).Sum(x => x.Area); - OnPropertyChanged(nameof(AreaPos)); SumTotal = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Sum(x => x.Value); - OnPropertyChanged(nameof(SumTotal)); SumNeg = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value < 0d).Sum(x => x.Value); - OnPropertyChanged(nameof(SumNeg)); SumPos = primitiveSet is null ? 0 : primitiveSet.ValuePrimitives.Where(x => x.Value > 0d).Sum(x => x.Value); + OnPropertyChanged(nameof(PrimitiveSet)); + OnPropertyChanged(nameof(AreaTotal)); + OnPropertyChanged(nameof(AreaNeg)); + OnPropertyChanged(nameof(AreaZero)); + OnPropertyChanged(nameof(AreaPos)); + OnPropertyChanged(nameof(SumTotal)); + OnPropertyChanged(nameof(SumNeg)); OnPropertyChanged(nameof(SumPos)); } @@ -215,21 +217,56 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels WorkPlaneBox.Height = ScrolHeight - 50; foreach (var primitive in PrimitiveSet.ValuePrimitives) { - if (primitive is IRectanglePrimitive) + if (primitive is IRectanglePrimitive rectanglePrimitive) { - IRectanglePrimitive rectanglePrimitive = primitive as IRectanglePrimitive; Rectangle rectangle = ProcessRectanglePrimitive(rectanglePrimitive); WorkPlaneCanvas.Children.Add(rectangle); } - else if (primitive is ICirclePrimitive) + else if (primitive is ICirclePrimitive circlePrimitive) { - ICirclePrimitive circlePrimitive = primitive as ICirclePrimitive; Ellipse ellipse = ProcessCirclePrimitive(circlePrimitive); WorkPlaneCanvas.Children.Add(ellipse); } + else if (primitive is ITrianglePrimitive triangle) + { + Path path = ProcessTrianglePrimitive(triangle); + WorkPlaneCanvas.Children.Add(path); + } else { throw new FieldVisulizerException(ErrorStrings.PrimitiveTypeIsUnknown); } } } + + private Path ProcessTrianglePrimitive(ITrianglePrimitive triangle) + { + // Create the PathFigure using triangle vertices. + var figure = new PathFigure + { + StartPoint = new Point(triangle.Point1.X, triangle.Point1.Y), + IsClosed = true, + IsFilled = true + }; + + // Add the remaining vertices as LineSegments + var segments = new PathSegmentCollection + { + new LineSegment(new Point(triangle.Point2.X, triangle.Point2.Y), true), + new LineSegment(new Point(triangle.Point3.X, triangle.Point3.Y), true) + // Closing is handled by IsClosed = true, so we don't need to add a segment back to Point1 + }; + figure.Segments = segments; + + // Create geometry and path + var geometry = new PathGeometry(); + geometry.Figures.Add(figure); + + var path = new Path + { + Data = geometry, + }; + ProcessShape(path, triangle, 0, 0, false); + return path; + } + private Rectangle ProcessRectanglePrimitive(IRectanglePrimitive rectanglePrimitive) { Rectangle rectangle = new Rectangle @@ -239,7 +276,7 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels }; double addX = rectanglePrimitive.Width / 2; double addY = rectanglePrimitive.Height / 2; - ProcessShape(rectangle, rectanglePrimitive, addX, addY); + ProcessShape(rectangle, rectanglePrimitive, addX, addY, true); return rectangle; } private Ellipse ProcessCirclePrimitive(ICirclePrimitive circlePrimitive) @@ -252,10 +289,10 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels double addX = circlePrimitive.Diameter / 2; double addY = circlePrimitive.Diameter / 2; - ProcessShape(ellipse, circlePrimitive, addX, addY); + ProcessShape(ellipse, circlePrimitive, addX, addY, true); return ellipse; } - private void ProcessShape(Shape shape, IValuePrimitive valuePrimitive, double addX, double addY) + private void ProcessShape(Shape shape, IValuePrimitive valuePrimitive, double addX, double addY, bool addCenter) { SolidColorBrush brush = new SolidColorBrush(); brush.Color = ColorOperations.GetColorByValue(valueRange, _ColorMap, valuePrimitive.Value); @@ -269,8 +306,15 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels shape.ToolTip = roundLogic.RoundValue(valuePrimitive.Value); shape.Tag = valuePrimitive; shape.Fill = brush; - Canvas.SetLeft(shape, valuePrimitive.CenterX - addX - dX); - Canvas.SetTop(shape, -valuePrimitive.CenterY - addY + dY); + double addLeft = - addX - dX; + double addTop = - addY + dY; + if (addCenter == true) + { + addLeft += valuePrimitive.CenterX; + addTop -= valuePrimitive.CenterY; + } + Canvas.SetLeft(shape, addLeft); + Canvas.SetTop(shape, addTop); } private void Zoom(double coefficient) { diff --git a/StructureHelper/Libraries/LoaderCalculator.dll b/StructureHelper/Libraries/LoaderCalculator.dll index ac7544e..1534490 100644 Binary files a/StructureHelper/Libraries/LoaderCalculator.dll and b/StructureHelper/Libraries/LoaderCalculator.dll differ diff --git a/StructureHelper/Libraries/Triangle.dll b/StructureHelper/Libraries/Triangle.dll new file mode 100644 index 0000000..4b74baf Binary files /dev/null and b/StructureHelper/Libraries/Triangle.dll differ diff --git a/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs b/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs index fd225e0..402157a 100644 --- a/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs +++ b/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs @@ -5,6 +5,7 @@ using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.ResultData; using LoaderCalculator.Logics; using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services; using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Triangulations; @@ -85,6 +86,10 @@ namespace StructureHelper.Services.ResultViewers { valuePrimitive = ProcessRectangle(shapeNdm, val); } + else if (ndm is ITriangleNdm triangle) + { + valuePrimitive = ProcessTriangle(triangle, val); + } else { valuePrimitive = ProcessCircle(ndm, val); @@ -92,6 +97,18 @@ namespace StructureHelper.Services.ResultViewers return valuePrimitive; } + private static IValuePrimitive ProcessTriangle(ITriangleNdm triangle, double val) + { + var primitive = new TrianglePrimitive() + { + Point1 = new Point2D() { X = triangle.Point1.X, Y = triangle.Point1.Y }, + Point2 = new Point2D() { X = triangle.Point2.X, Y = triangle.Point2.Y }, + Point3 = new Point2D() { X = triangle.Point3.X, Y = triangle.Point3.Y }, + Value = val + }; + return primitive; + } + private static IValuePrimitive ProcessRectangle(IRectangleNdm shapeNdm, double val) { return new RectanglePrimitive() diff --git a/StructureHelperCommon/Models/Shapes/Logics/PolygonGeometryUtils.cs b/StructureHelperCommon/Models/Shapes/Logics/PolygonGeometryUtils.cs index c88f7ab..7cbf59c 100644 --- a/StructureHelperCommon/Models/Shapes/Logics/PolygonGeometryUtils.cs +++ b/StructureHelperCommon/Models/Shapes/Logics/PolygonGeometryUtils.cs @@ -9,7 +9,7 @@ namespace StructureHelperCommon.Models.Shapes { public static class PolygonGeometryUtils { - public static ILinePolygonShape GetTratsfromedPolygon(ILinePolygonShape polygon, double dx, double dy) + public static ILinePolygonShape GetTransfromedPolygon(ILinePolygonShape polygon, double dx, double dy) { ILinePolygonShape newPolygon = new LinePolygonShape(Guid.Empty); var updateLogic = new LinePolygonShapeUpdateStrategy(); diff --git a/StructureHelperCommon/StructureHelperCommon.csproj b/StructureHelperCommon/StructureHelperCommon.csproj index 7ea0afb..f8c9854 100644 --- a/StructureHelperCommon/StructureHelperCommon.csproj +++ b/StructureHelperCommon/StructureHelperCommon.csproj @@ -11,7 +11,7 @@ - + diff --git a/StructureHelperLogics/NdmCalculations/Primitives/EllipseNdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/EllipseNdmPrimitive.cs index 4309574..2570944 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/EllipseNdmPrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/EllipseNdmPrimitive.cs @@ -67,7 +67,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives var ndms = new List(); var options = new CircleTriangulationLogicOptions(this) { - triangulationOptions = triangulationOptions + TriangulationOptions = triangulationOptions }; var logic = new CircleTriangulationLogic(options); ndms.AddRange(logic.GetNdmCollection()); diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/EllipsePrimitiveUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/EllipsePrimitiveUpdateStrategy.cs index 5f4092a..e9ae41c 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/Logics/EllipsePrimitiveUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/EllipsePrimitiveUpdateStrategy.cs @@ -1,6 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Shapes; -using StructureHelperCommon.Models.Shapes.Logics; using StructureHelperCommon.Services; namespace StructureHelperLogics.NdmCalculations.Primitives diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmElementUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmElementUpdateStrategy.cs index 49739c8..c14e6a8 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmElementUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/NdmElementUpdateStrategy.cs @@ -28,6 +28,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.Triangulate = sourceObject.Triangulate; tupleUpdateStrategy.Update(targetObject.UsersPrestrain, sourceObject.UsersPrestrain); + tupleUpdateStrategy.Update(targetObject.AutoPrestrain, sourceObject.AutoPrestrain); if (UpdateChildren == true) { if (sourceObject.HeadMaterial != null) diff --git a/StructureHelperLogics/NdmCalculations/Primitives/PointNdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/PointNdmPrimitive.cs index dbb6370..715dcf8 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/PointNdmPrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/PointNdmPrimitive.cs @@ -46,7 +46,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives public IEnumerable GetNdms(ITriangulationOptions triangulationOptions) { - var options = new PointTriangulationLogicOptions(this) { triangulationOptions = triangulationOptions}; + var options = new PointTriangulationLogicOptions(this) { TriangulationOptions = triangulationOptions}; var logic = new PointTriangulationLogic(options); return logic.GetNdmCollection(); } diff --git a/StructureHelperLogics/NdmCalculations/Primitives/RebarNdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/RebarNdmPrimitive.cs index 4b6fc31..a21d71e 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/RebarNdmPrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/RebarNdmPrimitive.cs @@ -78,7 +78,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives { var options = new RebarTriangulationLogicOptions(this) { - triangulationOptions = triangulationOptions + TriangulationOptions = triangulationOptions }; var logic = new RebarTriangulationLogic(options); var rebar = logic.GetRebarNdm(); @@ -89,7 +89,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives { var options = new RebarTriangulationLogicOptions(this) { - triangulationOptions = triangulationOptions + TriangulationOptions = triangulationOptions }; var logic = new RebarTriangulationLogic(options); var concrete = logic.GetConcreteNdm(); diff --git a/StructureHelperLogics/NdmCalculations/Primitives/RectangleNdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/RectangleNdmPrimitive.cs index b20fd89..269dec3 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/RectangleNdmPrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/RectangleNdmPrimitive.cs @@ -53,7 +53,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives var ndms = new List(); var options = new RectangleTriangulationLogicOptions(this) { - triangulationOptions = triangulationOptions + TriangulationOptions = triangulationOptions }; var logic = new RectangleTriangulationLogic(options); ndms.AddRange(logic.GetNdmCollection()); diff --git a/StructureHelperLogics/NdmCalculations/Primitives/ShapeNdmPrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/ShapeNdmPrimitive.cs index 54f755d..84aa9ea 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/ShapeNdmPrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/ShapeNdmPrimitive.cs @@ -16,11 +16,11 @@ namespace StructureHelperLogics.NdmCalculations.Primitives public string? Name { get; set; } = string.Empty; public IPoint2D Center { get; set; } = new Point2D(); public IShape Shape => shape; - public INdmElement NdmElement { get; } = new NdmElement(Guid.NewGuid()); + public INdmElement NdmElement { get; set; } = new NdmElement(Guid.NewGuid()); public ICrossSection? CrossSection { get; set; } - public IVisualProperty VisualProperty { get; } = new VisualProperty { Opacity = 0.8d }; + public IVisualProperty VisualProperty { get; set; } = new VisualProperty { Opacity = 0.8d }; public double RotationAngle { get; set; } - public IDivisionSize DivisionSize { get; } = new DivisionSize(Guid.NewGuid()); + public IDivisionSize DivisionSize { get; set; } = new DivisionSize(Guid.NewGuid()); public ShapeNdmPrimitive(Guid id) { Id = id; @@ -38,7 +38,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives public IEnumerable GetNdms(ITriangulationOptions triangulationOptions) { - throw new NotImplementedException(); + var triangulationLogicOption = new LinePolygonTriangulationLogicOption(this, triangulationOptions); + var logic = new LinePolygonTriangulationLogic(triangulationLogicOption); + return logic.GetNdmCollection(); } public List GetValuePoints() @@ -74,7 +76,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives { if (shape is ILinePolygonShape polygon) { - var newShape = PolygonGeometryUtils.GetTratsfromedPolygon(polygon, Center.X, Center.Y); + var newShape = PolygonGeometryUtils.GetTransfromedPolygon(polygon, Center.X, Center.Y); var calculator = new PolygonCalculator(); return calculator.ContainsPoint(newShape, point); } diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogic.cs index 3f71f5a..d6d1355 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogic.cs @@ -23,13 +23,13 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations { double diameter = options.Circle.Diameter; - double ndmMaxSize = options.NdmMaxSize; - int ndmMinDivision = options.NdmMinDivision; + double ndmMaxSize = options.DivisionSize.NdmMaxSize; + int ndmMinDivision = options.DivisionSize.NdmMinDivision; var logicOptions = new LoaderCalculator.Triangulations.CircleTriangulationLogicOptions(diameter, ndmMaxSize, ndmMinDivision); var logic = LoaderCalculator.Triangulations.Triangulation.GetLogicInstance(logicOptions); var ndmCollection = logic.GetNdmCollection(new LoaderCalculator.Data.Planes.CirclePlane { - Material = options.HeadMaterial.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm) + Material = options.HeadMaterial.GetLoaderMaterial(options.TriangulationOptions.LimiteState, options.TriangulationOptions.CalcTerm) }); TriangulationService.CommonTransform(ndmCollection, options); TriangulationService.SetPrestrain(ndmCollection, options.Prestrain); diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogicOptions.cs index 1e83906..985450d 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogicOptions.cs @@ -18,22 +18,19 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations public IPoint2D Center { get; set; } - public double NdmMaxSize { get; } - - public int NdmMinDivision { get; } - public StrainTuple Prestrain { get; set; } - public ITriangulationOptions triangulationOptions { get; set; } + public ITriangulationOptions TriangulationOptions { get; set; } public IHeadMaterial HeadMaterial { get; set; } public double RotationAngle { get; set; } + public IDivisionSize DivisionSize { get; } + public CircleTriangulationLogicOptions(IEllipseNdmPrimitive primitive) { Center = primitive.Center.Clone() as Point2D; //to do change to ellipse Circle = new CircleShape() { Diameter = primitive.Width }; - NdmMaxSize = primitive.DivisionSize.NdmMaxSize; - NdmMinDivision = primitive.DivisionSize.NdmMinDivision; + DivisionSize = primitive.DivisionSize; HeadMaterial = primitive.NdmElement.HeadMaterial; Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple; } diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/IShapeTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/IShapeTriangulationLogicOptions.cs index 4d200f4..cf0b4b5 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/IShapeTriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/IShapeTriangulationLogicOptions.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Collections.Generic; using System.Linq; @@ -11,16 +12,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations public interface IShapeTriangulationLogicOptions : ITriangulationLogicOptions, IHasCenter2D { /// - /// Center of shape + /// Parameters of division /// - IPoint2D Center { get; } - /// - /// Maximum size (width or height) of ndm part after triangulation - /// - double NdmMaxSize { get; } - /// - /// Minimum quantity of division of side of rectangle after triangulation - /// - int NdmMinDivision { get; } + IDivisionSize DivisionSize { get; } } } diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/ITriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/ITriangulationLogic.cs index 4f0639b..b1f234e 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/ITriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/ITriangulationLogic.cs @@ -1,12 +1,21 @@ -using System.Collections.Generic; -using LoaderCalculator.Data.Ndms; -using LoaderCalculator.Data.Materials; +using LoaderCalculator.Data.Ndms; namespace StructureHelperLogics.NdmCalculations.Triangulations { + /// + /// Implements logic of obtaining of collection of ndm parts + /// public interface ITriangulationLogic { + /// + /// Returns collection of ndm parts + /// + /// IEnumerable GetNdmCollection(); + /// + /// Check options of triangulation + /// + /// void ValidateOptions(ITriangulationLogicOptions options); } } diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/ITriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/ITriangulationLogicOptions.cs index 329d1fd..5388ff3 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/ITriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/ITriangulationLogicOptions.cs @@ -6,7 +6,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations { public interface ITriangulationLogicOptions { - ITriangulationOptions triangulationOptions { get; set; } + ITriangulationOptions TriangulationOptions { get; set; } StrainTuple Prestrain { get; set; } IHeadMaterial HeadMaterial { get; set; } } diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/LinePolygonTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/LinePolygonTriangulationLogic.cs new file mode 100644 index 0000000..f9e9c8d --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Triangulations/LinePolygonTriangulationLogic.cs @@ -0,0 +1,85 @@ +using LoaderCalculator.Data.Materials; +using LoaderCalculator.Data.Ndms; +using LoaderCalculator.Infrastructure.Geometry; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Shapes; +using TriangleNet.Geometry; +using TriangleNet.Meshing; +using static System.Windows.Forms.Design.AxImporter; + +namespace StructureHelperLogics.NdmCalculations.Triangulations +{ + /// + /// Logic for triangulation of line poligon shapr into collection of ndm parts + /// + public class LinePolygonTriangulationLogic : ITriangulationLogic + { + private LinePolygonTriangulationLogicOption options; + + public LinePolygonTriangulationLogic(LinePolygonTriangulationLogicOption triangulationLogicOption) + { + this.options = triangulationLogicOption; + } + + /// + public IEnumerable GetNdmCollection() + { + IMesh mesh = GetMesh(); + var material = options.HeadMaterial.GetLoaderMaterial(options.TriangulationOptions.LimiteState, options.TriangulationOptions.CalcTerm); + List ndms = GetNdmsByMesh(mesh, material); + return ndms; + } + + private List GetNdmsByMesh(IMesh mesh, IMaterial material) + { + List ndmCollection = []; + foreach (var triangle in mesh.Triangles) + { + List points = []; + for (int i = 0; i < 3; i++) + { + var vertex1 = triangle.GetVertex(i); + points.Add(new PointLd2D() { X = vertex1.X, Y = vertex1.Y }); + + } + var ndm = new TriangleNdm() { Point1 = points[0], Point2 = points[1], Point3 = points[2] }; + ndm.Material = material; + var ndm2 = new RectangleNdm() { Width = Math.Sqrt(ndm.Area), Height = Math.Sqrt(ndm.Area), CenterX = ndm.CenterX, CenterY = ndm.CenterY, Material = ndm.Material}; + ndmCollection.Add(ndm); + } + TriangulationService.SetPrestrain(ndmCollection, options.Prestrain); + return ndmCollection; + } + + private IMesh GetMesh() + { + if (options.Shape is not ILinePolygonShape polygonShape) + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(options.Shape) + ": Shape is not line polygon shape"); + } + var polygon = new Polygon(); + List vertices = polygonShape.Vertices.ToList(); + var contour = new List(); + foreach (var vertex in vertices) + { + contour.Add(new TriangleNet.Geometry.Vertex(vertex.Point.X, vertex.Point.Y)); + + } + // Add contour to polygon — this automatically defines the connecting segments + polygon.Add(new Contour(contour)); + var quality = new QualityOptions() + { + MinimumAngle = 25.0, + MaximumArea = options.DivisionSize.NdmMaxSize * options.DivisionSize.NdmMaxSize, + }; + var mesh = polygon.Triangulate(quality); + return mesh; + } + + /// + public void ValidateOptions(ITriangulationLogicOptions options) + { + throw new NotImplementedException(); + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/LinePolygonTriangulationLogicOption.cs b/StructureHelperLogics/NdmCalculations/Triangulations/LinePolygonTriangulationLogicOption.cs new file mode 100644 index 0000000..f19898c --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Triangulations/LinePolygonTriangulationLogicOption.cs @@ -0,0 +1,35 @@ +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Services.Forces; +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.NdmCalculations.Triangulations +{ + public class LinePolygonTriangulationLogicOption : IShapeTriangulationLogicOptions + { + public IPoint2D Center { get; set; } + public IDivisionSize DivisionSize { get; set; } + public ITriangulationOptions TriangulationOptions { get; set; } + public StrainTuple Prestrain { get; set; } + public IHeadMaterial HeadMaterial { get; set; } + public double RotationAngle { get; set; } = 0; + public IShape Shape { get; set; } + public LinePolygonTriangulationLogicOption(IShapeNdmPrimitive primitive, ITriangulationOptions triangulationOptions) + { + Center = primitive.Center; + DivisionSize = primitive.DivisionSize; + TriangulationOptions = triangulationOptions; + Shape = primitive.Shape; + HeadMaterial = primitive.NdmElement.HeadMaterial; + Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple; + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogic.cs index 49a3fc5..5d55567 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogic.cs @@ -22,7 +22,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations CenterX = options.Center.X, CenterY = options.Center.Y, Area = options.Area, - Material = options.HeadMaterial.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm) + Material = options.HeadMaterial.GetLoaderMaterial(options.TriangulationOptions.LimiteState, options.TriangulationOptions.CalcTerm) }; List ndmCollection = new () { ndm}; NdmTransform.SetPrestrain(ndmCollection, TupleConverter.ConvertToLoaderStrainMatrix(options.Prestrain)); diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs index 26805d1..d6a5bad 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogicOptions.cs @@ -12,7 +12,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations /// public class PointTriangulationLogicOptions : ITriangulationLogicOptions { - public ITriangulationOptions triangulationOptions { get; set; } + public ITriangulationOptions TriangulationOptions { get; set; } /// /// /// diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogic.cs index 4ad29ba..a4ce3d7 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogic.cs @@ -44,7 +44,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations CenterX = options.Center.X, CenterY = options.Center.Y, Area = options.Area, - Material = options.HeadMaterial.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm) + Material = options.HeadMaterial.GetLoaderMaterial(options.TriangulationOptions.LimiteState, options.TriangulationOptions.CalcTerm) }; ; NdmTransform.SetPrestrain(rebarNdm, TupleConverter.ConvertToLoaderStrainMatrix(options.Prestrain)); @@ -58,7 +58,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations var material = hostPrimitive .NdmElement .HeadMaterial - .GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm); + .GetLoaderMaterial(options.TriangulationOptions.LimiteState, options.TriangulationOptions.CalcTerm); var prestrain = ForceTupleService.SumTuples(hostPrimitive.NdmElement.UsersPrestrain, hostPrimitive.NdmElement.AutoPrestrain) diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogicOptions.cs index 5d5fff9..d3e5351 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogicOptions.cs @@ -13,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations { public class RebarTriangulationLogicOptions : ITriangulationLogicOptions { - public ITriangulationOptions triangulationOptions { get; set; } + public ITriangulationOptions TriangulationOptions { get; set; } /// /// /// diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs index 5aed9f5..2b739db 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs @@ -16,13 +16,13 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations { double width = options.Rectangle.Width; double height = options.Rectangle.Height; - double ndmMaxSize = options.NdmMaxSize; - int ndmMinDivision = options.NdmMinDivision; + double ndmMaxSize = options.DivisionSize.NdmMaxSize; + int ndmMinDivision = options.DivisionSize.NdmMinDivision; LoaderCalculator.Triangulations.RectangleTriangulationLogicOptions logicOptions = new LoaderCalculator.Triangulations.RectangleTriangulationLogicOptions(width, height, ndmMaxSize, ndmMinDivision); var logic = LoaderCalculator.Triangulations.Triangulation.GetLogicInstance(logicOptions); var ndmCollection = logic.GetNdmCollection(new LoaderCalculator.Data.Planes.RectangularPlane { - Material = options.HeadMaterial.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm) + Material = options.HeadMaterial.GetLoaderMaterial(options.TriangulationOptions.LimiteState, options.TriangulationOptions.CalcTerm) }); TriangulationService.CommonTransform(ndmCollection, options); double angle = options.RotationAngle; diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs index 54db198..eda2a3a 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogicOptions.cs @@ -16,21 +16,20 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations public double RotationAngle { get; set; } = 0d; /// public IRectangleShape Rectangle { get; } - /// - public double NdmMaxSize { get; } - /// - public int NdmMinDivision { get; } + /// public StrainTuple Prestrain { get; set; } - public ITriangulationOptions triangulationOptions { get; set; } + public ITriangulationOptions TriangulationOptions { get; set; } public IHeadMaterial HeadMaterial { get; set; } + public IDivisionSize DivisionSize { get; } = new DivisionSize(Guid.Empty); + public RectangleTriangulationLogicOptions(IPoint2D center, IRectangleShape rectangle, double ndmMaxSize, int ndmMinDivision) { Center = center; Rectangle = rectangle; - NdmMaxSize = ndmMaxSize; - NdmMinDivision = ndmMinDivision; + DivisionSize.NdmMaxSize = ndmMaxSize; + DivisionSize.NdmMinDivision = ndmMinDivision; Prestrain = new StrainTuple(); } @@ -39,8 +38,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations Center = new Point2D() {X = primitive.Center.X, Y = primitive.Center.Y }; RotationAngle = primitive.RotationAngle; Rectangle = primitive; - NdmMaxSize = primitive.DivisionSize.NdmMaxSize; - NdmMinDivision = primitive.DivisionSize.NdmMinDivision; + DivisionSize.NdmMaxSize = primitive.DivisionSize.NdmMaxSize; + DivisionSize.NdmMinDivision = primitive.DivisionSize.NdmMinDivision; HeadMaterial = primitive.NdmElement.HeadMaterial; Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple; } diff --git a/StructureHelperLogics/StructureHelperLogics.csproj b/StructureHelperLogics/StructureHelperLogics.csproj index cfe1fd5..3517da1 100644 --- a/StructureHelperLogics/StructureHelperLogics.csproj +++ b/StructureHelperLogics/StructureHelperLogics.csproj @@ -14,6 +14,9 @@ ..\StructureHelper\Libraries\LoaderCalculator.dll + + ..\StructureHelper\Libraries\Triangle.dll + diff --git a/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs b/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs index d366ccf..902a7e4 100644 --- a/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs +++ b/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs @@ -44,7 +44,7 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations IRectangleShape rectangle = new RectangleShape { Width = width, Height = height}; var options = new RectangleTriangulationLogicOptions(center, rectangle, ndmMaxSize, ndmMinDivision) { - triangulationOptions = new TriangulationOptions() { LimiteState = LimitStates.ULS, CalcTerm = CalcTerms.ShortTerm }, + TriangulationOptions = new TriangulationOptions() { LimiteState = LimitStates.ULS, CalcTerm = CalcTerms.ShortTerm }, HeadMaterial = materialMock.Object, RotationAngle = angle };