Add VisualAnalysisDTO

This commit is contained in:
Evgeny Redikultsev
2024-09-14 19:03:35 +05:00
parent 5a9e7c3c4f
commit c10d6eb94e
84 changed files with 958 additions and 410 deletions

View File

@@ -1,15 +1,12 @@
using StructureHelperCommon.Models.Analyses;
using StructureHelperLogics.Models.Analyses;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogic.Models.Analyses
{
public class CrossSectionNdmAnalysis : IAnalysis
{
private CrossSectionNdmAnalysisUpdateStrategy updateStrategy = new();
public Guid Id { get; private set; }
public string Name { get; set; }
public string Tags { get; set; }
@@ -21,7 +18,7 @@ namespace StructureHelperLogic.Models.Analyses
VersionProcessor = versionProcessor;
}
public CrossSectionNdmAnalysis() : this(new Guid(), new VersionProcessor())
public CrossSectionNdmAnalysis() : this(Guid.NewGuid(), new VersionProcessor())
{
CrossSection crossSection = new CrossSection();
VersionProcessor.AddVersion(crossSection);
@@ -29,7 +26,9 @@ namespace StructureHelperLogic.Models.Analyses
public object Clone()
{
throw new NotImplementedException();
CrossSectionNdmAnalysis newAnalysis = new();
updateStrategy.Update(newAnalysis, this);
return newAnalysis;
}
}
}

View File

@@ -0,0 +1,68 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Services;
using StructureHelperLogic.Models.Analyses;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Analyses
{
public class CrossSectionNdmAnalysisUpdateStrategy : IUpdateStrategy<CrossSectionNdmAnalysis>
{
private IUpdateStrategy<IAnalysis> analysisUpdateStrategy;
private IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy;
private IUpdateStrategy<IDateVersion> dateUpdateStrategy;
public CrossSectionNdmAnalysisUpdateStrategy(IUpdateStrategy<IAnalysis> analysisUpdateStrategy,
IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy,
IUpdateStrategy<IDateVersion> dateUpdateStrategy)
{
this.analysisUpdateStrategy = analysisUpdateStrategy;
this.crossSectionUpdateStrategy = crossSectionUpdateStrategy;
this.dateUpdateStrategy = dateUpdateStrategy;
}
public CrossSectionNdmAnalysisUpdateStrategy() : this(
new AnalysisUpdateStrategy(),
new CrossSectionUpdateStrategy(),
new DateVersionUpdateStrategy())
{
}
public void Update(CrossSectionNdmAnalysis targetObject, CrossSectionNdmAnalysis sourceObject)
{
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; };
analysisUpdateStrategy.Update(targetObject, sourceObject);
targetObject.VersionProcessor.Versions.Clear();
foreach (var version in sourceObject.VersionProcessor.Versions)
{
if (version.Item is ICrossSection crossSection)
{
updateVersion(targetObject, version, crossSection);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version.Item));
}
}
}
private void updateVersion(CrossSectionNdmAnalysis targetObject, IDateVersion version, ICrossSection crossSection)
{
DateVersion newVersion = new();
dateUpdateStrategy.Update(newVersion, version);
CrossSection newCrossection = new();
crossSectionUpdateStrategy.Update(newCrossection, crossSection);
newVersion.Item = newCrossection;
targetObject.VersionProcessor.Versions.Add(newVersion);
}
}
}

View File

@@ -13,7 +13,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
public class CircleGeometryLogic : IRCGeometryLogic
{
ICircleTemplate template;
CirclePrimitive concreteBlock;
EllipsePrimitive concreteBlock;
public IEnumerable<IHeadMaterial> HeadMaterials { get; set; }
@@ -35,7 +35,8 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
var diameter = template.Shape.Diameter;
var concreteMaterial = HeadMaterials.ToList()[0];
var primitives = new List<INdmPrimitive>();
concreteBlock = new CirclePrimitive() { Diameter = diameter, Name = "Concrete block", HeadMaterial = concreteMaterial };
concreteBlock = new EllipsePrimitive() { DiameterByX = diameter, Name = "Concrete block"};
concreteBlock.NdmElement.HeadMaterial = concreteMaterial;
primitives.Add(concreteBlock);
return primitives;
}
@@ -56,11 +57,11 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{
Area = barArea,
Name = "Left bottom point",
HeadMaterial = reinforcementMaterial,
HostPrimitive=concreteBlock };
point.Center.X = x;
point.Center.Y = y;
primitives.Add(point);
point.NdmElement.HeadMaterial = reinforcementMaterial;
}
return primitives;
}

View File

