Circle Primitive Added
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
internal class CircleTriangulationLogic : ITriangulationLogic
|
||||
{
|
||||
CircleTriangulationLogicOptions options;
|
||||
public ITriangulationLogicOptions Options { get; private set; }
|
||||
public CircleTriangulationLogic(ITriangulationLogicOptions options)
|
||||
{
|
||||
ValidateOptions(options);
|
||||
this.options = options as CircleTriangulationLogicOptions;
|
||||
Options = options;
|
||||
}
|
||||
|
||||
public IEnumerable<INdm> GetNdmCollection(IMaterial material)
|
||||
{
|
||||
|
||||
double diameter = options.Circle.Diameter;
|
||||
double ndmMaxSize = options.NdmMaxSize;
|
||||
int ndmMinDivision = options.NdmMinDivision;
|
||||
var logicOptions = new LoaderCalculator.Triangulations.CircleTriangulationLogicOptions(diameter, ndmMaxSize, ndmMinDivision);
|
||||
var logic = LoaderCalculator.Triangulations.Triangulation.GetLogicInstance(logicOptions);
|
||||
var ndmCollection = logic.GetNdmCollection(new LoaderCalculator.Data.Planes.CirclePlane { Material = material });
|
||||
TriangulationService.CommonTransform(ndmCollection, options);
|
||||
TriangulationService.SetPrestrain(ndmCollection, options.Prestrain);
|
||||
return ndmCollection;
|
||||
}
|
||||
|
||||
public void ValidateOptions(ITriangulationLogicOptions options)
|
||||
{
|
||||
if (options is not ICircleTriangulationLogicOptions )
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\n Expected: {nameof(ICircleTriangulationLogicOptions)}, But was: {nameof(options)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public class CircleTriangulationLogicOptions : ICircleTriangulationLogicOptions
|
||||
{
|
||||
public ICircleShape Circle { get; }
|
||||
|
||||
public IPoint2D Center { get; }
|
||||
|
||||
public double NdmMaxSize { get; }
|
||||
|
||||
public int NdmMinDivision { get; }
|
||||
|
||||
public IStrainTuple Prestrain { get; set; }
|
||||
|
||||
public CircleTriangulationLogicOptions(ICirclePrimitive primitive)
|
||||
{
|
||||
Center = new Point2D() { X = primitive.CenterX, Y = primitive.CenterY };
|
||||
Circle = primitive;
|
||||
NdmMaxSize = primitive.NdmMaxSize;
|
||||
NdmMinDivision = primitive.NdmMinDivision;
|
||||
Prestrain = new StrainTuple
|
||||
{
|
||||
Kx = primitive.UsersPrestrain.Kx + primitive.AutoPrestrain.Kx,
|
||||
Ky = primitive.UsersPrestrain.Ky + primitive.AutoPrestrain.Ky,
|
||||
EpsZ = primitive.UsersPrestrain.EpsZ + primitive.AutoPrestrain.EpsZ
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
internal interface ICircleTriangulationLogicOptions : IShapeTriangulationLogicOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Shape
|
||||
/// </summary>
|
||||
ICircleShape Circle { get; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,23 +6,11 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
/// Parameter of triangulation of rectangle part of section
|
||||
/// Параметры триангуляции прямоугольного участка сечения
|
||||
/// </summary>
|
||||
public interface IRectangleTriangulationLogicOptions : ITriangulationLogicOptions
|
||||
public interface IRectangleTriangulationLogicOptions : IShapeTriangulationLogicOptions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
IPoint2D Center { get; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
IRectangleShape Rectangle { get; }
|
||||
/// <summary>
|
||||
/// Maximum size (width or height) of ndm part after triangulation
|
||||
/// </summary>
|
||||
double NdmMaxSize { get; }
|
||||
/// <summary>
|
||||
/// Minimum quantity of division of side of rectangle after triangulation
|
||||
/// </summary>
|
||||
int NdmMinDivision { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public interface IShapeTriangulationLogicOptions : ITriangulationLogicOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Center of shape
|
||||
/// </summary>
|
||||
IPoint2D Center { get; }
|
||||
/// <summary>
|
||||
/// Maximum size (width or height) of ndm part after triangulation
|
||||
/// </summary>
|
||||
double NdmMaxSize { get; }
|
||||
/// <summary>
|
||||
/// Minimum quantity of division of side of rectangle after triangulation
|
||||
/// </summary>
|
||||
int NdmMinDivision { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public interface ITriangulationLogicOptions
|
||||
{
|
||||
double PrestrainKx { get;}
|
||||
double PrestrainKy { get;}
|
||||
double PrestrainEpsZ { get;}
|
||||
IStrainTuple Prestrain { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
List<INdm> ndmCollection = new List<INdm>();
|
||||
INdm ndm = new Ndm { CenterX = center.X, CenterY = center.Y, Area = area, Material = material };
|
||||
ndmCollection.Add(ndm);
|
||||
NdmTransform.SetPrestrain(ndmCollection, new StrainMatrix() { Kx = Options.PrestrainKx, Ky = Options.PrestrainKy, EpsZ = Options.PrestrainEpsZ });
|
||||
NdmTransform.SetPrestrain(ndmCollection, new StrainMatrix() { Kx = options.Prestrain.Kx, Ky = options.Prestrain.Ky, EpsZ = options.Prestrain.EpsZ });
|
||||
return ndmCollection;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
@@ -17,26 +18,27 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
public IPoint2D Center { get; }
|
||||
/// <inheritdoc />
|
||||
public double Area { get; }
|
||||
public IStrainTuple Prestrain { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public double PrestrainKx { get; }
|
||||
/// <inheritdoc />
|
||||
public double PrestrainKy { get; }
|
||||
/// <inheritdoc />
|
||||
public double PrestrainEpsZ { get; }
|
||||
|
||||
public PointTriangulationLogicOptions(IPoint2D center, double area)
|
||||
{
|
||||
Center = center;
|
||||
Area = area;
|
||||
Prestrain = new StrainTuple();
|
||||
}
|
||||
|
||||
public PointTriangulationLogicOptions(IPointPrimitive primitive)
|
||||
{
|
||||
Center = new Point2D() { X = primitive.CenterX, Y = primitive.CenterY };
|
||||
Area = primitive.Area;
|
||||
PrestrainKx = primitive.UsersPrestrain.Kx + primitive.AutoPrestrain.Kx;
|
||||
PrestrainKy = primitive.UsersPrestrain.Ky + primitive.AutoPrestrain.Ky;
|
||||
PrestrainEpsZ = primitive.UsersPrestrain.EpsZ + primitive.AutoPrestrain.EpsZ;
|
||||
Prestrain = new StrainTuple
|
||||
{
|
||||
Kx = primitive.UsersPrestrain.Kx + primitive.AutoPrestrain.Kx,
|
||||
Ky = primitive.UsersPrestrain.Ky + primitive.AutoPrestrain.Ky,
|
||||
EpsZ = primitive.UsersPrestrain.EpsZ + primitive.AutoPrestrain.EpsZ
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,39 +4,44 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using LoaderCalculator.Data.Ndms.Transformations;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public class RectangleTriangulationLogic : IRectangleTriangulationLogic
|
||||
{
|
||||
IRectangleTriangulationLogicOptions options;
|
||||
public ITriangulationLogicOptions Options { get; }
|
||||
|
||||
public IEnumerable<INdm> GetNdmCollection(IMaterial material)
|
||||
{
|
||||
IRectangleTriangulationLogicOptions rectangleOptions = Options as IRectangleTriangulationLogicOptions;
|
||||
double width = rectangleOptions.Rectangle.Width;
|
||||
double height = rectangleOptions.Rectangle.Height;
|
||||
double ndmMaxSize = rectangleOptions.NdmMaxSize;
|
||||
int ndmMinDivision = rectangleOptions.NdmMinDivision;
|
||||
double width = options.Rectangle.Width;
|
||||
double height = options.Rectangle.Height;
|
||||
double ndmMaxSize = options.NdmMaxSize;
|
||||
int ndmMinDivision = options.NdmMinDivision;
|
||||
LoaderCalculator.Triangulations.RectangleTriangulationLogicOptions logicOptions = new LoaderCalculator.Triangulations.RectangleTriangulationLogicOptions(width, height, ndmMaxSize, ndmMinDivision);
|
||||
var logic = LoaderCalculator.Triangulations.Triangulation.GetLogicInstance(logicOptions);
|
||||
var ndmCollection = logic.GetNdmCollection(new LoaderCalculator.Data.Planes.RectangularPlane { Material = material });
|
||||
double dX = rectangleOptions.Center.X;
|
||||
double dY = rectangleOptions.Center.Y;
|
||||
NdmTransform.Move(ndmCollection, dX, dY);
|
||||
double angle = rectangleOptions.Rectangle.Angle;
|
||||
TriangulationService.CommonTransform(ndmCollection, options);
|
||||
double angle = options.Rectangle.Angle;
|
||||
NdmTransform.Rotate(ndmCollection, angle);
|
||||
NdmTransform.SetPrestrain(ndmCollection, new StrainMatrix() { Kx = Options.PrestrainKx, Ky = Options.PrestrainKy, EpsZ = Options.PrestrainEpsZ });
|
||||
TriangulationService.SetPrestrain(ndmCollection, options.Prestrain);
|
||||
return ndmCollection;
|
||||
}
|
||||
|
||||
public void ValidateOptions(ITriangulationLogicOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (options is not IRectangleTriangulationLogicOptions)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\n Expected: {nameof(IRectangleTriangulationLogicOptions)}, But was: {nameof(options)}");
|
||||
}
|
||||
}
|
||||
|
||||
public RectangleTriangulationLogic(ITriangulationLogicOptions options)
|
||||
{
|
||||
ValidateOptions(options);
|
||||
this.options = options as IRectangleTriangulationLogicOptions;
|
||||
Options = options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
@@ -19,11 +20,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
/// <inheritdoc />
|
||||
public int NdmMinDivision { get; }
|
||||
/// <inheritdoc />
|
||||
public double PrestrainKx { get;}
|
||||
/// <inheritdoc />
|
||||
public double PrestrainKy { get; }
|
||||
/// <inheritdoc />
|
||||
public double PrestrainEpsZ { get;}
|
||||
public IStrainTuple Prestrain { get; set; }
|
||||
|
||||
public RectangleTriangulationLogicOptions(IPoint2D center, IRectangleShape rectangle, double ndmMaxSize, int ndmMinDivision)
|
||||
{
|
||||
@@ -31,6 +28,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
Rectangle = rectangle;
|
||||
NdmMaxSize = ndmMaxSize;
|
||||
NdmMinDivision = ndmMinDivision;
|
||||
Prestrain = new StrainTuple();
|
||||
}
|
||||
|
||||
public RectangleTriangulationLogicOptions(IRectanglePrimitive primitive)
|
||||
@@ -39,9 +37,12 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
Rectangle = primitive;
|
||||
NdmMaxSize = primitive.NdmMaxSize;
|
||||
NdmMinDivision = primitive.NdmMinDivision;
|
||||
PrestrainKx = primitive.UsersPrestrain.Kx + primitive.AutoPrestrain.Kx;
|
||||
PrestrainKy = primitive.UsersPrestrain.Ky + primitive.AutoPrestrain.Ky;
|
||||
PrestrainEpsZ = primitive.UsersPrestrain.EpsZ + primitive.AutoPrestrain.EpsZ;
|
||||
Prestrain = new StrainTuple
|
||||
{
|
||||
Kx = primitive.UsersPrestrain.Kx + primitive.AutoPrestrain.Kx,
|
||||
Ky = primitive.UsersPrestrain.Ky + primitive.AutoPrestrain.Ky,
|
||||
EpsZ = primitive.UsersPrestrain.EpsZ + primitive.AutoPrestrain.EpsZ
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using LoaderCalculator.Data.Ndms.Transformations;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.Design.AxImporter;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
internal static class TriangulationService
|
||||
{
|
||||
public static void SetPrestrain(IEnumerable<INdm> ndmCollection, IStrainTuple strainTuple)
|
||||
{
|
||||
NdmTransform.SetPrestrain(ndmCollection, new StrainMatrix() { Kx = strainTuple.Kx, Ky = strainTuple.Kx, EpsZ = strainTuple.Kx });
|
||||
}
|
||||
|
||||
public static void CommonTransform(IEnumerable<INdm> ndmCollection, IShapeTriangulationLogicOptions options)
|
||||
{
|
||||
double dX = options.Center.X;
|
||||
double dY = options.Center.Y;
|
||||
NdmTransform.Move(ndmCollection, dX, dY);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user