TripleLinear Material Diagram was added

This commit is contained in:
Evgeny Redikultsev
2023-11-25 20:05:49 +05:00
parent 4a8cf2d42a
commit b4b1720c70
23 changed files with 225 additions and 25 deletions

View File

@@ -28,6 +28,14 @@
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
<TextBlock Text="Material Model"/>
<ComboBox Height="25" VerticalAlignment="Top" ItemsSource="{Binding MaterialLogics}" SelectedItem="{Binding MaterialLogic}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>

View File

@@ -55,6 +55,7 @@
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}" Content="{Binding VisualProps}"/> <ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}" Content="{Binding VisualProps}"/>
<StackPanel Grid.Row="2" Orientation="Horizontal"> <StackPanel Grid.Row="2" Orientation="Horizontal">
<Button Margin="3" Content="Draw Lines" ToolTip="Draw lines" Command="{Binding RedrawLinesCommand}"/> <Button Margin="3" Content="Draw Lines" ToolTip="Draw lines" Command="{Binding RedrawLinesCommand}"/>
<Button Margin="3" Content="Show Areas" ToolTip="Area under lines" Command="{Binding GetAreaCommand}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
<lvc:CartesianChart Grid.Column="1" Series="{Binding SeriesCollection}" LegendLocation="Bottom" Zoom="Xy"> <lvc:CartesianChart Grid.Column="1" Series="{Binding SeriesCollection}" LegendLocation="Bottom" Zoom="Xy">

View File

