Add polygon shape
This commit is contained in:
@@ -27,6 +27,10 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
new EllipsePrimitiveUpdateStrategy().Update(circle, (EllipseNdmPrimitive)sourceObject);
|
||||
}
|
||||
else if (targetObject is IShapeNDMPrimitive shapePrimitive)
|
||||
{
|
||||
new ShapeNDMPrimitiveUpdateStrategy().Update(shapePrimitive, (IShapeNDMPrimitive)sourceObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(INdmPrimitive), sourceObject.GetType());
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
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
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.Shapes.Logics;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -18,12 +17,20 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public ShapeNDMPrimitiveUpdateStrategy(
|
||||
IUpdateStrategy<INdmPrimitive> basePrimitiveUpdateStrategy,
|
||||
IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy,
|
||||
IUpdateStrategy<IShape> shapeUpdateStrategy)
|
||||
IUpdateStrategy<IShape> shapeUpdateStrategy,
|
||||
IUpdateStrategy<IDivisionSize> divisionPropsUpdateStrategy)
|
||||
{
|
||||
this.basePrimitiveUpdateStrategy = basePrimitiveUpdateStrategy;
|
||||
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
|
||||
this.shapeUpdateStrategy = shapeUpdateStrategy;
|
||||
this.divisionPropsUpdateStrategy = divisionPropsUpdateStrategy;
|
||||
}
|
||||
|
||||
public ShapeNDMPrimitiveUpdateStrategy() : this(
|
||||
new BaseUpdateStrategy(),
|
||||
new ShapeUpdateStrategy(),
|
||||
new DivisionSizeUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IShapeNDMPrimitive targetObject, IShapeNDMPrimitive sourceObject)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public class RectangleNdmPrimitive : IRectangleNdmPrimitive
|
||||
{
|
||||
private readonly RectanglePrimitiveUpdateStrategy updateStrategy = new();
|
||||
private RectanglePrimitiveUpdateStrategy updateStrategy;
|
||||
private readonly RectangleShape rectangleShape = new();
|
||||
public Guid Id { get;}
|
||||
public string Name { get; set; }
|
||||
@@ -43,6 +43,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public object Clone()
|
||||
{
|
||||
var primitive = new RectangleNdmPrimitive();
|
||||
updateStrategy ??= new();
|
||||
updateStrategy.Update(primitive, this);
|
||||
return primitive;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
@@ -13,6 +15,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
public class ShapeNdmPrimitive : IShapeNDMPrimitive
|
||||
{
|
||||
private IShape shape;
|
||||
private IUpdateStrategy<IShapeNDMPrimitive> updateStrategy;
|
||||
|
||||
public Guid Id { get; }
|
||||
public string? Name { get; set; } = string.Empty;
|
||||
@@ -30,7 +33,12 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var primitive = new ShapeNdmPrimitive(Guid.NewGuid());
|
||||
PolygonShape polygon = new(Guid.NewGuid());
|
||||
primitive.SetShape(polygon);
|
||||
updateStrategy ??= new ShapeNDMPrimitiveUpdateStrategy();
|
||||
updateStrategy.Update(primitive, this);
|
||||
return primitive;
|
||||
}
|
||||
|
||||
public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions)
|
||||
@@ -69,7 +77,16 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public bool IsPointInside(IPoint2D point)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (shape is IPolygonShape polygon)
|
||||
{
|
||||
var newShape = PolygonGeometryUtils.GetTratsfromedPolygon(polygon, Center.X, Center.Y);
|
||||
var calculator = new PolygonCalculator();
|
||||
return calculator.ContainsPoint(newShape, point);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(shape));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetShape(IShape shape)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user