Value point graph was added

This commit is contained in:
Evgeny Redikultsev
2024-03-16 21:46:24 +05:00
parent b81b7a0929
commit f2f6840ffb
28 changed files with 383 additions and 107 deletions

View File

@@ -0,0 +1,60 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
public class DiagramFactory
{
private ArrayParameter<double> arrayParameter;
public List<IForcesTupleResult> TupleList { get; set; }
public Action<int> SetProgress { get; set; }
public ArrayParameter<double> GetCommonArray()
{
var labels = LabelsFactory.GetCommonLabels();
arrayParameter = new ArrayParameter<double>(TupleList.Count(), labels);
Calculate();
return arrayParameter;
}
private void Calculate()
{
var data = arrayParameter.Data;
for (int i = 0; i < TupleList.Count(); i++)
{
var valueList = ProcessResult(i);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
SetProgress?.Invoke(i);
}
}
private List<double> ProcessResult(int i)
{
var unitForce = CommonOperation.GetUnit(UnitTypes.Force);
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment);
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature);
return new List<double>
{
TupleList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
TupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
TupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
TupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
TupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
TupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
};
}
}
}

View File

@@ -58,9 +58,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
validTupleList = tupleList.Where(x => x.IsValid == true).ToList();
var labels = LabelsFactory.GetCommonLabels();
arrayParameter = new ArrayParameter<double>(validTupleList.Count(), labels);
Calculate();
var factory = new DiagramFactory()
{
TupleList = validTupleList,
SetProgress = SetProgress,
};
arrayParameter = factory.GetCommonArray();
}
public ShowDiagramLogic(IEnumerable<IForcesTupleResult> tupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
@@ -69,37 +72,5 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
this.ndmPrimitives = ndmPrimitives;
validTupleList = tupleList.Where(x => x.IsValid == true).ToList();
}
private void Calculate()
{
var data = arrayParameter.Data;
for (int i = 0; i < validTupleList.Count(); i++)
{
var valueList = ProcessResult(i);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
SetProgress?.Invoke(i);
}
}
private List<double> ProcessResult(int i)
{
var unitForce = CommonOperation.GetUnit(UnitTypes.Force);
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment);
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature);
return new List<double>
{
validTupleList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
};
}
}
}

View File

@@ -1,4 +1,5 @@
using StructureHelper.Windows.CalculationWindows.ProgressViews;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
@@ -82,8 +83,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
}
catch (Exception ex)
{
throw;
throw new StructureHelperException(ex);
}
}
}

View File

