Calculations fix

This commit is contained in:
NickAppLab
2022-08-30 19:47:52 +05:00
parent 51748407e8
commit cf0392ad6f
9 changed files with 115 additions and 98 deletions

View File

@@ -22,9 +22,9 @@ namespace StructureHelper.Windows.MainWindow
public IStrainMatrix Calculate(double mx, double my, double nz)
{
var unitSystem = unitSystemService.GetCurrentSystem();
return calculationService.GetPrimitiveStrainMatrix(primitiveRepository.GetPoints()
return calculationService.GetPrimitiveStrainMatrix(primitiveRepository.GetRectangles()
.Select(x => x.GetNdmPrimitive(unitSystem))
.Concat(primitiveRepository.GetRectangles().Select(x => x.GetNdmPrimitive(unitSystem))).ToArray(), mx, my, nz);
.Concat(primitiveRepository.GetPoints().Select(x => x.GetNdmPrimitive(unitSystem))).ToArray(), mx, my, nz);
}
}
}

View File

@@ -94,6 +94,7 @@
<Label VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Content="{Binding UnitsSystemName}"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button VerticalAlignment="Center" Margin="5" Content="Добавить тестовые примитивы" Command="{Binding AddTestCase}"/>
<Button VerticalAlignment="Center" Margin="5" Content="Добавить прямоугольник" Command="{Binding AddPrimitive}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button VerticalAlignment="Center" Margin="5" Content="Добавить точку" Command="{Binding AddPrimitive}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</StackPanel>

View File

@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Input;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
@@ -10,6 +12,7 @@ using StructureHelper.MaterialCatalogWindow;
using StructureHelper.Services;
using StructureHelper.Windows.ColorPickerWindow;
using StructureHelper.UnitSystem;
using StructureHelper.Models.Materials;
namespace StructureHelper.Windows.MainWindow
{
@@ -89,6 +92,7 @@ namespace StructureHelper.Windows.MainWindow
set => OnPropertyChanged(value, ref yY2);
}
public ICommand AddPrimitive { get; }
public ICommand AddTestCase { get; }
public ICommand LeftButtonDown { get; }
public ICommand LeftButtonUp { get; }
public ICommand PreviewMouseMove { get; }
@@ -190,14 +194,14 @@ namespace StructureHelper.Windows.MainWindow
primitive.ShowedZIndex = 1;
OnPropertyChanged(nameof(primitive.ShowedZIndex));
});
ScaleCanvasDown = new RelayCommand(o =>
{
ScrollPanelX = PanelX;
ScrollPanelY = PanelY;
ScaleValue *= scaleRate;
});
ScaleCanvasUp = new RelayCommand(o =>
{
ScrollPanelX = PanelX;
@@ -206,20 +210,34 @@ namespace StructureHelper.Windows.MainWindow
});
Primitives = new ObservableCollection<PrimitiveBase>();
AddPrimitive = new RelayCommand(o =>
{
if (!(o is PrimitiveType primitiveType)) return;
var primitive = primitiveType == PrimitiveType.Point
? (PrimitiveBase) new Point(50, YX1, XY1, this)
: (PrimitiveBase) new Rectangle(60, 40, YX1, XY1, this);
var primitive = primitiveType == PrimitiveType.Point
? (PrimitiveBase)new Point(50, 0, 0, this)
: (PrimitiveBase)new Rectangle(60, 40, 0, 0, this);
Primitives.Add(primitive);
PrimitiveRepository.Add(primitive);
});
AddTestCase = new RelayCommand(o =>
{
foreach (var primitive in GetTestCasePrimitives())
{
Primitives.Add(primitive);
PrimitiveRepository.Add(primitive);
}
});
Calculate = new RelayCommand(o =>
{
model.Calculate(-50e3, 0d, 0d);
var matrix = model.Calculate(10e3, 0d, 0d);
MessageBox.Show(
$"{nameof(matrix.EpsZ)} = {matrix.EpsZ};\n" +
$"{nameof(matrix.Kx)} = {matrix.Kx};\n" +
$"{nameof(matrix.Ky)} = {matrix.Ky}",
"StructureHelper");
});
SetPopupCanBeClosedTrue = new RelayCommand(o =>
@@ -234,5 +252,20 @@ namespace StructureHelper.Windows.MainWindow
primitive.PopupCanBeClosed = false;
});
}
private IEnumerable<PrimitiveBase> GetTestCasePrimitives()
{
var width = 400;
var height = 600;
var d1 = 12;
var d2 = 25;
var rectMaterial = new ConcreteDefinition("C40", 0, 40, 0, 1.3, 1.5);
var pointMaterial = new RebarDefinition("S400", 2, 400, 400, 1.15, 1.15);
yield return new Rectangle(width, height, -width / 2, -height / 2, this) { Material = rectMaterial, MaterialName = rectMaterial.MaterialClass };
yield return new Point(d1, -width / 2 + 50, -height / 2 + 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
yield return new Point(d1, 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 };
yield return new Point(d2, width / 2 - 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
}
}
}