Icons for force result were added

This commit is contained in:
Evgeny Redikultsev
2023-11-26 20:33:48 +05:00
parent b4b1720c70
commit 01e6f97429
41 changed files with 678 additions and 273 deletions

View File

@@ -1,16 +1,8 @@
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.SourceData;
using LoaderCalculator;
using StructureHelperCommon.Models.Calculators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using LoaderCalculator;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.ResultData;
using System.Windows;
using LoaderCalculator.Data.SourceData;
using StructureHelperCommon.Models.Calculators;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{

View File

@@ -0,0 +1,14 @@
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
{
public interface ILimitCurveLogic
{
List<IPoint2D> GetPoints(List<IPoint2D> points);
}
}

View File

@@ -0,0 +1,15 @@
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
{
public interface ILimitCurveParameterLogic
{
IPoint2D CurrentPoint { get; set; }
double GetParameter();
}
}

View File

@@ -0,0 +1,15 @@
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
{
public interface ISurroundProc
{
SurroundData SurroundData { get; set; }
List<IPoint2D> GetPoints();
}
}

View File

@@ -0,0 +1,63 @@
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class LimitCurveCalculator : ICalculator
{
private LimitCurveResult result;
private List<IPoint2D> surroundList;
private List<IPoint2D> factoredList;
private ILimitCurveLogic limitCurveLogic;
public string Name { get; set; }
public SurroundData SurroundData { get; set; }
public ISurroundProc SurroundProcLogic { get; set; }
public IResult Result => result;
public Action<IResult> ActionToOutputResults { get; set; }
public LimitCurveCalculator(ILimitCurveLogic limitCurveLogic)
{
this.limitCurveLogic = limitCurveLogic;
SurroundData = new();
//SurroundProcLogic = new RoundSurroundProc();
SurroundProcLogic = new RectSurroundProc();
}
public LimitCurveCalculator(Predicate<IPoint2D> limitPredicate)
: this(new LimitCurveLogic(limitPredicate))
{
}
public object Clone()
{
throw new NotImplementedException();
}
public void Run()
{
result = new LimitCurveResult();
result.IsValid = true;
SurroundProcLogic.SurroundData = SurroundData;
surroundList = SurroundProcLogic.GetPoints();
try
{
factoredList = limitCurveLogic.GetPoints(surroundList);
result.Points = factoredList;
}
catch (Exception ex)
{
result.IsValid = false;
result.Description = ex.Message;
}
}
}
}

View File

@@ -0,0 +1,55 @@
using StructureHelperCommon.Infrastructures.Exceptions;
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
{
public class LimitCurveLogic : ILimitCurveLogic
{
private IPoint2D currentPoint;
private ILimitCurveParameterLogic parameterLogic;
public Predicate<IPoint2D> LimitPredicate { get; set; }
public LimitCurveLogic(ILimitCurveParameterLogic parameterLogic)
{
this.parameterLogic = parameterLogic;
}
public LimitCurveLogic(Predicate<IPoint2D> limitPredicate) : this (new LimitCurveParameterLogic(limitPredicate))
{
LimitPredicate = limitPredicate;
}
public List<IPoint2D> GetPoints(List<IPoint2D> points)
{
List<IPoint2D> resultList = new();
if (LimitPredicate(new Point2D()) == true)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": predicate for zero value is not valid");
}
foreach (var point in points)
{
double parameter;
currentPoint = point.Clone() as IPoint2D;
parameterLogic.CurrentPoint = currentPoint;
if (LimitPredicate(point) == false)
{
parameter = 1d;
}
else
{
parameter = parameterLogic.GetParameter();
}
var resultPoint = new Point2D()
{
X = currentPoint.X * parameter,
Y = currentPoint.Y * parameter
};
resultList.Add(resultPoint);
}
return resultList;
}
}
}

View File

@@ -0,0 +1,45 @@
using StructureHelperCommon.Infrastructures.Exceptions;
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
{
public class LimitCurveParameterLogic : ILimitCurveParameterLogic
{
private Predicate<Point2D> limitPredicate;
public IPoint2D CurrentPoint { get; set; }
public LimitCurveParameterLogic(Predicate<Point2D> limitPredicate)
{
this.limitPredicate = limitPredicate;
}
public double GetParameter()
{
var parameterCalculator = new FindParameterCalculator()
{
Predicate = GetFactorPredicate,
};
parameterCalculator.Accuracy.IterationAccuracy = 0.001d;
parameterCalculator.Run();
if (parameterCalculator.Result.IsValid == false)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": predicate for point (x={CurrentPoint.X}, y={CurrentPoint.Y}) is not valid");
}
var result = parameterCalculator.Result as FindParameterResult;
var parameter = result.Parameter;
return parameter;
}
private bool GetFactorPredicate(double factor)
{
var newPoint = new Point2D() { X = CurrentPoint.X * factor, Y = CurrentPoint.Y * factor };
return limitPredicate(newPoint);
}
}
}

