Add polygon shape
This commit is contained in:
@@ -21,10 +21,5 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public DivisionSize() : this (Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
/// <inheritdoc/>
|
||||
public INdmElement NdmElement { get; } = new NdmElement();
|
||||
/// <inheritdoc/>
|
||||
public IDivisionSize DivisionSize { get; } = new DivisionSize();
|
||||
public IDivisionSize DivisionSize { get; } = new DivisionSize(Guid.NewGuid());
|
||||
/// <inheritdoc/>
|
||||
public IShape Shape => rectangleShape;
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -6,6 +6,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
double Area { get; set; }
|
||||
string Name { get; set; }
|
||||
Point2D Point { get; set; }
|
||||
IPoint2D Point { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public interface IShapeNDMPrimitive : INdmPrimitive, IHasDivisionSize
|
||||
{
|
||||
void SetShape(IShape shape);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public interface MeshNDMLogic
|
||||
{
|
||||
IEnumerable<INdm> GetNdms(ITriangulationOptions triangulation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
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
|
||||
{
|
||||
public class ShapeNDMPrimitiveUpdateStrategy : IUpdateStrategy<IShapeNDMPrimitive>
|
||||
{
|
||||
private IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy;
|
||||
private IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy;
|
||||
private IUpdateStrategy<IShape> shapeUpdateStrategy;
|
||||
|
||||
public ShapeNDMPrimitiveUpdateStrategy(
|
||||
IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy,
|
||||
IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy,
|
||||
IUpdateStrategy<IShape> shapeUpdateStrategy)
|
||||
{
|
||||
this.basePrimitiveUpdateStrategy = basePrimitiveUpdateStrategy;
|
||||
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
|
||||
this.shapeUpdateStrategy = shapeUpdateStrategy;
|
||||
}
|
||||
|
||||
public void Update(IShapeNDMPrimitive targetObject, IShapeNDMPrimitive sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject, "source object");
|
||||
CheckObject.IsNull(targetObject, "target object");
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
InitializeStrategies();
|
||||
basePrimitiveUpdateStrategy.Update(targetObject, sourceObject);
|
||||
divisionPropsUpdateStrategy.Update(targetObject.DivisionSize, sourceObject.DivisionSize);
|
||||
shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
basePrimitiveUpdateStrategy ??= new BaseUpdateStrategy();
|
||||
divisionPropsUpdateStrategy ??= new DivisionSizeUpdateStrategy();
|
||||
shapeUpdateStrategy ??= new ShapeUpdateStrategy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public class NamedAreaPoint : INamedAreaPoint
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Point2D Point { get; set; }
|
||||
public IPoint2D Point { get; set; }
|
||||
public double Area { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public INdmElement NdmElement { get; } = new NdmElement();
|
||||
|
||||
public IDivisionSize DivisionSize { get; } = new DivisionSize();
|
||||
public IDivisionSize DivisionSize { get; } = new DivisionSize(Guid.NewGuid());
|
||||
|
||||
public IShape Shape => rectangleShape;
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class ShapeNdmPrimitive : IShapeNDMPrimitive
|
||||
{
|
||||
private IShape shape;
|
||||
|
||||
public Guid Id { get; }
|
||||
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 ICrossSection? CrossSection { get; set; }
|
||||
public IVisualProperty VisualProperty { get; } = new VisualProperty { Opacity = 0.8d };
|
||||
public double RotationAngle { get; set; }
|
||||
public IDivisionSize DivisionSize { get; } = new DivisionSize(Guid.NewGuid());
|
||||
public ShapeNdmPrimitive(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<INamedAreaPoint> GetValuePoints()
|
||||
{
|
||||
var points = new List<INamedAreaPoint>();
|
||||
INamedAreaPoint newPoint;
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
Name = "Center",
|
||||
Point = Center.Clone() as Point2D,
|
||||
Area = 0d
|
||||
};
|
||||
points.Add(newPoint);
|
||||
if (shape is IPolygonShape polygon)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in polygon.Vertices)
|
||||
{
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
Name = $"Vertex {i}",
|
||||
Point = item.Point.Clone() as IPoint2D,
|
||||
Area = 0d
|
||||
};
|
||||
points.Add(newPoint);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
public bool IsPointInside(IPoint2D point)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetShape(IShape shape)
|
||||
{
|
||||
this.shape = shape;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user