Рефакторинг, добавление моделей примитивов
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Models.NdmPrimitives
|
||||
{
|
||||
public interface IPrimitive
|
||||
public interface IPrimitive : ICenterShape
|
||||
{
|
||||
ICenter Center { get;}
|
||||
IShape Shape { get;}
|
||||
INdmPrimitive GetNdmPrimitive();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,19 @@
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Entities;
|
||||
using StructureHelperLogics.NdmCalculations.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Models.NdmPrimitives
|
||||
{
|
||||
public class PointPrimitive : IPrimitive
|
||||
public class PointPrimitive : PrimitiveBase<IPoint>, IPoint
|
||||
{
|
||||
ICenter _center;
|
||||
IShape _shape;
|
||||
|
||||
public ICenter Center => _center;
|
||||
public IShape Shape => _shape;
|
||||
public double Area
|
||||
{
|
||||
get
|
||||
{
|
||||
IPoint point = _shape as IPoint;
|
||||
return point.Area;
|
||||
}
|
||||
set
|
||||
{
|
||||
IPoint point = _shape as IPoint;
|
||||
point.Area = value;
|
||||
}
|
||||
get => _shape.Area;
|
||||
set => _shape.Area = value;
|
||||
}
|
||||
|
||||
public PointPrimitive(ICenter center, IShape shape)
|
||||
{
|
||||
_center = center;
|
||||
_shape = shape;
|
||||
}
|
||||
public INdmPrimitive GetNdmPrimitive()
|
||||
public PointPrimitive(ICenter center, IPoint shape) : base(center, shape) { }
|
||||
public override INdmPrimitive GetNdmPrimitive()
|
||||
{
|
||||
double strength = 400;
|
||||
string materialName = "s400";
|
||||
|
||||
22
StructureHelperLogics/Models/NdmPrimitives/PrimitiveBase.cs
Normal file
22
StructureHelperLogics/Models/NdmPrimitives/PrimitiveBase.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Entities;
|
||||
|
||||
namespace StructureHelperLogics.Models.NdmPrimitives
|
||||
{
|
||||
public abstract class PrimitiveBase<T> : IPrimitive where T : IShape
|
||||
{
|
||||
protected ICenter _center;
|
||||
protected T _shape;
|
||||
|
||||
public ICenter Center => _center;
|
||||
public IShape Shape => _shape;
|
||||
|
||||
public PrimitiveBase(ICenter center, T shape)
|
||||
{
|
||||
_center = center;
|
||||
_shape = shape;
|
||||
}
|
||||
|
||||
public abstract INdmPrimitive GetNdmPrimitive();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Entities;
|
||||
using StructureHelperLogics.NdmCalculations.Materials;
|
||||
|
||||
namespace StructureHelperLogics.Models.NdmPrimitives
|
||||
{
|
||||
public class RectanglePrimitive : PrimitiveBase<IRectangle>, IRectangle
|
||||
{
|
||||
public RectanglePrimitive(ICenter center, IRectangle shape) : base(center, shape) { }
|
||||
|
||||
public double Width => _shape.Width;
|
||||
|
||||
public double Height => _shape.Height;
|
||||
|
||||
public double Angle => _shape.Angle;
|
||||
|
||||
public override INdmPrimitive GetNdmPrimitive()
|
||||
{
|
||||
double strength = 400;
|
||||
string materialName = "s400";
|
||||
IPrimitiveMaterial primitiveMaterial = new PrimitiveMaterial() { MaterialType = GetMaterialTypes(), ClassName = materialName, Strength = strength }; ;
|
||||
INdmPrimitive ndmPrimitive = new NdmPrimitive() { Center = _center, Shape = _shape, PrimitiveMaterial = primitiveMaterial };
|
||||
return ndmPrimitive;
|
||||
}
|
||||
|
||||
private MaterialTypes GetMaterialTypes()
|
||||
{
|
||||
return MaterialTypes.Reinforcement;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user