View File

@@ -0,0 +1,21 @@
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
{
public class LimitCurveResult : IResult
{
public bool IsValid { get; set; }
public string Description { get; set; }
public List<IPoint2D> Points { get; set; }
public LimitCurveResult()
{
Points = new List<IPoint2D>();
}
}
}

View File

@@ -0,0 +1,28 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
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
{
public class PredicateFactory
{
public IEnumerable<INdm> Ndms { get; set; }
public double My { get; set; }
public bool GetResult(IPoint2D point)
{
var calculator = new ForceTupleCalculator();
var tuple = new ForceTuple() { Nz = point.Y, Mx = point.X, My = My };
var inputData = new ForceTupleInputData() { Tuple = tuple, NdmCollection = Ndms };
calculator.InputData = inputData;
calculator.Run();
var result = calculator.Result;
return !result.IsValid;
}
}
}

View File

@@ -0,0 +1,53 @@
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
{
public class RectSurroundProc : ISurroundProc
{
private List<IPoint2D> surroundList;
public SurroundData SurroundData { get; set; }
public List<IPoint2D> GetPoints()
{
var xRadius = (SurroundData.XMax - SurroundData.XMin) / 2;
var yRadius = (SurroundData.YMax - SurroundData.YMin) / 2;
surroundList = new();
var pointCount = Convert.ToInt32(Math.Ceiling(SurroundData.PointCount / 8d));
double xStep = xRadius / pointCount;
double yStep = yRadius / pointCount;
double x, y;
x = SurroundData.XMax;
for (int i = 0; i < pointCount * 2; i++)
{
y = SurroundData.YMin + yStep * i;
surroundList.Add(new Point2D() { X = x, Y = y });
}
y = SurroundData.YMax;
for (int i = 0; i < pointCount * 2; i++)
{
x = SurroundData.XMax - xStep * i;
surroundList.Add(new Point2D() { X = x, Y = y });
}
x = SurroundData.XMin;
for (int i = 0; i < pointCount * 2; i++)
{
y = SurroundData.YMax - yStep * i;
surroundList.Add(new Point2D() { X = x, Y = y });
}
y = SurroundData.YMin;
for (int i = 0; i < pointCount * 2; i++)
{
x = SurroundData.XMin + xStep * i;
surroundList.Add(new Point2D() { X = x, Y = y });
}
surroundList.Add(surroundList[0].Clone() as IPoint2D);
return surroundList;
}
}
}

View File

@@ -0,0 +1,41 @@
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
{
public class RoundSurroundProc : ISurroundProc
{
private List<IPoint2D> surroundList;
public SurroundData SurroundData { get; set; }
public RoundSurroundProc()
{
SurroundData = new();
}
public List<IPoint2D> GetPoints()
{
var xRadius = (SurroundData.XMax - SurroundData.XMin) / 2;
var yRadius = (SurroundData.YMax - SurroundData.YMin) / 2;
var xCenter = (SurroundData.XMax + SurroundData.XMin) / 2;
var yCenter = (SurroundData.YMax + SurroundData.YMin) / 2;
surroundList = new();
var pointCount = Convert.ToInt32(Math.Ceiling(SurroundData.PointCount / 4d) * 4d);
double angleStep = 2d * Math.PI / pointCount;
double angle;
for (int i = 0; i < pointCount; i++)
{
double x, y;
angle = angleStep * i;
x = xRadius * Math.Cos(angle) + xCenter;
y = yRadius * Math.Sin(angle) + yCenter;
surroundList.Add(new Point2D() { X = x, Y = y });
}
surroundList.Add(surroundList[0].Clone() as IPoint2D);
return surroundList;
}
}
}

View File

@@ -0,0 +1,22 @@
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
{
public class StabLimitCurveLogic : ILimitCurveLogic
{
public List<IPoint2D> GetPoints(List<IPoint2D> points)
{
var result = new List<IPoint2D>();
foreach (var item in points)
{
result.Add(new Point2D() { X = item.X * 0.5d, Y = item.Y * 0.5d });
}
return result;
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class SurroundData
{
public double XMax { get; set; }
public double XMin { get; set; }
public double YMax { get; set; }
public double YMin { get; set; }
public int PointCount { get; set; }
}
}