diff --git a/DataAccess/DataAccess.csproj b/DataAccess/DataAccess.csproj index 2dd161f..cfa93e9 100644 --- a/DataAccess/DataAccess.csproj +++ b/DataAccess/DataAccess.csproj @@ -1,7 +1,7 @@  - net9.0-windows7.0 + net10.0-windows7.0 enable enable diff --git a/FieldVisualizer/FieldVisualizer.csproj b/FieldVisualizer/FieldVisualizer.csproj index 4226f64..b5ba674 100644 --- a/FieldVisualizer/FieldVisualizer.csproj +++ b/FieldVisualizer/FieldVisualizer.csproj @@ -1,7 +1,7 @@ - net9.0-windows7.0 + net10.0-windows7.0 enable true disable diff --git a/FiledVisualzerDemo/FieldVisualzerDemo.csproj b/FiledVisualzerDemo/FieldVisualzerDemo.csproj index f6f93f2..a46f7c0 100644 --- a/FiledVisualzerDemo/FieldVisualzerDemo.csproj +++ b/FiledVisualzerDemo/FieldVisualzerDemo.csproj @@ -2,7 +2,7 @@ WinExe - net9.0-windows7.0 + net10.0-windows7.0 enable true disable diff --git a/StructureHelper/Libraries/LoaderCalculator.dll b/StructureHelper/Libraries/LoaderCalculator.dll index 1534490..a701f0b 100644 Binary files a/StructureHelper/Libraries/LoaderCalculator.dll and b/StructureHelper/Libraries/LoaderCalculator.dll differ diff --git a/StructureHelper/Services/ResultViewers/ForceResultFuncFactory.cs b/StructureHelper/Services/ResultViewers/ForceResultFuncFactory.cs index 06d5350..4a6d08c 100644 --- a/StructureHelper/Services/ResultViewers/ForceResultFuncFactory.cs +++ b/StructureHelper/Services/ResultViewers/ForceResultFuncFactory.cs @@ -56,17 +56,18 @@ namespace StructureHelper.Services.ResultViewers } private static List GetStrainResultFuncs() { - List resultFuncs = new (); + List resultFuncs = []; resultFuncs.Add(new ForceResultFunc() { Name = "Section Strain", ResultFunction = stressLogic.GetSectionStrain }); resultFuncs.Add(new ForceResultFunc() { Name = "Total Strain", ResultFunction = stressLogic.GetTotalStrain }); resultFuncs.Add(new ForceResultFunc() { Name = "Prestrain", ResultFunction = stressLogic.GetPrestrain }); resultFuncs.Add(new ForceResultFunc() { Name = "Elastic Strain", ResultFunction = stressLogic.GetElasticStrain }); resultFuncs.Add(new ForceResultFunc() { Name = "Plastic Strain", ResultFunction = stressLogic.GetPlasticStrain }); + resultFuncs.Add(new ForceResultFunc() { Name = "Limit Strain Ratio", ResultFunction = stressLogic.GetLimitStrainRatio }); return resultFuncs; } private static List GetStressResultFuncs() { - List resultFuncs = new (); + List resultFuncs = []; resultFuncs.Add(new ForceResultFunc() { Name = "Stress", ResultFunction = stressLogic.GetStress, UnitFactor = unitStress.Multiplyer, UnitName = unitStress.Name }); resultFuncs.Add(new ForceResultFunc() { Name = "Secant modulus", ResultFunction = stressLogic.GetSecantModulus, UnitFactor = unitStress.Multiplyer, UnitName = unitStress.Name }); resultFuncs.Add(new ForceResultFunc() { Name = "Modulus degradation", ResultFunction = stressLogic.GetModulusDegradation }); @@ -74,7 +75,7 @@ namespace StructureHelper.Services.ResultViewers } private static List GetForcesResultFuncs() { - List resultFuncs = new (); + List resultFuncs = []; resultFuncs.Add(new ForceResultFunc() { Name = "Force", ResultFunction = stressLogic.GetForce, UnitFactor = unitForce.Multiplyer, UnitName = unitForce.Name }); resultFuncs.Add(new ForceResultFunc() { Name = "Moment X", ResultFunction = stressLogic.GetMomentX, UnitFactor = unitMoment.Multiplyer, UnitName = unitMoment.Name }); resultFuncs.Add(new ForceResultFunc() { Name = "Moment Y", ResultFunction = stressLogic.GetMomentY, UnitFactor = unitMoment.Multiplyer, UnitName = unitMoment.Name }); diff --git a/StructureHelper/StructureHelper.csproj b/StructureHelper/StructureHelper.csproj index 7d4251c..b8173b9 100644 --- a/StructureHelper/StructureHelper.csproj +++ b/StructureHelper/StructureHelper.csproj @@ -2,7 +2,7 @@ WinExe - net9.0-windows7.0 + net10.0-windows7.0 true enable true diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/GetMoqNdmLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/GetMoqNdmLogic.cs new file mode 100644 index 0000000..9f2bbfa --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/GetMoqNdmLogic.cs @@ -0,0 +1,34 @@ +using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.States; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Text; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews +{ + public class GetMoqNdmLogic : IGetMoqNdmLogic + { + public INdm GetMockNdm(INdmPrimitive ndmPrimitive, IStateCalcTermPair stateCalcTermPair, IPoint2D point, double area = 0) + { + var limitState = stateCalcTermPair.LimitState; + var calcTerm = stateCalcTermPair.CalcTerm; + var material = ndmPrimitive.NdmElement.HeadMaterial.GetLoaderMaterial(limitState, calcTerm); + var userPrestrain = ndmPrimitive.NdmElement.UsersPrestrain; + var autoPrestrain = ndmPrimitive.NdmElement.AutoPrestrain; + var ndm = new Ndm() + { + Area = area, + CenterX = point.X, + CenterY = point.Y, + Material = material, + }; + var prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * point.Y + + (userPrestrain.My + autoPrestrain.My) * point.X + + userPrestrain.Nz + autoPrestrain.Nz; + ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, prestrain); + return ndm; + } + } +} diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/IGetMoqNdmLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/IGetMoqNdmLogic.cs new file mode 100644 index 0000000..2071501 --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/IGetMoqNdmLogic.cs @@ -0,0 +1,15 @@ +using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.States; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Text; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews +{ + public interface IGetMoqNdmLogic + { + INdm GetMockNdm(INdmPrimitive ndmPrimitive, IStateCalcTermPair stateCalcTermPair, IPoint2D point, double area = 0); + } +} diff --git a/StructureHelper/Windows/Graphs/GraphViewModel.cs b/StructureHelper/Windows/Graphs/GraphViewModel.cs index 7a7586a..1ebd0c1 100644 --- a/StructureHelper/Windows/Graphs/GraphViewModel.cs +++ b/StructureHelper/Windows/Graphs/GraphViewModel.cs @@ -4,22 +4,12 @@ using StructureHelper.Infrastructure; using StructureHelper.Services.Exports; using StructureHelper.Windows.ViewModels; using StructureHelperCommon.Models.Parameters; -using StructureHelperCommon.Services.Exports; using StructureHelperCommon.Services.Exports.Factories; -using StructureHelperLogics.NdmCalculations.Analyses; -using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.IO; using System.Linq; -using System.Windows; -using System.Windows.Controls; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Media.Media3D; -using System.Xml.Linq; //Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia diff --git a/StructureHelper/Windows/MainWindow/CrossSections/AnalysisViewModelLogic.cs b/StructureHelper/Windows/MainWindow/CrossSections/AnalysisViewModelLogic.cs index f03c72d..ee8ab45 100644 --- a/StructureHelper/Windows/MainWindow/CrossSections/AnalysisViewModelLogic.cs +++ b/StructureHelper/Windows/MainWindow/CrossSections/AnalysisViewModelLogic.cs @@ -6,6 +6,7 @@ using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculato using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams; using StructureHelper.Windows.CalculationWindows.ProgressViews; using StructureHelper.Windows.Errors; +using StructureHelper.Windows.MainWindow.CrossSections; using StructureHelper.Windows.ViewModels.Calculations.Calculators; using StructureHelper.Windows.ViewModels.Errors; using StructureHelperCommon.Infrastructures.Exceptions; @@ -269,6 +270,12 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections var wnd = new CrackResultView(crackCalculator.Result as CrackResult); wnd.ShowDialog(); } + else if (SelectedItem is IValueDiagramCalculator valueDiagramCalculator) + { + IValueDiagramCalculatorResult? diagramCalcualtorResult = valueDiagramCalculator.Result as IValueDiagramCalculatorResult; + ValueDiagramLogic valueDiagramLogic = new(diagramCalcualtorResult); + valueDiagramLogic.Show(); + } else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem)); diff --git a/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml b/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml index 1ef32dd..5269f7f 100644 --- a/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml +++ b/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml @@ -156,7 +156,7 @@ + DescriptionText="Exports primitives to new *.dxf file"/> @@ -166,7 +166,7 @@ + DescriptionText="Imports primitives from *.dxf file"/> @@ -307,6 +307,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + deletAllCommand ??= new RelayCommand(DeleteAll, o => Items.Count > 0); + + private void DeleteAll(object obj) + { + var dialogResult = MessageBox.Show("Delete all primitives?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (dialogResult == DialogResult.Yes) + { + repository.Primitives.Clear(); + Items.Clear(); + Refresh(); + OnPropertyChanged(nameof(Items)); + OnPropertyChanged(nameof(PrimitivesCount)); + } + } + public ICommand DeleteSelectedCommand => deleteSelectedCommand ??= new RelayCommand(DeleteSelected, o => Items.Count > 0); + + private void DeleteSelected(object commandParameter) + { + var vm = new SelectPrimitivesViewModel(repository.Primitives); + var wnd = new SelectPrimitivesView(vm); + wnd.ShowDialog(); + if (wnd.DialogResult == true) + { + var selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive()); + var deletePrimitivesList = Items + .Where(x => selectedNdmPrimitives.Contains(x.NdmPrimitive)) + .ToList(); + foreach (var item in deletePrimitivesList) + { + repository.Primitives.Remove(item.NdmPrimitive); + Items.Remove(item); + } + Refresh(); + OnPropertyChanged(nameof(Items)); + OnPropertyChanged(nameof(PrimitivesCount)); + } + } + private void SetMaterialToPrimitives(object obj) { if (SelectedItem is null) { return; } @@ -478,5 +517,6 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections AddItems(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(this.repository.Primitives)); } + private RelayCommand deleteSelectedCommand; } } diff --git a/StructureHelper/Windows/MainWindow/CrossSections/ValueDiagramLogic.cs b/StructureHelper/Windows/MainWindow/CrossSections/ValueDiagramLogic.cs new file mode 100644 index 0000000..560c492 --- /dev/null +++ b/StructureHelper/Windows/MainWindow/CrossSections/ValueDiagramLogic.cs @@ -0,0 +1,224 @@ +using LoaderCalculator.Data.Matrix; +using LoaderCalculator.Data.Ndms; +using LoaderCalculator.Logics; +using StructureHelper.Services.ResultViewers; +using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews; +using StructureHelper.Windows.Graphs; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Parameters; +using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace StructureHelper.Windows.MainWindow.CrossSections +{ + internal class ValueDiagramLogic + { + private IStressLogic stressLogic = new StressLogic(); + private IValueDiagramCalculatorResult valueDiagramResult; + private List resultFuncs = []; + private List labels; + + public ValueDiagramLogic(IValueDiagramCalculatorResult valueDiagramResult) + { + this.valueDiagramResult = valueDiagramResult; + } + + internal void Show() + { + resultFuncs.AddRange(ForceResultFuncFactory.GetResultFuncs(FuncsTypes.Strain)); + resultFuncs.AddRange(ForceResultFuncFactory.GetResultFuncs(FuncsTypes.Stress)); + GetLabels(); + if (valueDiagramResult.IsValid == false || + valueDiagramResult.ForceTupleResults + .Where(x => x.IsValid) + .Count() == 0) + { + // + } + List seriesList = []; + foreach (var forceTupleResult in valueDiagramResult.ForceTupleResults) + { + if (forceTupleResult.IsValid == false) { continue; } + foreach (var entityResult in valueDiagramResult.EntityResults) + { + var primitives = valueDiagramResult.InputData.Primitives + .Where(x => x is IHasDivisionSize); + Series series = GetSeries(forceTupleResult, valueDiagramResult.InputData.Primitives, entityResult.PointList); + seriesList.Add(series); + } + } + var vm = new GraphViewModel(seriesList); + var wnd = new GraphView(vm); + wnd.ShowDialog(); + } + + private Series GetSeries(IForceTupleCalculatorResult tupleResult, List ndmPrimitives, List points) + { + List<(INdmPrimitive ndmPrimitive, IPoint2D point)> pointPrimitives = GetPrimitivePoints(ndmPrimitives, points); + ArrayParameter arrayParameter = new(pointPrimitives.Count + 3, labels); + var data = arrayParameter.Data; + IPoint2D startPoint = pointPrimitives[0].point; + IPoint2D endPoint = pointPrimitives[^1].point; + for (int i = 0; i < pointPrimitives.Count; i++) + { + IPoint2D currentPoint = pointPrimitives[i].point; + double distance = GetDistance(startPoint, currentPoint); + data[i, 0] = distance; + data[i, 1] = currentPoint.X; + data[i, 2] = currentPoint.Y; + for (int j = 0; j < resultFuncs.Count; j++) + { + data[i, j + 3] = GetValueByPoint(tupleResult.LoaderResults.StrainMatrix, pointPrimitives[i].ndmPrimitive, pointPrimitives[i].point, resultFuncs[j]); + } + + } + data[pointPrimitives.Count, 0] = GetDistance(startPoint, endPoint); + data[pointPrimitives.Count, 1] = endPoint.X; + data[pointPrimitives.Count, 2] = endPoint.Y; + + data[pointPrimitives.Count + 1, 0] = 0.0; + data[pointPrimitives.Count + 1, 1] = startPoint.X; + data[pointPrimitives.Count + 1, 2] = startPoint.Y; + + data[pointPrimitives.Count, 0] = 0.0; + data[pointPrimitives.Count + 2, 1] = startPoint.X; + data[pointPrimitives.Count + 2, 2] = startPoint.Y; + for (int j = 0; j < resultFuncs.Count; j++) + { + data[pointPrimitives.Count, j+3] = 0.0; + data[pointPrimitives.Count + 1, j+3] = 0.0; + data[pointPrimitives.Count + 2, j + 3] = GetValueByPoint(tupleResult.LoaderResults.StrainMatrix, pointPrimitives[0].ndmPrimitive, pointPrimitives[0].point, resultFuncs[j]); + } + + StructureHelperCommon.Models.Forces.IForceTuple inputForceTuple = tupleResult.InputData.ForceTuple; + Series series = new Series(arrayParameter) + { + Name = $"Mx = {inputForceTuple.Mx}, My = {inputForceTuple.My}, Nz = {inputForceTuple.Nz}", + }; + return series; + } + + private static double GetDistance(IPoint2D startPoint, IPoint2D currentPoint) + { + double dx = currentPoint.X - startPoint.X; + double dy = currentPoint.Y - startPoint.Y; + double distance = Math.Sqrt(dx * dx + dy * dy); + return distance; + } + + private List<(INdmPrimitive ndmPrimitive, IPoint2D point)> GetPrimitivePoints(List primitives, List points) + { + List<(INdmPrimitive ndmPrimitive, IPoint2D point)> values = []; + for (int i = 0; i < points.Count; i++) + { + var currentPoint = points[i]; + + var areaPrimitives = GetPrimitivesInPoint(primitives, currentPoint); + + if (areaPrimitives.Count() == 1) + { + (INdmPrimitive ndmPrimitive, IPoint2D point) newValue = (areaPrimitives[0], points[i]); + values.Add(newValue); + } + else if (areaPrimitives.Count() > 1) + { + values.AddRange(GetPrimitiveByFewPoints(areaPrimitives, points, i)); + } + } + return values; + } + + private static List GetPrimitivesInPoint(List primitives, IPoint2D point) + { + return primitives + .Where(x => x is IHasDivisionSize) + .Where(x => (x as IHasDivisionSize).IsPointInside(point) == true) + .ToList(); + } + + private List<(INdmPrimitive ndmPrimitive, IPoint2D point)> GetPrimitiveByFewPoints(List areaPrimitives, List points, int i) + { + List<(INdmPrimitive ndmPrimitive, IPoint2D point)> values = []; + var primitives = areaPrimitives + .OrderBy(x=> x.VisualProperty.ZIndex) + .ToList(); + if (primitives[0] is IHasDivisionSize firstPrimitiveHasSize) + { + if (firstPrimitiveHasSize.DivisionSize.ClearUnderlying == true) + { + if (primitives[0].NdmElement.Triangulate == true) + { + (INdmPrimitive ndmPrimitive, IPoint2D point) newValue = (primitives[0], points[i]); + values.Add(newValue); + } + } + else + { + if (primitives.Count > 2) + { + throw new StructureHelperException($"Too many primitives in point X = {points[i].X}, Y = {points[i].Y}"); + } + if (i == 0) + { + var primitive = GetPrimitiveInAjacentPoint(primitives, points, i, 1); + (INdmPrimitive ndmPrimitive, IPoint2D point) newValue = (primitive, points[i]); + values.Add(newValue); + } + else if (i == points.Count - 1) + { + var primitive = GetPrimitiveInAjacentPoint(primitives, points, i, -1); + (INdmPrimitive ndmPrimitive, IPoint2D point) newValue = (primitive, points[i]); + values.Add(newValue); + } + else + { + foreach (var primitive in primitives) + { + (INdmPrimitive ndmPrimitive, IPoint2D point) newValue = (primitive, points[i]); + values.Add(newValue); + } + } + } + } + return values; + } + + private INdmPrimitive GetPrimitiveInAjacentPoint(List primitives, List points, int i, int sign) + { + var nextPointPrimitives = GetPrimitivesInPoint(primitives, points[i + 1 * sign]); + try + { + var primitive = nextPointPrimitives.Single(); + return primitive; + } + catch (Exception ex) + { + throw new StructureHelperException($"Error of obtaining of primitive X = {points[i].X}, Y = {points[i].Y}"); + } + } + + private double GetValueByPoint(IStrainMatrix strainMatrix, INdmPrimitive primitive, IPoint2D point, ForceResultFunc resultFunc) + { + var logic = new GetMoqNdmLogic(); + var moqNdm = logic.GetMockNdm(primitive, valueDiagramResult.InputData.StateTermPair, point); + return resultFunc.ResultFunction(strainMatrix, moqNdm) * resultFunc.UnitFactor; + } + + private void GetLabels() + { + labels = []; + labels.Add("Distance"); + labels.Add("Global X"); + labels.Add("Global Y"); + foreach (var resultFunc in resultFuncs) + { + labels.Add($"{resultFunc.Name}, {resultFunc.UnitName}"); + } + } + } +} diff --git a/StructureHelper/Windows/Shapes/PolygonShapeView.xaml b/StructureHelper/Windows/Shapes/PolygonShapeView.xaml index c99a955..b6842e0 100644 --- a/StructureHelper/Windows/Shapes/PolygonShapeView.xaml +++ b/StructureHelper/Windows/Shapes/PolygonShapeView.xaml @@ -123,9 +123,14 @@ - + + + + + + - + @@ -139,7 +144,7 @@ - @@ -147,7 +152,7 @@ - + diff --git a/StructureHelper/Windows/UserControls/WorkPlane.xaml b/StructureHelper/Windows/UserControls/WorkPlane.xaml index 19aa224..97a4008 100644 --- a/StructureHelper/Windows/UserControls/WorkPlane.xaml +++ b/StructureHelper/Windows/UserControls/WorkPlane.xaml @@ -103,6 +103,22 @@ + + + + + + + + + + + + + + + + diff --git a/StructureHelperCommon/StructureHelperCommon.csproj b/StructureHelperCommon/StructureHelperCommon.csproj index 819d17b..1460606 100644 --- a/StructureHelperCommon/StructureHelperCommon.csproj +++ b/StructureHelperCommon/StructureHelperCommon.csproj @@ -1,7 +1,7 @@  - net9.0-windows7.0 + net10.0-windows7.0 disable enable true diff --git a/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs b/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs index 752eb61..69c9191 100644 --- a/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs +++ b/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs @@ -20,7 +20,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections return calculators; } - private ValueDiagramCalculator GetDiagramCalculator() + private static ValueDiagramCalculator GetDiagramCalculator() { ValueDiagramCalculator diagramCalculator = new(Guid.NewGuid()) { Name = "New value diagram calcualtor"}; ValueDiagramEntity diagramEntity = new(Guid.NewGuid()) { Name = "New diagram" }; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorResult.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorResult.cs index 819f370..77dc90d 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorResult.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramCalculatorResult.cs @@ -7,7 +7,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams public interface IValueDiagramCalculatorResult : IResult { IValueDiagramCalculatorInputData? InputData { get; set; } - List Points { get; set; } - List ForceTupleResults { get; set; } + List EntityResults { get; set; } + List ForceTupleResults { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramEntityResult.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramEntityResult.cs new file mode 100644 index 0000000..7be7c11 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/IValueDiagramEntityResult.cs @@ -0,0 +1,14 @@ +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Text; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public interface IValueDiagramEntityResult : IResult + { + IValueDiagramEntity ValueDiagramEntity { get; } + List PointList { get; set;} + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/IValueDiagramEntityLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/IValueDiagramEntityLogic.cs new file mode 100644 index 0000000..4ceac9b --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/IValueDiagramEntityLogic.cs @@ -0,0 +1,14 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Text; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public interface IValueDiagramEntityLogic : ILogic + { + IValueDiagramEntity ValueDiagramEntity { get; set; } + IValueDiagramEntityResult Result { get; } + void Run(); + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorLogic.cs index 3113b0c..1362ee4 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramCalculatorLogic.cs @@ -1,21 +1,21 @@ -using StructureHelperCommon.Infrastructures.Enums; +using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Sections; +using StructureHelperCommon.Models.Sections.Logics; +using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.Services.NdmPrimitives; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams { public class ValueDiagramCalculatorLogic : IValueDiagramCalculatorLogic { + private readonly IValueDiagramEntityLogic entityLogic = new ValueDiagramEntityLogic(); private ITriangulatePrimitiveLogic triangulateLogic; - + private List ndms; private IValueDiagramCalculatorResult result; public IValueDiagramCalculatorInputData InputData { get; set; } public IShiftTraceLogger? TraceLogger { get; set; } @@ -23,7 +23,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams public IValueDiagramCalculatorResult GetResult() { PrepareResult(); - GetPoints(); + GetEntitiesResults(); CalculateTupleResults(); return result; } @@ -37,30 +37,67 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams CalcTerm = InputData.StateTermPair.CalcTerm, TraceLogger = TraceLogger }; - var ndms = triangulateLogic.GetNdms(); + ndms = triangulateLogic.GetNdms(); foreach (var forceAction in InputData.ForceActions) { var combination = forceAction.GetCombinations(); List forceTuples = []; foreach (var action in combination) { - var actionCombination = action + var forceTuple = action .DesignForces - .Where(x => x.LimitState == InputData.StateTermPair.LimitState && x.CalcTerm == InputData.StateTermPair.CalcTerm); - } - ForceTupleInputData forceTupleInputData = new() - { - NdmCollection = ndms, - Accuracy = new Accuracy(), - CheckStrainLimit = true, + .Single(x => x.LimitState == InputData.StateTermPair.LimitState && x.CalcTerm == InputData.StateTermPair.CalcTerm) + .ForceTuple; + + + IPoint2D point2D; + IProcessorLogic forcelogic = new ForceTupleCopier(forceTuple); + if (action.SetInGravityCenter == true) + { + var (Cx, Cy) = LoaderCalculator.Logics.Geometry.GeometryOperations.GetGravityCenter(ndms); + point2D = new Point2D() { X = Cx, Y = Cy }; + forcelogic = new ForceTupleMoveToPointDecorator(forcelogic) { Point2D = point2D }; + } + var newTuple = forcelogic.GetValue(); + GetForceTupleResult(forceAction, newTuple); + } - }; } } - private void GetPoints() + private void GetForceTupleResult(IForceAction forceAction, IForceTuple forceTuple) { - throw new NotImplementedException(); + ForceTupleInputData forceTupleInputData = new() + { + ForceTuple = forceTuple, + NdmCollection = ndms, + Accuracy = new Accuracy() { IterationAccuracy = 0.001, MaxIterationCount = 1000}, + CheckStrainLimit = InputData.CheckStrainLimit, + }; + ForceTupleCalculator calculator = new ForceTupleCalculator() + { + InputData = forceTupleInputData, + TraceLogger = TraceLogger?.GetSimilarTraceLogger(100) + }; + calculator.Run(); + var tupleResult = calculator.Result as IForceTupleCalculatorResult; + if (tupleResult.IsValid == false) + { + TraceLogger?.AddMessage($"Result is not valid for action {forceAction.Name}: {tupleResult.Description}", TraceLogStatuses.Error); + } + result.ForceTupleResults.Add(tupleResult); + } + + private void GetEntitiesResults() + { + var entities = InputData.Digrams + .Where(x => x.IsTaken == true); + foreach (var entity in entities) + { + entityLogic.ValueDiagramEntity = entity; + entityLogic.Run(); + result.EntityResults.Add(entityLogic.Result); + } } private void PrepareResult() diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramEntityLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramEntityLogic.cs new file mode 100644 index 0000000..4780ab6 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/Logics/ValueDiagramEntityLogic.cs @@ -0,0 +1,43 @@ +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Text; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public class ValueDiagramEntityLogic : IValueDiagramEntityLogic + { + public IValueDiagramEntity ValueDiagramEntity { get; set; } + + private IValueDiagramEntityResult result; + + public IShiftTraceLogger? TraceLogger { get; set; } + + public IValueDiagramEntityResult Result => result; + + public void Run() + { + result = new ValueDiagramEntityResult(ValueDiagramEntity); + result.PointList = GetPoints(); + } + + private List GetPoints() + { + TraceLogger?.AddMessage($"Getting point for diagram {ValueDiagramEntity.Name} has been started"); + var startPoint = ValueDiagramEntity.ValueDigram.Point2DRange.StartPoint; + var endPoint = ValueDiagramEntity.ValueDigram.Point2DRange.EndPoint; + double dx = (endPoint.X - startPoint.X) / ValueDiagramEntity.ValueDigram.StepNumber; + double dy = (endPoint.Y - startPoint.Y) / ValueDiagramEntity.ValueDigram.StepNumber; + List point2Ds = []; + for (int i = 0; i < ValueDiagramEntity.ValueDigram.StepNumber + 1; i++) + { + double x = startPoint.X + dx * i; + double y = startPoint.Y + dy * i; + point2Ds.Add(new Point2D(x, y)); + } + TraceLogger?.AddMessage($"Getting point for diagram {ValueDiagramEntity.Name} has been finished, total {point2Ds.Count} points obtained"); + return point2Ds; + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculator.cs index 45a9d77..4421ba4 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculator.cs @@ -1,16 +1,13 @@ -using StructureHelperCommon.Models; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperLogics.NdmCalculations.Analyses.ByForces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams { public class ValueDiagramCalculator : IValueDiagramCalculator { + private readonly IValueDiagramCalculatorLogic valueDiagramCalculatorLogic = new ValueDiagramCalculatorLogic(); + private readonly ICheckInputDataLogic checkInputDataLogic; private IValueDiagramCalculatorResult result; public Guid Id { get; } @@ -38,7 +35,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams public void Run() { - throw new NotImplementedException(); + valueDiagramCalculatorLogic.InputData = InputData; + result = valueDiagramCalculatorLogic.GetResult(); } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorResult.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorResult.cs index 2b2b433..4311527 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorResult.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramCalculatorResult.cs @@ -7,11 +7,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams { public IValueDiagramCalculatorInputData? InputData { get; set; } - public List Points { get; set; } = []; - - public List ForceTupleResults { get; set; } = []; + public List ForceTupleResults { get; set; } = []; public bool IsValid { get; set; } = true; public string? Description { get; set; } = string.Empty; + public List EntityResults { get; set; } = []; } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramEntityResult.cs b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramEntityResult.cs new file mode 100644 index 0000000..e9b27df --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ValueDiagrams/ValueDiagramEntityResult.cs @@ -0,0 +1,21 @@ +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Text; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams +{ + public class ValueDiagramEntityResult : IValueDiagramEntityResult + { + public IValueDiagramEntity ValueDiagramEntity { get; } + + public ValueDiagramEntityResult(IValueDiagramEntity valueDiagramEntity) + { + ValueDiagramEntity = valueDiagramEntity; + } + + public List PointList { get; set; } = []; + public bool IsValid { get; set; } = true; + public string? Description { get; set; } = string.Empty; + } +} diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/CheckPrimitiveCollectionLogic.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/CheckPrimitiveCollectionLogic.cs index 97b3e30..acabea8 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/Logics/CheckPrimitiveCollectionLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/CheckPrimitiveCollectionLogic.cs @@ -1,13 +1,6 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; -using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Materials; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Primitives.Logics { @@ -57,8 +50,16 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics } else { + foreach (var primitive in Entity.Primitives) { + if (primitive.NdmElement.HeadMaterial is null) + { + result = false; + string message = $"Primitive {primitive.Name} does not have material\n"; + checkResult += message; + TraceLogger?.AddMessage(message, TraceLogStatuses.Error); + } if (primitive is IRebarNdmPrimitive rebar) { CheckRebar(rebar); diff --git a/StructureHelperLogics/StructureHelperLogics.csproj b/StructureHelperLogics/StructureHelperLogics.csproj index 3517da1..dfc6ea3 100644 --- a/StructureHelperLogics/StructureHelperLogics.csproj +++ b/StructureHelperLogics/StructureHelperLogics.csproj @@ -1,7 +1,7 @@  - net9.0-windows7.0 + net10.0-windows7.0 enable enable diff --git a/StructureHelperTests/StructureHelperTests.csproj b/StructureHelperTests/StructureHelperTests.csproj index 3b1bbb5..b982019 100644 --- a/StructureHelperTests/StructureHelperTests.csproj +++ b/StructureHelperTests/StructureHelperTests.csproj @@ -1,7 +1,7 @@  - net9.0-windows7.0 + net10.0-windows7.0 enable enable false