@@ -48,7 +48,8 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
private IEnumerable<INdmPrimitive> GetConcretePrimitives()
{
var primitives = new List<INdmPrimitive>();
concreteBlock = new RectanglePrimitive(concrete) { Width = width, Height = height, Name = "Concrete block" };
concreteBlock = new RectanglePrimitive() { Width = width, Height = height, Name = "Concrete block" };
concreteBlock.NdmElement.HeadMaterial = concrete;
primitives.Add(concreteBlock);
return primitives;
}
@@ -63,9 +64,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{
Area = area1,
Name = "Left bottom rebar",
HeadMaterial = reinforcement,
HostPrimitive=concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0];
point.Center.Y = ys[0];
primitives.Add(point);
@@ -73,9 +75,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{
Area = area1,
Name = "Right bottom rebar",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[1];
point.Center.Y = ys[0];
primitives.Add(point);
@@ -83,9 +85,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{
Area = area2,
Name = "Left top rebar",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0];
point.Center.Y = ys[1];
primitives.Add(point);
@@ -93,9 +95,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{
Area = area2,
Name = "Right top rebar",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[1];
point.Center.Y = ys[1];
primitives.Add(point);
@@ -115,11 +117,23 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
double dist = (xs[1] - xs[0]) / count;
for (int i = 1; i < count; i++)
{
point = new RebarPrimitive() { Area = area1, Name = $"Bottom rebar {i}", HeadMaterial = reinforcement, HostPrimitive = concreteBlock };
point = new RebarPrimitive()
{
Area = area1,
Name = $"Bottom rebar {i}",
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0] + dist * i;
point.Center.Y = ys[0];
primitives.Add(point);
point = new RebarPrimitive() {Area = area2, Name = $"Top rebar {i}", HeadMaterial = reinforcement, HostPrimitive = concreteBlock };
point = new RebarPrimitive()
{
Area = area2,
Name = $"Top rebar {i}",
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0] + dist * i;
point.Center.Y = ys[1];
primitives.Add(point);
@@ -135,9 +149,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{
Area = area1,
Name = $"Left point {i}",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[0];
point.Center.Y = ys[0] + dist * i;
primitives.Add(point);
@@ -145,9 +159,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{
Area = area1,
Name = $"Right point {i}",
HeadMaterial = reinforcement,
HostPrimitive = concreteBlock
};
point.NdmElement.HeadMaterial = reinforcement;
point.Center.X = xs[1];
point.Center.Y = ys[0] + dist * i;
primitives.Add(point);

View File

@@ -26,7 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC
inputData.CrossSectionArea = ndmPrimitive.Area;
var diameter = Math.Sqrt(ndmPrimitive.Area / Math.PI) * 2d;
inputData.CrossSectionPerimeter = Math.PI * diameter;
if (ndmPrimitive.HeadMaterial is null)
if (ndmPrimitive.NdmElement.HeadMaterial is null)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": main material is incorrect or null");
}
@@ -52,7 +52,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC
if (primitive.HostPrimitive is not null)
{
var host = primitive.HostPrimitive;
var hostMaterial = host.HeadMaterial.HelperMaterial;
var hostMaterial = host
.NdmElement
.HeadMaterial
.HelperMaterial;
if (hostMaterial is IConcreteLibMaterial)
{
var concreteMaterial = hostMaterial as IConcreteLibMaterial;
@@ -65,9 +68,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC
private static double GetReinforcementStrength(LimitStates limitState, CalcTerms calcTerm, RebarPrimitive primitive)
{
if (primitive.HeadMaterial.HelperMaterial is IReinforcementLibMaterial)
if (primitive.NdmElement.HeadMaterial.HelperMaterial is IReinforcementLibMaterial)
{
var material = primitive.HeadMaterial.HelperMaterial as IReinforcementLibMaterial;
var material = primitive.NdmElement.HeadMaterial.HelperMaterial as IReinforcementLibMaterial;
var strength = material.GetStrength(limitState, calcTerm).Tensile;
return strength;
}

View File

@@ -44,7 +44,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
RebarPrimitive rebarCopy = null;
rebarCopy = Rebar.Clone() as RebarPrimitive;
rebarCopy.HeadMaterial = rebarCopy.HeadMaterial.Clone() as IHeadMaterial;
rebarCopy.NdmElement.HeadMaterial = rebarCopy.NdmElement.HeadMaterial.Clone() as IHeadMaterial;
triangulationLogicLoc = new CrackedSectionTriangulationLogic(InputData.Primitives);
crackableNdmsLoc = triangulationLogicLoc.GetNdmCollection();
crackedNdmsLoc = triangulationLogicLoc.GetCrackedNdmCollection();

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
/// <inheritdoc/>
public class DivisionSize : IDivisionSize
{
/// <inheritdoc/>
public double NdmMaxSize { get; set; } = 0.01d;
/// <inheritdoc/>
public int NdmMinDivision { get; set; } = 10;
/// <inheritdoc/>
public bool ClearUnderlying { get; set; } = false;
}
}

View File

@@ -9,46 +9,54 @@ using StructureHelperLogics.NdmCalculations.Triangulations;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class CirclePrimitive : ICirclePrimitive
public class EllipsePrimitive : IEllipsePrimitive
{
static readonly CircleUpdateStrategy updateStrategy = new();
private static readonly EllipsePrimitiveUpdateStrategy updateStrategy = new();
private readonly RectangleShape rectangleShape = new();
/// <inheritdoc/>
public Guid Id { get; set; }
/// <inheritdoc/>
public string Name { get; set; }
/// <inheritdoc/>
public IPoint2D Center { get; private set; }
public IHeadMaterial? HeadMaterial { get; set; }
public StrainTuple UsersPrestrain { get; }
public StrainTuple AutoPrestrain { get; }
public IVisualProperty VisualProperty { get; }
public double Diameter { get; set; }
public double NdmMaxSize { get; set; }
public int NdmMinDivision { get; set; }
public bool ClearUnderlying { get; set; }
public bool Triangulate { get; set; }
public IPoint2D Center { get; set; } = new Point2D();
/// <inheritdoc/>
public IVisualProperty VisualProperty { get; } = new VisualProperty { Opacity = 0.8d };
/// <inheritdoc/>
public double DiameterByX
{
get
{
return rectangleShape.Width;
}
set
{
rectangleShape.Width = value;
rectangleShape.Height = value;
}
}
/// <inheritdoc/>
public double DiameterByY { get => rectangleShape.Height; set => rectangleShape.Height = value; }
/// <inheritdoc/>
public ICrossSection? CrossSection { get; set; }
/// <inheritdoc/>
public INdmElement NdmElement { get; } = new NdmElement();
/// <inheritdoc/>
public IDivisionSize DivisionSize { get; } = new DivisionSize();
/// <inheritdoc/>
public IShape Shape => rectangleShape;
public CirclePrimitive(Guid id)
public EllipsePrimitive(Guid id)
{
Id = id;
Name = "New Circle";
NdmMaxSize = 0.01d;
NdmMinDivision = 10;
Center = new Point2D();
VisualProperty = new VisualProperty { Opacity = 0.8d };
UsersPrestrain = new StrainTuple();
AutoPrestrain = new StrainTuple();
ClearUnderlying = false;
Triangulate = true;
}
public CirclePrimitive() : this (Guid.NewGuid())
{}
public EllipsePrimitive() : this (Guid.NewGuid()) {}
/// <inheritdoc/>
public object Clone()
{
var primitive = new CirclePrimitive();
var primitive = new EllipsePrimitive();
updateStrategy.Update(primitive, this);
return primitive;
}
@@ -70,7 +78,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
var dX = Center.X - point.X;
var dY = Center.Y - point.Y;
var distance = Math.Sqrt(dX * dX + dY * dY);
if (distance > Diameter / 2) { return false; }
if (distance > DiameterByX / 2) { return false; }
return true;
}
@@ -88,28 +96,28 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
newPoint = new NamedAreaPoint
{
Name = "Left",
Point = new Point2D() { X = Center.X - Diameter / 2d, Y = Center.Y},
Point = new Point2D() { X = Center.X - DiameterByX / 2d, Y = Center.Y},
Area = 0d
};
points.Add(newPoint);
newPoint = new NamedAreaPoint
{
Name = "Top",
Point = new Point2D() { X = Center.X, Y = Center.Y + Diameter / 2d },
Point = new Point2D() { X = Center.X, Y = Center.Y + DiameterByX / 2d },
Area = 0d
};
points.Add(newPoint);
newPoint = new NamedAreaPoint
{
Name = "Right",
Point = new Point2D() { X = Center.X + Diameter / 2d, Y = Center.Y },
Point = new Point2D() { X = Center.X + DiameterByX / 2d, Y = Center.Y },
Area = 0d
};
points.Add(newPoint);
newPoint = new NamedAreaPoint
{
Name = "Bottom",
Point = new Point2D() { X = Center.X, Y = Center.Y - Diameter / 2d },
Point = new Point2D() { X = Center.X, Y = Center.Y - DiameterByX / 2d },
Area = 0d
};
points.Add(newPoint);

View File

@@ -0,0 +1,29 @@
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 StructureHelperLogics.NdmCalculations.Primitives
{
/// <summary>
/// Include parameters of triangulation for shapes
/// </summary>
public interface IDivisionSize
{
/// <summary>
/// Maximum size of Ndm part
/// </summary>
double NdmMaxSize { get; set; }
/// <summary>
/// Mimimum division for sides of shape
/// </summary>
int NdmMinDivision { get; set; }
/// <summary>
/// Flag of removing ndm part which located inside shape
/// </summary>
bool ClearUnderlying { get; set; }
}
}

View File

@@ -7,7 +7,10 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public interface ICirclePrimitive : INdmPrimitive, IHasDivisionSize, ICircleShape
public interface IEllipsePrimitive : INdmPrimitive, IHasDivisionSize
{
double DiameterByX { get; set; }
double DiameterByY { get; set; }
}
}

View File

@@ -1,5 +1,4 @@
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,23 +7,10 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
/// <summary>
/// Include parameters of triangulation for shapes
/// </summary>
public interface IHasDivisionSize
{
/// <summary>
/// Maximum size of Ndm part
/// </summary>
double NdmMaxSize { get; set; }
/// <summary>
/// Mimimum division for sides of shape
/// </summary>
int NdmMinDivision { get; set; }
/// <summary>
/// Flag of removing ndm part which located inside shape
/// </summary>
bool ClearUnderlying { get; set; }
///<inheritdoc/>
IDivisionSize DivisionSize { get; }
/// <summary>
/// Shows if point is located inside shape
/// </summary>

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public interface ILinePrimitive : IHasDivisionSize, ILineShape
public interface ILinePrimitive : IDivisionSize, ILineShape
{
}
}

View File

@@ -13,10 +13,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
{
public interface INdmElement : ISaveable, ICloneable
{
/// <summary>
/// Base point of primitive
/// </summary>
IPoint2D Center { get; }
/// <summary>
/// Material of primitive
/// </summary>

View File

@@ -17,38 +17,22 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
/// <summary>
/// Geometrical primitive which generates ndm elemtntary part
/// </summary>
public interface INdmPrimitive : ISaveable, ICloneable
public interface INdmPrimitive : ISaveable, IHasCenter2D, ICloneable
{
/// <summary>
/// Name of primitive
/// </summary>
string? Name { get; set; }
INdmElement NdmElement { get;}
IShape Shape { get; }
/// <summary>
/// Base point of primitive
/// Base properties of primitive
/// </summary>
IPoint2D Center { get; }
INdmElement NdmElement { get;}
/// <summary>
/// Host cross-section for primitive
/// </summary>
ICrossSection? CrossSection { get; set; }
/// <summary>
/// Material of primitive
/// </summary>
IHeadMaterial? HeadMaterial { get; set; }
/// <summary>
/// Flag of triangulation
/// </summary>
bool Triangulate { get; set; }
/// <summary>
/// Prestrain assigned from user
/// </summary>
StrainTuple UsersPrestrain { get; }
/// <summary>
/// Prestrain assigned from calculations
/// </summary>
StrainTuple AutoPrestrain { get; }
/// <summary>
/// Visual settings
/// </summary>
IVisualProperty VisualProperty {get; }

View File

@@ -23,11 +23,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name;
if (sourceObject.HeadMaterial != null) targetObject.HeadMaterial = sourceObject.HeadMaterial;
targetObject.Triangulate = sourceObject.Triangulate;
if (sourceObject.NdmElement.HeadMaterial != null)
{
targetObject.NdmElement.HeadMaterial = sourceObject.NdmElement.HeadMaterial;
}
targetObject.NdmElement.Triangulate = sourceObject.NdmElement.Triangulate;
point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center);
visualPropsUpdateStrategy.Update(targetObject.VisualProperty, sourceObject.VisualProperty);
tupleUpdateStrategy.Update(targetObject.UsersPrestrain, sourceObject.UsersPrestrain);
tupleUpdateStrategy.Update(targetObject.NdmElement.UsersPrestrain, sourceObject.NdmElement.UsersPrestrain);
}
}

View File

@@ -60,10 +60,10 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
}
}
if (RebarPrimitive.HostPrimitive.HeadMaterial.HelperMaterial is not ICrackedMaterial)
if (RebarPrimitive.HostPrimitive.NdmElement.HeadMaterial.HelperMaterial is not ICrackedMaterial)
{
result = false;
string message = $"Material of host of {RebarPrimitive.Name} ({RebarPrimitive.HostPrimitive.HeadMaterial.Name}) does not support cracking\n";
string message = $"Material of host of {RebarPrimitive.Name} ({RebarPrimitive.HostPrimitive.NdmElement.HeadMaterial.Name}) does not support cracking\n";
checkResult += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}

View File

@@ -1,25 +0,0 @@
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.NdmCalculations.Primitives
{
internal class CircleUpdateStrategy : IUpdateStrategy<CirclePrimitive>
{
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
static readonly DivisionPropsUpdateStrategy divisionPropsUpdateStrategy = new();
static readonly CircleShapeUpdateStrategy shapeUpdateStrategy = new();
public void Update(CirclePrimitive targetObject, CirclePrimitive sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
divisionPropsUpdateStrategy.Update(targetObject, sourceObject);
shapeUpdateStrategy.Update(targetObject, sourceObject);
}
}
}

View File

@@ -7,9 +7,9 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
internal class DivisionPropsUpdateStrategy : IUpdateStrategy<IHasDivisionSize>
internal class DivisionPropsUpdateStrategy : IUpdateStrategy<IDivisionSize>
{
public void Update(IHasDivisionSize targetObject, IHasDivisionSize sourceObject)
public void Update(IDivisionSize targetObject, IDivisionSize sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.NdmMaxSize = sourceObject.NdmMaxSize;

View File

@@ -0,0 +1,39 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Models.Shapes.Logics;
using StructureHelperCommon.Services;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
internal class EllipsePrimitiveUpdateStrategy : IUpdateStrategy<IEllipsePrimitive>
{
private IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy;
private IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy;
private IUpdateStrategy<IShape> shapeUpdateStrategy;
public EllipsePrimitiveUpdateStrategy(IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy,
IUpdateStrategy<IShape> shapeUpdateStrategy,
IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy)
{
this.basePrimitiveUpdateStrategy = basePrimitiveUpdateStrategy;
this.shapeUpdateStrategy = shapeUpdateStrategy;
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
}
public EllipsePrimitiveUpdateStrategy() : this(
new BaseUpdateStrategy(),
new ShapeUpdateStrategy(),
new DivisionPropsUpdateStrategy())
{
}
public void Update(IEllipsePrimitive targetObject, IEllipsePrimitive sourceObject)
{
CheckObject.IsNull(sourceObject, "source object");
CheckObject.IsNull(targetObject, "target object");
if (ReferenceEquals(targetObject, sourceObject)) { return; }
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
divisionPropsUpdateStrategy.Update(targetObject.DivisionSize, sourceObject.DivisionSize);
shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape);
}
}
}

View File

@@ -5,21 +5,16 @@ using StructureHelperCommon.Services;
namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
{
public class INdmElementUpdateStrategy : IUpdateStrategy<INdmElement>
public class NdmElementUpdateStrategy : IUpdateStrategy<INdmElement>
{
private readonly IUpdateStrategy<IPoint2D> point2DUpdateStrategy;
private readonly IUpdateStrategy<IForceTuple> tupleUpdateStrategy;
public INdmElementUpdateStrategy(IUpdateStrategy<IPoint2D> point2DUpdateStrategy,
IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
public NdmElementUpdateStrategy(IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
{
this.point2DUpdateStrategy = point2DUpdateStrategy;
this.tupleUpdateStrategy = tupleUpdateStrategy;
}
public INdmElementUpdateStrategy() : this (
new Point2DUpdateStrategy(),
new ForceTupleUpdateStrategy())
public NdmElementUpdateStrategy() : this (new ForceTupleUpdateStrategy())
{
}
@@ -29,8 +24,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
{
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
point2DUpdateStrategy.Update(targetObject.Center, sourceObject.Center);
if (sourceObject.HeadMaterial != null)
{
targetObject.HeadMaterial = sourceObject.HeadMaterial;

View File

@@ -21,11 +21,11 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
}
else if (targetObject is RectanglePrimitive rectangle)
{
new RectangleUpdateStrategy().Update(rectangle, (RectanglePrimitive)sourceObject);
new RectanglePrimitiveUpdateStrategy().Update(rectangle, (RectanglePrimitive)sourceObject);
}
else if (targetObject is CirclePrimitive circle)
else if (targetObject is EllipsePrimitive circle)
{
new CircleUpdateStrategy().Update(circle, (CirclePrimitive)sourceObject);
new EllipsePrimitiveUpdateStrategy().Update(circle, (EllipsePrimitive)sourceObject);
}
else
{

View File

@@ -0,0 +1,45 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Models.Shapes.Logics;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
internal class RectanglePrimitiveUpdateStrategy : IUpdateStrategy<IRectanglePrimitive>
{
private IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy;
private IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy;
private IUpdateStrategy<IShape> shapeUpdateStrategy;
public RectanglePrimitiveUpdateStrategy(IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy,
IUpdateStrategy<IShape> shapeUpdateStrategy,
IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy)
{
this.basePrimitiveUpdateStrategy = basePrimitiveUpdateStrategy;
this.shapeUpdateStrategy = shapeUpdateStrategy;
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
}
public RectanglePrimitiveUpdateStrategy() : this(
new BaseUpdateStrategy(),
new ShapeUpdateStrategy(),
new DivisionPropsUpdateStrategy())
{
}
public void Update(IRectanglePrimitive targetObject, IRectanglePrimitive sourceObject)
{
CheckObject.IsNull(sourceObject, "source object");
CheckObject.IsNull(targetObject, "target object");
if (ReferenceEquals(targetObject, sourceObject)) { return; }
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
divisionPropsUpdateStrategy.Update(targetObject.DivisionSize, sourceObject.DivisionSize);
shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape);
}
}
}

View File

@@ -1,24 +0,0 @@
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.NdmCalculations.Primitives
{
internal class RectangleUpdateStrategy : IUpdateStrategy<RectanglePrimitive>
{
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
static readonly DivisionPropsUpdateStrategy divisionPropsUpdateStrategy = new();
static readonly RectangleShapeUpdateStrategy shapeUpdateStrategy = new();
public void Update(RectanglePrimitive targetObject, RectanglePrimitive sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
divisionPropsUpdateStrategy.Update(targetObject, sourceObject);
shapeUpdateStrategy.Update(targetObject, sourceObject);
}
}
}

View File

@@ -18,11 +18,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
/// <inheritdoc/>
public Guid Id { get; }
/// <inheritdoc/>
public IPoint2D Center { get; } = new Point2D();
/// <inheritdoc/>
public IHeadMaterial? HeadMaterial { get; set; }
/// <inheritdoc/>
public bool Triangulate { get; set; }
public bool Triangulate { get; set; } = true;
/// <inheritdoc/>
public StrainTuple UsersPrestrain { get; } = new();
/// <inheritdoc/>

View File

@@ -14,34 +14,26 @@ namespace StructureHelperLogics.Models.Primitives
static readonly PointUpdateStrategy updateStrategy = new();
public Guid Id { get; }
public string? Name { get; set; }
public IPoint2D Center { get; private set; }
public IHeadMaterial HeadMaterial { get; set; }
//public double NdmMaxSize { get; set; }
//public int NdmMinDivision { get; set; }
public StrainTuple UsersPrestrain { get; private set; }
public StrainTuple AutoPrestrain { get; private set; }
public IPoint2D Center { get; set; }
public double Area { get; set; }
public IVisualProperty VisualProperty { get; }
public bool Triangulate { get; set; }
public IVisualProperty VisualProperty { get; } = new VisualProperty();
public ICrossSection? CrossSection { get; set; }
public INdmElement NdmElement { get; } = new NdmElement();
public IShape Shape => throw new NotImplementedException();
public PointPrimitive(Guid id)
{
Id = id;
Name = "New Point";
Area = 0.0005d;
Center = new Point2D();
VisualProperty = new VisualProperty();
UsersPrestrain = new StrainTuple();
AutoPrestrain = new StrainTuple();
Triangulate = true;
}
public PointPrimitive() : this (Guid.NewGuid())
{}
public PointPrimitive(IHeadMaterial material) : this() { HeadMaterial = material; }
public object Clone()
{

View File

@@ -27,17 +27,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
/// <inheritdoc/>
public string Name { get; set; }
/// <inheritdoc/>
public IPoint2D Center { get; private set; }
public IPoint2D Center { get; set; }
/// <inheritdoc/>
public IHeadMaterial? HeadMaterial { get; set; }
/// <inheritdoc/>
public bool Triangulate { get; set; }
/// <inheritdoc/>
public StrainTuple UsersPrestrain { get; private set; }
/// <inheritdoc/>
public StrainTuple AutoPrestrain { get; private set; }
/// <inheritdoc/>
public IVisualProperty VisualProperty { get; private set; }
public IVisualProperty VisualProperty { get; private set; } = new VisualProperty();
/// <inheritdoc/>
public Guid Id { get; set; }
/// <inheritdoc/>
@@ -49,16 +41,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
public INdmElement NdmElement { get; } = new NdmElement();
public IShape Shape => throw new NotImplementedException();
public RebarPrimitive(Guid id)
{
Id = id;
Name = "New Reinforcement";
Area = 0.0005d;
Center = new Point2D();
VisualProperty = new VisualProperty();
UsersPrestrain = new StrainTuple();
AutoPrestrain = new StrainTuple();
Triangulate = true;
}
public RebarPrimitive() : this(Guid.NewGuid())
{

View File

@@ -11,46 +11,34 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class RectanglePrimitive : IRectanglePrimitive
{
readonly RectangleUpdateStrategy updateStrategy = new();
private readonly RectanglePrimitiveUpdateStrategy updateStrategy = new();
private readonly RectangleShape rectangleShape = new();
public Guid Id { get;}
public string Name { get; set; }
public IHeadMaterial? HeadMaterial { get; set; }
public StrainTuple UsersPrestrain { get; private set; }
public StrainTuple AutoPrestrain { get; private set; }
public double NdmMaxSize { get; set; }
public int NdmMinDivision { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public double Angle { get; set; }
public bool ClearUnderlying { get; set; }
public bool Triangulate { get; set; }
public IVisualProperty VisualProperty { get; }
public double Width { get => rectangleShape.Width; set => rectangleShape.Width = value; }
public double Height { get => rectangleShape.Height; set => rectangleShape.Height = value; }
public double Angle { get => rectangleShape.Angle; set => rectangleShape.Angle = value; }
public IVisualProperty VisualProperty { get; } = new VisualProperty() { Opacity = 0.8d };
public ICrossSection? CrossSection { get; set; }
public IPoint2D Center { get; private set; }
public IPoint2D Center { get; set; } = new Point2D();
public INdmElement NdmElement { get; } = new NdmElement();
public IDivisionSize DivisionSize { get; } = new DivisionSize();
public IShape Shape => rectangleShape;
public RectanglePrimitive(Guid id)
{
Id = id;
Name = "New Rectangle";
NdmMaxSize = 0.01d;
NdmMinDivision = 10;
Center = new Point2D();
VisualProperty = new VisualProperty { Opacity = 0.8d};
UsersPrestrain = new StrainTuple();
AutoPrestrain = new StrainTuple();
ClearUnderlying = false;
Triangulate = true;
}
public RectanglePrimitive() : this(Guid.NewGuid())
{
}
public RectanglePrimitive(IHeadMaterial material) : this() { HeadMaterial = material; }
public object Clone()
{
var primitive = new RectanglePrimitive();

View File

@@ -25,14 +25,15 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
public ITriangulationOptions triangulationOptions { get; set; }
public IHeadMaterial HeadMaterial { get; set; }
public CircleTriangulationLogicOptions(ICirclePrimitive primitive)
public CircleTriangulationLogicOptions(IEllipsePrimitive primitive)
{
Center = primitive.Center.Clone() as Point2D;
Circle = primitive;
NdmMaxSize = primitive.NdmMaxSize;
NdmMinDivision = primitive.NdmMinDivision;
HeadMaterial = primitive.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
//to do change to ellipse
Circle = new CircleShape() { Diameter = primitive.DiameterByX };
NdmMaxSize = primitive.DivisionSize.NdmMaxSize;
NdmMinDivision = primitive.DivisionSize.NdmMinDivision;
HeadMaterial = primitive.NdmElement.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
}
}
}

View File

@@ -28,8 +28,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
{
Center = primitive.Center.Clone() as Point2D;
Area = primitive.Area;
HeadMaterial = primitive.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
HeadMaterial = primitive.NdmElement.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
}
}
}

View File

@@ -55,11 +55,12 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
{
var hostPrimitive = options.HostPrimitive;
var material = hostPrimitive
.NdmElement
.HeadMaterial
.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm);
var prestrain = ForceTupleService.SumTuples(hostPrimitive.UsersPrestrain,
hostPrimitive.AutoPrestrain)
var prestrain = ForceTupleService.SumTuples(hostPrimitive.NdmElement.UsersPrestrain,
hostPrimitive.NdmElement.AutoPrestrain)
as StrainTuple;
var concreteNdm = new Ndm

View File

@@ -30,9 +30,9 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
{
Center = primitive.Center.Clone() as Point2D;
Area = primitive.Area;
HeadMaterial = primitive.HeadMaterial;
HeadMaterial = primitive.NdmElement.HeadMaterial;
HostPrimitive = primitive.HostPrimitive;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
}
}
}

View File

@@ -35,10 +35,10 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
{
Center = new Point2D() {X = primitive.Center.X, Y = primitive.Center.Y };
Rectangle = primitive;
NdmMaxSize = primitive.NdmMaxSize;
NdmMinDivision = primitive.NdmMinDivision;
HeadMaterial = primitive.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
NdmMaxSize = primitive.DivisionSize.NdmMaxSize;
NdmMinDivision = primitive.DivisionSize.NdmMinDivision;
HeadMaterial = primitive.NdmElement.HeadMaterial;
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
}
}
}

View File

@@ -32,7 +32,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
Dictionary<Guid, IHeadMaterial> headMaterials = new Dictionary<Guid, IHeadMaterial>();
foreach (var ndmPrimitive in ndmPrimitives)
{
IHeadMaterial material = ndmPrimitive.HeadMaterial;
IHeadMaterial material = ndmPrimitive.NdmElement.HeadMaterial;
if (!headMaterials.ContainsKey(material.Id)) { headMaterials.Add(material.Id, material); }
}
return headMaterials;

View File

@@ -25,7 +25,9 @@ namespace StructureHelperLogics.Services.NdmPrimitives
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
if (!Primitives.Any(x => x.Triangulate == true))
if (!Primitives.Any(x => x
.NdmElement
.Triangulate == true))
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
@@ -33,8 +35,8 @@ namespace StructureHelperLogics.Services.NdmPrimitives
}
foreach (var item in Primitives)
{
if (item.Triangulate == true &
item.HeadMaterial is null)
if (item.NdmElement.Triangulate == true &
item.NdmElement.HeadMaterial is null)
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);

View File

@@ -9,10 +9,22 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
/// <summary>
/// Implement logic of triangulation of primitives which have parameters of division
/// </summary>
public interface IMeshHasDivisionLogic : ILogic
{
List<INdm> NdmCollection { get; set; }
IHasDivisionSize Primitive { get; set; }
/// <summary>
/// Input collection of existing ndm parts
/// </summary>
List<INdm>? NdmCollection { get; set; }
/// <summary>
/// Input triangulated primitive
/// </summary>
IHasDivisionSize? Primitive { get; set; }
/// <summary>
/// Run process of triangulation
/// </summary>
void MeshHasDivision();
}
}