@@ -4,10 +4,12 @@ using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.Converters.Units; using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Models.Materials; using StructureHelper.Models.Materials;
using StructureHelper.Windows.ViewModels; using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Infrastructures.Settings;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
@@ -15,12 +17,22 @@ namespace StructureHelper.Windows.Graphs
{ {
public class MaterialDiagramViewModel : ViewModelBase public class MaterialDiagramViewModel : ViewModelBase
{ {
class StressEntity
{
public LimitStateEntity LimitState { get; set; }
public CalcTermEntity CalcTerm { get; set; }
public IHeadMaterial Material { get; set; }
public double Strain { get; set; }
public double Stress { get; set; }
}
private IHeadMaterial material; private IHeadMaterial material;
private ICommand redrawLinesCommand; private ICommand redrawLinesCommand;
double minValue; double minValue;
double maxValue; double maxValue;
int stepCount; int stepCount;
bool positiveInTension; bool positiveInTension;
private ICommand getAreaCommand;
public string MaterialName => material.Name; public string MaterialName => material.Name;
public GraphVisualProps VisualProps { get; } public GraphVisualProps VisualProps { get; }
@@ -79,6 +91,15 @@ namespace StructureHelper.Windows.Graphs
get => redrawLinesCommand ??= new RelayCommand(o => DrawLines(), b => IsDrawPossible()); get => redrawLinesCommand ??= new RelayCommand(o => DrawLines(), b => IsDrawPossible());
} }
public ICommand GetAreaCommand
{
get => getAreaCommand ??= new RelayCommand(o =>
{
var str = GetAreas();
MessageBox.Show(str);
}, b => IsDrawPossible());
}
public MaterialDiagramViewModel(IEnumerable<IHeadMaterial> headMaterials, IHeadMaterial material) public MaterialDiagramViewModel(IEnumerable<IHeadMaterial> headMaterials, IHeadMaterial material)
{ {
MaterialsModel = new SelectItemsViewModel<IHeadMaterial>(headMaterials) { ShowButtons = true }; MaterialsModel = new SelectItemsViewModel<IHeadMaterial>(headMaterials) { ShowButtons = true };
@@ -100,12 +121,80 @@ namespace StructureHelper.Windows.Graphs
VisualProps = new(); VisualProps = new();
SetLines(); SetLines();
} }
private string GetAreas()
{
var materials = MaterialsModel.SelectedItems;
var limitStates = LimitStatesModel.SelectedItems;
var calcTerms = CalcTermsModel.SelectedItems;
double step = (maxValue - minValue) / stepCount;
var factor = positiveInTension ? 1d : -1d;
var values = GetValueList();
string str = string.Empty;
foreach (var limitState in limitStates)
{
foreach (var calcTerm in calcTerms)
{
foreach (var material in materials)
{
double sumStress = 0d;
var stressList = values
.Where(x => x.LimitState == limitState & x.CalcTerm == calcTerm & x.Material == material).ToList();
for (int i = 1; i < stressList.Count(); i++)
{
double midStress = (stressList[i - 1].Stress + stressList[i].Stress) / 2;
sumStress += midStress * UnitConstants.Stress * step;
}
str += $"{material.Name}, {limitState.Name}, {calcTerm.Name}: {sumStress} \n";
}
}
}
return str;
}
private List<StressEntity> GetValueList()
{
var materials = MaterialsModel.SelectedItems;
var limitStates = LimitStatesModel.SelectedItems;
var calcTerms = CalcTermsModel.SelectedItems;
double step = (maxValue - minValue) / stepCount;
var factor = positiveInTension ? 1d : -1d;
var result = new List<StressEntity>();
foreach (var limitState in limitStates)
{
foreach (var calcTerm in calcTerms)
{
foreach (var material in materials)
{
var loaderMaterial = material.GetLoaderMaterial(limitState.LimitState, calcTerm.CalcTerm);
for (double s = minValue; s < maxValue; s += step)
{
double strain = s * factor;
double diagramValue = loaderMaterial.Diagram.Invoke(loaderMaterial.DiagramParameters, strain) * factor;
StressEntity stressEntity = new()
{
LimitState = limitState,
CalcTerm = calcTerm,
Material = material,
Strain = strain,
Stress = diagramValue
};
result.Add(stressEntity);
}
}
}
}
return result;
}
private void SetLines() private void SetLines()
{ {
var materials = MaterialsModel.SelectedItems; var materials = MaterialsModel.SelectedItems;
var limitStates = LimitStatesModel.SelectedItems; var limitStates = LimitStatesModel.SelectedItems;
var calcTerms = CalcTermsModel.SelectedItems; ; var calcTerms = CalcTermsModel.SelectedItems;
var labels = new List<string>(); var labels = new List<string>();
var factor = positiveInTension ? 1d : -1d; var factor = positiveInTension ? 1d : -1d;

View File

@@ -2,6 +2,7 @@
using StructureHelper.Models.Materials; using StructureHelper.Models.Materials;
using StructureHelper.Windows.AddMaterialWindow; using StructureHelper.Windows.AddMaterialWindow;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperCommon.Services.ColorServices; using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Materials;

View File

@@ -4,6 +4,7 @@ using StructureHelper.Windows.AddMaterialWindow;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Codes; using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Materials;
using System; using System;
@@ -22,6 +23,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
ICommand showSafetyFactors; ICommand showSafetyFactors;
SafetyFactorsViewModel safetyFactorsViewModel; SafetyFactorsViewModel safetyFactorsViewModel;
private ICodeEntity codeEntity; private ICodeEntity codeEntity;
private IMaterialLogic materialLogic;
public ILibMaterialEntity MaterialEntity public ILibMaterialEntity MaterialEntity
{ {
@@ -47,6 +49,9 @@ namespace StructureHelper.Windows.ViewModels.Materials
} }
} }
public List<IMaterialLogic> MaterialLogics => material.MaterialLogics;
public IMaterialLogic MaterialLogic { get => material.MaterialLogic; set => material.MaterialLogic = value; }
private void FillMaterialKinds() private void FillMaterialKinds()
{ {
var materialKinds = ProgramSetting var materialKinds = ProgramSetting

View File

@@ -1,6 +1,7 @@
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Codes; using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Codes.Factories; using StructureHelperCommon.Models.Codes.Factories;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperCommon.Models.Materials.Libraries;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -11,6 +12,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
{ {
public static class ProgramSetting public static class ProgramSetting
{ {
private static List<IMaterialLogic> materialLogics;
private static List<ICodeEntity> codesList; private static List<ICodeEntity> codesList;
private static IMaterialRepository materialRepository; private static IMaterialRepository materialRepository;
private static NatSystems natSystem; private static NatSystems natSystem;
@@ -52,5 +54,13 @@ namespace StructureHelperCommon.Infrastructures.Settings
} }
} }
public static List<IMaterialLogic> MaterialLogics
{
get
{
materialLogics ??= MaterialLogicsFactory.GetMaterialLogics();
return materialLogics;
}
}
} }
} }

