diff --git a/StructureHelper.csproj b/StructureHelper.csproj
index d20e7d0..97c4f4d 100644
--- a/StructureHelper.csproj
+++ b/StructureHelper.csproj
@@ -116,6 +116,9 @@
App.xaml
Code
+
+ CalculationPropertyView.xaml
+
ColorPickerView.xaml
@@ -143,6 +146,7 @@
RectangleTemplate.xaml
+
@@ -172,6 +176,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/StructureHelperLogics/Models/Calculations/CalculationProperties/CalculationProperty.cs b/StructureHelperLogics/Models/Calculations/CalculationProperties/CalculationProperty.cs
new file mode 100644
index 0000000..dc18378
--- /dev/null
+++ b/StructureHelperLogics/Models/Calculations/CalculationProperties/CalculationProperty.cs
@@ -0,0 +1,27 @@
+using LoaderCalculator.Data.Matrix;
+using StructureHelperLogics.Infrastructures.CommonEnums;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StructureHelperLogics.Models.Calculations.CalculationProperties
+{
+ public class CalculationProperty : ICalculationProperty
+ {
+ public List ForceCombinations { get; set; }
+ public LimitStates LimitState { get; set; }
+ public CalcTerms CalcTerm { get; set; }
+ public IIterationProperty IterationProperty { get; }
+
+ public CalculationProperty()
+ {
+ ForceCombinations = new List
+ {
+ new ForceCombination()
+ };
+ LimitState = LimitStates.Collapse;
+ CalcTerm = CalcTerms.ShortTerm;
+ IterationProperty = new IterationProperty() { Accuracy = 0.001d, MaxIterationCount = 100};
+ }
+ }
+}
diff --git a/StructureHelperLogics/Models/Calculations/CalculationProperties/ForceCombination.cs b/StructureHelperLogics/Models/Calculations/CalculationProperties/ForceCombination.cs
new file mode 100644
index 0000000..731ddca
--- /dev/null
+++ b/StructureHelperLogics/Models/Calculations/CalculationProperties/ForceCombination.cs
@@ -0,0 +1,19 @@
+using LoaderCalculator.Data.Matrix;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StructureHelperLogics.Models.Calculations.CalculationProperties
+{
+ public class ForceCombination : IForceCombination
+ {
+ public IForceMatrix ForceMatrix { get; private set; }
+ public bool TakeInCalculate { get; set; }
+
+ public ForceCombination()
+ {
+ ForceMatrix = new ForceMatrix() { Mx = 0d, My = 0d, Nz = 0d};
+ TakeInCalculate = true;
+ }
+ }
+}
diff --git a/StructureHelperLogics/Models/Calculations/CalculationProperties/ICalculationProperty.cs b/StructureHelperLogics/Models/Calculations/CalculationProperties/ICalculationProperty.cs
new file mode 100644
index 0000000..15ef710
--- /dev/null
+++ b/StructureHelperLogics/Models/Calculations/CalculationProperties/ICalculationProperty.cs
@@ -0,0 +1,16 @@
+using LoaderCalculator.Data.Matrix;
+using StructureHelperLogics.Infrastructures.CommonEnums;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StructureHelperLogics.Models.Calculations.CalculationProperties
+{
+ public interface ICalculationProperty
+ {
+ List ForceCombinations { get; set; }
+ LimitStates LimitState { get; set; }
+ CalcTerms CalcTerm { get; set; }
+ IIterationProperty IterationProperty {get;}
+ }
+}
diff --git a/StructureHelperLogics/Models/Calculations/CalculationProperties/IForceCombination.cs b/StructureHelperLogics/Models/Calculations/CalculationProperties/IForceCombination.cs
new file mode 100644
index 0000000..edbbc6b
--- /dev/null
+++ b/StructureHelperLogics/Models/Calculations/CalculationProperties/IForceCombination.cs
@@ -0,0 +1,13 @@
+using LoaderCalculator.Data.Matrix;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StructureHelperLogics.Models.Calculations.CalculationProperties
+{
+ public interface IForceCombination
+ {
+ IForceMatrix ForceMatrix { get; }
+ bool TakeInCalculate { get; set; }
+ }
+}
diff --git a/StructureHelperLogics/Models/Calculations/CalculationProperties/IIterationProperty.cs b/StructureHelperLogics/Models/Calculations/CalculationProperties/IIterationProperty.cs
new file mode 100644
index 0000000..05a3023
--- /dev/null
+++ b/StructureHelperLogics/Models/Calculations/CalculationProperties/IIterationProperty.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StructureHelperLogics.Models.Calculations.CalculationProperties
+{
+ public interface IIterationProperty
+ {
+ double Accuracy { get; set; }
+ int MaxIterationCount { get; set; }
+ }
+}
diff --git a/StructureHelperLogics/Models/Calculations/CalculationProperties/IterationProperty.cs b/StructureHelperLogics/Models/Calculations/CalculationProperties/IterationProperty.cs
new file mode 100644
index 0000000..51a99fe
--- /dev/null
+++ b/StructureHelperLogics/Models/Calculations/CalculationProperties/IterationProperty.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StructureHelperLogics.Models.Calculations.CalculationProperties
+{
+ public class IterationProperty : IIterationProperty
+ {
+ public double Accuracy { get; set; }
+ public int MaxIterationCount { get; set; }
+ }
+}
diff --git a/StructureHelperLogics/Models/Calculations/CalculationsResults/CalculationResult.cs b/StructureHelperLogics/Models/Calculations/CalculationsResults/CalculationResult.cs
new file mode 100644
index 0000000..1c0eb99
--- /dev/null
+++ b/StructureHelperLogics/Models/Calculations/CalculationsResults/CalculationResult.cs
@@ -0,0 +1,18 @@
+using LoaderCalculator.Data.ResultData;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StructureHelperLogics.Models.Calculations.CalculationsResults
+{
+ ///
+ class CalculationResult : ICalculationResult
+ {
+ ///
+ public bool IsValid { get; set; }
+ ///
+ public string Desctription { get; set; }
+ ///
+ public ILoaderResults LoaderResults { get; set; }
+ }
+}
diff --git a/StructureHelperLogics/Models/Calculations/CalculationsResults/ICalculationResult.cs b/StructureHelperLogics/Models/Calculations/CalculationsResults/ICalculationResult.cs
new file mode 100644
index 0000000..5ab8105
--- /dev/null
+++ b/StructureHelperLogics/Models/Calculations/CalculationsResults/ICalculationResult.cs
@@ -0,0 +1,26 @@
+using LoaderCalculator.Data.ResultData;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StructureHelperLogics.Models.Calculations.CalculationsResults
+{
+ ///
+ /// Represent result of calculation of ndm analisys
+ ///
+ public interface ICalculationResult
+ {
+ ///
+ /// True if result of calculation is valid
+ ///
+ bool IsValid { get; }
+ ///
+ /// Text of result of calculations
+ ///
+ string Desctription { get; }
+ ///
+ /// Keep result of calculations from ndm-library
+ ///
+ ILoaderResults LoaderResults { get; }
+ }
+}
diff --git a/StructureHelperLogics/Services/CalculationService.cs b/StructureHelperLogics/Services/CalculationService.cs
index 3558321..2bac1bd 100644
--- a/StructureHelperLogics/Services/CalculationService.cs
+++ b/StructureHelperLogics/Services/CalculationService.cs
@@ -7,6 +7,9 @@ using LoaderCalculator.Data.SourceData;
using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Infrastructures.CommonEnums;
+using StructureHelperLogics.Models.Calculations.CalculationsResults;
+using StructureHelperLogics.Models.Calculations.CalculationProperties;
+using System;
namespace StructureHelperLogics.Services
{
@@ -35,5 +38,42 @@ namespace StructureHelperLogics.Services
calculator.Run(loaderData, new CancellationToken());
return calculator.Result.StrainMatrix;
}
+
+ public List GetCalculationResults(ICalculationProperty calculationProperty, IEnumerable ndms)
+ {
+ List results = new List();
+ foreach (var forceCombinations in calculationProperty.ForceCombinations)
+ {
+ var forceMatrix = forceCombinations.ForceMatrix;
+ results.Add(GetCalculationResult(forceMatrix, ndms, calculationProperty.IterationProperty.Accuracy, calculationProperty.IterationProperty.MaxIterationCount));
+ }
+ return results;
+ }
+
+ public ICalculationResult GetCalculationResult(IForceMatrix forceMatrix, IEnumerable ndmCollection, double accuracyRate, int maxIterationCount)
+ {
+ try
+ {
+ var loaderData = new LoaderOptions
+ {
+ Preconditions = new Preconditions
+ {
+ ConditionRate = accuracyRate,
+ MaxIterationCount = maxIterationCount,
+ StartForceMatrix = forceMatrix
+ },
+ NdmCollection = ndmCollection
+ };
+ var calculator = new Calculator();
+ calculator.Run(loaderData, new CancellationToken());
+ var result = calculator.Result;
+ if (result.AccuracyRate <= accuracyRate) { return new CalculationResult() { IsValid = true, Desctription = "Analisys is done succsefully", LoaderResults=result };}
+ else { return new CalculationResult() { IsValid = false, Desctription = "Required accuracy rate has not achived", LoaderResults = result }; }
+ }
+ catch (Exception ex)
+ {
+ return new CalculationResult() { IsValid = false, Desctription = $"Error is appeared due to analysis. Error: {ex}" };
+ }
+ }
}
}
diff --git a/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml b/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml
new file mode 100644
index 0000000..bffb544
--- /dev/null
+++ b/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml.cs b/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml.cs
new file mode 100644
index 0000000..8a368fe
--- /dev/null
+++ b/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml.cs
@@ -0,0 +1,70 @@
+using StructureHelper.Windows.ViewModels.Calculations.CalculationProperies;
+using StructureHelperLogics.Infrastructures.CommonEnums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow
+{
+ ///
+ /// Логика взаимодействия для CalculationPropertyView.xaml
+ ///
+ public partial class CalculationPropertyView : Window
+ {
+ private CalculationPropertyViewModel viewModel;
+ public CalculationPropertyView(CalculationPropertyViewModel calculationProperty)
+ {
+ InitializeComponent();
+ viewModel = calculationProperty;
+ this.DataContext = viewModel;
+ if (viewModel.LimitState == LimitStates.Collapse) { LsCollapse.IsChecked = true; }
+ else { LsServiceability.IsChecked = true; }
+ if (viewModel.CalcTerm == CalcTerms.ShortTerm) { ShortLoads.IsChecked = true; }
+ else { LongLoads.IsChecked = true; }
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ viewModel.SaveProperties();
+ }
+
+ private void LsCollapse_Checked(object sender, RoutedEventArgs e)
+ {
+ var chBox = sender as RadioButton;
+ if (chBox.IsChecked == true & viewModel != null) { viewModel.LimitState = LimitStates.Collapse; }
+ }
+
+ private void LsServiceability_Checked(object sender, RoutedEventArgs e)
+ {
+ var chBox = sender as RadioButton;
+ if (chBox.IsChecked == true & viewModel != null) { viewModel.LimitState = LimitStates.ServiceAbility; }
+ }
+
+ private void ShortLoads_Checked(object sender, RoutedEventArgs e)
+ {
+ var chBox = sender as RadioButton;
+ if (chBox.IsChecked == true & viewModel != null) { viewModel.CalcTerm = CalcTerms.ShortTerm; }
+ }
+
+ private void LongLoads_Checked(object sender, RoutedEventArgs e)
+ {
+ var chBox = sender as RadioButton;
+ if (chBox.IsChecked == true & viewModel != null) { viewModel.CalcTerm = CalcTerms.LongTerm; }
+ }
+
+ private void ForceGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ }
+ }
+}
diff --git a/Windows/MainWindow/MainModel.cs b/Windows/MainWindow/MainModel.cs
index fb4f95f..30a2b16 100644
--- a/Windows/MainWindow/MainModel.cs
+++ b/Windows/MainWindow/MainModel.cs
@@ -7,6 +7,7 @@ using StructureHelper.Services;
using StructureHelper.UnitSystem;
using StructureHelper.UnitSystem.Systems;
using StructureHelperLogics.Infrastructures.CommonEnums;
+using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services;
using System.Collections;
@@ -21,12 +22,16 @@ namespace StructureHelper.Windows.MainWindow
private IPrimitiveRepository primitiveRepository;
private CalculationService calculationService;
private UnitSystemService unitSystemService;
+
+ public ICalculationProperty CalculationProperty { get; private set; }
public MainModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService)
{
this.primitiveRepository = primitiveRepository;
this.calculationService = calculationService;
this.unitSystemService = unitSystemService;
+
+ CalculationProperty = new CalculationProperty();
}
public IStrainMatrix Calculate(double mx, double my, double nz)
diff --git a/Windows/MainWindow/MainView.xaml b/Windows/MainWindow/MainView.xaml
index 97aa213..2364f1c 100644
--- a/Windows/MainWindow/MainView.xaml
+++ b/Windows/MainWindow/MainView.xaml
@@ -23,6 +23,7 @@
+
@@ -30,7 +31,15 @@
-
+
+
diff --git a/Windows/MainWindow/MainViewModel.cs b/Windows/MainWindow/MainViewModel.cs
index 26fa692..b250a7a 100644
--- a/Windows/MainWindow/MainViewModel.cs
+++ b/Windows/MainWindow/MainViewModel.cs
@@ -16,6 +16,10 @@ using StructureHelper.Models.Materials;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using StructureHelper.Services.ResultViewers;
+using StructureHelper.Windows.ViewModels.Calculations.CalculationProperies;
+using StructureHelperLogics.Models.Calculations.CalculationProperties;
+using StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow;
+using StructureHelperLogics.Services;
namespace StructureHelper.Windows.MainWindow
{
@@ -30,6 +34,7 @@ namespace StructureHelper.Windows.MainWindow
public ObservableCollection Primitives { get; set; }
private double panelX, panelY, scrollPanelX, scrollPanelY;
+ private CalculationProperty calculationProperty;
public double PanelX
{
@@ -111,6 +116,7 @@ namespace StructureHelper.Windows.MainWindow
public ICommand Calculate { get; }
public ICommand SetPopupCanBeClosedTrue { get; }
public ICommand SetPopupCanBeClosedFalse { get; }
+ public ICommand EditCalculationPropertyCommand { get; }
public string UnitsSystemName => unitSystemService.GetCurrentSystem().Name;
private double delta = 0.5;
@@ -126,6 +132,9 @@ namespace StructureHelper.Windows.MainWindow
XY1 = CanvasHeight / 2;
YX1 = CanvasWidth / 2;
YY2 = CanvasHeight;
+ calculationProperty = new CalculationProperty();
+
+
LeftButtonUp = new RelayCommand(o =>
{
if (o is Rectangle rect) rect.BorderCaptured = false;
@@ -231,6 +240,7 @@ namespace StructureHelper.Windows.MainWindow
Primitives.Add(primitive);
PrimitiveRepository.Add(primitive);
}
+ AddTestLoads();
});
Calculate = new RelayCommand(o =>
@@ -244,6 +254,8 @@ namespace StructureHelper.Windows.MainWindow
CalculateResult();
});
+ EditCalculationPropertyCommand = new RelayCommand (o => EditCalculationProperty());
+
SetPopupCanBeClosedTrue = new RelayCommand(o =>
{
if (!(o is PrimitiveBase primitive)) return;
@@ -259,10 +271,14 @@ namespace StructureHelper.Windows.MainWindow
private void CalculateResult()
{
- IForceMatrix forceMatrix = new ForceMatrix() { Mx = 10e3, My = 10e3, Nz = 0 };
IEnumerable ndms = Model.GetNdms();
- var loaderResult = Model.CalculateResult(ndms, forceMatrix);
- ShowIsoFieldResult.ShowResult(loaderResult.StrainMatrix, ndms, ResultFuncFactory.GetResultFuncs());
+ CalculationService calculationService = new CalculationService();
+ var loaderResults = calculationService.GetCalculationResults(calculationProperty, ndms);
+ if (loaderResults[0].IsValid)
+ {
+ IStrainMatrix strainMatrix = loaderResults[0].LoaderResults.ForceStrainPair.StrainMatrix;
+ ShowIsoFieldResult.ShowResult(strainMatrix, ndms, ResultFuncFactory.GetResultFuncs());
+ }
}
private IEnumerable GetTestCasePrimitives()
@@ -279,5 +295,19 @@ namespace StructureHelper.Windows.MainWindow
yield return new Point(d2, -width / 2 + 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
yield return new Point(d2, width / 2 - 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
}
+ private void EditCalculationProperty()
+ {
+ CalculationPropertyViewModel viewModel = new CalculationPropertyViewModel(calculationProperty);
+ var view = new CalculationPropertyView(viewModel);
+ view.ShowDialog();
+ }
+ private void AddTestLoads()
+ {
+ calculationProperty.ForceCombinations.Clear();
+ calculationProperty.ForceCombinations.Add(new ForceCombination());
+ calculationProperty.ForceCombinations[0].ForceMatrix.Mx = 40e3d;
+ calculationProperty.ForceCombinations[0].ForceMatrix.My = 20e3d;
+ calculationProperty.ForceCombinations[0].ForceMatrix.Nz = 0d;
+ }
}
}
\ No newline at end of file
diff --git a/Windows/ViewModels/Calculations/CalculationProperies/CalculationPropertyViewModel.cs b/Windows/ViewModels/Calculations/CalculationProperies/CalculationPropertyViewModel.cs
new file mode 100644
index 0000000..87e49f5
--- /dev/null
+++ b/Windows/ViewModels/Calculations/CalculationProperies/CalculationPropertyViewModel.cs
@@ -0,0 +1,124 @@
+using StructureHelper.Infrastructure;
+using StructureHelperLogics.Infrastructures.CommonEnums;
+using StructureHelperLogics.Models.Calculations.CalculationProperties;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace StructureHelper.Windows.ViewModels.Calculations.CalculationProperies
+{
+ public class CalculationPropertyViewModel : ViewModelBase, IDataErrorInfo
+ {
+ public ObservableCollection ForceCombinations { get; private set; }
+ public double IterationAccuracy
+ {
+ get
+ {
+ return calculationProperty.IterationProperty.Accuracy;
+ }
+ set
+ {
+ calculationProperty.IterationProperty.Accuracy = value;
+ OnPropertyChanged("Accuracy");
+ }
+ }
+ public int MaxIterationCount
+ {
+ get
+ {
+ return calculationProperty.IterationProperty.MaxIterationCount;
+ }
+ set
+ {
+ calculationProperty.IterationProperty.MaxIterationCount = value;
+ OnPropertyChanged("MaxIterationCount");
+ }
+ }
+ public IForceCombination SelectedCombination { get; set; }
+ public LimitStates LimitState
+ {
+ get
+ {
+ return calculationProperty.LimitState;
+ }
+ set
+ {
+ calculationProperty.LimitState = value;
+ OnPropertyChanged(nameof(LimitState));
+ }
+ }
+ public CalcTerms CalcTerm
+ {
+ get
+ {
+ return calculationProperty.CalcTerm;
+ }
+ set
+ {
+ calculationProperty.CalcTerm = value;
+ OnPropertyChanged(nameof(CalcTerm));
+ }
+ }
+
+ public string Error => throw new NotImplementedException();
+ public string this[string columnName]
+ {
+ get
+ {
+ string error = string.Empty;
+ if (columnName == nameof(IterationAccuracy))
+ {
+ if (IterationAccuracy < 1e-10) { error = "Assigned accuracy of iterations is not valid"; }
+ }
+ else if (columnName == nameof(MaxIterationCount))
+ {
+ if (MaxIterationCount < 2) { error = "Number of iterations should be greater than 1"; }
+ }
+ return error;
+ }
+ }
+
+ public ICommand AddForceCombinationCommand { get; private set; }
+ public ICommand RemoveForceCombinationCommand { get; private set; }
+
+
+
+ private readonly ICalculationProperty calculationProperty;
+
+ public CalculationPropertyViewModel(ICalculationProperty calculationProperty)
+ {
+ this.calculationProperty = calculationProperty;
+ ForceCombinations = new ObservableCollection();
+ foreach (var force in calculationProperty.ForceCombinations)
+ {
+ ForceCombinations.Add(force);
+ }
+ AddForceCombinationCommand = new RelayCommand(o => AddForceCombination());
+ RemoveForceCombinationCommand = new RelayCommand(o => RemoveForceCombination(), o => SelectedCombination != null);
+ }
+
+
+
+ public void SaveProperties()
+ {
+ calculationProperty.ForceCombinations.Clear();
+ foreach (var force in ForceCombinations)
+ {
+ calculationProperty.ForceCombinations.Add(force);
+ }
+ }
+ private void AddForceCombination()
+ {
+ ForceCombinations.Add(new ForceCombination());
+ }
+ private void RemoveForceCombination()
+ {
+ ForceCombinations.Remove(SelectedCombination);
+ }
+ }
+}