View File

@@ -30,7 +30,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
CheckPrimitive();
List<INdm> ndmCollection = new();
if (Primitive.HeadMaterial.HelperMaterial is ICrackedMaterial)
if (Primitive.NdmElement.HeadMaterial.HelperMaterial is ICrackedMaterial)
{
ProcessICracked(ndmCollection);
}
@@ -74,13 +74,13 @@ namespace StructureHelperLogics.Services.NdmPrimitives
private void SetNewMaterial(INdmPrimitive? newPrimititve)
{
TraceLogger?.AddMessage($"Process material {newPrimititve.HeadMaterial.Name} has started");
var newHeadMaterial = newPrimititve.HeadMaterial.Clone() as IHeadMaterial;
TraceLogger?.AddMessage($"Process material {newPrimititve.NdmElement.HeadMaterial.Name} has started");
var newHeadMaterial = newPrimititve.NdmElement.HeadMaterial.Clone() as IHeadMaterial;
var newMaterial = newHeadMaterial.HelperMaterial.Clone() as ICrackedMaterial;
TraceLogger?.AddMessage($"Set work in tension zone for material {newPrimititve.HeadMaterial.Name}");
TraceLogger?.AddMessage($"Set work in tension zone for material {newPrimititve.NdmElement.HeadMaterial.Name}");
newMaterial.TensionForSLS = false;
newHeadMaterial.HelperMaterial = newMaterial as IHelperMaterial;
newPrimititve.HeadMaterial = newHeadMaterial;
newPrimititve.NdmElement.HeadMaterial = newHeadMaterial;
}
private List<INdm> GetNdms(INdmPrimitive primitive)