View File

@@ -1,5 +1,6 @@
using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders; using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
namespace StructureHelperCommon.Models.Materials namespace StructureHelperCommon.Models.Materials
@@ -25,6 +26,9 @@ namespace StructureHelperCommon.Models.Materials
} }
} }
public MaterialTypes MaterialType { get; set; }
public DiagramType DiagramType { get; set; }
public IMaterial GetLoaderMaterial() public IMaterial GetLoaderMaterial()
{ {
GetLoaderOptions(); GetLoaderOptions();

View File

@@ -0,0 +1,25 @@
using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials
{
internal static class MaterialLogicsFactory
{
public static List<IMaterialLogic> GetMaterialLogics()
{
var items = new List<IMaterialLogic>()
{
new ReinforcementByBuilderLogic() { MaterialType = MaterialTypes.Reinforcement, Name="Bilinear", DiagramType = DiagramType.Bilinear},
new ReinforcementByBuilderLogic() { MaterialType = MaterialTypes.Reinforcement, Name="Triplelinear", DiagramType = DiagramType.TripleLinear},
new ConcreteCurveLogic() { MaterialType = MaterialTypes.Concrete, Name = "Curve", DiagramType = DiagramType.Curve},
};
return items;
}
}
}

View File

@@ -1,4 +1,5 @@
using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -13,5 +14,7 @@ namespace StructureHelperCommon.Models.Materials
string Name { get; set; } string Name { get; set; }
IMaterialLogicOptions Options { get; set; } IMaterialLogicOptions Options { get; set; }
IMaterial GetLoaderMaterial(); IMaterial GetLoaderMaterial();
MaterialTypes MaterialType { get; set; }
DiagramType DiagramType { get; set; }
} }
} }

View File

