Crack Calculator was added
This commit is contained in:
@@ -3,24 +3,20 @@ using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.ShapeServices;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class CirclePrimitive : ICirclePrimitive
|
||||
{
|
||||
static readonly CircleUpdateStrategy updateStrategy = new();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public string Name { get; set; }
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IPoint2D Center { get; private set; }
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
public StrainTuple UsersPrestrain { get; }
|
||||
public StrainTuple AutoPrestrain { get; }
|
||||
@@ -32,12 +28,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public bool Triangulate { get; set; }
|
||||
public ICrossSection? CrossSection { get; set; }
|
||||
|
||||
|
||||
public CirclePrimitive(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();
|
||||
@@ -46,16 +44,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
}
|
||||
public CirclePrimitive() : this (Guid.NewGuid())
|
||||
{}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new CirclePrimitive();
|
||||
NdmPrimitivesService.CopyNdmProperties(this, primitive);
|
||||
NdmPrimitivesService.CopyDivisionProperties(this, primitive);
|
||||
ShapeService.CopyCircleProperties(this, primitive);
|
||||
updateStrategy.Update(primitive, this);
|
||||
return primitive;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<INdm> GetNdms(IMaterial material)
|
||||
{
|
||||
var ndms = new List<INdm>();
|
||||
@@ -64,24 +60,14 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
ndms.AddRange(logic.GetNdmCollection(material));
|
||||
return ndms;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool IsPointInside(IPoint2D point)
|
||||
{
|
||||
var dX = CenterX - point.X;
|
||||
var dY = CenterY - point.Y;
|
||||
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; }
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public interface INdmPrimitive : ISaveable, ICloneable
|
||||
{
|
||||
string? Name { get; set; }
|
||||
double CenterX { get; set; }
|
||||
double CenterY { get; set; }
|
||||
IPoint2D Center { get; }
|
||||
ICrossSection? CrossSection { get; set; }
|
||||
IHeadMaterial? HeadMaterial { get; set; }
|
||||
/// <summary>
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.ShapeServices;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
@@ -54,8 +46,8 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new LinePrimitive();
|
||||
NdmPrimitivesService.CopyDivisionProperties(this, primitive);
|
||||
ShapeService.CopyLineProperties(this, primitive);
|
||||
throw new NotImplementedException();
|
||||
|
||||
return primitive;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes.Logics;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
internal class BaseUpdateStrategy : IUpdateStrategy<INdmPrimitive>
|
||||
{
|
||||
static readonly PointShapeUpdateStrategy pointShapeUpdateStrategy = new();
|
||||
readonly ForceTupleUpdateStrategy tupleUpdateStrategy = new();
|
||||
readonly VisualPropsUpdateStrategy visualPropsUpdateStrategy = new();
|
||||
|
||||
public void Update(INdmPrimitive target, INdmPrimitive source)
|
||||
{
|
||||
target.Name = source.Name;
|
||||
if (source.HeadMaterial != null) target.HeadMaterial = source.HeadMaterial;
|
||||
target.Triangulate = source.Triangulate;
|
||||
pointShapeUpdateStrategy.Update(target.Center, source.Center);
|
||||
visualPropsUpdateStrategy.Update(target.VisualProperty, source.VisualProperty);
|
||||
tupleUpdateStrategy.Update(target.UsersPrestrain, source.UsersPrestrain);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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)
|
||||
{
|
||||
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
|
||||
divisionPropsUpdateStrategy.Update(targetObject, sourceObject);
|
||||
shapeUpdateStrategy.Update(targetObject, sourceObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
internal class DivisionPropsUpdateStrategy : IUpdateStrategy<IHasDivisionSize>
|
||||
{
|
||||
public void Update(IHasDivisionSize targetObject, IHasDivisionSize sourceObject)
|
||||
{
|
||||
targetObject.NdmMaxSize = sourceObject.NdmMaxSize;
|
||||
targetObject.NdmMinDivision = sourceObject.NdmMinDivision;
|
||||
targetObject.ClearUnderlying = sourceObject.ClearUnderlying;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class NdmPrimitiveUpdateStrategy : IUpdateStrategy<INdmPrimitive>
|
||||
{
|
||||
public void Update(INdmPrimitive targetObject, INdmPrimitive sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
if (targetObject is PointPrimitive point)
|
||||
{
|
||||
new PointUpdateStrategy().Update(point, (PointPrimitive)sourceObject);
|
||||
}
|
||||
else if (targetObject is RebarPrimitive rebar)
|
||||
{
|
||||
new RebarUpdateStrategy().Update(rebar, (RebarPrimitive)sourceObject);
|
||||
}
|
||||
else if (targetObject is RectanglePrimitive rectangle)
|
||||
{
|
||||
new RectangleUpdateStrategy().Update(rectangle, (RectanglePrimitive)sourceObject);
|
||||
}
|
||||
else if (targetObject is CirclePrimitive circle)
|
||||
{
|
||||
new CircleUpdateStrategy().Update(circle, (CirclePrimitive)sourceObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(INdmPrimitive), sourceObject.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
internal class PointUpdateStrategy : IUpdateStrategy<PointPrimitive>
|
||||
{
|
||||
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
|
||||
public void Update(PointPrimitive targetObject, PointPrimitive sourceObject)
|
||||
{
|
||||
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
|
||||
targetObject.Area = sourceObject.Area;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
internal class RebarUpdateStrategy : IUpdateStrategy<RebarPrimitive>
|
||||
{
|
||||
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
|
||||
public void Update(RebarPrimitive targetObject, RebarPrimitive sourceObject)
|
||||
{
|
||||
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
|
||||
targetObject.Area = sourceObject.Area;
|
||||
targetObject.HostPrimitive = sourceObject.HostPrimitive;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
{
|
||||
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
|
||||
divisionPropsUpdateStrategy.Update(targetObject, sourceObject);
|
||||
shapeUpdateStrategy.Update(targetObject, sourceObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class VisualPropsUpdateStrategy : IUpdateStrategy<IVisualProperty>
|
||||
{
|
||||
public void Update(IVisualProperty targetObject, IVisualProperty sourceObject)
|
||||
{
|
||||
targetObject.IsVisible = sourceObject.IsVisible;
|
||||
targetObject.Color = sourceObject.Color;
|
||||
targetObject.SetMaterialColor = sourceObject.SetMaterialColor;
|
||||
targetObject.Opacity = sourceObject.Opacity;
|
||||
targetObject.ZIndex = sourceObject.ZIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,10 @@ namespace StructureHelperLogics.Models.Primitives
|
||||
{
|
||||
public class PointPrimitive : IPointPrimitive
|
||||
{
|
||||
static readonly PointUpdateStrategy updateStrategy = new();
|
||||
public Guid Id { get; }
|
||||
public string? Name { get; set; }
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
public IPoint2D Center { get; private set; }
|
||||
public IHeadMaterial HeadMaterial { get; set; }
|
||||
//public double NdmMaxSize { get; set; }
|
||||
//public int NdmMinDivision { get; set; }
|
||||
@@ -31,11 +31,13 @@ namespace StructureHelperLogics.Models.Primitives
|
||||
public bool Triangulate { get; set; }
|
||||
public ICrossSection? CrossSection { get; set; }
|
||||
|
||||
|
||||
public PointPrimitive(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
Name = "New Point";
|
||||
Area = 0.0005d;
|
||||
Center = new Point2D();
|
||||
VisualProperty = new VisualProperty();
|
||||
UsersPrestrain = new StrainTuple();
|
||||
AutoPrestrain = new StrainTuple();
|
||||
@@ -52,16 +54,10 @@ namespace StructureHelperLogics.Models.Primitives
|
||||
return logic.GetNdmCollection(material);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new PointPrimitive();
|
||||
NdmPrimitivesService.CopyNdmProperties(this, primitive);
|
||||
primitive.Area = Area;
|
||||
updateStrategy.Update(primitive, this);
|
||||
return primitive;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
@@ -17,15 +19,14 @@ using System.Windows.Media.Media3D;
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class ReinforcementPrimitive : IPointPrimitive, IHasHostPrimitive
|
||||
public class RebarPrimitive : IPointPrimitive, IHasHostPrimitive
|
||||
{
|
||||
IDataRepository<ReinforcementPrimitive> repository;
|
||||
static readonly RebarUpdateStrategy updateStrategy = new();
|
||||
IDataRepository<RebarPrimitive> repository;
|
||||
/// <inheritdoc/>
|
||||
public string Name { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public double CenterX { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public double CenterY { get; set; }
|
||||
public IPoint2D Center { get; private set; }
|
||||
/// <inheritdoc/>
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
public bool Triangulate { get; set; }
|
||||
@@ -41,27 +42,27 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public INdmPrimitive HostPrimitive { get; set; }
|
||||
public ICrossSection? CrossSection { get; set; }
|
||||
|
||||
public ReinforcementPrimitive(Guid id)
|
||||
|
||||
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 ReinforcementPrimitive() : this(Guid.NewGuid())
|
||||
public RebarPrimitive() : this(Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new ReinforcementPrimitive();
|
||||
NdmPrimitivesService.CopyNdmProperties(this, primitive);
|
||||
primitive.Area = Area;
|
||||
primitive.HostPrimitive = HostPrimitive;
|
||||
var primitive = new RebarPrimitive();
|
||||
updateStrategy.Update(primitive, this);
|
||||
return primitive;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,18 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.ShapeServices;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class RectanglePrimitive : IRectanglePrimitive
|
||||
{
|
||||
readonly RectangleUpdateStrategy updateStrategy = new();
|
||||
public Guid Id { get;}
|
||||
public string Name { get; set; }
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
public StrainTuple UsersPrestrain { get; private set; }
|
||||
public StrainTuple AutoPrestrain { get; private set; }
|
||||
@@ -36,12 +26,15 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public IVisualProperty VisualProperty { get; }
|
||||
public ICrossSection? CrossSection { get; set; }
|
||||
|
||||
public IPoint2D Center { get; private set; }
|
||||
|
||||
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();
|
||||
@@ -58,9 +51,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new RectanglePrimitive();
|
||||
NdmPrimitivesService.CopyNdmProperties(this, primitive);
|
||||
NdmPrimitivesService.CopyDivisionProperties(this, primitive);
|
||||
ShapeService.CopyRectangleProperties(this, primitive);
|
||||
updateStrategy.Update(primitive, this);
|
||||
return primitive;
|
||||
}
|
||||
|
||||
@@ -73,17 +64,12 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
return ndms;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsPointInside(IPoint2D point)
|
||||
{
|
||||
var xMax = CenterX + Width / 2;
|
||||
var xMin = CenterX - Width / 2;
|
||||
var yMax = CenterY + Height / 2;
|
||||
var yMin = CenterY - Height / 2;
|
||||
var xMax = Center.X + Width / 2;
|
||||
var xMin = Center.X - Width / 2;
|
||||
var yMax = Center.Y + Height / 2;
|
||||
var yMin = Center.Y - Height / 2;
|
||||
if (point.X > xMax ||
|
||||
point.X < xMin ||
|
||||
point.Y > yMax ||
|
||||
|
||||
Reference in New Issue
Block a user