View File

@@ -1,4 +1,6 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
@@ -12,30 +14,55 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
/// <inheritdoc/>
public class MeshHasDivisionLogic : IMeshHasDivisionLogic
{
public List<INdm> NdmCollection { get; set; }
public IHasDivisionSize Primitive { get; set; }
/// <inheritdoc/>
public List<INdm>? NdmCollection { get; set; }
/// <inheritdoc/>
public IHasDivisionSize? Primitive { get; set; }
/// <inheritdoc/>
public IShiftTraceLogger? TraceLogger { get; set; }
public void MeshHasDivision()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
CheckInputData();
if (Primitive is IHasDivisionSize hasDivision)
{
if (hasDivision.ClearUnderlying == true)
if (hasDivision.DivisionSize.ClearUnderlying == true)
{
TraceLogger?.AddMessage("Removing of background part has started", TraceLogStatuses.Service);
NdmCollection
.RemoveAll(x =>
hasDivision
.IsPointInside(new Point2D()
{
X = x.CenterX,
Y = x.CenterY
}) == true);
NdmCollection.RemoveAll(x => IsCenterInside(x, hasDivision) == true);
}
}
}
private static bool IsCenterInside(INdm x, IHasDivisionSize hasDivision)
{
Point2D point = new Point2D()
{
X = x.CenterX,
Y = x.CenterY
};
return hasDivision.IsPointInside(point);
}
private void CheckInputData()
{
if (NdmCollection is null)
{
var message = ErrorStrings.ParameterIsNull + ": input NdmCollection";
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
throw new StructureHelperException(message);
}
if (Primitive is null)
{
var message = ErrorStrings.ParameterIsNull + ": input Primitive";
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
throw new StructureHelperException(message);
}
}
}
}

View File

@@ -87,7 +87,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
divisionLogic.Primitive = hasDivision;
divisionLogic.MeshHasDivision();
}
if (primitive.Triangulate == true)
if (primitive.NdmElement.Triangulate == true)
{
meshLogic.Primitive = primitive;
var ndms = meshLogic.MeshPrimitive();