@@ -11,6 +11,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
public ICodeEntity Code { get; set; } public ICodeEntity Code { get; set; }
public string Name { get; set; } public string Name { get; set; }
public double MainStrength { get; set; } public double MainStrength { get; set; }
public double InitModulus { get; set; }
public ConcreteMaterialEntity(Guid id) public ConcreteMaterialEntity(Guid id)
{ {

View File

@@ -231,21 +231,48 @@ namespace StructureHelperCommon.Models.Materials.Libraries
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "A240", Name = "A240",
MainStrength = 240e6 InitModulus = 2e11d,
MainStrength = 240e6d
}, },
new ReinforcementMaterialEntity(new Guid("ea422282-3465-433c-9b93-c5bbfba5a904")) new ReinforcementMaterialEntity(new Guid("ea422282-3465-433c-9b93-c5bbfba5a904"))
{ {
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "A400", Name = "A400",
MainStrength = 400e6 InitModulus = 2e11d,
MainStrength = 400e6d
}, },
new ReinforcementMaterialEntity(new Guid("045b54b1-0bbf-41fd-a27d-aeb20f600bb4")) new ReinforcementMaterialEntity(new Guid("045b54b1-0bbf-41fd-a27d-aeb20f600bb4"))
{ {
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "A500", Name = "A500",
MainStrength = 500e6 InitModulus = 2e11d,
MainStrength = 500e6d
},
new ReinforcementMaterialEntity(new Guid("e3cfc6fb-fbd0-47dd-ab4a-79c030704acf"))
{
CodeType = codeType,
Code = code,
Name = "A600",
InitModulus = 2e11d,
MainStrength = 600e6d
},
new ReinforcementMaterialEntity(new Guid("6f0882ef-53bf-464e-acf7-da421a43a825"))
{
CodeType = codeType,
Code = code,
Name = "A800",
InitModulus = 2e11d,
MainStrength = 800e6d
},
new ReinforcementMaterialEntity(new Guid("509fbaae-a3de-43c2-aae6-33387908dc43"))
{
CodeType = codeType,
Code = code,
Name = "A1000",
InitModulus = 2e11d,
MainStrength = 1000e6d
} }
}; };
return range; return range;
@@ -262,6 +289,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "K1400/1670", Name = "K1400/1670",
InitModulus = 1.95e11d,
MainStrength = 1400e6 MainStrength = 1400e6
}, },
new ReinforcementMaterialEntity(new Guid("93c48a27-ab37-4bd2-aeb8-2a7247e74a1b")) new ReinforcementMaterialEntity(new Guid("93c48a27-ab37-4bd2-aeb8-2a7247e74a1b"))
@@ -269,6 +297,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "K1500/1770", Name = "K1500/1770",
InitModulus = 1.95e11d,
MainStrength = 1500e6 MainStrength = 1500e6
}, },
new ReinforcementMaterialEntity(new Guid("6e0df35e-4839-4cf1-9182-c7ad7f81a548")) new ReinforcementMaterialEntity(new Guid("6e0df35e-4839-4cf1-9182-c7ad7f81a548"))
@@ -276,6 +305,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "K1600/1860", Name = "K1600/1860",
InitModulus = 1.95e11d,
MainStrength = 1600e6 MainStrength = 1600e6
}, },
new ReinforcementMaterialEntity(new Guid("29d7ef1b-bd30-471e-af0e-8b419eb9f043")) new ReinforcementMaterialEntity(new Guid("29d7ef1b-bd30-471e-af0e-8b419eb9f043"))
@@ -283,6 +313,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "K1700/1960", Name = "K1700/1960",
InitModulus = 1.95e11d,
MainStrength = 1700e6 MainStrength = 1700e6
}, },
new ReinforcementMaterialEntity(new Guid("494b959f-0194-4f02-9dcf-ff313c5e352b")) new ReinforcementMaterialEntity(new Guid("494b959f-0194-4f02-9dcf-ff313c5e352b"))
@@ -290,6 +321,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "K1800/2060", Name = "K1800/2060",
InitModulus = 1.95e11d,
MainStrength = 1800e6 MainStrength = 1800e6
}, },
new ReinforcementMaterialEntity(new Guid("02031332-fe1e-456d-b339-143eb9ca8293")) new ReinforcementMaterialEntity(new Guid("02031332-fe1e-456d-b339-143eb9ca8293"))
@@ -297,6 +329,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
CodeType = codeType, CodeType = codeType,
Code = code, Code = code,
Name = "K1900/2160", Name = "K1900/2160",
InitModulus = 1.95e11d,
MainStrength = 1900e6 MainStrength = 1900e6
} }
}; };

View File

@@ -16,7 +16,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
public ICodeEntity Code { get; set; } public ICodeEntity Code { get; set; }
public string Name { get; } public string Name { get; }
///<inheritdoc/> ///<inheritdoc/>
public double YoungsModulus { get; set; } public double InitModulus { get; set; }
///<inheritdoc/> ///<inheritdoc/>
public double MainStrength { get; } public double MainStrength { get; }
public FiberMaterialEntity(Guid id) public FiberMaterialEntity(Guid id)

View File

@@ -11,6 +11,6 @@ namespace StructureHelperCommon.Models.Materials.Libraries
/// <summary> /// <summary>
/// Modulus of elasticity, Pa /// Modulus of elasticity, Pa
/// </summary> /// </summary>
double YoungsModulus { get; set; } double InitModulus { get; set; }
} }
} }

View File

@@ -10,6 +10,10 @@ namespace StructureHelperCommon.Models.Materials.Libraries
ICodeEntity Code { get; set; } ICodeEntity Code { get; set; }
string Name { get; } string Name { get; }
/// <summary> /// <summary>
/// Initial Young's Modulus, Pa
/// </summary>
double InitModulus { get; set; }
/// <summary>
/// Strength of material, Pa /// Strength of material, Pa
/// </summary> /// </summary>
double MainStrength { get; } double MainStrength { get; }

View File

