CrossSection view model was improved
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
@@ -10,7 +11,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Fac
|
||||
public PredicateTypes PredicateType { get; set; }
|
||||
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
|
||||
public string Name { get; set; }
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Predicate<IPoint2D> GetPredicate()
|
||||
{
|
||||
@@ -19,6 +25,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Fac
|
||||
Ndms = Ndms,
|
||||
ConvertLogic = ConvertLogic
|
||||
};
|
||||
if (TraceLogger is not null)
|
||||
{
|
||||
factory.TraceLogger = TraceLogger;
|
||||
}
|
||||
TraceLogger?.AddMessage($"Predicate factory was obtained succsefully", TraceLogStatuses.Debug);
|
||||
var predicateType = PredicateType;
|
||||
var predicate = factory.GetPredicate(predicateType);
|
||||
return predicate;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
||||
{
|
||||
public interface IGetPredicateLogic
|
||||
public interface IGetPredicateLogic : ILogic, ICloneable
|
||||
{
|
||||
string Name { get; set; }
|
||||
Predicate<IPoint2D> GetPredicate();
|
||||
ITraceLogger? TraceLogger { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using LoaderCalculator;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
@@ -14,13 +17,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
Strength,
|
||||
Cracking
|
||||
}
|
||||
public class PredicateFactory
|
||||
public class PredicateFactory : ILogic
|
||||
{
|
||||
private ForceTupleCalculator calculator;
|
||||
private ForceTuple tuple;
|
||||
private ForceTupleInputData inputData;
|
||||
private IShiftTraceLogger logger;
|
||||
|
||||
public IEnumerable<INdm> Ndms { get; set; }
|
||||
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public PredicateFactory()
|
||||
{
|
||||
inputData = new();
|
||||
@@ -28,6 +35,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
}
|
||||
public Predicate<IPoint2D> GetPredicate(PredicateTypes predicateType)
|
||||
{
|
||||
if (TraceLogger is not null)
|
||||
{
|
||||
logger = new ShiftTraceLogger() { ShiftPriority = 500, KeepErrorStatus = false };
|
||||
//calculator.TraceLogger = logger; // too much results
|
||||
//ConvertLogic.TraceLogger = logger; //wrong work in different threads
|
||||
}
|
||||
if (predicateType == PredicateTypes.Strength)
|
||||
{
|
||||
return point2D => IsSectionFailure(point2D);
|
||||
@@ -44,6 +57,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
|
||||
private bool IsSectionFailure(IPoint2D point2D)
|
||||
{
|
||||
logger?.TraceLoggerEntries.Clear();
|
||||
var point3D = ConvertLogic.GetPoint3D(point2D);
|
||||
tuple = new()
|
||||
{
|
||||
@@ -54,12 +68,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
inputData.Tuple = tuple;
|
||||
inputData.NdmCollection = Ndms;
|
||||
calculator.Run();
|
||||
if (logger is not null)
|
||||
{
|
||||
TraceLogger?.TraceLoggerEntries.AddRange(logger.TraceLoggerEntries);
|
||||
}
|
||||
var result = calculator.Result;
|
||||
return !result.IsValid;
|
||||
}
|
||||
|
||||
private bool IsSectionCracked(IPoint2D point2D)
|
||||
{
|
||||
logger?.TraceLoggerEntries.Clear();
|
||||
var logic = new HoleSectionCrackedLogic();
|
||||
var point3D = ConvertLogic.GetPoint3D(point2D);
|
||||
tuple = new()
|
||||
@@ -72,6 +91,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
logic.NdmCollection = Ndms;
|
||||
try
|
||||
{
|
||||
if (logger is not null)
|
||||
{
|
||||
TraceLogger?.TraceLoggerEntries.AddRange(logger.TraceLoggerEntries);
|
||||
}
|
||||
var result = logic.IsSectionCracked();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
/// <inheritdoc/>
|
||||
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
if (TraceLogger is not null) { ParameterLogic.TraceLogger = TraceLogger; }
|
||||
if (TraceLogger is not null)
|
||||
{
|
||||
ParameterLogic.TraceLogger = TraceLogger;
|
||||
}
|
||||
result = new();
|
||||
resultList = new();
|
||||
TraceLogger?.AddMessage($"Predicate name is {GetPredicateLogic.Name}");
|
||||
@@ -74,12 +77,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
|
||||
private Point2D FindResultPoint(IPoint2D point)
|
||||
{
|
||||
Predicate<IPoint2D> limitPredicate;
|
||||
lock (lockObject)
|
||||
{
|
||||
limitPredicate = GetPredicateLogic.GetPredicate();
|
||||
}
|
||||
var resultPoint = FindResultPointByPredicate(point, limitPredicate);
|
||||
var resultPoint = FindResultPointByPredicate(point);
|
||||
lock (lockObject)
|
||||
{
|
||||
pointCount++;
|
||||
@@ -89,14 +87,23 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
return resultPoint;
|
||||
}
|
||||
|
||||
private Point2D FindResultPointByPredicate(IPoint2D point, Predicate<IPoint2D> limitPredicate)
|
||||
private Point2D FindResultPointByPredicate(IPoint2D point)
|
||||
{
|
||||
ShiftTraceLogger newLogger;
|
||||
Predicate<IPoint2D> limitPredicate;
|
||||
|
||||
lock (lockObject)
|
||||
{
|
||||
newLogger = new ShiftTraceLogger()
|
||||
{
|
||||
ShiftPriority = 100
|
||||
};
|
||||
GetPredicateLogic.TraceLogger = newLogger;
|
||||
limitPredicate = GetPredicateLogic.GetPredicate();
|
||||
}
|
||||
var localCurrentPoint = point.Clone() as IPoint2D;
|
||||
var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic;
|
||||
logic.TraceLogger = new ShiftTraceLogger()
|
||||
{
|
||||
ShiftPriority=100
|
||||
};
|
||||
logic.TraceLogger = newLogger;
|
||||
logic.CurrentPoint = localCurrentPoint;
|
||||
logic.LimitPredicate = limitPredicate;
|
||||
double parameter;
|
||||
@@ -119,7 +126,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
TraceLogger?.AddMessage($"Source point");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(localCurrentPoint));
|
||||
TraceLogger?.TraceLoggerEntries.AddRange(logic.TraceLogger.TraceLoggerEntries);
|
||||
TraceLogger?.TraceLoggerEntries.AddRange(newLogger.TraceLoggerEntries);
|
||||
TraceLogger?.AddMessage($"Parameter value {parameter} was obtained");
|
||||
TraceLogger?.AddMessage($"Calculated point\n(X={localCurrentPoint.X} * {parameter} = {resultPoint.X},\nY={localCurrentPoint.Y} * {parameter} = {resultPoint.Y})");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory(TraceLogStatuses.Info).GetByPoint2D(resultPoint));
|
||||
|
||||
@@ -106,7 +106,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic,
|
||||
PredicateType = predicateType
|
||||
};
|
||||
if (TraceLogger is not null) { getPredicateLogic.TraceLogger = TraceLogger; }
|
||||
if (TraceLogger is not null)
|
||||
{
|
||||
//getPredicateLogic.TraceLogger = TraceLogger;
|
||||
}
|
||||
var logic = new LimitCurveLogic(getPredicateLogic);
|
||||
var calculator = new LimitCurveCalculator(logic)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user