CrackedCalculator and TriangulationLogic were changed
This commit is contained in:
@@ -21,11 +21,18 @@ namespace StructureHelperLogics.Services.NdmCalculations
|
||||
public class CalculationService
|
||||
{
|
||||
private ICalculationProperty calculationProperty;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
public IStrainMatrix GetPrimitiveStrainMatrix(INdmPrimitive[] ndmPrimitives, double mx, double my, double nz)
|
||||
{
|
||||
var ndmCollection = new List<INdm>();
|
||||
ndmCollection.AddRange(NdmPrimitivesService.GetNdms(ndmPrimitives, calculationProperty.LimitState, calculationProperty.CalcTerm));
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = calculationProperty.LimitState,
|
||||
CalcTerm = calculationProperty.CalcTerm
|
||||
};
|
||||
ndmCollection.AddRange(triangulateLogic.GetNdms());
|
||||
var loaderData = new LoaderOptions
|
||||
{
|
||||
Preconditions = new Preconditions
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
{
|
||||
public interface ITriangulatePrimitiveLogic : ILogic
|
||||
{
|
||||
IEnumerable<INdmPrimitive> Primitives { get; set; }
|
||||
LimitStates LimitState { get; set; }
|
||||
CalcTerms CalcTerm { get; set; }
|
||||
List<INdm> GetNdms();
|
||||
bool CheckPrimitives(IEnumerable<INdmPrimitive> primitives);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
|
||||
namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
{
|
||||
public static class NdmPrimitivesService
|
||||
{
|
||||
public static List<INdm> GetNdms(IEnumerable<INdmPrimitive> primitives, LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
var orderedNdmPrimitives = primitives.OrderBy(x => x.VisualProperty.ZIndex);
|
||||
var ndms = new List<INdm>();
|
||||
var triangulationOptions = new TriangulationOptions() { LimiteState = limitState, CalcTerm = calcTerm };
|
||||
foreach (var item in orderedNdmPrimitives)
|
||||
{
|
||||
if (item is IHasDivisionSize)
|
||||
{
|
||||
var hasDivision = item as IHasDivisionSize;
|
||||
if (hasDivision.ClearUnderlying == true)
|
||||
{
|
||||
ndms.RemoveAll(x => hasDivision.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true);
|
||||
}
|
||||
}
|
||||
if (item.Triangulate == true)
|
||||
{
|
||||
ndms.AddRange(item.GetNdms(triangulationOptions));
|
||||
}
|
||||
}
|
||||
return ndms;
|
||||
}
|
||||
|
||||
public static bool CheckPrimitives(IEnumerable<INdmPrimitive> primitives)
|
||||
{
|
||||
if (!primitives.Any())
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero");
|
||||
}
|
||||
if (!primitives.Any(x => x.Triangulate == true))
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate");
|
||||
}
|
||||
foreach (var item in primitives)
|
||||
{
|
||||
if (item.Triangulate == true &
|
||||
item.HeadMaterial is null)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
|
||||
namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
{
|
||||
public class TriangulatePrimitiveLogic : ITriangulatePrimitiveLogic
|
||||
{
|
||||
private List<INdm> ndmCollection;
|
||||
|
||||
public IEnumerable<INdmPrimitive> Primitives { get; set; }
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
public bool ConsiderCracking { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public TriangulatePrimitiveLogic()
|
||||
{
|
||||
ConsiderCracking = false;
|
||||
}
|
||||
public List<INdm> GetNdms()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Total count of primitives n = {Primitives.Count()}", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Limit state is {LimitState}", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Calc term is {CalcTerm}", TraceLogStatuses.Service);
|
||||
var orderedNdmPrimitives = Primitives.OrderBy(x => x.VisualProperty.ZIndex);
|
||||
ndmCollection = new List<INdm>();
|
||||
foreach (var item in orderedNdmPrimitives)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Triangulation of primitive {item.Name} has started", TraceLogStatuses.Service);
|
||||
ProcessHasDivision(item);
|
||||
TriangulatePrimitive(item);
|
||||
}
|
||||
if (TraceLogger is not null)
|
||||
{
|
||||
TraceService.TraceNdmCollection(TraceLogger, ndmCollection);
|
||||
}
|
||||
return ndmCollection;
|
||||
}
|
||||
|
||||
private void TriangulatePrimitive(INdmPrimitive item)
|
||||
{
|
||||
if (item.Triangulate == true)
|
||||
{
|
||||
var triangulationOptions = new TriangulationOptions()
|
||||
{
|
||||
LimiteState = LimitState,
|
||||
CalcTerm = CalcTerm
|
||||
};
|
||||
var itemNdms = item.GetNdms(triangulationOptions);
|
||||
ndmCollection.AddRange(itemNdms);
|
||||
TraceLogger?.AddMessage($"Triangulation of primitive {item.Name} was finished, {itemNdms.Count()} part(s) were obtained", TraceLogStatuses.Service);
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceLogger?.AddMessage($"Triangulation of primitive was skiped cause its settings", TraceLogStatuses.Service);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessHasDivision(INdmPrimitive? item)
|
||||
{
|
||||
if (item is IHasDivisionSize hasDivision)
|
||||
{
|
||||
if (hasDivision.ClearUnderlying == true)
|
||||
{
|
||||
TraceLogger?.AddMessage("Removing of background part has started", TraceLogStatuses.Service);
|
||||
ndmCollection
|
||||
.RemoveAll(x =>
|
||||
hasDivision
|
||||
.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckPrimitives(IEnumerable<INdmPrimitive> primitives)
|
||||
{
|
||||
if (!primitives.Any())
|
||||
{
|
||||
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
if (!primitives.Any(x => x.Triangulate == true))
|
||||
{
|
||||
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
foreach (var item in primitives)
|
||||
{
|
||||
if (item.Triangulate == true &
|
||||
item.HeadMaterial is null)
|
||||
{
|
||||
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user