Limit curve vindow was changed
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
||||
{
|
||||
public class GetPredicateLogic : IGetPredicateLogic
|
||||
{
|
||||
public IEnumerable<INdm> Ndms { get; set; }
|
||||
public PredicateTypes PredicateType { get; set; }
|
||||
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
|
||||
|
||||
public Predicate<IPoint2D> GetPredicate()
|
||||
{
|
||||
var factory = new PredicateFactory()
|
||||
{
|
||||
Ndms = Ndms,
|
||||
ConvertLogic = ConvertLogic
|
||||
};
|
||||
var predicateType = PredicateType;
|
||||
var predicate = factory.GetPredicate(predicateType);
|
||||
return predicate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
||||
{
|
||||
public interface IGetPredicateLogic
|
||||
{
|
||||
Predicate<IPoint2D> GetPredicate();
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
public interface ILimitCurveParameterLogic : IHasActionByResult
|
||||
public interface ILimitCurveParameterLogic : IHasActionByResult, ICloneable
|
||||
{
|
||||
Predicate<Point2D> LimitPredicate { get; set; }
|
||||
IPoint2D CurrentPoint { get; set; }
|
||||
double GetParameter();
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
SurroundProcLogic = new RectSurroundProc();
|
||||
}
|
||||
|
||||
public LimitCurveCalculator(Predicate<IPoint2D> limitPredicate)
|
||||
: this(new LimitCurveLogic(limitPredicate))
|
||||
public LimitCurveCalculator(ILimitCurveParameterLogic parameterLogic)
|
||||
: this(new LimitCurveLogic(parameterLogic))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
||||
|
||||
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
@@ -10,37 +11,41 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
private FindParameterResult result;
|
||||
private List<IPoint2D> resultList;
|
||||
private IPoint2D currentPoint;
|
||||
private ILimitCurveParameterLogic parameterLogic;
|
||||
public Predicate<IPoint2D> LimitPredicate { get; set; }
|
||||
private int pointCount;
|
||||
public ILimitCurveParameterLogic ParameterLogic { get; set; }
|
||||
public IGetPredicateLogic GetPredicateLogic { get; private set; }
|
||||
|
||||
private object lockObject = new object();
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
|
||||
public LimitCurveLogic(ILimitCurveParameterLogic parameterLogic)
|
||||
{
|
||||
this.parameterLogic = parameterLogic;
|
||||
ParameterLogic = parameterLogic;
|
||||
}
|
||||
public LimitCurveLogic(Predicate<IPoint2D> limitPredicate) : this (new LimitCurveParameterLogic(limitPredicate))
|
||||
public LimitCurveLogic(IGetPredicateLogic getPredicateLogic)
|
||||
{
|
||||
LimitPredicate = limitPredicate;
|
||||
ParameterLogic = new LimitCurveParameterLogic();
|
||||
GetPredicateLogic = getPredicateLogic;
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
result = new();
|
||||
resultList = new();
|
||||
if (LimitPredicate(new Point2D()) == true)
|
||||
Predicate<IPoint2D> limitPredicate = GetPredicateLogic.GetPredicate();
|
||||
if (limitPredicate(new Point2D()) == true)
|
||||
{
|
||||
var range = points.Select(point => new Point2D { X = point.X * 0d, Y = point.Y * 0d }).ToList();
|
||||
resultList.AddRange(range);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
//MultyProcessPoints(points);
|
||||
MonoProcessPoints(points);
|
||||
pointCount = 0;
|
||||
MultyThreadProc(points);
|
||||
//MonoThreadProc(points);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private void MultyProcessPoints(IEnumerable<IPoint2D> points)
|
||||
private void MultyThreadProc(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
Task<IPoint2D>[] tasks = new Task<IPoint2D>[points.Count()];
|
||||
for (int i = 0; i < points.Count(); i++)
|
||||
@@ -54,12 +59,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
var taskResult = tasks[j].Result;
|
||||
resultList.Add(taskResult);
|
||||
result.IterationNumber = resultList.Count;
|
||||
ActionToOutputResults?.Invoke(result);
|
||||
}
|
||||
}
|
||||
|
||||
private void MonoProcessPoints(IEnumerable<IPoint2D> points)
|
||||
private void MonoThreadProc(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
foreach (var point in points)
|
||||
{
|
||||
@@ -71,29 +75,49 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
IPoint2D resultPoint = FindResultPoint(point);
|
||||
resultList.Add(resultPoint);
|
||||
result.IterationNumber = resultList.Count;
|
||||
lock (lockObject)
|
||||
{
|
||||
pointCount++;
|
||||
}
|
||||
result.IterationNumber = pointCount;
|
||||
ActionToOutputResults?.Invoke(result);
|
||||
}
|
||||
|
||||
private Point2D FindResultPoint(IPoint2D point)
|
||||
{
|
||||
double parameter;
|
||||
currentPoint = point.Clone() as IPoint2D;
|
||||
parameterLogic.CurrentPoint = currentPoint;
|
||||
if (LimitPredicate(point) == false)
|
||||
var locCurrentPoint = point.Clone() as IPoint2D;
|
||||
Predicate<IPoint2D> limitPredicate;
|
||||
lock (lockObject)
|
||||
{
|
||||
limitPredicate = GetPredicateLogic.GetPredicate();
|
||||
}
|
||||
var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic;
|
||||
logic.CurrentPoint = locCurrentPoint;
|
||||
logic.LimitPredicate = limitPredicate;
|
||||
|
||||
if (limitPredicate(locCurrentPoint) == false)
|
||||
{
|
||||
parameter = 1d;
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter = parameterLogic.GetParameter();
|
||||
parameter = logic.GetParameter();
|
||||
}
|
||||
|
||||
var resultPoint = new Point2D()
|
||||
{
|
||||
X = currentPoint.X * parameter,
|
||||
Y = currentPoint.Y * parameter
|
||||
X = locCurrentPoint.X * parameter,
|
||||
Y = locCurrentPoint.Y * parameter
|
||||
};
|
||||
lock (lockObject)
|
||||
{
|
||||
pointCount++;
|
||||
}
|
||||
result.IterationNumber = pointCount;
|
||||
ActionToOutputResults?.Invoke(result);
|
||||
return resultPoint;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public class LimitCurveParameterLogic : ILimitCurveParameterLogic
|
||||
{
|
||||
private FindParameterResult result;
|
||||
private Predicate<Point2D> limitPredicate;
|
||||
public Predicate<Point2D> LimitPredicate { get; set; }
|
||||
public IPoint2D CurrentPoint { get; set; }
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
|
||||
public LimitCurveParameterLogic(Predicate<Point2D> limitPredicate)
|
||||
public LimitCurveParameterLogic()
|
||||
{
|
||||
this.limitPredicate = limitPredicate;
|
||||
|
||||
}
|
||||
|
||||
public double GetParameter()
|
||||
@@ -49,7 +49,16 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
private bool GetFactorPredicate(double factor)
|
||||
{
|
||||
var newPoint = new Point2D() { X = CurrentPoint.X * factor, Y = CurrentPoint.Y * factor };
|
||||
return limitPredicate(newPoint);
|
||||
return LimitPredicate(newPoint);
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newItem = new LimitCurveParameterLogic();
|
||||
newItem.LimitPredicate = LimitPredicate;
|
||||
newItem.CurrentPoint = (CurrentPoint ?? new Point2D()).Clone() as IPoint2D;
|
||||
newItem.ActionToOutputResults = ActionToOutputResults;
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationsResults;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -71,7 +72,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
|
||||
foreach (var predicateEntry in InputData.PredicateEntries)
|
||||
{
|
||||
string calcName = $"{predicateEntry.Name}_{limitState}_{calcTerm}";
|
||||
LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry, calcName);
|
||||
LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry.PredicateType, calcName);
|
||||
calculators.Add(calculator);
|
||||
}
|
||||
}
|
||||
@@ -79,18 +80,21 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
|
||||
return calculators;
|
||||
}
|
||||
|
||||
private LimitCurveCalculator GetCalculator(List<INdm> ndms, PredicateEntry predicateEntry, string calcName)
|
||||
private LimitCurveCalculator GetCalculator(List<INdm> ndms, PredicateTypes predicateType, string calcName)
|
||||
{
|
||||
var factory = new PredicateFactory()
|
||||
{
|
||||
Ndms = ndms,
|
||||
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic
|
||||
};
|
||||
var predicateType = predicateEntry.PredicateType;
|
||||
var predicate = factory.GetPredicate(predicateType);
|
||||
//Predicate<IPoint2D> predicate = factory.IsSectionCracked;
|
||||
var logic = new LimitCurveLogic(predicate);
|
||||
//var logic = new StabLimitCurveLogic();
|
||||
var getPredicateLogic = new GetPredicateLogic()
|
||||
{
|
||||
Ndms = ndms,
|
||||
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic,
|
||||
PredicateType = predicateType
|
||||
};
|
||||
var logic = new LimitCurveLogic(getPredicateLogic);
|
||||
var calculator = new LimitCurveCalculator(logic)
|
||||
{
|
||||
Name = calcName,
|
||||
|
||||
Reference in New Issue
Block a user