@@ -1,11 +1,14 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using LoaderCalculator.Data.Ndms;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
@@ -25,7 +28,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
private IEnumerable<IForcesTupleResult> tupleList;
private IEnumerable<INdmPrimitive> ndmPrimitives;
private List<IForcesTupleResult> validTupleList;
private List<(PrimitiveBase PrimitiveBase, List<NamedValue<IPoint2D>>)> valuePoints;
private List<(PrimitiveBase PrimitiveBase, List<INamedAreaPoint> namedPoints)> valuePoints;
private List<IResultFunc> resultFuncList;
public ForceCalculator Calculator { get; set; }
@@ -42,8 +45,19 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
this.tupleList = tupleList;
this.ndmPrimitives = ndmPrimitives;
validTupleList = this.tupleList.Where(x => x.IsValid == true).ToList();
valuePoints = new List<(PrimitiveBase PrimitiveBase, List<NamedValue<IPoint2D>>)>();
foreach (var item in PrimitiveLogic.Collection.CollectionItems)
valuePoints = new List<(PrimitiveBase PrimitiveBase, List<INamedAreaPoint>)>();
}
public void SetParameters()
{
var factory = new DiagramFactory()
{
TupleList = validTupleList,
SetProgress = SetProgress,
};
arrayParameter = factory.GetCommonArray();
foreach (var item in PrimitiveLogic.Collection.CollectionItems)
{
var pointsCount = item.Item.ValuePoints.SelectedCount;
if (pointsCount > 0)
@@ -53,7 +67,79 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
valuePoints.Add((primitive, points));
}
}
var selectedDelegates = ValueDelegatesLogic.ResultFuncs.SelectedItems;
if (selectedDelegates.Count() == 0) { return; }
var labels = GetLabels(valuePoints, selectedDelegates);
var pointCount = valuePoints.Sum(x => x.namedPoints.Count());
List<double> values = new();
var tuplesList = tupleList
.Where(x => x.IsValid == true)
.ToList();
var newArray = new ArrayParameter<double>(tuplesList.Count(), labels);
for (int i = 0; i < tuplesList.Count(); i++)
{
var strainMatrix = tuplesList[i].LoaderResults.ForceStrainPair.StrainMatrix;
values.Clear();
foreach (var valuePoint in valuePoints)
{
foreach (var point in valuePoint.namedPoints)
{
var limitState = tuplesList[i].DesignForceTuple.LimitState;
var calcTerm = tuplesList[i].DesignForceTuple.CalcTerm;
var ndm = GetNdm(valuePoint, point, limitState, calcTerm);
foreach (var valDelegate in selectedDelegates)
{
double val = valDelegate.ResultFunction.Invoke(strainMatrix, ndm) * valDelegate.UnitFactor;
values.Add(val);
}
}
}
newArray.AddRow(i, values);
}
arrayParameter.AddArray(newArray);
}
private List<string> GetLabels(List<(PrimitiveBase PrimitiveBase, List<INamedAreaPoint> namedPoints)> valuePoints, IEnumerable<IResultFunc> selectedDelegates)
{
List<string> strings = new();
foreach (var valuePoint in valuePoints)
{
foreach (var item in valuePoint.namedPoints)
{
foreach (var deleg in selectedDelegates)
{
string s = valuePoint.PrimitiveBase.Name;
s += "_" + item.Name;
s += "_" + deleg.Name + ", " + deleg.UnitName;
strings.Add(s);
}
}
}
return strings;
}
private static RebarNdm GetNdm((PrimitiveBase PrimitiveBase, List<INamedAreaPoint> namedPoints) valuePoint, INamedAreaPoint point, LimitStates limitState, CalcTerms calcTerm)
{
var ndmPrimitive = valuePoint.PrimitiveBase.GetNdmPrimitive();
var material = ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
var userPrestrain = ndmPrimitive.UsersPrestrain;
var autoPrestrain = ndmPrimitive.AutoPrestrain;
var ndm = new RebarNdm()
{
Area = point.Area,
CenterX = point.Point.X,
CenterY = point.Point.Y,
Material = material,
};
ndm.Prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * point.Point.Y
+ (userPrestrain.My + autoPrestrain.My) * point.Point.X
+ userPrestrain.Nz + autoPrestrain.Nz;
return ndm;
}
public void ShowWindow()
{
SafetyProcessor.RunSafeProcess(() =>
@@ -89,7 +175,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
private void Show()
{
validTupleList = tupleList.Where(x => x.IsValid == true).ToList();
var factory = new DiagramFactory()
{
TupleList = validTupleList,
SetProgress = SetProgress,
};
arrayParameter = factory.GetCommonArray();
}
private List<string> GetColumnNames()

View File

@@ -152,12 +152,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
get => showGraphsCommand ??= new RelayCommand(o =>
{
InterpolateTuplesViewModel interploateTuplesViewModel;
InterpolateTuplesViewModel interpolateTuplesViewModel;
InterpolateTuplesView wndTuples;
ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples);
ShowInterpolationWindow(out interpolateTuplesViewModel, out wndTuples);
if (wndTuples.DialogResult != true) return;
var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.ForceInterpolationViewModel.Result);
var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interpolateTuplesViewModel.ForceInterpolationViewModel.Result);
showProgressLogic = new(interpolationLogic)
{
WindowTitle = "Interpolate forces"
@@ -298,18 +298,27 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
wnd.ShowDialog();
if (wnd.DialogResult != true) { return; }
var interpolationLogic = new InterpolationProgressLogic(forceCalculator, viewModel.ForceInterpolationViewModel.Result);
ShowValuePointDiagramLogic pointGraphLogic = new(ForcesResults.ForcesResultList, ndmPrimitives)
{
Calculator = interpolationLogic.InterpolateCalculator,
PrimitiveLogic = viewModel.PrimitiveLogic,
ValueDelegatesLogic = viewModel.ValueDelegatesLogic
};
progressLogic = interpolationLogic;
showProgressLogic = new(interpolationLogic)
{
ShowResult = pointGraphLogic.ShowWindow
WindowTitle = "Interpolate forces",
};
showProgressLogic.Show();
var result = interpolationLogic.InterpolateCalculator.Result;
if (result.IsValid == false) { return; }
if (result is IForcesResults)
{
var tupleResult = result as IForcesResults;
var pointGraphLogic = new ShowValuePointDiagramLogic(tupleResult.ForcesResultList, ndmPrimitives)
{
Calculator = interpolationLogic.InterpolateCalculator,
PrimitiveLogic = viewModel.PrimitiveLogic,
ValueDelegatesLogic = viewModel.ValueDelegatesLogic
};
pointGraphLogic.SetParameters();
pointGraphLogic.ShowWindow();
}
}
private void ShowInterpolationWindow(out InterpolateTuplesViewModel interploateTuplesViewModel, out InterpolateTuplesView wndTuples)