diff --git a/DataAccess/DTOs/DTOEntities/Curvatures/CurvatureCalculatorInputDataDTO.cs b/DataAccess/DTOs/DTOEntities/Curvatures/CurvatureCalculatorInputDataDTO.cs index 2785a9d..18b0b59 100644 --- a/DataAccess/DTOs/DTOEntities/Curvatures/CurvatureCalculatorInputDataDTO.cs +++ b/DataAccess/DTOs/DTOEntities/Curvatures/CurvatureCalculatorInputDataDTO.cs @@ -18,6 +18,9 @@ namespace DataAccess.DTOs public List ForceActions { get; } = []; [JsonProperty("Primitives")] public List Primitives { get; } = []; + [JsonProperty("ConsiderSofteningFactor")] + public bool ConsiderSofteningFactor { get; set; } = false; + public CurvatureCalculatorInputDataDTO(Guid id) { Id = id; diff --git a/StructureHelper/Infrastructure/HelixViewModelBase.cs b/StructureHelper/Infrastructure/HelixViewModelBase.cs index fbbfb4a..c7210d7 100644 --- a/StructureHelper/Infrastructure/HelixViewModelBase.cs +++ b/StructureHelper/Infrastructure/HelixViewModelBase.cs @@ -112,7 +112,7 @@ namespace StructureHelper.Infrastructure // setup lighting AmbientLightColor = Colors.DimGray; DirectionalLightColor = Colors.White; - DirectionalLightDirection = new Vector3D(-2, -5, -2); + DirectionalLightDirection = new Vector3D(-2, -5, 2); BackgroundTexture = BitmapExtensions.CreateLinearGradientBitmapStream(EffectsManager, 128, 128, Direct2DImageFormat.Bmp, diff --git a/StructureHelper/Libraries/LoaderCalculator.dll b/StructureHelper/Libraries/LoaderCalculator.dll index a701f0b..41f80ee 100644 Binary files a/StructureHelper/Libraries/LoaderCalculator.dll and b/StructureHelper/Libraries/LoaderCalculator.dll differ diff --git a/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs b/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs index 2741897..72f172e 100644 --- a/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs +++ b/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs @@ -2,6 +2,7 @@ using FieldVisualizer.WindowsOperation; using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Ndms; +using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services; @@ -22,7 +23,7 @@ namespace StructureHelper.Services.ResultViewers FieldViewerOperation.ShowViewer(primitiveSets); } - public static List GetPrimitiveSets(IStrainMatrix strainMatrix, IEnumerable ndms, IEnumerable resultFuncs) + public static List GetPrimitiveSets(IStrainMatrix strainMatrix, IEnumerable ndms, IEnumerable resultFuncs, bool convertRectangles = false) { List primitiveSets = new List(); foreach (var valDelegate in resultFuncs) @@ -31,7 +32,7 @@ namespace StructureHelper.Services.ResultViewers List primitives = new List(); foreach (INdm ndm in ndms) { - primitives.Add(ProcessNdm(strainMatrix, valDelegate, ndm)); + primitives.AddRange(ProcessNdm(strainMatrix, valDelegate, ndm, convertRectangles)); } primitiveSet.ValuePrimitives = primitives; primitiveSets.Add(primitiveSet); @@ -72,35 +73,47 @@ namespace StructureHelper.Services.ResultViewers return valuePrimitive; } - private static IValuePrimitive ProcessNdm(IStrainMatrix strainMatrix, ForceResultFunc valDelegate, INdm ndm) + private static List ProcessNdm(IStrainMatrix strainMatrix, ForceResultFunc valDelegate, INdm ndm, bool convertRectangles) { + List valuePrimitives = []; double delegateResult = valDelegate.ResultFunction.Invoke(strainMatrix, ndm); double val = delegateResult * valDelegate.UnitFactor; //val = roundLogic.RoundValue(val); IValuePrimitive valuePrimitive; if (ndm is IRectangleNdm shapeNdm) { - valuePrimitive = ProcessRectangle(shapeNdm, val); + if (convertRectangles) + { + valuePrimitives.AddRange(ProcessRectangleToTriangles(shapeNdm, strainMatrix, valDelegate)); + } + else + { + valuePrimitive = ProcessRectangle(shapeNdm, val); + valuePrimitives.Add(valuePrimitive); + } } else if (ndm is ITriangleNdm triangle) { //valuePrimitive = ProcessTriangle(triangle, val); valuePrimitive = ProcessTriangle(strainMatrix, valDelegate, triangle); + valuePrimitives.Add(valuePrimitive); } else { valuePrimitive = ProcessCircle(ndm, val); + valuePrimitives.Add(valuePrimitive); } - return valuePrimitive; + return valuePrimitives; } private static IValuePrimitive ProcessTriangle(IStrainMatrix strainMatrix, ForceResultFunc valDelegate, ITriangleNdm triangle) { double delegateResult = valDelegate.ResultFunction.Invoke(strainMatrix, triangle); double val = delegateResult * valDelegate.UnitFactor; - var moqNdm1 = new Ndm() { CenterX = triangle.Point1.X, CenterY = triangle.Point1.Y, Area = triangle.Area, Material = triangle.Material }; - var moqNdm2 = new Ndm() { CenterX = triangle.Point2.X, CenterY = triangle.Point2.Y, Area = triangle.Area, Material = triangle.Material }; - var moqNdm3 = new Ndm() { CenterX = triangle.Point3.X, CenterY = triangle.Point3.Y, Area = triangle.Area, Material = triangle.Material }; + var moqLogic = new GetMoqNdmLogic(); + var moqNdm1 = moqLogic.GetMockNdm(triangle, new Point2D(triangle.Point1.X, triangle.Point1.Y)); + var moqNdm2 = moqLogic.GetMockNdm(triangle, new Point2D(triangle.Point2.X, triangle.Point2.Y)); + var moqNdm3 = moqLogic.GetMockNdm(triangle, new Point2D(triangle.Point3.X, triangle.Point3.Y)); var primitive = new TrianglePrimitive() { Point1 = new Point2D() { X = triangle.Point1.X, Y = triangle.Point1.Y }, @@ -127,6 +140,19 @@ namespace StructureHelper.Services.ResultViewers // return primitive; //} + private static List ProcessRectangleToTriangles(IRectangleNdm shapeNdm, IStrainMatrix strainMatrix, ForceResultFunc valDelegate) + { + List triangles = NdmTransform.ConvertRectangleToTriangleNdm(shapeNdm); + List valuePrimitives = []; + foreach (var item in triangles) + { + double delegateResult = valDelegate.ResultFunction.Invoke(strainMatrix, item); + double val = delegateResult * valDelegate.UnitFactor; + valuePrimitives.Add(ProcessTriangle(strainMatrix, valDelegate, (ITriangleNdm)item)); + } + return valuePrimitives; + } + private static IValuePrimitive ProcessRectangle(IRectangleNdm shapeNdm, double val) { return new RectanglePrimitive() diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Curvatures/CurvatureCalculatorInputDataViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Curvatures/CurvatureCalculatorInputDataViewModel.cs index d0e969b..119fd47 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Curvatures/CurvatureCalculatorInputDataViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Curvatures/CurvatureCalculatorInputDataViewModel.cs @@ -12,8 +12,18 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.Curvatures public class CurvatureCalculatorInputDataViewModel : ViewModelBase { private ICurvatureCalculatorInputData inputData; + private bool considerSofteningFactor; public DeflectionFactorViewModel DeflectionFactor { get; } + public bool ConsiderSofteningFactor + { + get => inputData.ConsiderSofteningFactor; + set + { + inputData.ConsiderSofteningFactor = value; + OnPropertyChanged(nameof(ConsiderSofteningFactor)); + } + } public SourceTargetVM CombinationViewModel { get; } public SourceTargetVM PrimitivesViewModel { get; } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Curvatures/CurvatureCalculatorView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Curvatures/CurvatureCalculatorView.xaml index 0a8000c..6e9beb0 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Curvatures/CurvatureCalculatorView.xaml +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Curvatures/CurvatureCalculatorView.xaml @@ -48,11 +48,14 @@ + - + + + - + @@ -71,7 +74,7 @@ - + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/GetMoqNdmLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/GetMoqNdmLogic.cs index 9f2bbfa..45a177c 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/GetMoqNdmLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/GetMoqNdmLogic.cs @@ -1,4 +1,6 @@ -using LoaderCalculator.Data.Ndms; +using LoaderCalculator.Data.Matrix; +using LoaderCalculator.Data.Ndms; +using LoaderCalculator.Infrastructure.Geometry; using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.States; using StructureHelperLogics.NdmCalculations.Primitives; @@ -24,11 +26,20 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu 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); + StrainMatrix prestrainMatrix = new() + { + Kx = (userPrestrain.Mx + autoPrestrain.Mx), + Ky = (userPrestrain.My + autoPrestrain.My), + EpsZ = userPrestrain.Nz + autoPrestrain.Nz + }; + ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, prestrainMatrix); return ndm; } + + public INdm GetMockNdm(INdm ndm, IPoint2D point) + { + INdm newNdm = NdmTransform.GetMoqNdmAtPoint(ndm, new PointLd2D(point.X, point.Y)); + return newNdm; + } } } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ValuePointDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ValuePointDiagramLogic.cs index a9355e1..20cf8ec 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ValuePointDiagramLogic.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ValuePointDiagramLogic.cs @@ -1,4 +1,5 @@ -using LoaderCalculator.Data.Ndms; +using LoaderCalculator.Data.Matrix; +using LoaderCalculator.Data.Ndms; using StructureHelper.Services.ResultViewers; using StructureHelper.Windows.Forces; using StructureHelperCommon.Infrastructures.Exceptions; @@ -145,10 +146,13 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu CenterY = valuePoint.areaPoint.Point.Y, Material = material, }; - var prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * valuePoint.areaPoint.Point.Y - + (userPrestrain.My + autoPrestrain.My) * valuePoint.areaPoint.Point.X - + userPrestrain.Nz + autoPrestrain.Nz; - ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, prestrain); + StrainMatrix prestrainMatrix = new() + { + Kx = (userPrestrain.Mx + autoPrestrain.Mx), + Ky = (userPrestrain.My + autoPrestrain.My), + EpsZ = userPrestrain.Nz + autoPrestrain.Nz + }; + ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, prestrainMatrix); return ndm; } private List GetValueLabels(IEnumerable selectedDelegates) diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs index 5e9c9df..9a0a641 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs @@ -154,7 +154,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu try { IStrainMatrix strainMatrix = SelectedResult.ForcesTupleResult.LoaderResults.ForceStrainPair.StrainMatrix; - var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ForceResultFuncFactory.GetResultFuncs()); + var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ForceResultFuncFactory.GetResultFuncs(), true); var report = new IsoField3DReport(primitiveSets); report.Show(); } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/GetModels3dByValuePrimivesLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/GetModels3dByValuePrimivesLogic.cs new file mode 100644 index 0000000..b61b8a2 --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/GetModels3dByValuePrimivesLogic.cs @@ -0,0 +1,149 @@ +using FieldVisualizer.Entities.ColorMaps; +using FieldVisualizer.Entities.Values; +using FieldVisualizer.Entities.Values.Primitives; +using FieldVisualizer.Services.ColorServices; +using HelixToolkit.Geometry; +using HelixToolkit.Maths; +using HelixToolkit.SharpDX; +using HelixToolkit.SharpDX.Core; +using HelixToolkit.Wpf.SharpDX; +using System; +using System.Collections.Generic; +using System.Numerics; +using System.Text; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews +{ + public class GetModels3dByValuePrimivesLogic : IGetModels3dLogic + { + public double ZoomValue { get; set; } + public bool InvertNormal { get; set; } + public IColorMap ColorMap { get; set; } + public IValueRange ValueRange { get; set; } + public bool ShowZeroPlane { get; set; } + + public void GetModels3d(IEnumerable valuePrimitives, Viewport3DX viewport) + { + foreach (var primitive in valuePrimitives) + { + if (primitive is ICirclePrimitive circlePrimitive) + { + if (circlePrimitive.Value != 0) + { + var model2 = CreateCylinder(circlePrimitive); + viewport.Items.Add(model2); + } + } + else if (primitive is ITrianglePrimitive triangle) + { + var model2 = CreateTriangle(triangle); + viewport.Items.Add(model2); + if (ShowZeroPlane == true) + { + var model1 = CreateZeroTriangle(triangle); + viewport.Items.Add(model1); + } + } + } + } + + private MeshGeometryModel3D CreateCylinder(ICirclePrimitive circle) + { + // Create mesh along Z-axis + var builder = new MeshBuilder(); + + Vector3 p0 = new Vector3((float)circle.CenterX, (float)circle.CenterY, 0); // bottom center + float cylinderHeight = (float)(circle.Value * ZoomValue); + Vector3 p1 = new Vector3((float)circle.CenterX, (float)circle.CenterY, cylinderHeight); // top center + + builder.AddCylinder(p0, p1, (float)circle.Diameter, 8); + + // Build geometry + var cylinderGeometry = builder.ToMeshGeometry3D(); + + // Create material (constant grey) + var material = new PhongMaterial + { + DiffuseColor = ToColor4(ColorOperations.GetColorByValue(ValueRange, ColorMap, circle.Value)), + SpecularShininess = 50f + }; + + // Create model + var cylinderModel = new MeshGeometryModel3D + { + Geometry = cylinderGeometry, + Material = material + }; + return cylinderModel; + } + + private MeshGeometryModel3D CreateZeroTriangle(ITrianglePrimitive triangle) + { + // Triangle vertices + Vector3 p0 = new Vector3((float)triangle.Point1.X, (float)triangle.Point1.Y, 0); + Vector3 p1 = new Vector3((float)triangle.Point2.X, (float)triangle.Point2.Y, 0); + Vector3 p2 = new Vector3((float)triangle.Point3.X, (float)triangle.Point3.Y, 0); + + var builder = new MeshBuilder(); + builder.AddTriangle(p0, p1, p2); + + var mesh = builder.ToMeshGeometry3D(); + + var material = new PBRMaterial + { + AlbedoColor = new Color4(0.5f, 0.5f, 0.5f, 0.4f), // 40% opacity + RoughnessFactor = 0.8f, + MetallicFactor = 0.0f + }; + + + var model = new MeshGeometryModel3D + { + Geometry = mesh, + Material = material, + CullMode = SharpDX.Direct3D11.CullMode.None, + InvertNormal = InvertNormal, + }; + return model; + } + + private MeshGeometryModel3D CreateTriangle(ITrianglePrimitive triangle) + { + // Triangle vertices + Vector3 p0 = new Vector3((float)triangle.Point1.X, (float)triangle.Point1.Y, (float)(triangle.ValuePoint1 * ZoomValue)); + Vector3 p1 = new Vector3((float)triangle.Point2.X, (float)triangle.Point2.Y, (float)(triangle.ValuePoint2 * ZoomValue)); + Vector3 p2 = new Vector3((float)triangle.Point3.X, (float)triangle.Point3.Y, (float)(triangle.ValuePoint3 * ZoomValue)); + + var builder = new MeshBuilder(); + builder.AddTriangle(p0, p1, p2); + + var mesh = builder.ToMeshGeometry3D(); + + var material = new PhongMaterial + { + DiffuseColor = ToColor4(ColorOperations.GetColorByValue(ValueRange, ColorMap, triangle.Value)), + SpecularShininess = 50f + }; + + + var model = new MeshGeometryModel3D + { + Geometry = mesh, + Material = material, + CullMode = SharpDX.Direct3D11.CullMode.None, + InvertNormal = InvertNormal + }; + return model; + } + + public static Color4 ToColor4(System.Windows.Media.Color c) + { + return new Color4( + c.R / 255f, + c.G / 255f, + c.B / 255f, + c.A / 255f + ); + } + } +} diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IGetModels3dLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IGetModels3dLogic.cs new file mode 100644 index 0000000..d177b1a --- /dev/null +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IGetModels3dLogic.cs @@ -0,0 +1,21 @@ +using FieldVisualizer.Entities.ColorMaps; +using FieldVisualizer.Entities.Values; +using FieldVisualizer.Entities.Values.Primitives; +using HelixToolkit.Maths; +using HelixToolkit.Wpf.SharpDX; +using System.Collections.Generic; + +namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews +{ + public interface IGetModels3dLogic + { + IColorMap ColorMap { get; set; } + bool InvertNormal { get; set; } + bool ShowZeroPlane { get; set; } + IValueRange ValueRange { get; set; } + double ZoomValue { get; set; } + + static abstract Color4 ToColor4(System.Windows.Media.Color c); + void GetModels3d(IEnumerable valuePrimitives, Viewport3DX viewport); + } +} \ No newline at end of file diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml index 663f01d..01ff978 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml @@ -5,33 +5,87 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews" xmlns:hx="http://helix-toolkit.org/wpf/SharpDX" + xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance local:IsoField3DViewerViewModel}" mc:Ignorable="d" - Title="Contour 3DViewer" Height="450" Width="800" MinHeight="300" MinWidth="300" MaxHeight="1000" MaxWidth="1400" WindowStartupLocation="CenterScreen"> - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - + + - - - + + + + + + - - + + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml.cs index d2156bd..b09b842 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml.cs @@ -25,7 +25,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu this.viewModel = viewModel; this.DataContext = viewModel; viewModel.ViewportViewModel.Viewport3D = View3D; - viewModel.Refresh(); + viewModel.SaveCopyViewModel.FrameWorkElement = ViewportGrid; } } } diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerViewModel.cs index eedde4a..09e87c7 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerViewModel.cs @@ -5,28 +5,24 @@ using FieldVisualizer.Entities.Values.Primitives; using FieldVisualizer.Services.ColorServices; using FieldVisualizer.Services.PrimitiveServices; using FieldVisualizer.Services.ValueRanges; -using HelixToolkit; using HelixToolkit.Geometry; using HelixToolkit.Maths; using HelixToolkit.SharpDX; using HelixToolkit.Wpf.SharpDX; using StructureHelper.Infrastructure; -using StructureHelper.Models.Materials; +using StructureHelper.Windows.Graphs; using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Numerics; -using System.Windows.Media; -using System.Windows.Media.Media3D; -using Color = HelixToolkit.Maths.Color; +using System.Windows.Input; namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews { public class IsoField3DViewerViewModel : ViewModelBase { const int RangeNumber = 16; - private int userZoomFactor = 100; + private int userZoomFactor = 30; private IEnumerable primitiveSets; private Element3D item0; private Element3D item1; @@ -39,8 +35,10 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu private IColorMap _ColorMap; private ColorMapsTypes _ColorMapType; + public ContourViewportViewModel ViewportViewModel { get; } = new ContourViewportViewModel(); public IEnumerable PrimitiveSets { get => primitiveSets;} + public SaveCopyFWElementViewModel SaveCopyViewModel { get; private set; } = new(); public IsoField3DViewerViewModel(IEnumerable primitiveSets) { @@ -54,6 +52,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu set { selectedPrimitiveSet = value; + ViewportViewModel.Title = selectedPrimitiveSet.Name; OnPropertyChanged(nameof(SelectedPrimitiveSet)); RebuildPrimitives(); } @@ -66,12 +65,32 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { userZoomFactor = value; OnPropertyChanged(nameof(UserZoomFactor)); - RebuildPrimitives (); + } + } + + public bool ShowZeroPlane + { + get => showZeroPlane; + set + { + showZeroPlane = value; + OnPropertyChanged(nameof(ShowZeroPlane)); + } + } + + public bool InvertNormal + { + get => invertNormal; + set + { + invertNormal = value; + OnPropertyChanged(nameof(InvertNormal)); } } private void RebuildPrimitives() { + if (SelectedPrimitiveSet is null) { return; } SetColor(); item0 = ViewportViewModel.Viewport3D.Items[0]; item1 = ViewportViewModel.Viewport3D.Items[1]; @@ -81,61 +100,16 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu ViewportViewModel.Viewport3D.Items.Add(item1); ViewportViewModel.Viewport3D.Items.Add(item2); double maxValue = SelectedPrimitiveSet.ValuePrimitives.Max(x => x.Value) - SelectedPrimitiveSet.ValuePrimitives.Min(x => x.Value); - zoomValue = UserZoomFactor / 100.0 / maxValue; - foreach (var primitive in SelectedPrimitiveSet.ValuePrimitives) + zoomValue = (Math.Pow(1.1, UserZoomFactor) - 1) / 100.0 / maxValue; + var logic = new GetModels3dByValuePrimivesLogic() { - if (primitive is ITrianglePrimitive triangle) - { - var model = CreateTriangle(triangle); - ViewportViewModel.Viewport3D.Items.Add(model); - } - } - } - - - private MeshGeometryModel3D CreateTriangle(ITrianglePrimitive triangle) - { - // Triangle vertices - Vector3 p0 = new Vector3((float)triangle.Point1.X, (float)triangle.Point1.Y, (float)(triangle.ValuePoint1 * zoomValue)); - Vector3 p1 = new Vector3((float)triangle.Point2.X, (float)triangle.Point2.Y, (float)(triangle.ValuePoint2 * zoomValue)); - Vector3 p2 = new Vector3((float)triangle.Point3.X, (float)triangle.Point3.Y, (float)(triangle.ValuePoint3 * zoomValue)); - - var builder = new MeshBuilder(); - builder.AddTriangle(p0, p1, p2); - - var mesh = builder.ToMeshGeometry3D(); - - var material = new PhongMaterial - { - DiffuseColor = ToColor4(ColorOperations.GetColorByValue(valueRange, _ColorMap, triangle.Value)), - SpecularShininess = 50f + ZoomValue = zoomValue, + ShowZeroPlane = ShowZeroPlane, + InvertNormal = InvertNormal, + ColorMap = _ColorMap, + ValueRange = valueRange, }; - - - var model = new MeshGeometryModel3D - { - Geometry = mesh, - Material = material, - CullMode = SharpDX.Direct3D11.CullMode.None, - ToolTip = triangle.Value - }; - return model; - } - - public static Color4 ToColor4(System.Windows.Media.Color c) - { - return new Color4( - c.R / 255f, - c.G / 255f, - c.B / 255f, - c.A / 255f - ); - } - - internal void Refresh() - { - - + logic.GetModels3d(SelectedPrimitiveSet.ValuePrimitives, ViewportViewModel.Viewport3D); } private void SetColor() @@ -144,5 +118,16 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu valueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber); valueColorRanges = ColorOperations.GetValueColorRanges(valueRange, valueRanges, _ColorMap); } + + private RelayCommand rebuildCommand; + private bool showZeroPlane = true; + private bool invertNormal = false; + + public ICommand RebuildCommand => rebuildCommand ??= new RelayCommand(Rebuild); + + private void Rebuild(object commandParameter) + { + RebuildPrimitives(); + } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceTupleTraceResultLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceTupleTraceResultLogic.cs index 223cc83..9ac37e1 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceTupleTraceResultLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceTupleTraceResultLogic.cs @@ -67,7 +67,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces var exitMx = stiffness[0, 0] * strain.Kx + stiffness[0, 1] * strain.Ky + stiffness[0, 2] * strain.EpsZ; var exitMy = stiffness[1, 0] * strain.Kx + stiffness[1, 1] * strain.Ky + stiffness[1, 2] * strain.EpsZ; var exitNz = stiffness[2, 0] * strain.Kx + stiffness[2, 1] * strain.Ky + stiffness[2, 2] * strain.EpsZ; - var PrestressMatrix = new ForceLogic() + var PrestressMatrix = new CalculateForceMatrixLogic() .GetPrestressMatrix(new StiffnessLogic(), ndmCollection, strain); double mx = exitMx + PrestressMatrix.Mx; double my = exitMy + PrestressMatrix.My; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureCalculatorInputData.cs index 0a802f1..1e05f59 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureCalculatorInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureCalculatorInputData.cs @@ -10,6 +10,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures public List Primitives { get; } = []; public IDeflectionFactor DeflectionFactor { get; set; } = new DeflectionFactor(Guid.NewGuid()); + public bool ConsiderSofteningFactor { get; set; } = false; public CurvatureCalculatorInputData(Guid id) { diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureForceCalculator.cs index 3e15de6..68d7795 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureForceCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureForceCalculator.cs @@ -1,4 +1,6 @@ -using StructureHelperCommon.Infrastructures.Enums; +using LoaderCalculator.Data.Materials; +using LoaderCalculator.Logics; +using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; @@ -36,16 +38,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures PrepareResult(); try { - if (CheckForCracks(InputData.ForcePair.FullForceTuple, CalcTerms.ShortTerm) || CheckForCracks(InputData.ForcePair.LongForceTuple, CalcTerms.ShortTerm)) - { - TraceLogger?.AddMessage($"Section is cracked"); - calculator = new CurvatureTermCrackedCalculator(TraceLogger) { InputData = InputData }; - } - else - { - TraceLogger?.AddMessage($"Section is not cracked"); - calculator = new CurvatureTermUncrackedCalculator(TraceLogger) { InputData = InputData }; - } + GetCaclculator(); } catch (Exception ex) { @@ -64,7 +57,26 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures result.SectionResult = calcResult; } - private bool CheckForCracks(IForceTuple forceTuple, CalcTerms calcTerm) + private void GetCaclculator() + { + if (InputData.ConsiderSofteningFactor == false) + { + calculator = new CurvatureTermUncrackedCalculator(TraceLogger) { InputData = InputData }; + return; + } + if (IsSectionCracked(InputData.ForcePair.FullForceTuple, CalcTerms.ShortTerm) || IsSectionCracked(InputData.ForcePair.LongForceTuple, CalcTerms.ShortTerm)) + { + TraceLogger?.AddMessage($"Section is cracked"); + calculator = new CurvatureTermCrackedCalculator(TraceLogger) { InputData = InputData }; + } + else + { + TraceLogger?.AddMessage($"Section is not cracked"); + calculator = new CurvatureTermUncrackedCalculator(TraceLogger) { InputData = InputData }; + } + } + + private bool IsSectionCracked(IForceTuple forceTuple, CalcTerms calcTerm) { var triangulateLogic = new TriangulatePrimitiveLogic() { @@ -74,6 +86,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures TraceLogger = TraceLogger }; var ndms = triangulateLogic.GetNdms(); + if (!ndms.Where(x => x.Material is ICrackMaterial).Any()) + { + return false; + } var logic = new IsSectionCrackedByForceLogic() { ForceTuple = forceTuple, diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureForceCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureForceCalculatorInputData.cs index b02d33a..b60ea40 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureForceCalculatorInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/CurvatureForceCalculatorInputData.cs @@ -8,5 +8,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures public IDesignForcePair ForcePair { get; set; } public List Primitives { get; set; } = []; public IDeflectionFactor DeflectionFactor { get; set; } + public bool ConsiderSofteningFactor { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/ICurvatureCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/ICurvatureCalculatorInputData.cs index 2d45f65..706f6bc 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/ICurvatureCalculatorInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/ICurvatureCalculatorInputData.cs @@ -11,5 +11,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures public interface ICurvatureCalculatorInputData : IInputData, ISaveable, IHasForceActions, IHasPrimitives { IDeflectionFactor DeflectionFactor { get; set; } + bool ConsiderSofteningFactor { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/ICurvatureForceCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/ICurvatureForceCalculatorInputData.cs index fb66650..e863ad7 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/ICurvatureForceCalculatorInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/ICurvatureForceCalculatorInputData.cs @@ -8,5 +8,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures { IDesignForcePair ForcePair {get;set;} IDeflectionFactor DeflectionFactor { get; set; } + bool ConsiderSofteningFactor { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/Logics/CurvatureCalculatorInputDataUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/Logics/CurvatureCalculatorInputDataUpdateStrategy.cs index 258e334..8d66164 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/Logics/CurvatureCalculatorInputDataUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/Logics/CurvatureCalculatorInputDataUpdateStrategy.cs @@ -46,7 +46,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures if (ReferenceEquals(target, source)) return; - + target.ConsiderSofteningFactor = source.ConsiderSofteningFactor; if (UpdateChildren) { ValidateChildProperties(target, source); diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/Logics/CurvatureCalculatorLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/Logics/CurvatureCalculatorLogic.cs index f044bb2..0671f9d 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/Logics/CurvatureCalculatorLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Curvatures/Logics/CurvatureCalculatorLogic.cs @@ -71,7 +71,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures { ForcePair = pair, Primitives = InputData.Primitives, - DeflectionFactor = InputData.DeflectionFactor + DeflectionFactor = InputData.DeflectionFactor, + ConsiderSofteningFactor = InputData.ConsiderSofteningFactor, }; ForceCalculator.InputData = forceInputData; ForceCalculator.Run(); diff --git a/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs b/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs index 7544676..73ba4ff 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs @@ -1,4 +1,5 @@ -using LoaderCalculator.Data.Matrix; +using LoaderCalculator; +using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Ndms; using LoaderCalculator.Logics; using StructureHelperCommon.Infrastructures.Enums; @@ -6,11 +7,6 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperLogics.Models.Materials; using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Triangulations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.RC { @@ -42,7 +38,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC { inputData.ReinforcementStress = inputData.ReinforcementStrength; } - inputData.IsPrestressed = ndm.PrestrainLogic.GetByType(PrestrainTypes.Prestrain).Sum(x => x.PrestrainValue) > 0.0005d ? true : false; + var prestrainLogic = new GetNdmPrestrainLogic(); + var prestrainValue = prestrainLogic.GetPrestrainValueAtCenter(ndm); + inputData.IsPrestressed = prestrainValue > 0.0005d ? true : false; inputData.LappedCountRate = lappedCountRate; return inputData; } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/IsSectionCrackedByForceLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/IsSectionCrackedByForceLogic.cs index 49f07a2..77b38ce 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/IsSectionCrackedByForceLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/IsSectionCrackedByForceLogic.cs @@ -5,7 +5,6 @@ using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; -using System.Diagnostics.Eventing.Reader; namespace StructureHelperLogics.NdmCalculations.Cracking { @@ -46,7 +45,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking } var strainMatrix = calcResult.LoaderResults.ForceStrainPair.StrainMatrix; IEnumerable checkedNdmCollection; - var isSectionCracked = stressLogic.IsSectionCracked(strainMatrix, CheckedNdmCollection); + var crackLogic = new CrackedSectionLogic(); + var isSectionCracked = crackLogic.IsSectionCracked(strainMatrix, CheckedNdmCollection); if (isSectionCracked == true) { TraceLogger?.AddMessage($"Cracks are appeared in cross-section for current force combination"); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/RebarStressCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/RebarStressCalculator.cs index fd38971..1fc0201 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/RebarStressCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/RebarStressCalculator.cs @@ -1,4 +1,5 @@ -using LoaderCalculator.Data.Ndms; +using LoaderCalculator; +using LoaderCalculator.Data.Ndms; using LoaderCalculator.Logics; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; @@ -9,6 +10,7 @@ using StructureHelperCommon.Services.Forces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Triangulations; +using System.Runtime.Intrinsics.Arm; namespace StructureHelperLogics.NdmCalculations.Cracking { @@ -63,7 +65,9 @@ namespace StructureHelperLogics.NdmCalculations.Cracking var strainMatrix = ForceTupleConverter.ConvertToLoaderStrainMatrix(strainTuple); result.RebarStrain = stressLogic.GetSectionStrain(strainMatrix, rebarNdm); result.RebarStress = stressLogic.GetStress(strainMatrix, rebarNdm); - result.ConcreteStrain = -concreteNdm.PrestrainLogic.GetAll().Sum(x => x.PrestrainValue); + var prestrainLogic = new GetNdmPrestrainLogic(); + var prestrainValue = prestrainLogic.GetPrestrainValueAtCenter(concreteNdm); + result.ConcreteStrain = - prestrainValue; } private void PrepareNewResult() diff --git a/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/RebarStressSofteningLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/RebarStressSofteningLogic.cs index f06be3f..1b5b391 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/RebarStressSofteningLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/RebarStressSofteningLogic.cs @@ -1,4 +1,5 @@ -using LoaderCalculator.Data.Ndms; +using LoaderCalculator; +using LoaderCalculator.Data.Ndms; using LoaderCalculator.Logics; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; @@ -13,6 +14,7 @@ using StructureHelperLogics.NdmCalculations.Triangulations; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Intrinsics.Arm; using System.Text; using System.Threading.Tasks; @@ -107,10 +109,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking rebarActualStrain = actualRebarResult.RebarStrain; rebarActualStress = actualRebarResult.RebarStress; TraceLogger?.AddMessage($"Actual strain of rebar EpsilonS = {rebarActualStrain}(dimensionless)"); - concreteStrainActual = concreteNdm - .PrestrainLogic - .GetAll() - .Sum(x => x.PrestrainValue); + var prestrainLogic = new GetNdmPrestrainLogic(); + concreteStrainActual = prestrainLogic.GetPrestrainValueAtCenter(concreteNdm); TraceLogger?.AddMessage($"Actual strain of concrete on the axis of rebar EpsilonC = {concreteStrainActual}(dimensionless)"); if (crackResult.IsSectionCracked == false) { diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogic.cs index cc81af9..fddbd8a 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/PointTriangulationLogic.cs @@ -1,5 +1,4 @@ using LoaderCalculator.Data.Ndms; -using LoaderCalculator.Data.Ndms.Transformations; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Services.Forces; diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogic.cs index a4e4c8e..d460471 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/RebarTriangulationLogic.cs @@ -1,17 +1,7 @@ -using LoaderCalculator.Data.Materials; -using LoaderCalculator.Data.Matrix; -using LoaderCalculator.Data.Ndms; -using LoaderCalculator.Data.Ndms.Transformations; +using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.Forces; -using StructureHelperLogics.Models.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Triangulations { diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs index 2b739db..05389ad 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/RectangleTriangulationLogic.cs @@ -1,5 +1,4 @@ using LoaderCalculator.Data.Ndms; -using LoaderCalculator.Data.Ndms.Transformations; using StructureHelperCommon.Infrastructures.Exceptions; namespace StructureHelperLogics.NdmCalculations.Triangulations diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/TriangulationService.cs b/StructureHelperLogics/NdmCalculations/Triangulations/TriangulationService.cs index 9bbd1ff..de8444c 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/TriangulationService.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/TriangulationService.cs @@ -1,13 +1,6 @@ using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Ndms; -using LoaderCalculator.Data.Ndms.Transformations; using StructureHelperCommon.Models.Forces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static System.Windows.Forms.Design.AxImporter; namespace StructureHelperLogics.NdmCalculations.Triangulations { diff --git a/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs b/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs index 9d092a6..e1e3058 100644 --- a/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs +++ b/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs @@ -1,4 +1,6 @@ -using LoaderCalculator.Data.Ndms; +using LoaderCalculator; +using LoaderCalculator.Data.Matrix; +using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models; @@ -38,11 +40,12 @@ namespace StructureHelperLogics.Services.NdmPrimitives var material = ndm.Material; var materialFunc = material.Diagram; var newMaterialFunc = (double strain) => strain * material.InitModulus; - var existingPrestrain = ndm.PrestrainLogic.GetAll().Sum(x => x.PrestrainValue); + var prestrainLogic = new GetNdmPrestrainLogic(); + var existingPrestrain = prestrainLogic.GetPrestrainValueAtCenter(ndm); var newPrestrain = materialFunc(existingPrestrain) / material.InitModulus; ndm.Material.Diagram = newMaterialFunc; ndm.PrestrainLogic.DeleteAll(); - ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, newPrestrain); + ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, new StrainMatrix() { EpsZ = newPrestrain }); } return ndms; } diff --git a/StructureHelperTests/LibrariesTests/Ndms/RCSections/RCSectionTest.cs b/StructureHelperTests/LibrariesTests/Ndms/RCSections/RCSectionTest.cs index ff0a7b5..ac1d605 100644 --- a/StructureHelperTests/LibrariesTests/Ndms/RCSections/RCSectionTest.cs +++ b/StructureHelperTests/LibrariesTests/Ndms/RCSections/RCSectionTest.cs @@ -2,7 +2,6 @@ using LoaderCalculator.Data.Materials.MaterialBuilders; using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Ndms; -using LoaderCalculator.Data.Ndms.Transformations; using LoaderCalculator.Data.Planes; using LoaderCalculator.Data.SourceData; using LoaderCalculator.Tests.Infrastructures.Logics;