@@ -11,6 +11,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
public ICodeEntity Code { get; set; } public ICodeEntity Code { get; set; }
public string Name { get; set; } public string Name { get; set; }
public double MainStrength { get; set; } public double MainStrength { get; set; }
public double InitModulus { get; set; }
public ReinforcementMaterialEntity(Guid id) public ReinforcementMaterialEntity(Guid id)
{ {

View File

@@ -15,6 +15,7 @@ namespace StructureHelperCommon.Models.Materials
public void SetMaterialOptions(LCMB.IMaterialOptions materialOptions) public void SetMaterialOptions(LCMB.IMaterialOptions materialOptions)
{ {
materialOptions.InitModulus = options.MaterialEntity.InitModulus;
materialOptions.Strength = options.MaterialEntity.MainStrength; materialOptions.Strength = options.MaterialEntity.MainStrength;
if (options.MaterialEntity.CodeType == CodeTypes.EuroCode_2_1990) if (options.MaterialEntity.CodeType == CodeTypes.EuroCode_2_1990)
{ {

View File

@@ -1,30 +1,31 @@
using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders; using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Services;
namespace StructureHelperCommon.Models.Materials namespace StructureHelperCommon.Models.Materials
{ {
public class ReinforcementBiLinearLogic : IMaterialLogic public class ReinforcementByBuilderLogic : IMaterialLogic
{ {
private ReinforcementLogicOptions options;
private ReinforcementOptions materialOptions; private ReinforcementOptions materialOptions;
private IMaterialOptionLogic optionLogic; private IMaterialOptionLogic optionLogic;
private ReinforcementLogicOptions options;
private IMaterialLogicOptions options1;
public string Name { get; set; } public string Name { get; set; }
public DiagramType DiagramType { get; set; }
public IMaterialLogicOptions Options public IMaterialLogicOptions Options
{ {
get => options; get => options;
set set
{ {
if (value is not ReinforcementLogicOptions) CheckObject.CheckType(value, typeof(ReinforcementLogicOptions));
{
throw new StructureHelperException($"{ErrorStrings.ExpectedWas(typeof(ReinforcementLogicOptions), value)}");
}
options = (ReinforcementLogicOptions)value; options = (ReinforcementLogicOptions)value;
} }
} }
public MaterialTypes MaterialType { get; set; }
public IMaterial GetLoaderMaterial() public IMaterial GetLoaderMaterial()
{ {
GetLoaderOptions(); GetLoaderOptions();
@@ -42,7 +43,7 @@ namespace StructureHelperCommon.Models.Materials
private void GetLoaderOptions() private void GetLoaderOptions()
{ {
materialOptions = new ReinforcementOptions(); materialOptions = new ReinforcementOptions() { DiagramType = DiagramType};
optionLogic = new MaterialCommonOptionLogic(options); optionLogic = new MaterialCommonOptionLogic(options);
optionLogic.SetMaterialOptions(materialOptions); optionLogic.SetMaterialOptions(materialOptions);
} }

View File

@@ -1,6 +1,7 @@
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Materials;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -32,7 +33,15 @@ namespace StructureHelperCommon.Services
} }
public static void IsNull(object item, string message = "") public static void IsNull(object item, string message = "")
{ {
if (item is null) {throw new StructureHelperException (ErrorStrings.ParameterIsNull + message);} if (item is null) { throw new StructureHelperException(ErrorStrings.ParameterIsNull + message); }
}
public static void CheckType(object sourceObject, Type targetType)
{
if (sourceObject.GetType() != targetType)
{
throw new StructureHelperException($"{ErrorStrings.ExpectedWas(targetType, sourceObject.GetType())}");
}
} }
} }
} }

View File

@@ -12,6 +12,8 @@ namespace StructureHelperLogics.Models.Materials
{ {
public class ConcreteLibMaterial : IConcreteLibMaterial public class ConcreteLibMaterial : IConcreteLibMaterial
{ {
const MaterialTypes materialType = MaterialTypes.Concrete;
private readonly List<IMaterialLogic> materialLogics;
private LMBuilders.ConcreteOptions lmOptions; private LMBuilders.ConcreteOptions lmOptions;
private IMaterialOptionLogic optionLogic; private IMaterialOptionLogic optionLogic;
private IFactorLogic factorLogic => new FactorLogic(SafetyFactors); private IFactorLogic factorLogic => new FactorLogic(SafetyFactors);
@@ -31,11 +33,11 @@ namespace StructureHelperLogics.Models.Materials
/// <inheritdoc/> /// <inheritdoc/>
public IMaterialLogic MaterialLogic { get; set; } public IMaterialLogic MaterialLogic { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public List<IMaterialLogic> MaterialLogics { get; } public List<IMaterialLogic> MaterialLogics => materialLogics;
public ConcreteLibMaterial() public ConcreteLibMaterial()
{ {
MaterialLogic = new ConcreteCurveLogic(); materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
MaterialLogic = materialLogics.First();
SafetyFactors = new List<IMaterialSafetyFactor>(); SafetyFactors = new List<IMaterialSafetyFactor>();
lmOptions = new LMBuilders.ConcreteOptions(); lmOptions = new LMBuilders.ConcreteOptions();
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultConcreteSafetyFactors(ProgramSetting.CodeType)); SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultConcreteSafetyFactors(ProgramSetting.CodeType));

View File

@@ -17,7 +17,6 @@ namespace StructureHelperLogics.Models.Materials
targetObject.TensionForULS = sourceObject.TensionForULS; targetObject.TensionForULS = sourceObject.TensionForULS;
targetObject.TensionForSLS = sourceObject.TensionForSLS; targetObject.TensionForSLS = sourceObject.TensionForSLS;
targetObject.RelativeHumidity = sourceObject.RelativeHumidity; targetObject.RelativeHumidity = sourceObject.RelativeHumidity;
targetObject.MaterialLogic = sourceObject.MaterialLogic;
} }
} }
} }

View File

@@ -15,6 +15,7 @@ namespace StructureHelperLogics.Models.Materials
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.MaterialEntity = sourceObject.MaterialEntity; targetObject.MaterialEntity = sourceObject.MaterialEntity;
targetObject.SafetyFactors.Clear(); targetObject.SafetyFactors.Clear();
targetObject.MaterialLogic = sourceObject.MaterialLogic;
foreach (var item in sourceObject.SafetyFactors) foreach (var item in sourceObject.SafetyFactors)
{ {
targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor); targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor);

View File

@@ -10,26 +10,28 @@ using LMBuilders = LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderMaterialLogics = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics; using LoaderMaterialLogics = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics;
using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Models.Materials; using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Infrastructures.Settings;
namespace StructureHelperLogics.Models.Materials namespace StructureHelperLogics.Models.Materials
{ {
public class ReinforcementLibMaterial : IReinforcementLibMaterial public class ReinforcementLibMaterial : IReinforcementLibMaterial
{ {
private LMBuilders.ReinforcementOptions lmOptions; const MaterialTypes materialType = MaterialTypes.Reinforcement;
private IMaterialOptionLogic optionLogic;
private IFactorLogic factorLogic => new FactorLogic(SafetyFactors); private IFactorLogic factorLogic => new FactorLogic(SafetyFactors);
private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic; private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic;
private readonly List<IMaterialLogic> materialLogics;
public ILibMaterialEntity MaterialEntity { get; set; } public ILibMaterialEntity MaterialEntity { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; } public List<IMaterialSafetyFactor> SafetyFactors { get; }
public IMaterialLogic MaterialLogic { get; set; } public IMaterialLogic MaterialLogic { get; set; }
public List<IMaterialLogic> MaterialLogics { get; } public List<IMaterialLogic> MaterialLogics => materialLogics;
public ReinforcementLibMaterial() public ReinforcementLibMaterial()
{ {
MaterialLogic = new ReinforcementBiLinearLogic(); materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
MaterialLogic = materialLogics.First();
SafetyFactors = new List<IMaterialSafetyFactor>(); SafetyFactors = new List<IMaterialSafetyFactor>();
lmOptions = new LMBuilders.ReinforcementOptions();
} }
public object Clone() public object Clone()