diff --git a/FieldVisualizer/Entities/ColorMaps/IValueColorArray.cs b/FieldVisualizer/Entities/ColorMaps/IValueColorArray.cs
new file mode 100644
index 0000000..1bed0b5
--- /dev/null
+++ b/FieldVisualizer/Entities/ColorMaps/IValueColorArray.cs
@@ -0,0 +1,13 @@
+using System.Windows.Media;
+
+namespace FieldVisualizer.Entities.ColorMaps
+{
+ public interface IValueColorArray
+ {
+ double AverageValue { get; set; }
+ Color BottomColor { get; set; }
+ double BottomValue { get; set; }
+ Color TopColor { get; set; }
+ double TopValue { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/FieldVisualizer/Entities/ColorMaps/IValueColorRange.cs b/FieldVisualizer/Entities/ColorMaps/IValueColorRange.cs
index 395993c..85063a2 100644
--- a/FieldVisualizer/Entities/ColorMaps/IValueColorRange.cs
+++ b/FieldVisualizer/Entities/ColorMaps/IValueColorRange.cs
@@ -11,25 +11,8 @@ namespace FieldVisualizer.Entities.ColorMaps
/// Flag of activity
///
bool IsActive { get; set; }
- ///
- /// Minimum value of range
- ///
- double BottomValue { get; set; }
- ///
- /// Average value of range
- ///
- double AverageValue { get; set; }
- ///
- /// Maximum value of range
- ///
- double TopValue {get;set;}
- ///
- /// Color correspondent to minimum value
- ///
- Color BottomColor { get; set; }
- ///
- /// Color correspondent to maximum value
- ///
- Color TopColor { get; set; }
+ IValueColorArray ExactValues { get; }
+ IValueColorArray RoundedValues { get; }
+
}
}
diff --git a/FieldVisualizer/Entities/ColorMaps/ValueColorArray.cs b/FieldVisualizer/Entities/ColorMaps/ValueColorArray.cs
new file mode 100644
index 0000000..66cd001
--- /dev/null
+++ b/FieldVisualizer/Entities/ColorMaps/ValueColorArray.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace FieldVisualizer.Entities.ColorMaps
+{
+ public class ValueColorArray : IValueColorArray
+ {
+ ///
+ /// Minimum value of range
+ ///
+ public double BottomValue { get; set; }
+ ///
+ /// Average value of range
+ ///
+ public double AverageValue { get; set; }
+ ///
+ /// Maximum value of range
+ ///
+ public double TopValue { get; set; }
+ ///
+ /// Color correspondent to minimum value
+ ///
+ public Color BottomColor { get; set; }
+ ///
+ /// Color correspondent to maximum value
+ ///
+ public Color TopColor { get; set; }
+ }
+}
diff --git a/FieldVisualizer/Entities/ColorMaps/ValueColorRange.cs b/FieldVisualizer/Entities/ColorMaps/ValueColorRange.cs
index 695cca3..6813268 100644
--- a/FieldVisualizer/Entities/ColorMaps/ValueColorRange.cs
+++ b/FieldVisualizer/Entities/ColorMaps/ValueColorRange.cs
@@ -7,15 +7,10 @@ namespace FieldVisualizer.Entities.ColorMaps
{
///
public bool IsActive { get; set; }
- ///
- public double BottomValue { get; set; }
- ///
- public double AverageValue { get; set; }
- ///
- public double TopValue { get; set; }
- ///
- public Color BottomColor { get; set; }
- ///
- public Color TopColor { get; set; }
+
+ public IValueColorArray ExactValues { get; private set; } = new ValueColorArray();
+
+ public IValueColorArray RoundedValues { get; private set; } = new ValueColorArray();
+
}
}
diff --git a/FieldVisualizer/Services/ColorServices/ColorOperations.cs b/FieldVisualizer/Services/ColorServices/ColorOperations.cs
index 9b3148d..412f247 100644
--- a/FieldVisualizer/Services/ColorServices/ColorOperations.cs
+++ b/FieldVisualizer/Services/ColorServices/ColorOperations.cs
@@ -1,6 +1,7 @@
using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.Values;
using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Text;
@@ -11,6 +12,7 @@ namespace FieldVisualizer.Services.ColorServices
public static class ColorOperations
{
const byte Alpha = 0xff;
+ static IMathRoundLogic roundLogic = new SmartRoundLogic();
///
///
///
@@ -23,15 +25,18 @@ namespace FieldVisualizer.Services.ColorServices
var colorRanges = new List();
foreach (var valueRange in valueRanges)
{
- IValueColorRange valueColorRange = new ValueColorRange
+ var valueColorRange = new ValueColorRange
{
IsActive = true,
- BottomValue = valueRange.BottomValue,
- AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2,
- TopValue = valueRange.TopValue
};
- valueColorRange.BottomColor = GetColorByValue(fullRange, colorMap, valueColorRange.BottomValue);
- valueColorRange.TopColor = GetColorByValue(fullRange, colorMap, valueColorRange.TopValue);
+ valueColorRange.ExactValues.BottomValue = valueRange.BottomValue;
+ valueColorRange.ExactValues.AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2;
+ valueColorRange.ExactValues.TopValue = valueRange.TopValue;
+ valueColorRange.ExactValues.BottomColor = GetColorByValue(fullRange, colorMap, valueColorRange.ExactValues.BottomValue);
+ valueColorRange.ExactValues.TopColor = GetColorByValue(fullRange, colorMap, valueColorRange.ExactValues.TopValue);
+ valueColorRange.RoundedValues.BottomValue = roundLogic.RoundValue(valueColorRange.ExactValues.BottomValue);
+ valueColorRange.RoundedValues.AverageValue = roundLogic.RoundValue(valueColorRange.ExactValues.AverageValue);
+ valueColorRange.RoundedValues.TopValue = roundLogic.RoundValue(valueColorRange.ExactValues.TopValue);
colorRanges.Add(valueColorRange);
}
return colorRanges;
@@ -85,11 +90,16 @@ namespace FieldVisualizer.Services.ColorServices
return map.Colors[^1];
}
double colorPerc = 1d / (map.Colors.Count - 1d); // % of each block of color. the last is the "100% Color"
- double blockOfColor = valPerc / colorPerc;// the integer part repersents how many block to skip
+ double blockOfColor = valPerc / colorPerc;// the integer part represents how many block to skip
int blockIdx = (int)Math.Truncate(blockOfColor);// Idx of
double valPercResidual = valPerc - (blockIdx * colorPerc);//remove the part represented of block
double percOfColor = valPercResidual / colorPerc;// % of color of this block that will be filled
+ //in some cases due to accuracy of double type percent of color may be less than zero
+ if (percOfColor <= 0d)
+ {
+ return map.Colors[blockIdx];
+ }
Color c = GetColorByColorMap(map, blockIdx, percOfColor);
return c;
}
diff --git a/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs b/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs
index 540abf1..ca3b3a0 100644
--- a/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs
+++ b/FieldVisualizer/ViewModels/FieldViewerViewModels/FieldViewerViewModel.cs
@@ -9,6 +9,7 @@ using FieldVisualizer.Services.ColorServices;
using FieldVisualizer.Services.PrimitiveServices;
using FieldVisualizer.Services.ValueRanges;
using FieldVisualizer.Windows.UserControls;
+using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -22,6 +23,7 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{
public class FieldViewerViewModel : ViewModelBase, IDataErrorInfo
{
+ private IMathRoundLogic roundLogic = new SmartRoundLogic() { DigitQuant = 3 };
public ICommand RebuildCommand { get; }
public ICommand ZoomInCommand { get; }
public ICommand ZoomOutCommand { get; }
@@ -159,8 +161,8 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
private ColorMapsTypes _ColorMapType;
private IColorMap _ColorMap;
private IValueRange valueRange;
- private IEnumerable _ValueRanges;
- private IEnumerable _ValueColorRanges;
+ private IEnumerable valueRanges;
+ private IEnumerable valueColorRanges;
private bool setMinValue;
private bool setMaxValue;
private double crossLineX;
@@ -190,7 +192,7 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
if ((PrimitiveSet is null) == false)
{
ProcessPrimitives();
- Legend.ValueColorRanges = _ValueColorRanges;
+ Legend.ValueColorRanges = valueColorRanges;
Legend.Refresh();
}
}
@@ -257,14 +259,14 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{
SolidColorBrush brush = new SolidColorBrush();
brush.Color = ColorOperations.GetColorByValue(valueRange, _ColorMap, valuePrimitive.Value);
- foreach (var valueRange in _ValueColorRanges)
+ foreach (var valueRange in valueColorRanges)
{
- if (valuePrimitive.Value >= valueRange.BottomValue & valuePrimitive.Value <= valueRange.TopValue & (!valueRange.IsActive))
+ if (valuePrimitive.Value >= valueRange.ExactValues.BottomValue & valuePrimitive.Value <= valueRange.ExactValues.TopValue & (!valueRange.IsActive))
{
brush.Color = Colors.Gray;
}
}
- shape.ToolTip = valuePrimitive.Value;
+ shape.ToolTip = roundLogic.RoundValue(valuePrimitive.Value);
shape.Tag = valuePrimitive;
shape.Fill = brush;
Canvas.SetLeft(shape, valuePrimitive.CenterX - addX - dX);
@@ -301,10 +303,24 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{
UserValueRange.TopValue = UserValueRange.BottomValue;
}
- if (SetMinValue) { valueRange.BottomValue = UserValueRange.BottomValue; } else { UserValueRange.BottomValue = valueRange.BottomValue; }
- if (SetMaxValue) { valueRange.TopValue = UserValueRange.TopValue; } else { UserValueRange.TopValue = valueRange.TopValue; }
- _ValueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
- _ValueColorRanges = ColorOperations.GetValueColorRanges(valueRange, _ValueRanges, _ColorMap);
+ if (SetMinValue == true)
+ {
+ valueRange.BottomValue = UserValueRange.BottomValue;
+ }
+ else
+ {
+ UserValueRange.BottomValue = valueRange.BottomValue;
+ }
+ if (SetMaxValue == true)
+ {
+ valueRange.TopValue = UserValueRange.TopValue;
+ }
+ else
+ {
+ UserValueRange.TopValue = valueRange.TopValue;
+ }
+ valueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
+ valueColorRanges = ColorOperations.GetValueColorRanges(valueRange, valueRanges, _ColorMap);
}
private void SetCrossLine(object commandParameter)
{
diff --git a/FieldVisualizer/Windows/UserControls/VerticalLegend.xaml b/FieldVisualizer/Windows/UserControls/VerticalLegend.xaml
index 5116791..58c8315 100644
--- a/FieldVisualizer/Windows/UserControls/VerticalLegend.xaml
+++ b/FieldVisualizer/Windows/UserControls/VerticalLegend.xaml
@@ -20,23 +20,23 @@
-
+
-
+
-
-
+
+
-
-
+
+
-
+
diff --git a/FieldVisualizer/Windows/WndFieldViewer.xaml b/FieldVisualizer/Windows/WndFieldViewer.xaml
index 7362c15..7a290d6 100644
--- a/FieldVisualizer/Windows/WndFieldViewer.xaml
+++ b/FieldVisualizer/Windows/WndFieldViewer.xaml
@@ -6,7 +6,7 @@
xmlns:FieldViewerControl="clr-namespace:FieldVisualizer.Windows.UserControls"
xmlns:local="clr-namespace:FieldVisualizer.Windows"
mc:Ignorable="d"
- Title="FieldViewer" Height="800" Width="1200" WindowStartupLocation="CenterOwner">
+ Title="FieldViewer" Height="800" Width="1200" MinHeight="400" MinWidth="800" MaxHeight="1000" MaxWidth="1500" WindowStartupLocation="CenterScreen" ShowInTaskbar="False">
diff --git a/StructureHelper/App.xaml b/StructureHelper/App.xaml
index 04fc9ba..70db8cc 100644
--- a/StructureHelper/App.xaml
+++ b/StructureHelper/App.xaml
@@ -19,6 +19,7 @@
+
diff --git a/StructureHelper/Infrastructure/Enums/CalculatorTypes.cs b/StructureHelper/Infrastructure/Enums/CalculatorTypes.cs
index 8383ce8..fd4e157 100644
--- a/StructureHelper/Infrastructure/Enums/CalculatorTypes.cs
+++ b/StructureHelper/Infrastructure/Enums/CalculatorTypes.cs
@@ -10,6 +10,7 @@ namespace StructureHelper.Infrastructure.Enums
{
ForceCalculator,
LimitCurveCalculator,
+ CrackCalculator,
FireCalculator
}
}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/Area.cs b/StructureHelper/Infrastructure/UI/Converters/Units/Area.cs
index 383fb7f..74a112d 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/Area.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/Area.cs
@@ -14,7 +14,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
internal class Area : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Area; }
- public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm2"); }
+ public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm2"); }
public override string UnitName { get => "Area"; }
}
}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/CrackWidth.cs b/StructureHelper/Infrastructure/UI/Converters/Units/CrackWidth.cs
new file mode 100644
index 0000000..e520311
--- /dev/null
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/CrackWidth.cs
@@ -0,0 +1,28 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Services;
+using StructureHelperCommon.Services.Units;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Infrastructure.UI.Converters.Units
+{
+ internal class CrackWidth : UnitBase
+ {
+ public CrackWidth()
+ {
+ OperationLogic = new ConvertUnitLogic()
+ {
+ MathRoundLogic = new FixedRoundLogic()
+ {
+ DigitQuant = 3
+ }
+ };
+ }
+ public override UnitTypes UnitType { get => UnitTypes.Length; }
+ public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm"); }
+ public override string UnitName { get => "Length"; }
+ }
+}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/Curvature.cs b/StructureHelper/Infrastructure/UI/Converters/Units/Curvature.cs
index ec5a34b..1a34053 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/Curvature.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/Curvature.cs
@@ -11,7 +11,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
internal class Curvature : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Curvature; }
- public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "1/mm"); }
+ public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "1/mm"); }
public override string UnitName { get => "Curvature"; }
}
}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/Force.cs b/StructureHelper/Infrastructure/UI/Converters/Units/Force.cs
index 408660d..941f47d 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/Force.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/Force.cs
@@ -13,7 +13,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
internal class Force : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Force; }
- public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kN"); }
+ public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "kN"); }
public override string UnitName { get => "Force"; }
}
}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/Length.cs b/StructureHelper/Infrastructure/UI/Converters/Units/Length.cs
index 5cac7d1..e4a01e1 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/Length.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/Length.cs
@@ -5,8 +5,9 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Length : UnitBase
{
+
public override UnitTypes UnitType { get => UnitTypes.Length; }
- public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm"); }
+ public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm"); }
public override string UnitName { get => "Length"; }
}
}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/Moment.cs b/StructureHelper/Infrastructure/UI/Converters/Units/Moment.cs
index 76f8d6d..f260d7a 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/Moment.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/Moment.cs
@@ -11,7 +11,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
internal class Moment : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Moment; }
- public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kNm"); }
+ public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "kNm"); }
public override string UnitName { get => "Moment"; }
}
}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/PlainDouble.cs b/StructureHelper/Infrastructure/UI/Converters/Units/PlainDouble.cs
index e4958d1..48cd0ac 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/PlainDouble.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/PlainDouble.cs
@@ -12,6 +12,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class PlainDouble : IValueConverter
{
+ IConvertUnitLogic operationLogic = new ConvertUnitLogic();
+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
@@ -28,7 +30,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{
try
{
- return CommonOperation.ConvertToDoubleChangeComma((string)value);
+ return ProcessString.ConvertCommaToCultureSettings((string)value);
}
catch (Exception)
{
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/Stress.cs b/StructureHelper/Infrastructure/UI/Converters/Units/Stress.cs
index eec20ab..f07de25 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/Stress.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/Stress.cs
@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Services;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
@@ -12,8 +13,19 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Stress : UnitBase
{
+
public override UnitTypes UnitType { get => UnitTypes.Stress; }
- public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "MPa"); }
+ public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "MPa"); }
public override string UnitName { get => "Stress"; }
+ public Stress()
+ {
+ OperationLogic = new ConvertUnitLogic()
+ {
+ MathRoundLogic = new SmartRoundLogic()
+ {
+ DigitQuant = 3
+ }
+ };
+ }
}
}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/UnitBase.cs b/StructureHelper/Infrastructure/UI/Converters/Units/UnitBase.cs
index ef778b0..4955cf1 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/UnitBase.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/UnitBase.cs
@@ -1,4 +1,7 @@
using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Parameters;
+using StructureHelperCommon.Services;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
@@ -14,19 +17,61 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal abstract class UnitBase : IValueConverter
{
+ IMathRoundLogic roundLogic = new DirectRoundLogic();
+ public IConvertUnitLogic OperationLogic { get; set; } = new ConvertUnitLogic();
+ public IGetUnitLogic UnitLogic { get; set; } = new GetUnitLogic();
public abstract UnitTypes UnitType { get; }
public abstract IUnit CurrentUnit { get; }
public abstract string UnitName { get;}
+ ///
+ /// From variable to user
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- return CommonOperation.Convert(CurrentUnit, UnitName, value);
+ var pair = OperationLogic.Convert(CurrentUnit, UnitName, value);
+ var result = pair.Value;
+ if (parameter is not null)
+ {
+ if (parameter is string paramString)
+ {
+ var logic = new ProcessDoublePairLogic() { DigitPlace = DigitPlace.Any };
+ var paramPair = logic.GetValuePairByString(paramString);
+ string paramTextPart = paramPair.Text.ToLower();
+ int paramValuePart = (int)paramPair.Value;
+ if (paramTextPart == "smart")
+ {
+ roundLogic = new SmartRoundLogic() { DigitQuant = paramValuePart };
+ }
+ else if (paramTextPart == "fixed")
+ {
+ roundLogic = new FixedRoundLogic() { DigitQuant = paramValuePart };
+ }
+ result = roundLogic.RoundValue(result);
+ }
+ }
+ string strValue = $"{result} {pair.Text}";
+ return strValue;
}
-
+ ///
+ /// From user to variable
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
- return CommonOperation.ConvertBack(UnitType, CurrentUnit, value);
+ double result = OperationLogic.ConvertBack(UnitType, CurrentUnit, value);
+
+ return result;
}
catch (Exception)
{
diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
index deaeb92..7e48c6e 100644
--- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
+++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml
@@ -1,8 +1,8 @@
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StructureHelper/Infrastructure/UI/Resources/Converters.xaml b/StructureHelper/Infrastructure/UI/Resources/Converters.xaml
index cfda1fd..f02301e 100644
--- a/StructureHelper/Infrastructure/UI/Resources/Converters.xaml
+++ b/StructureHelper/Infrastructure/UI/Resources/Converters.xaml
@@ -12,5 +12,6 @@
+
\ No newline at end of file
diff --git a/StructureHelper/Infrastructure/UI/Resources/Cracks.xaml b/StructureHelper/Infrastructure/UI/Resources/Cracks.xaml
new file mode 100644
index 0000000..12f6a73
--- /dev/null
+++ b/StructureHelper/Infrastructure/UI/Resources/Cracks.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml b/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml
index 7c7acb2..4324620 100644
--- a/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml
+++ b/StructureHelper/Infrastructure/UI/Resources/ItemEditPanels.xaml
@@ -23,7 +23,8 @@
+ ItemTemplate="{Binding ItemDataDemplate}"
+ >
@@ -41,8 +42,16 @@
-
-
+
+
+
+
+
+
+
+
+
+
@@ -54,7 +63,8 @@
-
+
+
\ No newline at end of file
diff --git a/StructureHelper/Infrastructure/UI/Resources/ServiceColors.xaml b/StructureHelper/Infrastructure/UI/Resources/ServiceColors.xaml
new file mode 100644
index 0000000..782b8b2
--- /dev/null
+++ b/StructureHelper/Infrastructure/UI/Resources/ServiceColors.xaml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StructureHelper/Libraries/LoaderCalculator.dll b/StructureHelper/Libraries/LoaderCalculator.dll
index 7a3289f..fd7ba77 100644
Binary files a/StructureHelper/Libraries/LoaderCalculator.dll and b/StructureHelper/Libraries/LoaderCalculator.dll differ
diff --git a/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user b/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user
index 7cc792e..7b83bfc 100644
--- a/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/StructureHelper/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
- True|2024-02-02T07:22:50.1454015Z;True|2023-02-25T13:37:39.2738786+05:00;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;
+ True|2024-03-11T15:33:14.1457807Z;True|2024-03-10T19:11:27.6834663+05:00;True|2024-02-02T12:22:50.1454015+05:00;True|2023-02-25T13:37:39.2738786+05:00;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;
\ No newline at end of file
diff --git a/StructureHelper/Services/ResultViewers/CrackResultFunc.cs b/StructureHelper/Services/ResultViewers/CrackResultFunc.cs
new file mode 100644
index 0000000..b66aa96
--- /dev/null
+++ b/StructureHelper/Services/ResultViewers/CrackResultFunc.cs
@@ -0,0 +1,20 @@
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Services.ResultViewers
+{
+ public class CrackResultFunc : IResultFunc>
+ {
+ public string Name { get; set; }
+
+ public Func ResultFunction { get; set; }
+
+ public string UnitName { get; set; }
+
+ public double UnitFactor { get; set; }
+ }
+}
diff --git a/StructureHelper/Services/ResultViewers/CrackResultFuncFactory.cs b/StructureHelper/Services/ResultViewers/CrackResultFuncFactory.cs
new file mode 100644
index 0000000..b44a902
--- /dev/null
+++ b/StructureHelper/Services/ResultViewers/CrackResultFuncFactory.cs
@@ -0,0 +1,99 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Services.Units;
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Services.ResultViewers
+{
+
+ public static class CrackResultFuncFactory
+ {
+ private static readonly IConvertUnitLogic operationLogic = new ConvertUnitLogic();
+ private static readonly IGetUnitLogic UnitLogic = new GetUnitLogic();
+
+ static IUnit unitStress = UnitLogic.GetUnit(UnitTypes.Stress);
+ static IUnit unitLength = UnitLogic.GetUnit(UnitTypes.Length, "mm");
+
+ public static List GetResultFuncs()
+ {
+ List results = new()
+ {
+ new()
+ {
+ Name = "Long crack width",
+ ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.CrackWidth,
+ UnitFactor = unitLength.Multiplyer,
+ UnitName = unitLength.Name
+ },
+ new()
+ {
+ Name = "Short crack width",
+ ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.CrackWidth,
+ UnitFactor = unitLength.Multiplyer,
+ UnitName = unitLength.Name
+ },
+ new()
+ {
+ Name = "Long softening factor",
+ ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.SofteningFactor,
+ UnitFactor = 1,
+ UnitName = "Dimensionless"
+ },
+ new()
+ {
+ Name = "Short softening factor",
+ ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.SofteningFactor,
+ UnitFactor = 1,
+ UnitName = "Dimensionless"
+ },
+ new()
+ {
+ Name = "Long rebar stress",
+ ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.RebarStress,
+ UnitFactor = unitStress.Multiplyer,
+ UnitName = unitStress.Name
+ },
+ new()
+ {
+ Name = "Short rebar stress",
+ ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.RebarStress,
+ UnitFactor = unitStress.Multiplyer,
+ UnitName = unitStress.Name
+ },
+ new()
+ {
+ Name = "Long rebar strain",
+ ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.RebarStrain,
+ UnitFactor = 1d,
+ UnitName = string.Empty
+ },
+ new()
+ {
+ Name = "Short rebar strain",
+ ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.RebarStrain,
+ UnitFactor = 1d,
+ UnitName = string.Empty
+ },
+ new()
+ {
+ Name = "Long concrete strain",
+ ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.ConcreteStrain,
+ UnitFactor = 1d,
+ UnitName = string.Empty
+ },
+ new()
+ {
+ Name = "Short concrete strain",
+ ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.ConcreteStrain,
+ UnitFactor = 1d,
+ UnitName = string.Empty
+ }
+ };
+ return results;
+ }
+ }
+}
diff --git a/StructureHelper/Services/ResultViewers/ResultFunc.cs b/StructureHelper/Services/ResultViewers/ForceResultFunc.cs
similarity index 74%
rename from StructureHelper/Services/ResultViewers/ResultFunc.cs
rename to StructureHelper/Services/ResultViewers/ForceResultFunc.cs
index d0b624c..724374f 100644
--- a/StructureHelper/Services/ResultViewers/ResultFunc.cs
+++ b/StructureHelper/Services/ResultViewers/ForceResultFunc.cs
@@ -8,13 +8,14 @@ using System.Threading.Tasks;
namespace StructureHelper.Services.ResultViewers
{
- public class ResultFunc : IResultFunc
+ public class ForceResultFunc : IResultFunc>
{
public string Name { get; set; }
public Func ResultFunction { get; set; }
+ public string UnitName { get; set; }
public double UnitFactor { get; set; }
- public ResultFunc()
+ public ForceResultFunc()
{
UnitFactor = 1d;
}
diff --git a/StructureHelper/Services/ResultViewers/ForceResultFuncFactory.cs b/StructureHelper/Services/ResultViewers/ForceResultFuncFactory.cs
new file mode 100644
index 0000000..06d5350
--- /dev/null
+++ b/StructureHelper/Services/ResultViewers/ForceResultFuncFactory.cs
@@ -0,0 +1,84 @@
+using LoaderCalculator.Logics;
+using StructureHelper.Infrastructure.UI.Converters.Units;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Services.Units;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Services.ResultViewers
+{
+ public enum FuncsTypes
+ {
+ Strain,
+ Stress,
+ Forces,
+ Full,
+ }
+ public static class ForceResultFuncFactory
+ {
+ static IGetUnitLogic unitLogic = new GetUnitLogic();
+ static IUnit unitForce = unitLogic.GetUnit(UnitTypes.Force);
+ static IUnit unitStress = unitLogic.GetUnit(UnitTypes.Stress);
+ static IUnit unitMoment = unitLogic.GetUnit(UnitTypes.Moment);
+ static IUnit unitCurvature = unitLogic.GetUnit(UnitTypes.Curvature);
+
+ static readonly IStressLogic stressLogic = new StressLogic();
+ public static List GetResultFuncs(FuncsTypes funcsType = FuncsTypes.Full)
+ {
+ List results = new();
+ if (funcsType == FuncsTypes.Strain)
+ {
+ results.AddRange(GetStrainResultFuncs());
+ }
+ else if (funcsType == FuncsTypes.Stress)
+ {
+ results.AddRange(GetStressResultFuncs());
+ }
+ else if (funcsType == FuncsTypes.Forces)
+ {
+ results.AddRange(GetForcesResultFuncs());
+ }
+ else if (funcsType == FuncsTypes.Full)
+ {
+ results.AddRange(GetStrainResultFuncs());
+ results.AddRange(GetStressResultFuncs());
+ results.AddRange(GetForcesResultFuncs());
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(funcsType));
+ }
+ return results;
+ }
+ private static List GetStrainResultFuncs()
+ {
+ List resultFuncs = new ();
+ 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 });
+ return resultFuncs;
+ }
+ private static List GetStressResultFuncs()
+ {
+ List resultFuncs = new ();
+ 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 });
+ return resultFuncs;
+ }
+ private static List GetForcesResultFuncs()
+ {
+ List resultFuncs = new ();
+ 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 });
+ return resultFuncs;
+ }
+ }
+}
diff --git a/StructureHelper/Services/ResultViewers/IResultFunc.cs b/StructureHelper/Services/ResultViewers/IResultFunc.cs
index 21110f5..6ab3b7a 100644
--- a/StructureHelper/Services/ResultViewers/IResultFunc.cs
+++ b/StructureHelper/Services/ResultViewers/IResultFunc.cs
@@ -8,10 +8,11 @@ using System.Threading.Tasks;
namespace StructureHelper.Services.ResultViewers
{
- public interface IResultFunc
+ public interface IResultFunc
{
string Name { get; }
- Func ResultFunction { get; }
+ T ResultFunction { get; }
+ string UnitName { get; set; }
double UnitFactor { get; }
}
}
diff --git a/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs b/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs
deleted file mode 100644
index d4dc1ac..0000000
--- a/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using LoaderCalculator.Logics;
-using StructureHelper.Infrastructure.UI.Converters.Units;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StructureHelper.Services.ResultViewers
-{
- public enum FuncsTypes
- {
- Strain,
- Stress,
- Forces,
- Full,
- }
- public static class ResultFuncFactory
- {
- static readonly IStressLogic stressLogic = new StressLogic();
- public static List GetResultFuncs(FuncsTypes funcsType = FuncsTypes.Full)
- {
- List results = new();
- if (funcsType == FuncsTypes.Strain)
- {
- results.AddRange(GetStrainResultFuncs());
- }
- else if (funcsType == FuncsTypes.Stress)
- {
- results.AddRange(GetStressResultFuncs());
- }
- else if (funcsType == FuncsTypes.Forces)
- {
- results.AddRange(GetForcesResultFuncs());
- }
- else if (funcsType == FuncsTypes.Full)
- {
- results.AddRange(GetStrainResultFuncs());
- results.AddRange(GetStressResultFuncs());
- results.AddRange(GetForcesResultFuncs());
- }
- else
- {
- throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(funcsType));
- }
- return results;
- }
- private static List GetStrainResultFuncs()
- {
- List resultFuncs = new List();
- resultFuncs.Add(new ResultFunc() { Name = "Total Strain", ResultFunction = stressLogic.GetTotalStrain });
- resultFuncs.Add(new ResultFunc() { Name = "Total Strain with prestrain", ResultFunction = stressLogic.GetTotalStrainWithPresrain });
- resultFuncs.Add(new ResultFunc() { Name = "Elastic Strain", ResultFunction = stressLogic.GetElasticStrain });
- resultFuncs.Add(new ResultFunc() { Name = "Plastic Strain", ResultFunction = stressLogic.GetPlasticStrain });
- return resultFuncs;
- }
- private static List GetStressResultFuncs()
- {
- List resultFuncs = new List();
- resultFuncs.Add(new ResultFunc() { Name = "Stress", ResultFunction = stressLogic.GetStress, UnitFactor = UnitConstants.Stress });
- resultFuncs.Add(new ResultFunc() { Name = "Secant modulus", ResultFunction = stressLogic.GetSecantModulus, UnitFactor = UnitConstants.Stress });
- resultFuncs.Add(new ResultFunc() { Name = "Modulus degradation", ResultFunction = stressLogic.GetModulusDegradation });
- return resultFuncs;
- }
- private static List GetForcesResultFuncs()
- {
- List resultFuncs = new List();
- resultFuncs.Add(new ResultFunc() { Name = "Force", ResultFunction = stressLogic.GetForce, UnitFactor = UnitConstants.Force });
- resultFuncs.Add(new ResultFunc() { Name = "Moment X", ResultFunction = stressLogic.GetMomentX, UnitFactor = UnitConstants.Force });
- resultFuncs.Add(new ResultFunc() { Name = "Moment Y", ResultFunction = stressLogic.GetMomentY, UnitFactor = UnitConstants.Force });
- return resultFuncs;
- }
- }
-}
diff --git a/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs b/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs
index 035fc76..ef0762a 100644
--- a/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs
+++ b/StructureHelper/Services/ResultViewers/ShowIsoFieldResult.cs
@@ -4,6 +4,10 @@ using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.ResultData;
using LoaderCalculator.Logics;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Services;
+using StructureHelperLogics.NdmCalculations.Cracking;
+using StructureHelperLogics.NdmCalculations.Triangulations;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -14,13 +18,14 @@ namespace StructureHelper.Services.ResultViewers
{
public static class ShowIsoFieldResult
{
- public static void ShowResult(IStrainMatrix strainMatrix, IEnumerable ndms, IEnumerable resultFuncs)
+ static IMathRoundLogic roundLogic = new SmartRoundLogic() { DigitQuant = 3 };
+ public static void ShowResult(IStrainMatrix strainMatrix, IEnumerable ndms, IEnumerable resultFuncs)
{
var primitiveSets = GetPrimitiveSets(strainMatrix, ndms, resultFuncs);
FieldViewerOperation.ShowViewer(primitiveSets);
}
- public static List GetPrimitiveSets(IStrainMatrix strainMatrix, IEnumerable ndms, IEnumerable resultFuncs)
+ public static List GetPrimitiveSets(IStrainMatrix strainMatrix, IEnumerable ndms, IEnumerable resultFuncs)
{
List primitiveSets = new List();
foreach (var valDelegate in resultFuncs)
@@ -29,23 +34,85 @@ namespace StructureHelper.Services.ResultViewers
List primitives = new List();
foreach (INdm ndm in ndms)
{
- double val = valDelegate.ResultFunction.Invoke(strainMatrix, ndm) * valDelegate.UnitFactor;
- IValuePrimitive valuePrimitive;
- if (ndm is IRectangleNdm)
- {
- var shapeNdm = ndm as IRectangleNdm;
- valuePrimitive = new RectanglePrimitive() { CenterX = ndm.CenterX, CenterY = ndm.CenterY, Height = shapeNdm.Height, Width = shapeNdm.Width, Value = val };
- }
- else
- {
- valuePrimitive = new CirclePrimitive() { CenterX = ndm.CenterX, CenterY = ndm.CenterY, Diameter = Math.Sqrt(ndm.Area / Math.PI) * 2, Value = val };
- }
- primitives.Add(valuePrimitive);
+ primitives.Add(ProcessNdm(strainMatrix, valDelegate, ndm));
}
primitiveSet.ValuePrimitives = primitives;
primitiveSets.Add(primitiveSet);
}
return primitiveSets;
}
+
+ public static List GetPrimitiveSets(IEnumerable rebarResults, IEnumerable resultFuncs)
+ {
+ List primitiveSets = new List();
+ foreach (var valDelegate in resultFuncs)
+ {
+ PrimitiveSet primitiveSet = new PrimitiveSet() { Name = valDelegate.Name };
+ List primitives = new List();
+ foreach (var rebarResult in rebarResults)
+ {
+ primitives.Add(ProcessNdm(valDelegate, rebarResult));
+ }
+ primitiveSet.ValuePrimitives = primitives;
+ primitiveSets.Add(primitiveSet);
+ }
+ return primitiveSets;
+ }
+
+ private static IValuePrimitive ProcessNdm(CrackResultFunc valDelegate, RebarCrackResult rebarResult)
+ {
+ double delegateResult = valDelegate.ResultFunction.Invoke(rebarResult);
+ var val = delegateResult * valDelegate.UnitFactor;
+ //val = roundLogic.RoundValue(val);
+ IValuePrimitive valuePrimitive;
+ var rebarNdm = rebarResult.RebarPrimitive.GetRebarNdm(new TriangulationOptions()
+ {
+ LimiteState = LimitStates.SLS,
+ CalcTerm = CalcTerms.ShortTerm
+ }
+ );
+ valuePrimitive = ProcessCircle(rebarNdm, val);
+ return valuePrimitive;
+ }
+
+ private static IValuePrimitive ProcessNdm(IStrainMatrix strainMatrix, ForceResultFunc valDelegate, INdm ndm)
+ {
+ 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);
+ }
+ else
+ {
+ valuePrimitive = ProcessCircle(ndm, val);
+ }
+ return valuePrimitive;
+ }
+
+ private static IValuePrimitive ProcessRectangle(IRectangleNdm shapeNdm, double val)
+ {
+ return new RectanglePrimitive()
+ {
+ CenterX = shapeNdm.CenterX,
+ CenterY = shapeNdm.CenterY,
+ Height = shapeNdm.Height,
+ Width = shapeNdm.Width,
+ Value = val
+ };
+ }
+
+ private static IValuePrimitive ProcessCircle(INdm ndm, double val)
+ {
+ return new CirclePrimitive()
+ {
+ CenterX = ndm.CenterX,
+ CenterY = ndm.CenterY,
+ Diameter = Math.Sqrt(ndm.Area / Math.PI) * 2,
+ Value = val
+ };
+ }
}
}
diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user
index c6ef7d2..c2ddce4 100644
--- a/StructureHelper/StructureHelper.csproj.user
+++ b/StructureHelper/StructureHelper.csproj.user
@@ -12,6 +12,15 @@
Code
+
+ Code
+
+
+ Code
+
+
+ Code
+
Code
@@ -68,6 +77,9 @@
+
+ Designer
+
Designer
@@ -83,9 +95,24 @@
Designer
+
+ Designer
+
Designer
+
+ Designer
+
+
+ Designer
+
+
+ Designer
+
+
+ Designer
+
Designer
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs
index b514987..0a41407 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/CrackDiagramLogic.cs
@@ -21,7 +21,11 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
internal class CrackDiagramLogic : ILongProcessLogic
{
+ static IConvertUnitLogic operationLogic = new ConvertUnitLogic();
+ static IGetUnitLogic unitLogic = new GetUnitLogic();
static readonly CrackForceCalculator calculator = new();
+ private ITriangulatePrimitiveLogic triangulateLogic;
+
private List ValidTupleList { get; set; }
ArrayParameter arrayParameter;
private IEnumerable TupleList { get; set; }
@@ -65,9 +69,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
arrayParameter = new ArrayParameter(ValidTupleList.Count(), labels);
CalculateWithCrack(ValidTupleList,
NdmPrimitives,
- CommonOperation.GetUnit(UnitTypes.Force),
- CommonOperation.GetUnit(UnitTypes.Moment),
- CommonOperation.GetUnit(UnitTypes.Curvature));
+ unitLogic.GetUnit(UnitTypes.Force),
+ unitLogic.GetUnit(UnitTypes.Moment),
+ unitLogic.GetUnit(UnitTypes.Curvature));
}
public void ShowWindow()
@@ -102,7 +106,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
calculator.EndTuple = validTupleList[i].DesignForceTuple.ForceTuple;
var limitState = validTupleList[i].DesignForceTuple.LimitState;
var calcTerm = validTupleList[i].DesignForceTuple.CalcTerm;
- var ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
+ triangulateLogic = new TriangulatePrimitiveLogic()
+ {
+ Primitives = ndmPrimitives,
+ LimitState = limitState,
+ CalcTerm = calcTerm,
+ TraceLogger = TraceLogger
+ };
+ var ndms = triangulateLogic.GetNdms();
calculator.NdmCollection = ndms;
calculator.Run();
var result = (CrackForceResult)calculator.Result;
@@ -143,7 +154,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
const string crc = "Crc";
const string crcFactor = "CrcSofteningFactor";
var labels = LabelsFactory.GetCommonLabels();
- IUnit unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature);
+ IUnit unitCurvature = unitLogic.GetUnit(UnitTypes.Curvature);
var crclabels = new List
{
$"{crc}{GeometryNames.CurvFstName}, {unitCurvature.Name}",
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataView.xaml
new file mode 100644
index 0000000..d09396a
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataView.xaml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataView.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataView.xaml.cs
new file mode 100644
index 0000000..d720440
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataView.xaml.cs
@@ -0,0 +1,39 @@
+using StructureHelper.Windows.ViewModels.Calculations.Calculators;
+using StructureHelper.Windows.ViewModels.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ ///
+ /// Логика взаимодействия для CrackCalculatorInputDataView.xaml
+ ///
+ public partial class CrackCalculatorInputDataView : Window
+ {
+ private CrackCalculatorInputDataViewModel viewModel;
+
+ public CrackCalculatorInputDataView(CrackCalculatorInputDataViewModel viewModel)
+ {
+ this.viewModel = viewModel;
+ viewModel.ParentWindow = this;
+ DataContext = viewModel;
+ InitializeComponent();
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ viewModel.Refresh();
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataViewModel.cs
new file mode 100644
index 0000000..0cd6bb9
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackCalculatorInputDataViewModel.cs
@@ -0,0 +1,115 @@
+using StructureHelper.Infrastructure.UI.DataContexts;
+using StructureHelper.Windows.ViewModels;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperLogics.NdmCalculations.Cracking;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ public class CrackCalculatorInputDataViewModel : OkCancelViewModelBase
+ {
+ private CrackCalculator calculator;
+ CrackInputData crackInputData;
+ private bool setUserValueSofteningFactor;
+ private double softeningFactor;
+ private string name;
+
+ public SourceTargetVM CombinationViewModel { get; }
+ public SourceTargetVM PrimitivesViewModel { get; private set; }
+ public string WindowTitle => "Crack calculator: " + Name;
+ public string Name
+ {
+ get => calculator.Name;
+ set
+ {
+ calculator.Name = value;
+ OnPropertyChanged(nameof(Name));
+ OnPropertyChanged(nameof(WindowTitle));
+ }
+ }
+ public bool SetSofteningFactor
+ {
+ get => crackInputData.UserCrackInputData.SetSofteningFactor;
+ set
+ {
+ crackInputData.UserCrackInputData.SetSofteningFactor = value;
+ OnPropertyChanged(nameof(SetSofteningFactor));
+ }
+ }
+ public double SofteningFactor
+ {
+ get => crackInputData.UserCrackInputData.SofteningFactor; set
+ {
+ if (value > 1d || value < 0d) { return; }
+ crackInputData.UserCrackInputData.SofteningFactor = value;
+ OnPropertyChanged(nameof(SetSofteningFactor));
+ }
+ }
+ public bool SetLengthBetweenCracks
+ {
+ get => crackInputData.UserCrackInputData.SetLengthBetweenCracks;
+ set
+ {
+ crackInputData.UserCrackInputData.SetLengthBetweenCracks = value;
+ OnPropertyChanged(nameof(SetLengthBetweenCracks));
+ }
+ }
+ public double LengthBetweenCracks
+ {
+ get => crackInputData.UserCrackInputData.LengthBetweenCracks; set
+ {
+ if (value <= 0d) { return; }
+ crackInputData.UserCrackInputData.LengthBetweenCracks = value;
+ OnPropertyChanged(nameof(SetLengthBetweenCracks));
+ }
+ }
+
+ public double UltLongTermCrackWidth
+ {
+ get => crackInputData.UserCrackInputData.UltimateLongCrackWidth; set
+ {
+ if (value <= 0d) { return; }
+ crackInputData.UserCrackInputData.UltimateLongCrackWidth = value;
+ OnPropertyChanged(nameof(UltLongTermCrackWidth));
+ }
+ }
+ public double UltShortTermCrackWidth
+ {
+ get => crackInputData.UserCrackInputData.UltimateShortCrackWidth; set
+ {
+ if (value <= 0d) { return; }
+ crackInputData.UserCrackInputData.UltimateShortCrackWidth = value;
+ OnPropertyChanged(nameof(UltShortTermCrackWidth));
+ }
+ }
+
+ public CrackCalculatorInputDataViewModel(IEnumerable allowedPrimitives, IEnumerable allowedCombinations, CrackCalculator crackCalculator)
+ {
+ calculator = crackCalculator;
+ crackInputData = calculator.InputData;
+ CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(allowedCombinations, crackInputData.ForceActions);
+ PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(allowedPrimitives, crackInputData.Primitives);
+ }
+
+ public void Refresh()
+ {
+ var combinations = CombinationViewModel.GetTargetItems();
+ crackInputData.ForceActions.Clear();
+ foreach (var item in combinations)
+ {
+ crackInputData.ForceActions.Add(item);
+ }
+ crackInputData.Primitives.Clear();
+ foreach (var item in PrimitivesViewModel.GetTargetItems())
+ {
+ crackInputData.Primitives.Add(item.GetNdmPrimitive());
+ }
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultView.xaml
new file mode 100644
index 0000000..549134c
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultView.xaml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultView.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultView.xaml.cs
new file mode 100644
index 0000000..1bd09b0
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultView.xaml.cs
@@ -0,0 +1,36 @@
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ ///
+ /// Логика взаимодействия для CrackResultView.xaml
+ ///
+ public partial class CrackResultView : Window
+ {
+ private readonly CrackResultViewModel viewModel;
+
+ public CrackResultView(CrackResultViewModel viewModel)
+ {
+ this.viewModel = viewModel;
+ InitializeComponent();
+ this.DataContext = this.viewModel;
+ }
+ public CrackResultView(CrackResult result) : this(new CrackResultViewModel(result))
+ {
+
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultViewModel.cs
new file mode 100644
index 0000000..9682c08
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/CrackResultViewModel.cs
@@ -0,0 +1,51 @@
+using StructureHelper.Infrastructure;
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ public class CrackResultViewModel : ViewModelBase
+ {
+ IShowCrackIsoFieldsLogic showCrackIsoFieldsLogic => new ShowCrackIsoFieldsLogic();
+ private CrackResult crackResult;
+ private RelayCommand? showIsoFieldCommand;
+ private RelayCommand? showRebarsCommand;
+
+ public TupleCrackResult SelectedResult { get; set; }
+ public List TupleResults => CrackResult.TupleResults;
+ public ICommand ShowRebarsCommand
+ {
+ get
+ {
+ return showRebarsCommand ??= new RelayCommand(o =>
+ {
+ var wnd = new TupleCrackResultView(SelectedResult);
+ wnd.ShowDialog();
+ }, o => SelectedResult != null && SelectedResult.IsValid);
+ }
+ }
+
+ public ICommand ShowIsoFieldCommand
+ {
+ get
+ {
+ return showIsoFieldCommand ??= new RelayCommand(o =>
+ {
+ showCrackIsoFieldsLogic.ShowIsoField(SelectedResult.RebarResults);
+ }, o => SelectedResult != null && SelectedResult.IsValid);
+ }
+ }
+
+ public CrackResult CrackResult => crackResult;
+
+ public CrackResultViewModel(CrackResult crackResult)
+ {
+ this.crackResult = crackResult;
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/Cracks.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/Cracks.xaml
new file mode 100644
index 0000000..0064bfd
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/Cracks.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/IShowCrackIsoFieldsLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/IShowCrackIsoFieldsLogic.cs
new file mode 100644
index 0000000..0377302
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/IShowCrackIsoFieldsLogic.cs
@@ -0,0 +1,10 @@
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System.Collections.Generic;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ public interface IShowCrackIsoFieldsLogic
+ {
+ void ShowIsoField(IEnumerable rebarResults);
+ }
+}
\ No newline at end of file
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/ShowCrackIsoFieldsLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/ShowCrackIsoFieldsLogic.cs
new file mode 100644
index 0000000..deef0fe
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/ShowCrackIsoFieldsLogic.cs
@@ -0,0 +1,37 @@
+using StructureHelper.Services.Reports.CalculationReports;
+using StructureHelper.Services.ResultViewers;
+using StructureHelper.Windows.Errors;
+using StructureHelper.Windows.ViewModels.Errors;
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ public class ShowCrackIsoFieldsLogic : IShowCrackIsoFieldsLogic
+ {
+ private IsoFieldReport isoFieldReport;
+
+ public void ShowIsoField(IEnumerable rebarResults)
+ {
+ try
+ {
+ var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(rebarResults, CrackResultFuncFactory.GetResultFuncs());
+ isoFieldReport = new IsoFieldReport(primitiveSets);
+ isoFieldReport.Show();
+ }
+ catch (Exception ex)
+ {
+ var vm = new ErrorProcessor()
+ {
+ ShortText = "Errors apearred during showing isofield, see detailed information",
+ DetailText = $"{ex}"
+ };
+ new ErrorMessage(vm).ShowDialog();
+ }
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultView.xaml
new file mode 100644
index 0000000..94b8a54
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultView.xaml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultView.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultView.xaml.cs
new file mode 100644
index 0000000..042665c
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultView.xaml.cs
@@ -0,0 +1,35 @@
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ ///
+ /// Логика взаимодействия для TupleCrackResultView.xaml
+ ///
+ public partial class TupleCrackResultView : Window
+ {
+ TupleCrackResultViewModel viewModel;
+ public TupleCrackResultView(TupleCrackResultViewModel viewModel)
+ {
+ InitializeComponent();
+ this.viewModel = viewModel;
+ DataContext = this.viewModel;
+ }
+ public TupleCrackResultView(TupleCrackResult crackResult) : this(new TupleCrackResultViewModel(crackResult))
+ {
+
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultViewModel.cs
new file mode 100644
index 0000000..8f5d5d5
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/Cracks/TupleCrackResultViewModel.cs
@@ -0,0 +1,46 @@
+using LoaderCalculator.Data.Matrix;
+using LoaderCalculator.Data.Ndms;
+using StructureHelper.Infrastructure;
+using StructureHelper.Services.Reports.CalculationReports;
+using StructureHelper.Services.ResultViewers;
+using StructureHelper.Windows.Errors;
+using StructureHelper.Windows.ViewModels.Errors;
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ public class TupleCrackResultViewModel : ViewModelBase
+ {
+ IShowCrackIsoFieldsLogic showCrackIsoFieldsLogic => new ShowCrackIsoFieldsLogic();
+ private TupleCrackResult crackResult;
+ private RelayCommand showIsoFieldCommand;
+ private IsoFieldReport isoFieldReport;
+
+ public TupleCrackResult CrackResult => crackResult;
+ public List RebarResults => crackResult.RebarResults;
+ public RebarCrackResult SelectedResult { get; set; }
+ public string WindowTitle => "Result of calculation of cracks for action " + crackResult.InputData.TupleName;
+ public ICommand ShowIsoFieldCommand
+ {
+ get
+ {
+ return showIsoFieldCommand ??= new RelayCommand(o =>
+ {
+ showCrackIsoFieldsLogic.ShowIsoField(crackResult.RebarResults);
+ });
+ }
+ }
+ public TupleCrackResultViewModel(TupleCrackResult crackResult)
+ {
+ this.crackResult = crackResult;
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/DiagramFactory.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/DiagramFactory.cs
new file mode 100644
index 0000000..2b74dd7
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/DiagramFactory.cs
@@ -0,0 +1,68 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models.Parameters;
+using StructureHelperCommon.Services.Units;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
+{
+ ///
+ /// Create array of common values
+ ///
+ public class DiagramFactory
+ {
+ IConvertUnitLogic operationLogic = new ConvertUnitLogic();
+ IGetUnitLogic unitLogic = new GetUnitLogic();
+ private ArrayParameter arrayParameter;
+ ///
+ /// Collection of force results
+ ///
+ public List TupleList { get; set; }
+
+ //public Action SetProgress { get; set; }
+
+ public ArrayParameter GetCommonArray()
+ {
+ var labels = LabelsFactory.GetCommonLabels();
+ arrayParameter = new ArrayParameter(TupleList.Count(), labels);
+ Calculate();
+ return arrayParameter;
+ }
+
+ private void Calculate()
+ {
+ var data = arrayParameter.Data;
+ for (int i = 0; i < TupleList.Count(); i++)
+ {
+ var valueList = ProcessResult(i);
+ for (int j = 0; j < valueList.Count; j++)
+ {
+ data[i, j] = valueList[j];
+ }
+ //SetProgress?.Invoke(i);
+ }
+ }
+
+
+ private List ProcessResult(int i)
+ {
+ var unitForce = unitLogic.GetUnit(UnitTypes.Force);
+ var unitMoment = unitLogic.GetUnit(UnitTypes.Moment);
+ var unitCurvature = unitLogic.GetUnit(UnitTypes.Curvature);
+
+ return new List
+ {
+ TupleList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
+ TupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
+ TupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
+ TupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
+ TupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
+ TupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
+ };
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/IValuePointDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/IValuePointDiagramLogic.cs
new file mode 100644
index 0000000..a4919bf
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/IValuePointDiagramLogic.cs
@@ -0,0 +1,18 @@
+using StructureHelper.Windows.Forces;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Parameters;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
+using System.Collections.Generic;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
+{
+ public interface IValuePointDiagramLogic
+ {
+ ForceCalculator Calculator { get; set; }
+ PointPrimitiveLogic PrimitiveLogic { get; set; }
+ IEnumerable TupleList { get; set; }
+ ValueDelegatesLogic ValueDelegatesLogic { get; set; }
+
+ GenericResult> GetArrayParameter();
+ }
+}
\ No newline at end of file
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs
index 2a5f059..625265f 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InteractionDiagramLogic.cs
@@ -25,10 +25,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
const string ForceUnitString = "kN";
const string MomentUnitString = "kNm";
+ IConvertUnitLogic operationLogic;
+
//private List> arrayParameters;
private IResult result;
- private IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force, ForceUnitString);
- private IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, MomentUnitString);
+ private IUnit unitForce;
+ private IUnit unitMoment;
private int stepCount;
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
@@ -48,7 +50,11 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
stepCount *= InputData.CalcTerms.Count();
stepCount *= InputData.PredicateEntries.Count();
//arrayParameters = new();
- }
+ operationLogic = new ConvertUnitLogic();
+ IGetUnitLogic unitLogic = new GetUnitLogic();
+ unitForce = unitLogic.GetUnit(UnitTypes.Force, ForceUnitString);
+ unitMoment = unitLogic.GetUnit(UnitTypes.Moment, MomentUnitString);
+ }
private void DoCalculations()
{
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InterpolateValuePointsLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InterpolateValuePointsLogic.cs
new file mode 100644
index 0000000..fc1d066
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/InterpolateValuePointsLogic.cs
@@ -0,0 +1,86 @@
+using StructureHelper.Windows.Forces;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using StructureHelper.Infrastructure.UI.DataContexts;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Calculators;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
+{
+ public class InterpolateValuePointsLogic
+ {
+ private InterpolationProgressLogic interpolationLogic;
+ private ValuePointsInterpolateViewModel viewModel;
+ private IResult result;
+ private ValuePointsInterpolationInputData inputData;
+ public ForcesTupleResult SelectedResult { get; set; }
+ public IEnumerable NdmPrimitives { get; set; }
+ public ForceCalculator ForceCalculator { get; set; }
+
+
+ public ILongProcessLogic ProgressLogic { get; set; }
+ public ShowProgressLogic ShowProgressLogic { get; set; }
+
+ public void InterpolateValuePoints()
+ {
+ var tuple = SelectedResult.DesignForceTuple ?? throw new StructureHelperException(ErrorStrings.NullReference + ": Design force combination");
+ PrepareInputData(tuple);
+ viewModel = new ValuePointsInterpolateViewModel(inputData);
+ if (ShowDialog() == false) { return; };
+ ShowDiagram(result);
+ }
+
+ private void PrepareInputData(IDesignForceTuple tuple)
+ {
+ inputData = new ValuePointsInterpolationInputData()
+ {
+ FinishDesignForce = tuple.Clone() as IDesignForceTuple,
+ LimitState = tuple.LimitState,
+ CalcTerm = tuple.CalcTerm,
+ };
+ inputData.PrimitiveBases.AddRange(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(NdmPrimitives));
+ }
+
+ private bool ShowDialog()
+ {
+ var wnd = new ValuePointsInterpolateView(viewModel);
+ wnd.ShowDialog();
+ if (wnd.DialogResult != true) { return false; }
+ interpolationLogic = new InterpolationProgressLogic(ForceCalculator, viewModel.ForceInterpolationViewModel.Result);
+ ProgressLogic = interpolationLogic;
+ ShowProgressLogic = new(interpolationLogic)
+ {
+ WindowTitle = "Interpolate forces",
+ };
+ ShowProgressLogic.Show();
+ result = interpolationLogic.InterpolateCalculator.Result;
+ return true;
+ }
+
+ private void ShowDiagram(IResult result)
+ {
+ if (result.IsValid == false) { return; }
+ if (result is not IForcesResults)
+ {
+ throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(IForcesResults), result));
+ }
+ var tupleResult = result as IForcesResults;
+ var pointGraphLogic = new ShowValuePointDiagramLogic()
+ {
+ Calculator = interpolationLogic.InterpolateCalculator,
+ PrimitiveLogic = viewModel.PrimitiveLogic,
+ ValueDelegatesLogic = viewModel.ValueDelegatesLogic,
+ TupleList = tupleResult.ForcesResultList
+ };
+ pointGraphLogic.ShowWindow();
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs
index db6552e..47f58ca 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/LabelsFactory.cs
@@ -11,9 +11,11 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
public static class LabelsFactory
{
- private static IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force);
- private static IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment);
- private static IUnit unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature);
+ static IConvertUnitLogic operationLogic = new ConvertUnitLogic();
+ static IGetUnitLogic unitLogic = new GetUnitLogic();
+ private static IUnit unitForce = unitLogic.GetUnit(UnitTypes.Force);
+ private static IUnit unitMoment = unitLogic.GetUnit(UnitTypes.Moment);
+ private static IUnit unitCurvature = unitLogic.GetUnit(UnitTypes.Curvature);
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public static List GetCommonLabels()
{
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs
index 04445c5..f03902b 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackResultLogic.cs
@@ -18,6 +18,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
internal class ShowCrackResultLogic
{
private CrackForceCalculator calculator;
+ private ITriangulatePrimitiveLogic triangulateLogic;
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public LimitStates LimitState { get; set; }
@@ -42,7 +43,13 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
calculator.TraceLogger = new ShiftTraceLogger();
calculator.StartTuple = startDesignTuple;
calculator.EndTuple = finishDesignTuple;
- calculator.NdmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitState, CalcTerm);
+ triangulateLogic = new TriangulatePrimitiveLogic()
+ {
+ Primitives = ndmPrimitives,
+ LimitState = LimitState,
+ CalcTerm = CalcTerm
+ };
+ calculator.NdmCollection = triangulateLogic.GetNdms();
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid)
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs
index 4410f59..54eccf4 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowCrackWidthLogic.cs
@@ -19,14 +19,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
internal void Show()
{
- var inputData = new CrackWidthCalculatorInputData()
+ var inputData = new TupleCrackInputData()
{
- LimitState = LimitState,
- CalcTerm = CalcTerm,
- ForceTuple = ForceTuple,
- NdmPrimitives = ndmPrimitives
+ //LimitState = LimitState,
+ //CalcTerm = CalcTerm,
+ LongTermTuple = ForceTuple,
+ Primitives = ndmPrimitives
};
- var calculator = new CrackWidthCalculator() { InputData = inputData };
+ var calculator = new TupleCrackCalculator() { InputData = inputData };
calculator.Run();
var result = calculator.Result;
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs
index 8e42820..033e827 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowDiagramLogic.cs
@@ -58,9 +58,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
validTupleList = tupleList.Where(x => x.IsValid == true).ToList();
- var labels = LabelsFactory.GetCommonLabels();
- arrayParameter = new ArrayParameter(validTupleList.Count(), labels);
- Calculate();
+ var factory = new DiagramFactory()
+ {
+ TupleList = validTupleList,
+ //SetProgress = SetProgress,
+ };
+ arrayParameter = factory.GetCommonArray();
}
public ShowDiagramLogic(IEnumerable tupleList, IEnumerable ndmPrimitives)
@@ -69,37 +72,5 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
this.ndmPrimitives = ndmPrimitives;
validTupleList = tupleList.Where(x => x.IsValid == true).ToList();
}
-
- private void Calculate()
- {
- var data = arrayParameter.Data;
- for (int i = 0; i < validTupleList.Count(); i++)
- {
- var valueList = ProcessResult(i);
- for (int j = 0; j < valueList.Count; j++)
- {
- data[i, j] = valueList[j];
- }
- SetProgress?.Invoke(i);
- }
- }
-
-
- private List ProcessResult(int i)
- {
- var unitForce = CommonOperation.GetUnit(UnitTypes.Force);
- var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment);
- var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature);
-
- return new List
- {
- validTupleList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
- validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
- validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
- validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
- validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
- validTupleList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
- };
- }
}
}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowProgressLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowProgressLogic.cs
index ecf5414..23c4e20 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowProgressLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowProgressLogic.cs
@@ -1,4 +1,5 @@
using StructureHelper.Windows.CalculationWindows.ProgressViews;
+using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
@@ -11,7 +12,7 @@ using System.Windows.Forms;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
- internal class ShowProgressLogic
+ public class ShowProgressLogic
{
private ShowProgressViewModel progressViewModel;
private ShowProgressView wndProgress;
@@ -82,8 +83,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
}
catch (Exception ex)
{
-
- throw;
+ throw new StructureHelperException(ex);
}
}
}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs
index f527fcc..abcc47d 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ShowValuePointDiagramLogic.cs
@@ -1,11 +1,17 @@
-using StructureHelper.Infrastructure.UI.DataContexts;
+using LoaderCalculator.Data.Materials.MaterialBuilders;
+using LoaderCalculator.Data.Ndms;
+using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Services.ResultViewers;
+using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
+using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
@@ -17,45 +23,43 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
+//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
+//All rights reserved.
+
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
- public class ShowValuePointDiagramLogic : ILongProcessLogic
+ public class ShowValuePointDiagramLogic //: ILongProcessLogic
{
private ArrayParameter arrayParameter;
- private IEnumerable tupleList;
- private IEnumerable ndmPrimitives;
- private List validTupleList;
- private List<(PrimitiveBase PrimitiveBase, List>)> valuePoints;
- private List resultFuncList;
+ private IValuePointDiagramLogic pointDiagramLogic;
+ public IEnumerable TupleList { get; set; }
public ForceCalculator Calculator { get; set; }
public PointPrimitiveLogic PrimitiveLogic { get; set; }
public ValueDelegatesLogic ValueDelegatesLogic { get; set; }
- public int StepCount => throw new NotImplementedException();
+ //public int StepCount => throw new NotImplementedException();
- public Action SetProgress { get; set; }
- public bool Result { get; set; }
- public IShiftTraceLogger? TraceLogger { get; set; }
- public ShowValuePointDiagramLogic(IEnumerable tupleList, IEnumerable ndmPrimitives)
+ //public Action SetProgress { get; set; }
+ //public bool Result { get; set; }
+ //public IShiftTraceLogger? TraceLogger { get; set; }
+ public ShowValuePointDiagramLogic(IValuePointDiagramLogic pointDiagramLogic)
{
- this.tupleList = tupleList;
- this.ndmPrimitives = ndmPrimitives;
- validTupleList = this.tupleList.Where(x => x.IsValid == true).ToList();
- valuePoints = new List<(PrimitiveBase PrimitiveBase, List>)>();
- foreach (var item in PrimitiveLogic.Collection.CollectionItems)
- {
- var pointsCount = item.Item.ValuePoints.SelectedCount;
- if (pointsCount > 0)
- {
- var points = item.Item.ValuePoints.SelectedItems.ToList();
- var primitive = item.Item.PrimitiveBase;
- valuePoints.Add((primitive, points));
- }
- }
+ this.pointDiagramLogic = pointDiagramLogic;
+ }
+ public ShowValuePointDiagramLogic() : this(new ValuePointDiagramLogic())
+ {
+
}
public void ShowWindow()
{
+ var result = GetResult();
+ if (result.IsValid != true)
+ {
+ SafetyProcessor.ShowMessage(ErrorStrings.DataIsInCorrect, result.Description);
+ return;
+ }
+ arrayParameter = result.Value;
SafetyProcessor.RunSafeProcess(() =>
{
var series = new Series(arrayParameter)
@@ -71,32 +75,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
}, ErrorStrings.ErrorDuring("building chart"));
}
- public void WorkerDoWork(object sender, DoWorkEventArgs e)
+ private GenericResult> GetResult()
{
- Show();
- Result = true;
- }
-
- public void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
- {
- //Nothing to do
- }
-
- public void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- //Nothing to do
- }
-
- private void Show()
- {
-
- }
-
- private List GetColumnNames()
- {
- var columnNames = LabelsFactory.GetCommonLabels();
-
- return columnNames;
+ pointDiagramLogic.TupleList = TupleList;
+ pointDiagramLogic.PrimitiveLogic = PrimitiveLogic;
+ pointDiagramLogic.Calculator = Calculator;
+ pointDiagramLogic.ValueDelegatesLogic = ValueDelegatesLogic;
+ var results = pointDiagramLogic.GetArrayParameter();
+ return results;
}
}
}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ValuePointDiagramLogic.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ValuePointDiagramLogic.cs
new file mode 100644
index 0000000..b08bb5c
--- /dev/null
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceResultLogic/ValuePointDiagramLogic.cs
@@ -0,0 +1,173 @@
+using LoaderCalculator.Data.Ndms;
+using StructureHelper.Infrastructure.UI.DataContexts;
+using StructureHelper.Services.ResultViewers;
+using StructureHelper.Windows.Forces;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Parameters;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic
+{
+ public class ValuePointDiagramLogic : IValuePointDiagramLogic
+ {
+ private ArrayParameter arrayParameter;
+ private List<(INamedAreaPoint areaPoint, INdmPrimitive ndmPrimitive)> pointCollection;
+ private List validTuplesList;
+ private ArrayParameter arrayOfValuesByPoint;
+ private IEnumerable selectedDelegates;
+ private string exceptionMessage;
+
+ public IEnumerable TupleList { get; set; }
+ public ForceCalculator Calculator { get; set; }
+ public PointPrimitiveLogic PrimitiveLogic { get; set; }
+ public ValueDelegatesLogic ValueDelegatesLogic { get; set; }
+
+ public GenericResult> GetArrayParameter()
+ {
+ SetParameters();
+ var checkResult = CheckParameters();
+ if (checkResult != true)
+ {
+ return GetFalseResult();
+ }
+ PrepareArray();
+ return GetValidResult();
+ }
+
+ private GenericResult> GetValidResult()
+ {
+ int i = 0;
+ foreach (var tuple in validTuplesList)
+ {
+ ProcessPointByTuple(tuple, i);
+ i++;
+ }
+ arrayParameter.AddArray(arrayOfValuesByPoint);
+ return new GenericResult>()
+ {
+ IsValid = true,
+ Value = arrayParameter
+ };
+ }
+ private GenericResult> GetFalseResult()
+ {
+ return new GenericResult>()
+ {
+ IsValid = false,
+ Description = exceptionMessage
+ };
+ }
+ private void SetParameters()
+ {
+ GetPointCollection();
+ selectedDelegates = ValueDelegatesLogic.ResultFuncs.SelectedItems;
+ validTuplesList = TupleList
+ .Where(x => x.IsValid == true)
+ .ToList();
+ }
+ private bool CheckParameters()
+ {
+ var result = true;
+ exceptionMessage = ErrorStrings.DataIsInCorrect;
+ if (pointCollection.Any() == false)
+ {
+ exceptionMessage += ", point collection is null";
+ result = false;
+ }
+ if (selectedDelegates.Any() == false)
+ {
+ exceptionMessage += ", value expression collection is null";
+ result = false;
+ }
+ if (validTuplesList.Any() == false)
+ {
+ exceptionMessage += ", force list is empty";
+ result = false;
+ }
+ return result;
+ }
+ private void GetPointCollection()
+ {
+ pointCollection = new();
+ foreach (var primitiveValuePoint in PrimitiveLogic.Collection.CollectionItems)
+ {
+ foreach (var selectedPoint in primitiveValuePoint.Item.ValuePoints.SelectedItems)
+ {
+ var newPoint = (selectedPoint, primitiveValuePoint.Item.PrimitiveBase.GetNdmPrimitive());
+ pointCollection.Add(newPoint);
+ }
+ }
+ }
+ private void ProcessPointByTuple(IForcesTupleResult tuple, int i)
+ {
+ var values = new List();
+ var strainMatrix = tuple.LoaderResults.ForceStrainPair.StrainMatrix;
+
+ foreach (var valuePoint in pointCollection)
+ {
+ var ndm = GetMockNdm(valuePoint, tuple);
+
+ foreach (var valDelegate in selectedDelegates)
+ {
+ double val = valDelegate.ResultFunction.Invoke(strainMatrix, ndm) * valDelegate.UnitFactor;
+ values.Add(val);
+ }
+ }
+ arrayOfValuesByPoint.AddRow(i, values);
+ }
+ private void PrepareArray()
+ {
+ var factory = new DiagramFactory()
+ {
+ TupleList = validTuplesList,
+ //SetProgress = SetProgress,
+ };
+ arrayParameter = factory.GetCommonArray();
+
+ var labels = GetValueLabels(selectedDelegates);
+ arrayOfValuesByPoint = new ArrayParameter(validTuplesList.Count(), labels);
+ }
+ private INdm GetMockNdm((INamedAreaPoint areaPoint, INdmPrimitive ndmPrimitive) valuePoint, IForcesTupleResult tuple)
+ {
+ var limitState = tuple.DesignForceTuple.LimitState;
+ var calcTerm = tuple.DesignForceTuple.CalcTerm;
+ var material = valuePoint.ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
+ var userPrestrain = valuePoint.ndmPrimitive.UsersPrestrain;
+ var autoPrestrain = valuePoint.ndmPrimitive.AutoPrestrain;
+ var ndm = new Ndm()
+ {
+ Area = valuePoint.areaPoint.Area,
+ CenterX = valuePoint.areaPoint.Point.X,
+ CenterY = valuePoint.areaPoint.Point.Y,
+ Material = material,
+ };
+ ndm.Prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * valuePoint.areaPoint.Point.Y
+ + (userPrestrain.My + autoPrestrain.My) * valuePoint.areaPoint.Point.X
+ + userPrestrain.Nz + autoPrestrain.Nz;
+ return ndm;
+ }
+ private List GetValueLabels(IEnumerable selectedDelegates)
+ {
+ List strings = new();
+ foreach (var valuePoint in pointCollection)
+ {
+ foreach (var deleg in selectedDelegates)
+ {
+ string s = valuePoint.ndmPrimitive.Name;
+ s += "_" + valuePoint.areaPoint.Name;
+ s += "_" + deleg.Name + ", " + deleg.UnitName;
+ strings.Add(s);
+ }
+ }
+ return strings;
+ }
+ }
+}
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
index 4b48b33..c059250 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
d:DataContext="{d:DesignInstance local:ForcesResultsViewModel}"
mc:Ignorable="d"
- Title="Calculation Results" Height="350" Width="850" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterScreen">
+ Title="Calculation Results" Height="350" Width="850" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterScreen" ShowInTaskbar="False">
@@ -25,7 +25,11 @@
-
+
@@ -59,13 +63,11 @@
-
-
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs
index cac1378..1191a0a 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs
@@ -43,7 +43,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private ShowProgressLogic showProgressLogic;
private InteractionDiagramLogic interactionDiagramLogic;
private static readonly ShowCrackResultLogic showCrackResultLogic = new();
- private static readonly ShowCrackWidthLogic showCrackWidthLogic = new();
+ //private static readonly ShowCrackWidthLogic showCrackWidthLogic = new();
private IForcesResults forcesResults;
private IEnumerable ndmPrimitives;
private IEnumerable selectedNdmPrimitives;
@@ -152,12 +152,12 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
get => showGraphsCommand ??= new RelayCommand(o =>
{
- InterpolateTuplesViewModel interploateTuplesViewModel;
+ InterpolateTuplesViewModel interpolateTuplesViewModel;
InterpolateTuplesView wndTuples;
- ShowInterpolationWindow(out interploateTuplesViewModel, out wndTuples);
+ ShowInterpolationWindow(out interpolateTuplesViewModel, out wndTuples);
if (wndTuples.DialogResult != true) return;
- var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interploateTuplesViewModel.ForceInterpolationViewModel.Result);
+ var interpolationLogic = new InterpolationProgressLogic(forceCalculator, interpolateTuplesViewModel.ForceInterpolationViewModel.Result);
showProgressLogic = new(interpolationLogic)
{
WindowTitle = "Interpolate forces"
@@ -225,22 +225,22 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
showCrackResultLogic.Show(SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple);
}
- public ICommand ShowCrackWidthResultCommand
- {
- get => showCrackWidthResult ??= new RelayCommand(o =>
- {
- SafetyProcessor.RunSafeProcess(ShowCrackWidthResult);
- }, o => SelectedResult != null && SelectedResult.IsValid);
- }
+ //public ICommand ShowCrackWidthResultCommand
+ //{
+ // get => showCrackWidthResult ??= new RelayCommand(o =>
+ // {
+ // SafetyProcessor.RunSafeProcess(ShowCrackWidthResult);
+ // }, o => SelectedResult != null && SelectedResult.IsValid);
+ //}
- private void ShowCrackWidthResult()
- {
- showCrackWidthLogic.LimitState = SelectedResult.DesignForceTuple.LimitState;
- showCrackWidthLogic.CalcTerm = SelectedResult.DesignForceTuple.CalcTerm;
- showCrackWidthLogic.ForceTuple = SelectedResult.DesignForceTuple.ForceTuple;
- showCrackWidthLogic.ndmPrimitives = ndmPrimitives.ToList();
- showCrackWidthLogic.Show();
- }
+ //private void ShowCrackWidthResult()
+ //{
+ // showCrackWidthLogic.LimitState = SelectedResult.DesignForceTuple.LimitState;
+ // showCrackWidthLogic.CalcTerm = SelectedResult.DesignForceTuple.CalcTerm;
+ // showCrackWidthLogic.ForceTuple = SelectedResult.DesignForceTuple.ForceTuple;
+ // showCrackWidthLogic.ndmPrimitives = ndmPrimitives.ToList();
+ // showCrackWidthLogic.Show();
+ //}
public ICommand InterpolateCommand
{
get
@@ -285,31 +285,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
throw new StructureHelperException(ErrorStrings.NullReference + ": Nothing is selected");
}
- var tuple = SelectedResult.DesignForceTuple ?? throw new StructureHelperException(ErrorStrings.NullReference + ": Design force combination");
- var inputData = new ValuePointsInterpolationInputData()
+ var logic = new InterpolateValuePointsLogic()
{
- FinishDesignForce = tuple.Clone() as IDesignForceTuple,
- LimitState = tuple.LimitState,
- CalcTerm = tuple.CalcTerm,
+ SelectedResult = SelectedResult,
+ ForceCalculator = forceCalculator,
+ NdmPrimitives = ndmPrimitives,
+ ProgressLogic = progressLogic,
+ ShowProgressLogic = showProgressLogic
};
- inputData.PrimitiveBases.AddRange(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(ndmPrimitives));
- var viewModel = new ValuePointsInterpolateViewModel(inputData);
- var wnd = new ValuePointsInterpolateView(viewModel);
- wnd.ShowDialog();
- if (wnd.DialogResult != true) { return; }
- var interpolationLogic = new InterpolationProgressLogic(forceCalculator, viewModel.ForceInterpolationViewModel.Result);
- ShowValuePointDiagramLogic pointGraphLogic = new(ForcesResults.ForcesResultList, ndmPrimitives)
- {
- Calculator = interpolationLogic.InterpolateCalculator,
- PrimitiveLogic = viewModel.PrimitiveLogic,
- ValueDelegatesLogic = viewModel.ValueDelegatesLogic
- };
- progressLogic = interpolationLogic;
- showProgressLogic = new(interpolationLogic)
- {
- ShowResult = pointGraphLogic.ShowWindow
- };
- showProgressLogic.Show();
+ logic.InterpolateValuePoints();
}
private void ShowInterpolationWindow(out InterpolateTuplesViewModel interploateTuplesViewModel, out InterpolateTuplesView wndTuples)
@@ -432,7 +416,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
try
{
IStrainMatrix strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix;
- var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ResultFuncFactory.GetResultFuncs());
+ var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ForceResultFuncFactory.GetResultFuncs());
isoFieldReport = new IsoFieldReport(primitiveSets);
isoFieldReport.Show();
}
@@ -445,7 +429,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
};
new ErrorMessage(vm).ShowDialog();
}
-
}
private void GetNdms()
{
diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs
index db1f181..15fbb13 100644
--- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs
+++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/UserControls/SurroundDataViewModel.cs
@@ -21,7 +21,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
const string ForceUnitString = "kN";
const string MomentUnitString = "kNm";
-
+ static IConvertUnitLogic operationLogic = new ConvertUnitLogic();
+ static IGetUnitLogic unitLogic = new GetUnitLogic();
public SurroundData SurroundData
{
get => surroundData; set
@@ -47,8 +48,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
OnPropertyChanged(nameof(ZUnitLabel));
}
- private static readonly IUnit unitForce = CommonOperation.GetUnit(UnitTypes.Force, ForceUnitString);
- private static readonly IUnit unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, MomentUnitString);
+ private static IUnit unitForce = unitLogic.GetUnit(UnitTypes.Force, ForceUnitString);
+ private static IUnit unitMoment = unitLogic.GetUnit(UnitTypes.Moment, MomentUnitString);
private SurroundData surroundData;
public IValueConverter ForceConverter { get => new Force(); }
diff --git a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml
index 5d8f958..0e8b5c0 100644
--- a/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml
+++ b/StructureHelper/Windows/CalculationWindows/ProgressViews/TraceDocumentView.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
d:DataContext="{d:DesignInstance local:TraceDocumentVM}"
mc:Ignorable="d"
- Title="Trace Document Viewer" Height="450" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen">
+ Title="Trace Document Viewer" Height="450" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen" ShowInTaskbar="False">
diff --git a/StructureHelper/Windows/Forces/PrimitiveValuePoints.cs b/StructureHelper/Windows/Forces/PrimitiveValuePoints.cs
index 4d56791..9b74b00 100644
--- a/StructureHelper/Windows/Forces/PrimitiveValuePoints.cs
+++ b/StructureHelper/Windows/Forces/PrimitiveValuePoints.cs
@@ -2,6 +2,7 @@
using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
+using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,13 +14,13 @@ namespace StructureHelper.Windows.Forces
public class PrimitiveValuePoints
{
public PrimitiveBase PrimitiveBase {get;set;}
- public SelectItemsVM> ValuePoints { get; set; }
+ public SelectItemsVM ValuePoints { get; set; }
public PrimitiveValuePoints(PrimitiveBase primitiveBase)
{
var ndmPrimitive = primitiveBase.GetNdmPrimitive();
var pointCollection = ndmPrimitive.GetValuePoints();
- ValuePoints = new SelectItemsVM>(pointCollection)
+ ValuePoints = new SelectItemsVM(pointCollection)
{
ShowButtons = false
};
diff --git a/StructureHelper/Windows/Forces/ValueDelegatesLogic.cs b/StructureHelper/Windows/Forces/ValueDelegatesLogic.cs
index ed5f5a1..d85b6f0 100644
--- a/StructureHelper/Windows/Forces/ValueDelegatesLogic.cs
+++ b/StructureHelper/Windows/Forces/ValueDelegatesLogic.cs
@@ -11,14 +11,13 @@ namespace StructureHelper.Windows.Forces
{
public class ValueDelegatesLogic : ViewModelBase
{
- private readonly List resultFuncs;
- public SelectItemsVM ResultFuncs { get; }
+ private readonly List resultFuncs;
+ public SelectItemsVM ResultFuncs { get; }
public ValueDelegatesLogic()
{
- resultFuncs = new List();
- resultFuncs.AddRange(ResultFuncFactory.GetResultFuncs(FuncsTypes.Strain));
- resultFuncs.AddRange(ResultFuncFactory.GetResultFuncs(FuncsTypes.Stress));
- ResultFuncs = new SelectItemsVM(resultFuncs)
+ resultFuncs = new List();
+ resultFuncs.AddRange(ForceResultFuncFactory.GetResultFuncs(FuncsTypes.Full));
+ ResultFuncs = new SelectItemsVM(resultFuncs)
{
ShowButtons = true
};
diff --git a/StructureHelper/Windows/Forces/ValuePointsInterpolateView.xaml b/StructureHelper/Windows/Forces/ValuePointsInterpolateView.xaml
index 161f420..104bc62 100644
--- a/StructureHelper/Windows/Forces/ValuePointsInterpolateView.xaml
+++ b/StructureHelper/Windows/Forces/ValuePointsInterpolateView.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.Forces"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:ValuePointsInterpolateViewModel}"
- Title="Value Poits Interpolation" Height="250" Width="460" MinHeight="250" MinWidth="460" MaxHeight="450" MaxWidth="460" WindowStartupLocation="CenterScreen">
+ Title="Value Points Interpolation" Height="250" Width="460" MinHeight="250" MinWidth="460" MaxHeight="450" MaxWidth="460" WindowStartupLocation="CenterScreen">
@@ -24,7 +24,7 @@
-
+
diff --git a/StructureHelper/Windows/Forces/ValuePointsInterpolateView.xaml.cs b/StructureHelper/Windows/Forces/ValuePointsInterpolateView.xaml.cs
index 0ee9ac7..15e783e 100644
--- a/StructureHelper/Windows/Forces/ValuePointsInterpolateView.xaml.cs
+++ b/StructureHelper/Windows/Forces/ValuePointsInterpolateView.xaml.cs
@@ -1,16 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
+using System.Windows;
namespace StructureHelper.Windows.Forces
{
@@ -22,10 +10,11 @@ namespace StructureHelper.Windows.Forces
private ValuePointsInterpolateViewModel viewModel;
public ValuePointsInterpolateView(ValuePointsInterpolateViewModel viewModel)
{
- InitializeComponent();
this.viewModel = viewModel;
this.viewModel.ParentWindow = this;
this.DataContext = this.viewModel;
+ InitializeComponent();
+ InterpolationControl.Properties = viewModel.ForceInterpolationViewModel;
}
}
}
diff --git a/StructureHelper/Windows/Forces/ValuePointsInterpolateViewModel.cs b/StructureHelper/Windows/Forces/ValuePointsInterpolateViewModel.cs
index 29155fe..c5039d2 100644
--- a/StructureHelper/Windows/Forces/ValuePointsInterpolateViewModel.cs
+++ b/StructureHelper/Windows/Forces/ValuePointsInterpolateViewModel.cs
@@ -1,4 +1,5 @@
using StructureHelper.Windows.ViewModels;
+using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
diff --git a/StructureHelper/Windows/Graphs/GraphView.xaml b/StructureHelper/Windows/Graphs/GraphView.xaml
index e1e49bd..ad233fa 100644
--- a/StructureHelper/Windows/Graphs/GraphView.xaml
+++ b/StructureHelper/Windows/Graphs/GraphView.xaml
@@ -18,8 +18,9 @@
-->
-
-
+
+
+
@@ -31,7 +32,7 @@
-
+
@@ -81,7 +82,8 @@
-
+
+
diff --git a/StructureHelper/Windows/MainWindow/CrossSectionModel.cs b/StructureHelper/Windows/MainWindow/CrossSectionModel.cs
index 95488a7..874a705 100644
--- a/StructureHelper/Windows/MainWindow/CrossSectionModel.cs
+++ b/StructureHelper/Windows/MainWindow/CrossSectionModel.cs
@@ -1,4 +1,5 @@
using LoaderCalculator;
+using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.ResultData;
@@ -9,6 +10,7 @@ using StructureHelper.Services.Primitives;
using StructureHelper.UnitSystem;
using StructureHelper.UnitSystem.Systems;
using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.Models.CrossSections;
@@ -26,6 +28,8 @@ namespace StructureHelper.Windows.MainWindow
{
public class CrossSectionModel
{
+ private ITriangulatePrimitiveLogic triangulateLogic;
+
public ICrossSection Section { get; private set; }
private IPrimitiveRepository primitiveRepository;
public IHeadMaterialRepository HeadMaterialRepository { get; }
@@ -52,7 +56,13 @@ namespace StructureHelper.Windows.MainWindow
public IEnumerable GetNdms(ICalculationProperty calculationProperty)
{
var ndmPrimitives = Section.SectionRepository.Primitives;
- return NdmPrimitivesService.GetNdms(ndmPrimitives, calculationProperty.LimitState, calculationProperty.CalcTerm);
+ triangulateLogic = new TriangulatePrimitiveLogic()
+ {
+ Primitives = ndmPrimitives,
+ LimitState = calculationProperty.LimitState,
+ CalcTerm = calculationProperty.CalcTerm
+ };
+ return triangulateLogic.GetNdms();
////Настройки триангуляции, пока опции могут быть только такие
//ITriangulationOptions options = new TriangulationOptions { LimiteState = calculationProperty.LimitState, CalcTerm = calculationProperty.CalcTerm };
diff --git a/StructureHelper/Windows/MainWindow/CrossSectionView.xaml b/StructureHelper/Windows/MainWindow/CrossSectionView.xaml
index ba96004..ac8b107 100644
--- a/StructureHelper/Windows/MainWindow/CrossSectionView.xaml
+++ b/StructureHelper/Windows/MainWindow/CrossSectionView.xaml
@@ -79,7 +79,9 @@
@@ -143,67 +145,79 @@
Content="Fact" ToolTip="Add Factored Combination"/>
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
@@ -338,7 +352,16 @@
+
diff --git a/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs
index 37c5e69..51a5d3b 100644
--- a/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs
+++ b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs
@@ -29,6 +29,8 @@ namespace StructureHelper.Windows.MainWindow
{
private ICrossSection section;
private ICrossSectionRepository repository => section.SectionRepository;
+ private ITriangulatePrimitiveLogic triangulateLogic;
+
public CrossSectionVisualPropertyVM VisualProperty { get; private set; }
@@ -172,7 +174,13 @@ namespace StructureHelper.Windows.MainWindow
MovePrimitiveToGravityCenterCommand = new RelayCommand(o =>
{
if (CheckMaterials() == false) { return;}
- var ndms = NdmPrimitivesService.GetNdms(repository.Primitives, LimitStates.SLS, CalcTerms.ShortTerm);
+ triangulateLogic = new TriangulatePrimitiveLogic()
+ {
+ Primitives = repository.Primitives,
+ LimitState = LimitStates.SLS,
+ CalcTerm = CalcTerms.ShortTerm
+ };
+ var ndms = triangulateLogic.GetNdms();
var center = GeometryOperations.GetGravityCenter(ndms);
foreach (var item in PrimitiveLogic.Items)
{
diff --git a/StructureHelper/Windows/UserControls/MultiplyDouble.xaml.cs b/StructureHelper/Windows/UserControls/MultiplyDouble.xaml.cs
index 365ccdf..856725e 100644
--- a/StructureHelper/Windows/UserControls/MultiplyDouble.xaml.cs
+++ b/StructureHelper/Windows/UserControls/MultiplyDouble.xaml.cs
@@ -25,6 +25,7 @@ namespace StructureHelper.Windows.UserControls
///
public partial class MultiplyDouble : UserControl
{
+ IConvertUnitLogic operationLogic = new ConvertUnitLogic();
public event EventHandler ValueChanged;
public MultiplyDouble()
@@ -40,7 +41,7 @@ namespace StructureHelper.Windows.UserControls
try
{
string s = (string)o;
- double factor = CommonOperation.ConvertToDoubleChangeComma(s);
+ double factor = ProcessString.ConvertCommaToCultureSettings(s);
ChangeValue(factor);
}
catch(Exception ex)
diff --git a/StructureHelper/Windows/ViewModels/Calculations/CalculationResult/CalculationResultViewModel.cs b/StructureHelper/Windows/ViewModels/Calculations/CalculationResult/CalculationResultViewModel.cs
index 1145ff7..5bafcf7 100644
--- a/StructureHelper/Windows/ViewModels/Calculations/CalculationResult/CalculationResultViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Calculations/CalculationResult/CalculationResultViewModel.cs
@@ -55,7 +55,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.CalculationResult
private void ShowIsoField()
{
IStrainMatrix strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix;
- var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ResultFuncFactory.GetResultFuncs());
+ var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ForceResultFuncFactory.GetResultFuncs());
isoFieldReport = new IsoFieldReport(primitiveSets);
isoFieldReport.Show();
}
diff --git a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
index 0a829bf..7fccf0d 100644
--- a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
@@ -1,18 +1,13 @@
using StructureHelper.Infrastructure.Enums;
-using StructureHelper.Models.Materials;
using StructureHelper.Services.Settings;
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
-using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using StructureHelperLogics.NdmCalculations.Cracking;
using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Forces
@@ -98,24 +93,40 @@ namespace StructureHelper.Windows.ViewModels.Forces
{
bool result = true;
var calcRepository = repository.CalculatorsList;
- foreach (var item in calcRepository)
+ foreach (var calc in calcRepository)
{
- if (item is IForceCalculator)
+ if (calc is IForceCalculator)
{
- var forceCalculator = item as IForceCalculator;
- var containSelected = forceCalculator.ForceActions.Contains(SelectedItem);
- if (containSelected)
- {
- var dialogResultCalc = MessageBox.Show($"Action is contained in calculator {item.Name}", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
- if (dialogResultCalc == DialogResult.Yes)
- {
- forceCalculator.ForceActions.Remove(SelectedItem);
- }
- else result = false;
- }
+ var forceCombinations = calc as IHasForceCombinations;
+ result = DeleteActionFromHost(result, calc, forceCombinations);
+ }
+ else if (calc is CrackCalculator calculator)
+ {
+ var forceCombinations = calculator.InputData as IHasForceCombinations;
+ result = DeleteActionFromHost(result, calc, forceCombinations);
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc));
}
}
return result;
}
+
+ private bool DeleteActionFromHost(bool result, ICalculator item, IHasForceCombinations? forceCombinations)
+ {
+ var containSelected = forceCombinations.ForceActions.Contains(SelectedItem);
+ if (containSelected)
+ {
+ var dialogResultCalc = MessageBox.Show($"Action is contained in calculator {item.Name}", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
+ if (dialogResultCalc == DialogResult.Yes)
+ {
+ forceCombinations.ForceActions.Remove(SelectedItem);
+ }
+ else result = false;
+ }
+
+ return result;
+ }
}
}
diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs
index 1e0d167..41e100a 100644
--- a/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs
+++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs
@@ -1,7 +1,10 @@
-using StructureHelper.Infrastructure;
+using LoaderCalculator;
+using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
+using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.CalculationWindows.ProgressViews;
+using StructureHelper.Windows.Errors;
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Exceptions;
@@ -10,6 +13,8 @@ using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
+using StructureHelperLogics.NdmCalculations.Cracking;
+using System;
using System.Windows;
using System.Windows.Forms;
using MessageBox = System.Windows.Forms.MessageBox;
@@ -25,32 +30,79 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private InteractionDiagramLogic interactionDiagramLogic;
public override void AddMethod(object parameter)
+ {
+ if (CheckParameter(parameter) == false) { return; }
+ AddCalculator(parameter);
+ base.AddMethod(parameter);
+ }
+
+ private void AddCalculator(object parameter)
{
var parameterType = (CalculatorTypes)parameter;
if (parameterType == CalculatorTypes.ForceCalculator)
{
- NewItem = new ForceCalculator()
- {
- Name = "New force calculator",
- TraceLogger = new ShiftTraceLogger(),
- };
+ AddForceCalculator();
}
else if (parameterType == CalculatorTypes.LimitCurveCalculator)
{
- var inputData = new LimitCurveInputData(repository.Primitives);
- NewItem = new LimitCurvesCalculator()
- {
- Name = "New interaction diagram calculator",
- InputData = inputData,
- TraceLogger = new ShiftTraceLogger(),
- };
+ AddLimitCurveCalculator();
+ }
+ else if (parameterType == CalculatorTypes.CrackCalculator)
+ {
+ AddCrackCalculator();
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(parameterType));
}
- base.AddMethod(parameter);
}
+
+ private void AddCrackCalculator()
+ {
+ var inputData = new CrackInputData();
+ var calculator = new CrackCalculator(inputData, new CheckCrackCalculatorInputDataLogic(inputData))
+ {
+ Name = "New crack calculator",
+ TraceLogger = new ShiftTraceLogger(),
+ };
+ NewItem = calculator;
+ }
+
+ private void AddLimitCurveCalculator()
+ {
+ var inputData = new LimitCurveInputData(repository.Primitives);
+ NewItem = new LimitCurvesCalculator()
+ {
+ Name = "New interaction diagram calculator",
+ InputData = inputData,
+ TraceLogger = new ShiftTraceLogger(),
+ };
+ }
+
+ private void AddForceCalculator()
+ {
+ NewItem = new ForceCalculator()
+ {
+ Name = "New force calculator",
+ TraceLogger = new ShiftTraceLogger(),
+ };
+ }
+
+ private bool CheckParameter(object parameter)
+ {
+ if (parameter is null)
+ {
+ SafetyProcessor.ShowMessage(ErrorStrings.ParameterIsNull, "It is imposible to add object cause parameter is null");
+ return false;
+ }
+ if (parameter is not CalculatorTypes)
+ {
+ SafetyProcessor.ShowMessage(ErrorStrings.ExpectedWas(typeof(CalculatorTypes), parameter), "Parameter is not correspondent to any type of calculator");
+ return false;
+ }
+ return true;
+ }
+
public override void EditMethod(object parameter)
{
SafetyProcessor.RunSafeProcess(EditCalculator, $"Error of editing: {SelectedItem.Name}");
@@ -59,20 +111,18 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void EditCalculator()
{
- if (SelectedItem is ForceCalculator)
- {
- var calculator = SelectedItem as ForceCalculator;
- EditForceCalculator(calculator);
- }
- else if (SelectedItem is LimitCurvesCalculator)
- {
- var calculator = SelectedItem as LimitCurvesCalculator;
- EditLimitCurveCalculator(calculator);
- }
- else
- {
- throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
- }
+ if (SelectedItem is ForceCalculator forceCalculator) { EditForceCalculator(forceCalculator);}
+ else if (SelectedItem is LimitCurvesCalculator limitCurvesCalculator) { EditLimitCurveCalculator(limitCurvesCalculator); }
+ else if (SelectedItem is CrackCalculator crackCalculator) { EditCrackCalculator(crackCalculator);}
+ else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));}
+ }
+
+ private void EditCrackCalculator(CrackCalculator calculator)
+ {
+ var calculatorCopy = calculator.Clone() as CrackCalculator;
+ var vm = new CrackCalculatorInputDataViewModel(repository.Primitives, repository.ForceActions, calculator);
+ var wnd = new CrackCalculatorInputDataView(vm);
+ ShowWindow(calculator, calculatorCopy, wnd);
}
private void EditLimitCurveCalculator(LimitCurvesCalculator calculator)
@@ -134,7 +184,6 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
}
if (SelectedItem is LimitCurvesCalculator calculator)
{
- var inputData = calculator.InputData;
ShowInteractionDiagramByInputData(calculator);
}
else
@@ -143,13 +192,20 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
var result = SelectedItem.Result;
if (result.IsValid == false)
{
- MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ var vm = new ErrorProcessor()
+ {
+ ShortText = "Errors apearred during calculations, see detailed information",
+ DetailText = SelectedItem.Result.Description
+ };
+ new ErrorMessage(vm).ShowDialog();
+ return;
}
else
{
ProcessResult();
}
}
+
if (SelectedItem.TraceLogger is not null)
{
var wnd = new TraceDocumentView(SelectedItem.TraceLogger.TraceLoggerEntries);
@@ -171,13 +227,17 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void ProcessResult()
{
- if (SelectedItem is IForceCalculator)
+ if (SelectedItem is ForceCalculator forceCalculator)
{
- var calculator = SelectedItem as ForceCalculator;
- var vm = new ForcesResultsViewModel(calculator);
+ var vm = new ForcesResultsViewModel(forceCalculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
+ else if (SelectedItem is CrackCalculator crackCalculator)
+ {
+ var wnd = new CrackResultView(crackCalculator.Result as CrackResult);
+ wnd.ShowDialog();
+ }
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs
index 790fb4a..f438ee2 100644
--- a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs
+++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs
@@ -7,6 +7,8 @@ using StructureHelper.Windows.PrimitiveTemplates.RCs.Beams;
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
using StructureHelper.Windows.Services;
using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.CrossSections;
@@ -14,6 +16,7 @@ using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
+using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
@@ -135,9 +138,24 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{
if (calc is IForceCalculator)
{
- var forceCalc = calc as IForceCalculator;
+ var forceCalc = calc as IHasPrimitives;
forceCalc.Primitives.Remove(ndmPrimitive);
}
+ else if (calc is LimitCurvesCalculator calculator)
+ {
+ //to do
+ //var forceCalc = calculator.InputData as IHasPrimitives;
+ //forceCalc.Primitives.Remove(ndmPrimitive);
+ }
+ else if (calc is CrackCalculator crackCalculator)
+ {
+ var forceCalc = crackCalculator.InputData as IHasPrimitives;
+ forceCalc.Primitives.Remove(ndmPrimitive);
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ICalculator), calc));
+ }
}
foreach (var primitive in repository.Primitives)
{
diff --git a/StructureHelperCommon/Infrastructures/Exceptions/StructureHelperException.cs b/StructureHelperCommon/Infrastructures/Exceptions/StructureHelperException.cs
index ab76f9d..0bf94cf 100644
--- a/StructureHelperCommon/Infrastructures/Exceptions/StructureHelperException.cs
+++ b/StructureHelperCommon/Infrastructures/Exceptions/StructureHelperException.cs
@@ -7,5 +7,9 @@ namespace StructureHelperCommon.Infrastructures.Exceptions
public StructureHelperException(string errorString) : base(errorString)
{
}
+ public StructureHelperException(Exception ex) : this(ex.Message)
+ {
+
+ }
}
}
diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ICheckInputDataLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/ICheckInputDataLogic.cs
new file mode 100644
index 0000000..5cf6ab5
--- /dev/null
+++ b/StructureHelperCommon/Infrastructures/Interfaces/ICheckInputDataLogic.cs
@@ -0,0 +1,14 @@
+using StructureHelperCommon.Models.Calculators;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Infrastructures.Interfaces
+{
+ public interface ICheckInputDataLogic : ICheckLogic
+ {
+ IInputData InputData { get; set; }
+ }
+}
diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ICheckLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/ICheckLogic.cs
new file mode 100644
index 0000000..dbefc5f
--- /dev/null
+++ b/StructureHelperCommon/Infrastructures/Interfaces/ICheckLogic.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Infrastructures.Interfaces
+{
+ public interface ICheckLogic : ILogic
+ {
+ string CheckResult { get; }
+ bool Check();
+ }
+}
diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IHasForceCombinations.cs b/StructureHelperCommon/Infrastructures/Interfaces/IHasForceCombinations.cs
index a9422bd..3fe260b 100644
--- a/StructureHelperCommon/Infrastructures/Interfaces/IHasForceCombinations.cs
+++ b/StructureHelperCommon/Infrastructures/Interfaces/IHasForceCombinations.cs
@@ -5,6 +5,9 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IHasForceCombinations
{
+ ///
+ /// Collection of force actions
+ ///
List ForceActions { get; }
}
}
diff --git a/StructureHelperCommon/Models/Calculators/GenericResult.cs b/StructureHelperCommon/Models/Calculators/GenericResult.cs
new file mode 100644
index 0000000..c03c6d6
--- /dev/null
+++ b/StructureHelperCommon/Models/Calculators/GenericResult.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Calculators
+{
+ public class GenericResult : IResult
+ {
+ public bool IsValid { get; set; }
+ public string? Description { get; set; }
+ public T? Value { get; set; }
+ }
+}
diff --git a/StructureHelperCommon/Models/Loggers/LoggerStrings.cs b/StructureHelperCommon/Models/Loggers/LoggerStrings.cs
index 60f5776..1f6e3b0 100644
--- a/StructureHelperCommon/Models/Loggers/LoggerStrings.cs
+++ b/StructureHelperCommon/Models/Loggers/LoggerStrings.cs
@@ -10,6 +10,7 @@ namespace StructureHelperCommon.Models.Loggers
{
public static string DimensionLess => "(dimensionless)";
public static string MethodBasedOn => "Method of calculation based on ";
+ public static string CalculationError => "Some errors happened during calculations: ";
public static string CalculationHasDone => "Calculation has done succesfully";
public static string Summary => "Summary";
public static string Maximum => "Maximum";
diff --git a/StructureHelperCommon/Models/Materials/ConcreteCurveLogic.cs b/StructureHelperCommon/Models/Materials/ConcreteCurveLogic.cs
index fc07e65..8031064 100644
--- a/StructureHelperCommon/Models/Materials/ConcreteCurveLogic.cs
+++ b/StructureHelperCommon/Models/Materials/ConcreteCurveLogic.cs
@@ -33,8 +33,16 @@ namespace StructureHelperCommon.Models.Materials
{
GetLoaderOptions();
IBuilderDirector director = GetMaterialDirector();
- var material = director.BuildMaterial();
- return material;
+ try
+ {
+ var material = director.BuildMaterial();
+ return material;
+ }
+ catch (System.Exception)
+ {
+
+ throw;
+ }
}
private IBuilderDirector GetMaterialDirector()
diff --git a/StructureHelperCommon/Models/Materials/ConcreteMaterialOptionLogic.cs b/StructureHelperCommon/Models/Materials/ConcreteMaterialOptionLogic.cs
index 69016d0..d1786ea 100644
--- a/StructureHelperCommon/Models/Materials/ConcreteMaterialOptionLogic.cs
+++ b/StructureHelperCommon/Models/Materials/ConcreteMaterialOptionLogic.cs
@@ -16,7 +16,7 @@ namespace StructureHelperCommon.Models.Materials
{
private ConcreteLogicOptions options;
private MaterialCommonOptionLogic optionLogic;
- private FactorLogic factorLogic;
+
public ConcreteMaterialOptionLogic(ConcreteLogicOptions options)
{
@@ -32,10 +32,6 @@ namespace StructureHelperCommon.Models.Materials
var concreteOptions = materialOptions as ConcreteOptions;
optionLogic = new MaterialCommonOptionLogic(options);
optionLogic.SetMaterialOptions(concreteOptions);
- factorLogic = new FactorLogic(options.SafetyFactors);
- var strength = factorLogic.GetTotalFactor(options.LimitState, options.CalcTerm);
- concreteOptions.ExternalFactor.Compressive = strength.Compressive;
- concreteOptions.ExternalFactor.Tensile = strength.Tensile;
concreteOptions.WorkInTension = options.WorkInTension;
concreteOptions.RelativeHumidity = options.RelativeHumidity;
concreteOptions.Age = options.Age;
diff --git a/StructureHelperCommon/Models/Materials/ICrackedMaterial.cs b/StructureHelperCommon/Models/Materials/ICrackedMaterial.cs
new file mode 100644
index 0000000..0643713
--- /dev/null
+++ b/StructureHelperCommon/Models/Materials/ICrackedMaterial.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Materials
+{
+ public interface ICrackedMaterial
+ {
+ bool TensionForULS { get; set; }
+ bool TensionForSLS { get; set; }
+ }
+}
diff --git a/StructureHelperCommon/Models/Materials/Libraries/Factories/LibMaterialFactory.cs b/StructureHelperCommon/Models/Materials/Libraries/Factories/LibMaterialFactory.cs
index c85cb09..1f31608 100644
--- a/StructureHelperCommon/Models/Materials/Libraries/Factories/LibMaterialFactory.cs
+++ b/StructureHelperCommon/Models/Materials/Libraries/Factories/LibMaterialFactory.cs
@@ -240,7 +240,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
Code = code,
Name = "A400",
InitModulus = 2e11d,
- MainStrength = 400e6d
+ MainStrength = 390e6d
},
new ReinforcementMaterialEntity(new Guid("045b54b1-0bbf-41fd-a27d-aeb20f600bb4"))
{
diff --git a/StructureHelperCommon/Models/Materials/MaterialCommonOptionLogic.cs b/StructureHelperCommon/Models/Materials/MaterialCommonOptionLogic.cs
index 80097e1..f5b1f7d 100644
--- a/StructureHelperCommon/Models/Materials/MaterialCommonOptionLogic.cs
+++ b/StructureHelperCommon/Models/Materials/MaterialCommonOptionLogic.cs
@@ -1,12 +1,16 @@
-using StructureHelperCommon.Infrastructures.Enums;
+using LoaderCalculator.Data.Materials.MaterialBuilders;
+using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models.Materials.Libraries;
using LCMB = LoaderCalculator.Data.Materials.MaterialBuilders;
+using SHEnums = StructureHelperCommon.Infrastructures.Enums;
namespace StructureHelperCommon.Models.Materials
{
public class MaterialCommonOptionLogic : IMaterialOptionLogic
{
private IMaterialLogicOptions options;
+ private FactorLogic factorLogic;
public MaterialCommonOptionLogic(IMaterialLogicOptions options)
{
@@ -17,6 +21,58 @@ namespace StructureHelperCommon.Models.Materials
{
materialOptions.InitModulus = options.MaterialEntity.InitModulus;
materialOptions.Strength = options.MaterialEntity.MainStrength;
+ ProcessCodeType(materialOptions);
+ ProcessLimitState(materialOptions);
+ ProcessCalcTerm(materialOptions);
+ ProcessExternalFactors(materialOptions);
+ }
+
+ private void ProcessExternalFactors(IMaterialOptions materialOptions)
+ {
+ factorLogic = new FactorLogic(options.SafetyFactors);
+ var strength = factorLogic.GetTotalFactor(options.LimitState, options.CalcTerm);
+ materialOptions.ExternalFactor.Compressive = strength.Compressive;
+ materialOptions.ExternalFactor.Tensile = strength.Tensile;
+ }
+
+ private void ProcessCalcTerm(IMaterialOptions materialOptions)
+ {
+ if (options.CalcTerm == CalcTerms.ShortTerm)
+ {
+ materialOptions.IsShortTerm = true;
+ }
+ else if (options.CalcTerm == CalcTerms.LongTerm)
+ {
+ materialOptions.IsShortTerm = false;
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid);
+ }
+ }
+
+ private void ProcessLimitState(IMaterialOptions materialOptions)
+ {
+ if (options.LimitState == SHEnums.LimitStates.ULS)
+ {
+ materialOptions.LimitState = LCMB.LimitStates.Collapse;
+ }
+ else if (options.LimitState == SHEnums.LimitStates.SLS)
+ {
+ materialOptions.LimitState = LCMB.LimitStates.ServiceAbility;
+ }
+ else if (options.LimitState == SHEnums.LimitStates.Special)
+ {
+ materialOptions.LimitState = LCMB.LimitStates.Special;
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid);
+ }
+ }
+
+ private void ProcessCodeType(IMaterialOptions materialOptions)
+ {
if (options.MaterialEntity.CodeType == CodeTypes.EuroCode_2_1990)
{
materialOptions.CodesType = LCMB.CodesType.EC2_1990;
@@ -25,23 +81,10 @@ namespace StructureHelperCommon.Models.Materials
{
materialOptions.CodesType = LCMB.CodesType.SP63_2018;
}
- else { throw new StructureHelperException($"{ErrorStrings.ObjectTypeIsUnknown} : {materialOptions.CodesType}"); }
- if (options.LimitState == LimitStates.ULS)
+ else
{
- materialOptions.LimitState = LCMB.LimitStates.Collapse;
+ throw new StructureHelperException($"{ErrorStrings.ObjectTypeIsUnknown} : {materialOptions.CodesType}");
}
- else if (options.LimitState == LimitStates.SLS)
- {
- materialOptions.LimitState = LCMB.LimitStates.ServiceAbility;
- }
- else if (options.LimitState == LimitStates.Special)
- {
- materialOptions.LimitState = LCMB.LimitStates.Special;
- }
- else { throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid); }
- if (options.CalcTerm == CalcTerms.ShortTerm) { materialOptions.IsShortTerm = true; }
- else if (options.CalcTerm == CalcTerms.LongTerm) { materialOptions.IsShortTerm = false; }
- else { throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid); }
}
}
}
diff --git a/StructureHelperCommon/Models/Materials/ReinforcementByBuilderLogic.cs b/StructureHelperCommon/Models/Materials/ReinforcementByBuilderLogic.cs
index 6104cdd..ac246ee 100644
--- a/StructureHelperCommon/Models/Materials/ReinforcementByBuilderLogic.cs
+++ b/StructureHelperCommon/Models/Materials/ReinforcementByBuilderLogic.cs
@@ -30,8 +30,17 @@ namespace StructureHelperCommon.Models.Materials
{
GetLoaderOptions();
IBuilderDirector director = GetMaterialDirector();
- var material = director.BuildMaterial();
- return material;
+ try
+ {
+ var material = director.BuildMaterial();
+ return material;
+ }
+ catch (System.Exception)
+ {
+
+ throw;
+ }
+
}
private IBuilderDirector GetMaterialDirector()
@@ -43,7 +52,10 @@ namespace StructureHelperCommon.Models.Materials
private void GetLoaderOptions()
{
- materialOptions = new ReinforcementOptions() { DiagramType = DiagramType};
+ materialOptions = new ReinforcementOptions()
+ {
+ DiagramType = DiagramType,
+ };
optionLogic = new MaterialCommonOptionLogic(options);
optionLogic.SetMaterialOptions(materialOptions);
}
diff --git a/StructureHelperCommon/Models/Parameters/ArrayParameter.cs b/StructureHelperCommon/Models/Parameters/ArrayParameter.cs
index 0b3df4f..59e2b05 100644
--- a/StructureHelperCommon/Models/Parameters/ArrayParameter.cs
+++ b/StructureHelperCommon/Models/Parameters/ArrayParameter.cs
@@ -43,5 +43,62 @@ namespace StructureHelperCommon.Models.Parameters
}
}
public ArrayParameter(int rowCount, List columnLabels) : this(rowCount, columnLabels.Count, columnLabels) { }
+ public void AddArray(IArrayParameter array)
+ {
+ var rowCount = array.Data.GetLength(0);
+ int existingRowCount = this.Data.GetLength(0);
+ if (rowCount != existingRowCount)
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": number of rows in new array {rowCount} is not equal existing row count {existingRowCount}");
+ }
+ var existingColumnCount = this.Data.GetLength(1);
+ var newColumnCount = array.Data.GetLength(1);
+ var totalCount = existingColumnCount + newColumnCount;
+ var newData = new T[rowCount, totalCount];
+ var lackColumns = existingColumnCount - ColumnLabels.Count;
+ if (lackColumns > 0)
+ {
+ for (int i = 0; i < lackColumns; i++)
+ {
+ ColumnLabels.Add(string.Empty);
+ }
+ }
+ ColumnLabels.AddRange(array.ColumnLabels);
+ for (int i = 0; i < rowCount; i++)
+ {
+ for (int j = 0; j < existingColumnCount; j++)
+ {
+ newData[i, j] = Data[i, j];
+ }
+ for (int j = 0; j < newColumnCount; j++)
+ {
+ newData[i, existingColumnCount + j] = array.Data[i,j];
+ }
+ }
+ Data = newData;
+ }
+
+ public void AddRow(int rowNumber, IEnumerable values)
+ {
+ CheckParams(rowNumber, values);
+ var valueList = values.ToList();
+ for (int i = 0; i < values.Count(); i++)
+ {
+ Data[rowNumber, i] = valueList[i];
+ }
+ }
+
+ private void CheckParams(int rowNumber, IEnumerable values)
+ {
+ int rowCount = Data.GetLength(0) - 1;
+ if (rowNumber > rowCount)
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": number of rows {rowNumber} is greater than length of array {rowCount}");
+ }
+ if (values.Count() != Data.GetLength(1))
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": number of colums in values {values.Count()} is not equal existing column count {Data.GetLength(1)}");
+ }
+ }
}
}
diff --git a/StructureHelperCommon/Models/Parameters/IProcessValuePairLogic.cs b/StructureHelperCommon/Models/Parameters/IProcessValuePairLogic.cs
new file mode 100644
index 0000000..94d7e76
--- /dev/null
+++ b/StructureHelperCommon/Models/Parameters/IProcessValuePairLogic.cs
@@ -0,0 +1,7 @@
+namespace StructureHelperCommon.Models.Parameters
+{
+ public interface IProcessValuePairLogic
+ {
+ ValuePair GetValuePairByString(string s);
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperCommon/Models/Parameters/IValuePair.cs b/StructureHelperCommon/Models/Parameters/IValuePair.cs
new file mode 100644
index 0000000..6dbdce0
--- /dev/null
+++ b/StructureHelperCommon/Models/Parameters/IValuePair.cs
@@ -0,0 +1,12 @@
+namespace StructureHelperCommon.Models.Parameters
+{
+ ///
+ /// Represent pair of value with text
+ ///
+ ///
+ public interface IValuePair
+ {
+ string Text { get; set; }
+ T Value { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperCommon/Models/Parameters/IValueParameter.cs b/StructureHelperCommon/Models/Parameters/IValueParameter.cs
index afdb75f..4f82874 100644
--- a/StructureHelperCommon/Models/Parameters/IValueParameter.cs
+++ b/StructureHelperCommon/Models/Parameters/IValueParameter.cs
@@ -7,14 +7,12 @@ using System.Windows.Media;
namespace StructureHelperCommon.Models.Parameters
{
- public interface IValueParameter
+ public interface IValueParameter : IValuePair
{
bool IsValid { get; set; }
string Name { get; set; }
string ShortName { get; set; }
Color Color { get; set; }
- string MeasurementUnit { get; set; }
- T Value { get; set; }
string Description { get; set; }
}
}
diff --git a/StructureHelperCommon/Models/Parameters/ProcessDoublePairLogic.cs b/StructureHelperCommon/Models/Parameters/ProcessDoublePairLogic.cs
new file mode 100644
index 0000000..f55c098
--- /dev/null
+++ b/StructureHelperCommon/Models/Parameters/ProcessDoublePairLogic.cs
@@ -0,0 +1,65 @@
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Services.Units;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows.Media.Media3D;
+
+namespace StructureHelperCommon.Models.Parameters
+{
+ public enum DigitPlace
+ {
+ Start,
+ Any
+ }
+ public class ProcessDoublePairLogic : IProcessValuePairLogic
+ {
+ const string digitalPattern = @"^[-]?[+]?\d*\.?\,?\d*";
+ const string allowedPattern = @"[0-9]|\.|\,";
+ const string characterPattern = "[a-z]+$";
+ const string target = "";
+
+ public DigitPlace DigitPlace { get; set; } = DigitPlace.Start;
+
+ public ValuePair GetValuePairByString(string s)
+ {
+ s = s.Replace(" ", string.Empty);
+
+ Regex regexText = new (allowedPattern);
+ string textString = regexText.Replace(s, target);
+ var textMatch = Regex.Match(textString, characterPattern, RegexOptions.IgnoreCase);
+ if (textMatch.Success == true)
+ {
+ textString = textMatch.Value.ToLower();
+ }
+ var digitalOnlyString = DigitPlace == DigitPlace.Start ? s : s.ToLower().Replace(textString, string.Empty);
+ var match = Regex.Match(digitalOnlyString, digitalPattern);
+ if (match.Success == true)
+ {
+ return GetDoubleValue(textString, match);
+ }
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
+ }
+
+ private static ValuePair GetDoubleValue(string textString, Match match)
+ {
+ string digitalString = match.Value;
+ if (digitalString != string.Empty || digitalString != "")
+ {
+ double digit = ProcessString.ConvertCommaToCultureSettings(digitalString);
+ return new ValuePair()
+ {
+ Value = digit,
+ Text = textString
+ };
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": value does not contain digital simbols");
+ }
+ }
+ }
+}
diff --git a/StructureHelperCommon/Services/Units/StringDoublePair.cs b/StructureHelperCommon/Models/Parameters/ValuePair.cs
similarity index 53%
rename from StructureHelperCommon/Services/Units/StringDoublePair.cs
rename to StructureHelperCommon/Models/Parameters/ValuePair.cs
index 7e2cb34..8454961 100644
--- a/StructureHelperCommon/Services/Units/StringDoublePair.cs
+++ b/StructureHelperCommon/Models/Parameters/ValuePair.cs
@@ -4,11 +4,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace StructureHelperCommon.Services.Units
+namespace StructureHelperCommon.Models.Parameters
{
- internal class StringDoublePair : IStringDoublePair
+ ///
+ public class ValuePair : IValuePair
{
- public double Digit { get; set; }
public string Text { get; set; }
+ public T Value { get; set; }
}
}
diff --git a/StructureHelperCommon/Models/Parameters/ValueParameter.cs b/StructureHelperCommon/Models/Parameters/ValueParameter.cs
index 1e008ba..18d8625 100644
--- a/StructureHelperCommon/Models/Parameters/ValueParameter.cs
+++ b/StructureHelperCommon/Models/Parameters/ValueParameter.cs
@@ -13,7 +13,7 @@ namespace StructureHelperCommon.Models.Parameters
public string Name { get; set; }
public string ShortName { get; set; }
public Color Color { get; set; }
- public string MeasurementUnit { get; set; }
+ public string Text { get; set; }
public T Value { get; set; }
public string Description { get; set; }
}
diff --git a/StructureHelperCommon/Models/Sections/Logics/AccidentalEccentricityLogic.cs b/StructureHelperCommon/Models/Sections/Logics/AccidentalEccentricityLogic.cs
deleted file mode 100644
index f90df30..0000000
--- a/StructureHelperCommon/Models/Sections/Logics/AccidentalEccentricityLogic.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using StructureHelperCommon.Models.Forces;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
-//All rights reserved.
-
-namespace StructureHelperCommon.Models.Sections
-{
- public class AccidentalEccentricityLogic : IAccidentalEccentricityLogic
- {
- private double lengthFactor;
- private double sizeFactor;
- private double minEccentricity;
-
- public double Length { get; set; }
- public double SizeX { get; set; }
- public double SizeY { get; set; }
- public IForceTuple InitialForceTuple { get; set; }
- public IShiftTraceLogger? TraceLogger { get; set; }
- public AccidentalEccentricityLogic()
- {
- lengthFactor = 600d;
- sizeFactor = 30d;
- minEccentricity = 0.01d;
- }
- public ForceTuple GetForceTuple()
- {
- var lengthEccetricity = Length / lengthFactor;
- TraceLogger?.AddMessage(string.Format("Accidental eccentricity by length ea = {0} / {1} = {2}", Length, lengthFactor, lengthEccetricity));
- var sizeXEccetricity = SizeX / sizeFactor;
- TraceLogger?.AddMessage(string.Format("Accidental eccentricity by SizeX ea ={0} / {1} = {2}", SizeX, sizeFactor, sizeXEccetricity));
- var sizeYEccetricity = SizeY / sizeFactor;
- TraceLogger?.AddMessage(string.Format("Accidental eccentricity by SizeY ea ={0} / {1} = {2}", SizeY, sizeFactor, sizeYEccetricity));
- TraceLogger?.AddMessage(string.Format("Minimum accidental eccentricity ea = {0}", minEccentricity));
- var xEccentricity = Math.Abs(InitialForceTuple.My / InitialForceTuple.Nz);
- TraceLogger?.AddMessage(string.Format("Actual eccentricity e0,x = {0}", xEccentricity));
- var yEccentricity = Math.Abs(InitialForceTuple.Mx / InitialForceTuple.Nz);
- TraceLogger?.AddMessage(string.Format("Actual eccentricity e0,y = {0}", yEccentricity));
-
- var xFullEccentricity = new List()
- {
- lengthEccetricity,
- sizeXEccetricity,
- minEccentricity,
- xEccentricity
- }
- .Max();
- string mesEx = string.Format("Eccentricity e,x = max({0}; {1}; {2}; {3}) = {4}",
- lengthEccetricity, sizeXEccetricity,
- minEccentricity, xEccentricity,
- xFullEccentricity);
- TraceLogger?.AddMessage(mesEx);
- var yFullEccentricity = new List()
- {
- lengthEccetricity,
- sizeYEccetricity,
- minEccentricity,
- yEccentricity
- }
- .Max();
- string mesEy = string.Format("Eccentricity e,y = max({0}; {1}; {2}; {3}) = {4}",
- lengthEccetricity, sizeYEccetricity,
- minEccentricity, yEccentricity,
- yFullEccentricity);
- TraceLogger?.AddMessage(mesEy);
- var xSign = InitialForceTuple.Mx == 0d ? -1d : Math.Sign(InitialForceTuple.Mx);
- var ySign = InitialForceTuple.My == 0d ? -1d : Math.Sign(InitialForceTuple.My);
- var mx = (-1d) * InitialForceTuple.Nz * yFullEccentricity * xSign;
- var my = (-1d) * InitialForceTuple.Nz * xFullEccentricity * ySign;
- TraceLogger?.AddMessage(string.Format("Bending moment arbitrary X-axis Mx = {0} * {1} = {2}", InitialForceTuple.Nz, yFullEccentricity, mx), TraceLogStatuses.Debug);
- TraceLogger?.AddMessage(string.Format("Bending moment arbitrary Y-axis My = {0} * {1} = {2}", InitialForceTuple.Nz, xFullEccentricity, my), TraceLogStatuses.Debug);
-
- var newTuple = new ForceTuple()
- {
- Mx = mx,
- My = my,
- Nz = InitialForceTuple.Nz,
- Qx = InitialForceTuple.Qx,
- Qy = InitialForceTuple.Qy,
- Mz = InitialForceTuple.Mz,
- };
- TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple));
- return newTuple;
- }
- }
-}
diff --git a/StructureHelperCommon/Models/Sections/Logics/ForceTupleCopier.cs b/StructureHelperCommon/Models/Sections/Logics/ForceTupleCopier.cs
new file mode 100644
index 0000000..d57fbdf
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/ForceTupleCopier.cs
@@ -0,0 +1,23 @@
+using StructureHelperCommon.Models.Forces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Sections.Logics
+{
+ public class ForceTupleCopier : IProcessorLogic
+ {
+ public IForceTuple InputForceTuple { get; set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public ForceTupleCopier(IForceTuple forceTuple)
+ {
+ InputForceTuple = forceTuple;
+ }
+ public IForceTuple GetValue()
+ {
+ return InputForceTuple.Clone() as IForceTuple;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Models/Sections/Logics/ForceTupleMoveToPointDecorator.cs b/StructureHelperCommon/Models/Sections/Logics/ForceTupleMoveToPointDecorator.cs
new file mode 100644
index 0000000..eaf8c73
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/ForceTupleMoveToPointDecorator.cs
@@ -0,0 +1,32 @@
+using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models.Shapes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Sections.Logics
+{
+ public class ForceTupleMoveToPointDecorator : IProcessorDecorator
+ {
+ public IPoint2D Point2D { get; set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ ///
+ /// Internal source of ForceTuple
+ ///
+ public IProcessorLogic ForceTupleLogics { get; }
+ public ForceTupleMoveToPointDecorator(IProcessorLogic procLogic)
+ {
+ ForceTupleLogics = procLogic;
+ }
+ public IForceTuple GetValue()
+ {
+ ForceTupleLogics.TraceLogger = TraceLogger;
+ var newTuple = ForceTupleLogics.GetValue();
+ newTuple.Mx += newTuple.Nz * Point2D.Y;
+ newTuple.My -= newTuple.Nz * Point2D.X;
+ return newTuple;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Models/Sections/Logics/IAccidentalEccentricityLogic.cs b/StructureHelperCommon/Models/Sections/Logics/IAccidentalEccentricityLogic.cs
deleted file mode 100644
index 27c9d2c..0000000
--- a/StructureHelperCommon/Models/Sections/Logics/IAccidentalEccentricityLogic.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using StructureHelperCommon.Infrastructures.Interfaces;
-using StructureHelperCommon.Models.Forces;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StructureHelperCommon.Models.Sections
-{
- ///
- /// Logic for calculating of value of accidental eccentricity
- ///
- public interface IAccidentalEccentricityLogic : ILogic
- {
- ///
- /// Properties of compressed member
- ///
- double Length { get;set;}
- ///
- /// Size of cross-section along X-axis, m
- ///
- double SizeX { get; set; }
- ///
- /// Size of cross-section along Y-axis, m
- ///
- double SizeY { get; set; }
- ///
- /// Initial tuple of force
- ///
- IForceTuple InitialForceTuple { get; set; }
- ///
- /// Returns new force tuple with accidental eccentricity
- ///
- ///
- ForceTuple GetForceTuple();
- }
-}
diff --git a/StructureHelperCommon/Models/Sections/Logics/IHasInputForce.cs b/StructureHelperCommon/Models/Sections/Logics/IHasInputForce.cs
new file mode 100644
index 0000000..03fc403
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/IHasInputForce.cs
@@ -0,0 +1,17 @@
+using StructureHelperCommon.Models.Forces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Sections.Logics
+{
+ public interface IHasInputForce
+ {
+ ///
+ /// Initial tuple of force
+ ///
+ IForceTuple InputForceTuple { get; set; }
+ }
+}
diff --git a/StructureHelperCommon/Models/Sections/Logics/IProcessorDecorator.cs b/StructureHelperCommon/Models/Sections/Logics/IProcessorDecorator.cs
new file mode 100644
index 0000000..517aa22
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/IProcessorDecorator.cs
@@ -0,0 +1,14 @@
+using StructureHelperCommon.Models.Forces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Sections.Logics
+{
+ public interface IProcessorDecorator : IProcessorLogic
+ {
+ IProcessorLogic ForceTupleLogics { get; }
+ }
+}
diff --git a/StructureHelperCommon/Models/Sections/Logics/IProcessorLogic.cs b/StructureHelperCommon/Models/Sections/Logics/IProcessorLogic.cs
new file mode 100644
index 0000000..cf90cc0
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/IProcessorLogic.cs
@@ -0,0 +1,22 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Forces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Sections
+{
+ ///
+ /// Logic for calculating of some value
+ ///
+ public interface IProcessorLogic : ILogic
+ {
+ ///
+ /// Returns new value
+ ///
+ ///
+ T GetValue();
+ }
+}
diff --git a/StructureHelperCommon/Models/Sections/Logics/IRcAccEccentricityLogic.cs b/StructureHelperCommon/Models/Sections/Logics/IRcAccEccentricityLogic.cs
new file mode 100644
index 0000000..4f929af
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/IRcAccEccentricityLogic.cs
@@ -0,0 +1,12 @@
+namespace StructureHelperCommon.Models.Sections.Logics
+{
+ public interface IRcAccEccentricityLogic : IProcessorLogic<(double ex, double ey)>
+ {
+ double Length { get; set; }
+ double SizeX { get; set; }
+ double SizeY { get; set; }
+ IShiftTraceLogger? TraceLogger { get; set; }
+
+ (double ex, double ey) GetValue();
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperCommon/Models/Sections/Logics/IRcEccentricityAxisLogic.cs b/StructureHelperCommon/Models/Sections/Logics/IRcEccentricityAxisLogic.cs
new file mode 100644
index 0000000..9c8695d
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/IRcEccentricityAxisLogic.cs
@@ -0,0 +1,8 @@
+namespace StructureHelperCommon.Models.Sections.Logics
+{
+ public interface IRcEccentricityAxisLogic : IProcessorLogic
+ {
+ double Length { get; set; }
+ double Size { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperCommon/Models/Sections/Logics/RcAccEccentricityLogic.cs b/StructureHelperCommon/Models/Sections/Logics/RcAccEccentricityLogic.cs
new file mode 100644
index 0000000..5db7f39
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/RcAccEccentricityLogic.cs
@@ -0,0 +1,54 @@
+using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models.Loggers;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
+//All rights reserved.
+
+namespace StructureHelperCommon.Models.Sections.Logics
+{
+ public class RcAccEccentricityLogic : IRcAccEccentricityLogic
+ {
+ private const string accEccMessage = "Accidental eccentricity along {0}-axis";
+ ///
+ /// Properties of compressed member
+ ///
+ public double Length { get; set; }
+ ///
+ /// Size of cross-section along X-axis, m
+ ///
+ public double SizeX { get; set; }
+ ///
+ /// Size of cross-section along Y-axis, m
+ ///
+ public double SizeY { get; set; }
+ ///
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ private IRcEccentricityAxisLogic eccentricityLogic;
+ public RcAccEccentricityLogic(IRcEccentricityAxisLogic eccentricityLogic)
+ {
+ this.eccentricityLogic = eccentricityLogic;
+ }
+ public RcAccEccentricityLogic() : this(new RcEccentricityAxisLogic())
+ {
+
+ }
+ public (double ex, double ey) GetValue()
+ {
+ eccentricityLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ TraceLogger?.AddMessage(string.Format(accEccMessage, "x"));
+ eccentricityLogic.Length = Length;
+ eccentricityLogic.Size = SizeX;
+ var xFullEccentricity = eccentricityLogic.GetValue();
+ TraceLogger?.AddMessage(string.Format(accEccMessage, "y"));
+ eccentricityLogic.Size = SizeY;
+ var yFullEccentricity = eccentricityLogic.GetValue();
+ return (xFullEccentricity, yFullEccentricity);
+ }
+ }
+}
diff --git a/StructureHelperCommon/Models/Sections/Logics/RcEccentricityAxisLogic.cs b/StructureHelperCommon/Models/Sections/Logics/RcEccentricityAxisLogic.cs
new file mode 100644
index 0000000..30e581e
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/RcEccentricityAxisLogic.cs
@@ -0,0 +1,57 @@
+using StructureHelperCommon.Models.Loggers;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Models.Sections.Logics
+{
+ public class RcEccentricityAxisLogic : IRcEccentricityAxisLogic
+ {
+ private readonly double lengthFactor;
+ private readonly double sizeFactor;
+ private readonly double minEccentricity;
+
+ ///
+ /// Properties of compressed member
+ ///
+ public double Length { get; set; }
+ ///
+ /// Size of cross-section along X-axis, m
+ ///
+ public double Size { get; set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public RcEccentricityAxisLogic()
+ {
+ lengthFactor = 600d;
+ sizeFactor = 30d;
+ minEccentricity = 0.01d;
+ }
+ public double GetValue()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ var lengthEccetricity = Length / lengthFactor;
+ TraceLogger?.AddMessage(string.Format("Length of member = {0}(m)", Length));
+ TraceLogger?.AddMessage(string.Format("Accidental eccentricity by length e,a = {0}(m) / {1} = {2}(m)", Length, lengthFactor, lengthEccetricity));
+ TraceLogger?.AddMessage(string.Format("Size of cross-section of member = {0}(m)", Size));
+ var sizeXEccetricity = Size / sizeFactor;
+ TraceLogger?.AddMessage(string.Format("Accidental eccentricity by size e,a ={0}(m) / {1} = {2}(m)", Size, sizeFactor, sizeXEccetricity)); ;
+ TraceLogger?.AddMessage(string.Format("In any case, minimum accidental eccentricity e,a = {0}(m)", minEccentricity));
+
+ var fullEccentricity = new List()
+ {
+ lengthEccetricity,
+ sizeXEccetricity,
+ minEccentricity,
+ }
+ .Max();
+ string mesEcc = string.Format("Maximum accidental eccentricity e,a = max({0}(m); {1}(m); {2}(m)) = {3}(m)",
+ lengthEccetricity, sizeXEccetricity,
+ minEccentricity,
+ fullEccentricity);
+ TraceLogger?.AddMessage(mesEcc);
+ return fullEccentricity;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Models/Sections/Logics/RcEccentricityLogic.cs b/StructureHelperCommon/Models/Sections/Logics/RcEccentricityLogic.cs
new file mode 100644
index 0000000..1743674
--- /dev/null
+++ b/StructureHelperCommon/Models/Sections/Logics/RcEccentricityLogic.cs
@@ -0,0 +1,100 @@
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models.Loggers;
+using StructureHelperCommon.Models.Sections.Logics;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
+//All rights reserved.
+
+namespace StructureHelperCommon.Models.Sections
+{
+ public class RcEccentricityLogic : IProcessorLogic, IHasInputForce
+ {
+ private const string fstAxisName = "x";
+ private const string sndAxisName = "y";
+ private const string actualEccMessage = "Actual eccentricity e0,{0} = {1}(m)";
+ private const string maxEccentricityMessage = "Eccentricity e,{0} = max({1}(m); {2}(m)) = {3}(m)";
+ private const string OutPutBendingMomentMessage = "Bending moment arbitrary {0}-axis M{0} = Nz * e,{0} = {1}(N) * {2}(m) = {3}(N*m)";
+
+ ///
+ /// Properties of compressed member
+ ///
+ public double Length { get; set; }
+ ///
+ /// Size of cross-section along X-axis, m
+ ///
+ public double SizeX { get; set; }
+ ///
+ /// Size of cross-section along Y-axis, m
+ ///
+ public double SizeY { get; set; }
+ ///
+ public IForceTuple? InputForceTuple { get; set; }
+ ///
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public IRcAccEccentricityLogic EccentricityLogic { get; private set; }
+
+ public RcEccentricityLogic(IRcAccEccentricityLogic eccentricityLogic)
+ {
+ EccentricityLogic = eccentricityLogic;
+ }
+
+ public RcEccentricityLogic() : this(new RcAccEccentricityLogic())
+ {
+
+ }
+
+ public IForceTuple GetValue()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ if (InputForceTuple is null)
+ {
+ string errorString = ErrorStrings.NullReference + $": {nameof(InputForceTuple)}";
+ TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
+ throw new StructureHelperException(errorString);
+ }
+
+ EccentricityLogic.Length = Length;
+ EccentricityLogic.SizeX = SizeX;
+ EccentricityLogic.SizeY = SizeY;
+ EccentricityLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
+
+ var (ex, ey) = EccentricityLogic.GetValue();
+
+ var xEccentricity = Math.Abs(InputForceTuple.My / InputForceTuple.Nz);
+ TraceLogger?.AddMessage(string.Format(actualEccMessage, fstAxisName, xEccentricity));
+ var yEccentricity = Math.Abs(InputForceTuple.Mx / InputForceTuple.Nz);
+ TraceLogger?.AddMessage(string.Format(actualEccMessage, sndAxisName, yEccentricity));
+
+ var xFullEccentricity = Math.Max(ex, xEccentricity);
+ var yFullEccentricity = Math.Max(ey, yEccentricity);
+ string mesEx = string.Format(maxEccentricityMessage, fstAxisName, ex, xEccentricity, xFullEccentricity);
+ TraceLogger?.AddMessage(mesEx);
+ string mesEy = string.Format(maxEccentricityMessage, sndAxisName, ey, yEccentricity, yFullEccentricity);
+ TraceLogger?.AddMessage(mesEy);
+ var xSign = InputForceTuple.Mx == 0d ? -1d : Math.Sign(InputForceTuple.Mx);
+ var ySign = InputForceTuple.My == 0d ? -1d : Math.Sign(InputForceTuple.My);
+ var mx = (-1d) * InputForceTuple.Nz * yFullEccentricity * xSign;
+ var my = (-1d) * InputForceTuple.Nz * xFullEccentricity * ySign;
+ TraceLogger?.AddMessage(string.Format(OutPutBendingMomentMessage, fstAxisName, InputForceTuple.Nz, yFullEccentricity, mx), TraceLogStatuses.Debug);
+ TraceLogger?.AddMessage(string.Format(OutPutBendingMomentMessage, sndAxisName, InputForceTuple.Nz, xFullEccentricity, my), TraceLogStatuses.Debug);
+
+ var newTuple = new ForceTuple()
+ {
+ Mx = mx,
+ My = my,
+ Nz = InputForceTuple.Nz,
+ Qx = InputForceTuple.Qx,
+ Qy = InputForceTuple.Qy,
+ Mz = InputForceTuple.Mz,
+ };
+ TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple));
+ return newTuple;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Services/DirectRoundLogic.cs b/StructureHelperCommon/Services/DirectRoundLogic.cs
new file mode 100644
index 0000000..cb82161
--- /dev/null
+++ b/StructureHelperCommon/Services/DirectRoundLogic.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Services
+{
+ public class DirectRoundLogic : IMathRoundLogic
+ {
+ public double RoundValue(double value)
+ {
+ return value;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Services/FixedRoundLogic.cs b/StructureHelperCommon/Services/FixedRoundLogic.cs
new file mode 100644
index 0000000..d36d747
--- /dev/null
+++ b/StructureHelperCommon/Services/FixedRoundLogic.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Services
+{
+ public class FixedRoundLogic : IDigitRoundLogic
+ {
+ public int DigitQuant { get; set; }
+
+ ///
+ /// Умное окруление до нужного числа значащих цифр, например (12345, 3) дает результат 12300, например (0.12345, 3) дает результат 0,123
+ ///
+ ///
+ ///
+ ///
+ public double RoundValue(double value)
+ {
+ double roundedValue = Math.Round(value, DigitQuant);
+ return roundedValue;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Services/Forces/ForceTupleService.cs b/StructureHelperCommon/Services/Forces/ForceTupleService.cs
index ab74200..2e51453 100644
--- a/StructureHelperCommon/Services/Forces/ForceTupleService.cs
+++ b/StructureHelperCommon/Services/Forces/ForceTupleService.cs
@@ -20,13 +20,6 @@ namespace StructureHelperCommon.Services.Forces
target.Clear();
SumTupleToTarget(source, target, factor);
}
- public static IForceTuple MoveTupleIntoPoint(IForceTuple forceTuple, IPoint2D point2D)
- {
- var newTuple = forceTuple.Clone() as IForceTuple;
- newTuple.Mx += newTuple.Nz * point2D.Y;
- newTuple.My -= newTuple.Nz * point2D.X;
- return newTuple;
- }
public static IForceTuple SumTuples(IForceTuple first, IForceTuple second, double factor = 1d)
{
CheckTuples(first, second);
diff --git a/StructureHelperCommon/Services/IDigitRoundLogic.cs b/StructureHelperCommon/Services/IDigitRoundLogic.cs
new file mode 100644
index 0000000..7b1246e
--- /dev/null
+++ b/StructureHelperCommon/Services/IDigitRoundLogic.cs
@@ -0,0 +1,7 @@
+namespace StructureHelperCommon.Services
+{
+ public interface IDigitRoundLogic : IMathRoundLogic
+ {
+ int DigitQuant { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperCommon/Services/IMathRoundLogic.cs b/StructureHelperCommon/Services/IMathRoundLogic.cs
new file mode 100644
index 0000000..3aca8d1
--- /dev/null
+++ b/StructureHelperCommon/Services/IMathRoundLogic.cs
@@ -0,0 +1,7 @@
+namespace StructureHelperCommon.Services
+{
+ public interface IMathRoundLogic
+ {
+ double RoundValue(double value);
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperCommon/Services/SmartRoundLogic.cs b/StructureHelperCommon/Services/SmartRoundLogic.cs
new file mode 100644
index 0000000..7b0d6c8
--- /dev/null
+++ b/StructureHelperCommon/Services/SmartRoundLogic.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Services
+{
+ public class SmartRoundLogic : IDigitRoundLogic
+ {
+ public int DigitQuant { get; set; } = 3;
+
+ ///
+ /// Умное окруление до нужного числа значащих цифр, например (12345, 3) дает результат 12300, например (0.12345, 3) дает результат 0,123
+ ///
+ ///
+ ///
+ ///
+ public double RoundValue(double value)
+ {
+ if (value == 0d) return 0d;
+ double valueOrder = Math.Log10(Math.Abs(value));
+ int order = Convert.ToInt32(Math.Ceiling(valueOrder));
+ double requiredOrder = Math.Pow(10, DigitQuant - order);
+ double roundedAbsValue = Math.Round(Math.Abs(value) * requiredOrder) / requiredOrder;
+ double roundedValue = Math.Sign(value) * roundedAbsValue;
+ return roundedValue;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Services/Units/CommonOperation.cs b/StructureHelperCommon/Services/Units/CommonOperation.cs
deleted file mode 100644
index 3e91fde..0000000
--- a/StructureHelperCommon/Services/Units/CommonOperation.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Services.Units;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text.RegularExpressions;
-using System.Windows.Documents;
-
-namespace StructureHelperCommon.Services.Units
-{
- public static class CommonOperation
- {
- private static IEnumerable units = UnitsFactory.GetUnitCollection();
-
- public static double ConvertToDoubleChangeComma(string s)
- {
- double result;
- if (!double.TryParse(s, NumberStyles.Any, CultureInfo.CurrentCulture, out result) &&
- !double.TryParse(s, NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out result) &&
- !double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
- {
- throw new StructureHelperException($"{ErrorStrings.IncorrectValue}: {s}");
- }
- return result;
- }
-
- public static IStringDoublePair DivideIntoStringDoublePair(string s)
- {
- s = s.Replace(" ", "");
- //string digitPattern = @"^[-]?[+]?\d+(\.?)|(\,?)\d*";
- string digitPattern = @"^[-]?[+]?\d*\.?\,?\d*";
- string textPattern = @"[0-9]|\.|\,";
- string caracterPattern = "[a-z]+$";
- string target = "";
- Regex regexText = new Regex(textPattern);
- string textString = regexText.Replace(s, target);
- var textMatch = Regex.Match(textString, caracterPattern, RegexOptions.IgnoreCase);
- if (textMatch.Success) {textString = textMatch.Value.ToLower();}
- var match = Regex.Match(s, digitPattern);
- if (match.Success)
- {
- string digitString = match.Value;
- double digit = ConvertToDoubleChangeComma(digitString);
- return new StringDoublePair() { Digit = digit, Text = textString };
- }
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
- }
-
- public static IUnit GetUnit(UnitTypes unitType, string unitName = null)
- {
- if (unitName is null)
- {
- var boolResult = DefaultUnitNames.TryGetValue(unitType, out unitName);
- if (boolResult == false)
- {
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": unit type{unitType} is unknown");
- }
- }
- return units.Where(u => u.UnitType == unitType & u.Name == unitName).Single();
- }
-
- public static Dictionary DefaultUnitNames => new()
- {
- { UnitTypes.Length, "m"},
- { UnitTypes.Area, "m2"},
- { UnitTypes.Force, "kN" },
- { UnitTypes.Moment, "kNm"},
- { UnitTypes.Stress, "MPa"},
- { UnitTypes.Curvature, "1/m"},
- };
-
-
- public static string Convert(IUnit unit, string unitName, object value)
- {
- double val;
- if (value != null) { val = (double)value; }
- else { throw new Exception($"{unitName} value is null"); }
- val *= unit.Multiplyer;
- string strValue = $"{val} {unit.Name}";
- return strValue;
- }
-
- public static double ConvertBack(UnitTypes unitType, IUnit unit, object value)
- {
- double val;
- double multy;
- double coefficient = unit.Multiplyer;
- var strVal = value as string;
- IStringDoublePair pair = DivideIntoStringDoublePair(strVal);
- try
- {
- multy = GetMultiplyer(unitType, pair.Text);
- }
- catch (Exception ex)
- {
- multy = coefficient;
- }
- val = pair.Digit / multy;
- return val;
- }
-
- public static double GetMultiplyer(UnitTypes unitType, string unitName)
- {
- try
- {
- return units.Where(u => u.UnitType == unitType & u.Name == unitName).Single().Multiplyer;
- }
- catch (Exception ex)
- {
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ex);
- }
- }
- }
-}
diff --git a/StructureHelperCommon/Services/Units/ConvertUnitLogic.cs b/StructureHelperCommon/Services/Units/ConvertUnitLogic.cs
new file mode 100644
index 0000000..0dbcbc1
--- /dev/null
+++ b/StructureHelperCommon/Services/Units/ConvertUnitLogic.cs
@@ -0,0 +1,85 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models.Parameters;
+using StructureHelperCommon.Services.Units;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Windows.Documents;
+
+namespace StructureHelperCommon.Services.Units
+{
+ public class ConvertUnitLogic : IConvertUnitLogic
+ {
+ private static IEnumerable units = UnitsFactory.GetUnitCollection();
+ private static IProcessValuePairLogic pairLogic = new ProcessDoublePairLogic();
+
+ public IMathRoundLogic MathRoundLogic { get; set; } = new DirectRoundLogic();
+
+ public ValuePair Convert(IUnit unit, string unitName, object value)
+ {
+ double val;
+ if (value != null)
+ {
+ try
+ {
+ val = (double)value;
+ }
+ catch (Exception ex)
+ {
+ throw new StructureHelperException($"{ErrorStrings.IncorrectValue}");
+ }
+ }
+ else
+ {
+ throw new StructureHelperException($"{ErrorStrings.ParameterIsNull}: {unitName}");
+ }
+ val *= unit.Multiplyer;
+ var pair = new ValuePair
+ {
+ Text = unit.Name,
+ Value = val
+ };
+ return pair;
+ }
+
+ public double ConvertBack(UnitTypes unitType, IUnit unit, object value)
+ {
+ double val;
+ double multy;
+ double factor = unit.Multiplyer;
+ var strVal = value as string;
+ var pair = pairLogic.GetValuePairByString(strVal);
+ try
+ {
+ multy = GetMultiplyer(unitType, pair.Text);
+ }
+ catch (Exception ex)
+ {
+ multy = factor;
+ }
+ val = pair.Value / multy;
+ return val;
+ }
+
+ private double GetMultiplyer(UnitTypes unitType, string unitName)
+ {
+ try
+ {
+ return units
+ .Where(u =>
+ u.UnitType == unitType
+ &
+ u.Name == unitName)
+ .Single()
+ .Multiplyer;
+ }
+ catch (Exception ex)
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ex);
+ }
+ }
+ }
+}
diff --git a/StructureHelperCommon/Services/Units/GetUnitLogic.cs b/StructureHelperCommon/Services/Units/GetUnitLogic.cs
new file mode 100644
index 0000000..ea68c44
--- /dev/null
+++ b/StructureHelperCommon/Services/Units/GetUnitLogic.cs
@@ -0,0 +1,50 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Services.Units
+{
+ public class GetUnitLogic : IGetUnitLogic
+ {
+ private static IEnumerable units = UnitsFactory.GetUnitCollection();
+ private Dictionary defaultUnitNames;
+
+
+ public GetUnitLogic()
+ {
+ defaultUnitNames = new()
+ {
+ { UnitTypes.Length, "m"},
+ { UnitTypes.Area, "m2"},
+ { UnitTypes.Force, "kN" },
+ { UnitTypes.Moment, "kNm"},
+ { UnitTypes.Stress, "MPa"},
+ { UnitTypes.Curvature, "1/m"},
+ };
+ }
+
+ public IUnit GetUnit(UnitTypes unitType, string unitName = null)
+ {
+ if (unitName is null)
+ {
+ var boolResult = defaultUnitNames.TryGetValue(unitType, out unitName);
+ if (boolResult == false)
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": unit type{unitType} is unknown");
+ }
+ }
+ return units
+ .Where(u =>
+ u.UnitType == unitType
+ &
+ u.Name == unitName)
+ .Single();
+ }
+
+
+ }
+}
diff --git a/StructureHelperCommon/Services/Units/IConvertUnitLogic.cs b/StructureHelperCommon/Services/Units/IConvertUnitLogic.cs
new file mode 100644
index 0000000..683b2cd
--- /dev/null
+++ b/StructureHelperCommon/Services/Units/IConvertUnitLogic.cs
@@ -0,0 +1,13 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models.Parameters;
+using System.Collections.Generic;
+
+namespace StructureHelperCommon.Services.Units
+{
+ public interface IConvertUnitLogic
+ {
+ IMathRoundLogic MathRoundLogic { get; set; }
+ ValuePair Convert(IUnit unit, string unitName, object value);
+ double ConvertBack(UnitTypes unitType, IUnit unit, object value);
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperCommon/Services/Units/IGetUnitLogic.cs b/StructureHelperCommon/Services/Units/IGetUnitLogic.cs
new file mode 100644
index 0000000..40fba7a
--- /dev/null
+++ b/StructureHelperCommon/Services/Units/IGetUnitLogic.cs
@@ -0,0 +1,9 @@
+using StructureHelperCommon.Infrastructures.Enums;
+
+namespace StructureHelperCommon.Services.Units
+{
+ public interface IGetUnitLogic
+ {
+ IUnit GetUnit(UnitTypes unitType, string unitName = null);
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperCommon/Services/Units/IStringDoublePair.cs b/StructureHelperCommon/Services/Units/IStringDoublePair.cs
deleted file mode 100644
index 6856098..0000000
--- a/StructureHelperCommon/Services/Units/IStringDoublePair.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StructureHelperCommon.Services.Units
-{
- public interface IStringDoublePair
- {
- double Digit { get; }
- string Text { get; }
- }
-}
diff --git a/StructureHelperCommon/Services/Units/ProcessString.cs b/StructureHelperCommon/Services/Units/ProcessString.cs
new file mode 100644
index 0000000..4cf1978
--- /dev/null
+++ b/StructureHelperCommon/Services/Units/ProcessString.cs
@@ -0,0 +1,25 @@
+using StructureHelperCommon.Infrastructures.Exceptions;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperCommon.Services.Units
+{
+ public static class ProcessString
+ {
+ public static double ConvertCommaToCultureSettings(string s)
+ {
+ double result;
+ if (!double.TryParse(s, NumberStyles.Any, CultureInfo.CurrentCulture, out result) &&
+ !double.TryParse(s, NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out result) &&
+ !double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
+ {
+ throw new StructureHelperException($"{ErrorStrings.IncorrectValue}: {s}");
+ }
+ return result;
+ }
+ }
+}
diff --git a/StructureHelperCommon/Services/Units/UnitsFactory.cs b/StructureHelperCommon/Services/Units/UnitsFactory.cs
index 53fd969..0219cba 100644
--- a/StructureHelperCommon/Services/Units/UnitsFactory.cs
+++ b/StructureHelperCommon/Services/Units/UnitsFactory.cs
@@ -5,6 +5,10 @@ namespace StructureHelperCommon.Services.Units
{
public static class UnitsFactory
{
+ ///
+ /// Returns collection of unit
+ ///
+ ///
public static List GetUnitCollection()
{
List units = new List();
@@ -28,8 +32,8 @@ namespace StructureHelperCommon.Services.Units
type = UnitTypes.Moment;
units.Add(new Unit() { UnitType = type, Name = "Nm", Multiplyer = 1d });
units.Add(new Unit() { UnitType = type, Name = "kNm", Multiplyer = 1e-3d });
- units.Add(new Unit() { UnitType = type, Name = "kgfm", Multiplyer = 9.8d });
- units.Add(new Unit() { UnitType = type, Name = "tfm", Multiplyer = 9.8e-3d });
+ units.Add(new Unit() { UnitType = type, Name = "kgfm", Multiplyer = 9.81d });
+ units.Add(new Unit() { UnitType = type, Name = "tfm", Multiplyer = 9.81e-3d });
type = UnitTypes.Curvature;
units.Add(new Unit() { UnitType = type, Name = "1/m", Multiplyer = 1d });
units.Add(new Unit() { UnitType = type, Name = "1/mm", Multiplyer = 1e-3d });
diff --git a/StructureHelperLogics/Models/Materials/IConcreteLibMaterial.cs b/StructureHelperLogics/Models/Materials/IConcreteLibMaterial.cs
index ee1fd73..1b8c339 100644
--- a/StructureHelperLogics/Models/Materials/IConcreteLibMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/IConcreteLibMaterial.cs
@@ -1,4 +1,5 @@
-using StructureHelperCommon.Models.Materials.Libraries;
+using StructureHelperCommon.Models.Materials;
+using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -7,10 +8,8 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Materials
{
- public interface IConcreteLibMaterial : ILibMaterial
+ public interface IConcreteLibMaterial : ILibMaterial, ICrackedMaterial
{
- bool TensionForULS { get; set; }
- bool TensionForSLS { get; set; }
///
/// Humidity of concrete
///
diff --git a/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs b/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs
index c4823bd..7f5d3d6 100644
--- a/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs
+++ b/StructureHelperLogics/Models/Templates/CrossSections/CalculatorLogic.cs
@@ -1,6 +1,7 @@
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
+using StructureHelperLogics.NdmCalculations.Cracking;
namespace StructureHelperLogics.Models.Templates.CrossSections
{
@@ -8,14 +9,21 @@ namespace StructureHelperLogics.Models.Templates.CrossSections
{
public IEnumerable GetNdmCalculators()
{
- var calculators = new List
+ var calculators = new List();
+ var forceCalculator = new ForceCalculator()
{
- new ForceCalculator()
- {
- Name = "New Force Calculator",
- TraceLogger = new ShiftTraceLogger()
- }
+ Name = "New Force Calculator",
+ TraceLogger = new ShiftTraceLogger()
};
+ calculators.Add(forceCalculator);
+ CrackInputData newInputData = new CrackInputData();
+ var checkLogic = new CheckCrackCalculatorInputDataLogic(newInputData);
+ var crackCalculator = new CrackCalculator(newInputData, checkLogic)
+ {
+ Name = "New Crack Calculator",
+ TraceLogger = new ShiftTraceLogger()
+ };
+ calculators.Add(crackCalculator);
return calculators;
}
}
diff --git a/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs b/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs
index dedcb13..7ce2603 100644
--- a/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs
+++ b/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs
@@ -4,6 +4,7 @@ using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Analyses;
+using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
@@ -62,6 +63,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
var forceCalculator = calculator as IHasForceCombinations;
forceCalculator.ForceActions.AddRange(combinations);
}
+ if (calculator is CrackCalculator crackCalculator)
+ {
+ crackCalculator.InputData.ForceActions.AddRange(combinations);
+ }
}
}
private void AddAllPrimitivesToCalculator()
@@ -73,6 +78,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
var primitiveCalculator = calculator as IHasPrimitives;
primitiveCalculator.Primitives.AddRange(primitives);
}
+ if (calculator is CrackCalculator crackCalculator)
+ {
+ crackCalculator.InputData.Primitives.AddRange(primitives);
+ }
}
}
}
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs
index 93e7fc2..1101562 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs
@@ -1,12 +1,12 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Sections;
+using StructureHelperCommon.Models.Sections.Logics;
using StructureHelperCommon.Models.Shapes;
-using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Buckling;
using StructureHelperLogics.NdmCalculations.Primitives;
@@ -19,6 +19,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
static readonly ForceCalculatorUpdateStrategy updateStrategy = new();
private readonly IForceTupleCalculator forceTupleCalculator;
private ForcesResults result;
+ private IProcessorLogic eccentricityLogic;
+ private ForceTupleBucklingLogic bucklingLogic;
+ private ITriangulatePrimitiveLogic triangulateLogic;
+
public string Name { get; set; }
public List LimitStatesList { get; private set; }
@@ -34,8 +38,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public void Run()
{
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
var checkResult = CheckInputData();
- if (checkResult != "")
+ if (checkResult != string.Empty)
{
Result = new ForcesResults()
{
@@ -44,11 +49,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
};
return;
}
- else
- {
- GetCombinations();
- CalculateResult();
- }
+ GetCombinations();
+ CalculateResult();
}
private void CalculateResult()
@@ -93,43 +95,36 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
IForcesTupleResult tupleResult;
LimitStates limitState = tuple.LimitState;
CalcTerms calcTerm = tuple.CalcTerm;
- var ndms = NdmPrimitivesService.GetNdms(Primitives, limitState, calcTerm);
+ triangulateLogic = new TriangulatePrimitiveLogic()
+ {
+ Primitives = Primitives,
+ LimitState = limitState,
+ CalcTerm = calcTerm,
+ TraceLogger = TraceLogger
+ };
+ var ndms = triangulateLogic.GetNdms();
IPoint2D point2D;
+ IProcessorLogic forcelogic = new ForceTupleCopier(tuple.ForceTuple);
if (combination.SetInGravityCenter == true)
{
var (Cx, Cy) = LoaderCalculator.Logics.Geometry.GeometryOperations.GetGravityCenter(ndms);
- point2D = new Point2D(){ X = Cx, Y = Cy };
+ point2D = new Point2D() { X = Cx, Y = Cy };
+ forcelogic = new ForceTupleMoveToPointDecorator(forcelogic) { Point2D = point2D};
}
- else point2D = combination.ForcePoint;
- var newTuple = ForceTupleService.MoveTupleIntoPoint(tuple.ForceTuple, point2D);
- TraceLogger?.AddMessage($"Input force combination");
+ var newTuple = forcelogic.GetValue();
+ TraceLogger?.AddMessage("Input force combination");
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple));
if (CompressedMember.Buckling == true)
{
if (newTuple.Nz >= 0d)
{
TraceLogger?.AddMessage(string.Format("Second order effect is not considered as Nz={0} >= 0", newTuple.Nz));
+ tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
}
else
{
- TraceLogger?.AddMessage("Get eccentricity for full load");
- newTuple = ProcessAccEccentricity(ndms, newTuple);
- var buckResult = GetForceTupleByBuckling(combination, limitState, calcTerm, ndms, newTuple);
- if (buckResult.isValid == true)
- {
- newTuple = buckResult.tuple;
- }
- else
- {
- return new ForcesTupleResult()
- {
- IsValid = false,
- DesignForceTuple = tuple,
- Description = buckResult.description,
- };
- }
- }
- tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
+ tupleResult = ProcessCompressedMember(combination, tuple, ndms, newTuple);
+ }
}
else
{
@@ -143,10 +138,19 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
return tupleResult;
}
- private (bool isValid, IForceTuple tuple, string description) GetForceTupleByBuckling(IForceCombinationList combination, LimitStates limitState, CalcTerms calcTerm, List ndms, IForceTuple newTuple)
+ private IForcesTupleResult ProcessCompressedMember(IForceCombinationList combination, IDesignForceTuple tuple, List ndms, IForceTuple newTuple)
{
- var tuple = newTuple.Clone() as IForceTuple;
- var inputData = new BucklingInputData()
+ IForcesTupleResult tupleResult;
+ LimitStates limitState = tuple.LimitState;
+ CalcTerms calcTerm = tuple.CalcTerm;
+
+ TraceLogger?.AddMessage("Get eccentricity for full load");
+ eccentricityLogic = new ProcessEccentricity(CompressedMember, ndms, newTuple)
+ {
+ TraceLogger = TraceLogger ?? null
+ };
+ newTuple = eccentricityLogic.GetValue();
+ var buclingInputData = new BucklingInputData()
{
Combination = combination,
LimitState = limitState,
@@ -154,127 +158,48 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
Ndms = ndms,
ForceTuple = newTuple
};
- var bucklingResult = ProcessBuckling(inputData);
-
- if (bucklingResult.IsValid != true)
+ bucklingLogic = new ForceTupleBucklingLogic(buclingInputData)
{
- TraceLogger?.AddMessage(bucklingResult.Description, TraceLogStatuses.Error);
- return (false, tuple, $"Buckling result:\n{bucklingResult.Description}");
+ CompressedMember = CompressedMember,
+ Accuracy = Accuracy,
+ Primitives = Primitives,
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ var buckResult = bucklingLogic.GetForceTupleByBuckling();
+ if (buckResult.IsValid == true)
+ {
+ newTuple = buckResult.Value;
}
else
{
- tuple = CalculateBuckling(tuple, bucklingResult);
- TraceLogger?.AddMessage(string.Intern("Force combination with considering of second order effects"));
- TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tuple));
+ return new ForcesTupleResult()
+ {
+ IsValid = false,
+ DesignForceTuple = tuple,
+ Description = buckResult.Description,
+ };
}
-
- return (true, tuple, string.Empty);
+ TraceLogger?.AddMessage(string.Intern("Result of second order was obtained succesfully, new force combination was obtained"));
+ tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
+ return tupleResult;
}
private IForcesTupleResult GetForceResult(LimitStates limitState, CalcTerms calcTerm, List ndms, IForceTuple newTuple)
{
+ TraceLogger?.AddMessage("Calculation of cross-section is started");
var tupleResult = GetPrimitiveStrainMatrix(ndms, newTuple, Accuracy);
tupleResult.DesignForceTuple.LimitState = limitState;
tupleResult.DesignForceTuple.CalcTerm = calcTerm;
tupleResult.DesignForceTuple.ForceTuple = newTuple;
return tupleResult;
-
}
- private IForceTuple ProcessAccEccentricity(List ndms, IForceTuple tuple)
- {
- var newTuple = tuple.Clone() as IForceTuple;
- var accLogic = new AccidentalEccentricityLogic()
- {
- Length = CompressedMember.GeometryLength,
- SizeX = ndms.Max(x => x.CenterX) - ndms.Min(x => x.CenterX),
- SizeY = ndms.Max(x => x.CenterY) - ndms.Min(x => x.CenterY),
- InitialForceTuple = newTuple,
- };
- if (TraceLogger is not null)
- {
- accLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
- }
- newTuple = accLogic.GetForceTuple();
- return newTuple;
- }
-
- private IConcreteBucklingResult ProcessBuckling(BucklingInputData inputData)
- {
- IForceTuple resultTuple;
- IForceTuple longTuple;
- if (inputData.CalcTerm == CalcTerms.LongTerm)
- {
- longTuple = inputData.ForceTuple;
- }
- else
- {
- longTuple = GetLongTuple(inputData.Combination.DesignForces, inputData.LimitState);
- }
- TraceLogger?.AddMessage("Get eccentricity for long term load");
- longTuple = ProcessAccEccentricity(inputData.Ndms, longTuple);
- var bucklingCalculator = GetBucklingCalculator(CompressedMember, inputData.LimitState, inputData.CalcTerm, inputData.ForceTuple, longTuple);
- if (TraceLogger is not null)
- {
- bucklingCalculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
- }
- bucklingCalculator.Run();
- var bucklingResult = bucklingCalculator.Result as IConcreteBucklingResult;
-
- return bucklingResult;
- }
-
- private IForceTuple GetLongTuple(List designForces, LimitStates limitState)
- {
- IForceTuple longTuple;
- try
- {
- longTuple = designForces
- .Where(x => x.LimitState == limitState & x.CalcTerm == CalcTerms.LongTerm)
- .Single()
- .ForceTuple;
- }
- catch (Exception)
- {
- longTuple = new ForceTuple();
- }
- return longTuple;
- }
-
- private IConcreteBucklingCalculator GetBucklingCalculator(ICompressedMember compressedMember, LimitStates limitStates, CalcTerms calcTerms, IForceTuple calcTuple, IForceTuple longTuple)
- {
- var options = new ConcreteBucklingOptions()
- {
- CompressedMember = compressedMember,
- LimitState = limitStates,
- CalcTerm = calcTerms,
- CalcForceTuple = calcTuple,
- LongTermTuple = longTuple,
- Primitives = Primitives
- };
- var bucklingCalculator = new ConcreteBucklingCalculator(options, Accuracy);
- return bucklingCalculator;
- }
-
- private ForceTuple CalculateBuckling(IForceTuple calcTuple, IConcreteBucklingResult bucklingResult)
- {
- var newTuple = calcTuple.Clone() as ForceTuple;
- newTuple.Mx *= bucklingResult.EtaFactorAlongY;
- newTuple.My *= bucklingResult.EtaFactorAlongX;
- return newTuple;
- }
-
-
private string CheckInputData()
{
- string result = "";
- try
+ string result = string.Empty;
+ if (! Primitives.Any())
{
- NdmPrimitivesService.CheckPrimitives(Primitives);
- }
- catch (Exception ex)
- {
- result += ex;
+ result += "Calculator does not contain any primitives \n";
}
if (ForceActions.Count == 0)
{
@@ -286,8 +211,20 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
}
if (CalcTermsList.Count == 0)
{
- result += "Calculator does not contain any duration \n";
+ result += "Calculator does not contain any calc term \n";
}
+ //try
+ //{
+ // triangulateLogic = new TriangulatePrimitiveLogic()
+ // {
+ // Primitives = Primitives
+ // };
+ // triangulateLogic.CheckPrimitives(Primitives);
+ //}
+ //catch (Exception ex)
+ //{
+ // result += ex;
+ //}
return result;
}
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/PredicateFactory.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/PredicateFactory.cs
index a0e746b..7947d3c 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/PredicateFactory.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/Factories/PredicateFactory.cs
@@ -83,7 +83,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private bool IsSectionCracked(IPoint2D point2D)
{
logger?.TraceLoggerEntries.Clear();
- var logic = new HoleSectionCrackedLogic();
+ var logic = new SectionCrackedLogic();
var point3D = ConvertLogic.GetPoint3D(point2D);
tuple = new()
{
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs
index e160803..b463e6d 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurveLogic.cs
@@ -60,14 +60,16 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private void MultiThreadProc(IEnumerable points)
{
Task[] tasks = new Task[points.Count()];
- for (int i = 0; i < points.Count(); i++)
+ int pointCount = points.Count();
+ List PointList = points.ToList();
+ for (int i = 0; i < pointCount; i++)
{
- var point = points.ToList()[i];
+ var point = PointList[i];
tasks[i] = new Task(() => FindResultPoint(point));
tasks[i].Start();
}
Task.WaitAll(tasks);
- for (int j = 0; j < points.Count(); j++)
+ for (int j = 0; j < pointCount; j++)
{
var taskResult = tasks[j].Result;
resultList.Add(taskResult);
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs
index 83db6dc..65984d0 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/LimitCurve/LimitCurvesCalculator.cs
@@ -15,6 +15,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
private LimitCurvesResult result;
private int curvesIterationCount;
+ private ITriangulatePrimitiveLogic triangulateLogic;
+
private LimitCurvesCalculatorUpdateStrategy updateStrategy => new();
public Guid Id { get; }
@@ -78,7 +80,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
foreach (var calcTerm in InputData.CalcTerms)
{
- var ndms = NdmPrimitivesService.GetNdms(primitiveSeries.Collection, limitState, calcTerm);
+ triangulateLogic = new TriangulatePrimitiveLogic()
+ {
+ Primitives = primitiveSeries.Collection,
+ LimitState = limitState,
+ CalcTerm = calcTerm,
+ TraceLogger = TraceLogger
+ };
+ var ndms = triangulateLogic.GetNdms();
TraceLogger?.AddMessage($"Number of elementary parts N={ndms.Count()} were obtainded succesfully");
TraceLogger?.AddMessage($"Summary area of elementary parts Asum={ndms.Sum(x=>x.Area * x.StressScale)}", TraceLogStatuses.Debug);
foreach (var predicateEntry in InputData.PredicateEntries)
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceTupleTraceResultLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceTupleTraceResultLogic.cs
index 0a412a5..63295aa 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceTupleTraceResultLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceTupleTraceResultLogic.cs
@@ -50,7 +50,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
Point2D minPoint = new(), maxPoint = new();
foreach (var item in ndmCollection)
{
- var strain = stressLogic.GetTotalStrain(strainMatrix, item);
+ var strain = stressLogic.GetSectionStrain(strainMatrix, item);
if (strain < minStrain)
{
minStrain = strain;
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ExportGeometryResultToCSVLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ExportGeometryResultToCSVLogic.cs
index 8c6ba64..d701a1e 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ExportGeometryResultToCSVLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ExportGeometryResultToCSVLogic.cs
@@ -55,7 +55,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses
{
item.Name,
item.ShortName,
- item.MeasurementUnit,
+ item.Text,
item.Value.ToString(),
item.Description
};
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs
index 46423ab..cc6eada 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs
@@ -5,6 +5,7 @@ using StructureHelperCommon.Services;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
+using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
@@ -28,6 +29,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Logics
{
new LimitCurvesCalculatorUpdateStrategy().Update(limitCurves, (LimitCurvesCalculator)sourceObject);
}
+ else if (targetObject is CrackCalculator crackCalculator)
+ {
+ new CrackCalculatorUpdateStrategy().Update(crackCalculator, (CrackCalculator)sourceObject);
+ }
else
{
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(INdmPrimitive), sourceObject.GetType());
diff --git a/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs b/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs
index a0b557a..88884c6 100644
--- a/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs
+++ b/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs
@@ -2,6 +2,7 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Logics;
using LoaderCalculator.Logics.Geometry;
+using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
@@ -24,6 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
private List concreteNdms;
private List otherNdms;
IForcesTupleResult forcesResults;
+ private ITriangulatePrimitiveLogic triangulateLogic;
public string Name { get; set; }
@@ -52,11 +54,77 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
Accuracy = accuracy;
var allPrimitives = options.Primitives;
- ndmCollection = NdmPrimitivesService.GetNdms(allPrimitives, options.LimitState, options.CalcTerm);
+ triangulateLogic = new TriangulatePrimitiveLogic()
+ {
+ Primitives = allPrimitives,
+ LimitState = options.LimitState,
+ CalcTerm = options.CalcTerm
+ };
+ ndmCollection = triangulateLogic.GetNdms();
concreteNdms = ndmCollection.Where(x => x.Material is ICrackMaterial).ToList();
otherNdms = ndmCollection.Except(concreteNdms).ToList();
}
+ public void Run()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ TraceLogger?.AddMessage(LoggerStrings.MethodBasedOn + "SP63.13330.2018");
+ var checkResult = CheckInputData();
+ if (checkResult != "")
+ {
+ ProcessFalseResult(checkResult);
+ return;
+ }
+ else
+ {
+ ProcessValidResult();
+ }
+ TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
+ }
+
+ private void ProcessValidResult()
+ {
+ var phiLLogic = GetPhiLogic();
+ var (DeltaLogicAboutX, DeltaLogicAboutY) = GetDeltaLogics();
+ stiffnessLogicX = new RCStiffnessLogicSP63(phiLLogic, DeltaLogicAboutX);
+ stiffnessLogicY = new RCStiffnessLogicSP63(phiLLogic, DeltaLogicAboutY);
+ if (TraceLogger is not null)
+ {
+ stiffnessLogicX.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
+ stiffnessLogicY.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
+ }
+ criticalForceLogic = new EilerCriticalForceLogic();
+ if (TraceLogger is not null)
+ {
+ criticalForceLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
+ }
+
+ var (EtaFactorX, EtaFactorY) = GetBucklingCoefficients();
+ var messageString = "Eta factor orbitrary {0} axis, Eta{0} = {1} (dimensionless)";
+ var messageStringX = string.Format(messageString, "X", EtaFactorX);
+ var messageStringY = string.Format(messageString, "Y", EtaFactorY);
+ TraceLogger?.AddMessage(messageStringX);
+ TraceLogger?.AddMessage(messageStringY);
+ Result = new ConcreteBucklingResult()
+ {
+ IsValid = true,
+ EtaFactorAlongX = EtaFactorX,
+ EtaFactorAlongY = EtaFactorY
+ };
+ }
+
+ private void ProcessFalseResult(string checkResult)
+ {
+ TraceLogger?.AddMessage(checkResult, TraceLogStatuses.Error);
+ Result = new ConcreteBucklingResult()
+ {
+ IsValid = false,
+ Description = checkResult,
+ EtaFactorAlongX = double.PositiveInfinity,
+ EtaFactorAlongY = double.PositiveInfinity
+ };
+ }
+
private (IConcreteDeltaELogic DeltaLogicX, IConcreteDeltaELogic DeltaLogicY) GetDeltaLogics()
{
IForceTuple forceTuple = options.CalcForceTuple;
@@ -66,6 +134,15 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
}
var eccentricityAlongX = options.CalcForceTuple.My / forceTuple.Nz;
var eccentricityAlongY = options.CalcForceTuple.Mx / forceTuple.Nz;
+ const string eccMesssage = "Eccentricity along {0}-axis e{0} = {1}(N * m) / {2}(N) = {3}(m)";
+ TraceLogger?.AddMessage(string.Format(eccMesssage,
+ "x",
+ options.CalcForceTuple.My, forceTuple.Nz,
+ eccentricityAlongX));
+ TraceLogger?.AddMessage(string.Format(eccMesssage,
+ "y",
+ options.CalcForceTuple.Mx, forceTuple.Nz,
+ eccentricityAlongY));
var sizeAlongX = ndmCollection.Max(x => x.CenterX) - ndmCollection.Min(x => x.CenterX);
var sizeAlongY = ndmCollection.Max(x => x.CenterY) - ndmCollection.Min(x => x.CenterY);
var DeltaElogicAboutX = new DeltaELogicSP63(eccentricityAlongY, sizeAlongY);
@@ -82,7 +159,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
{
const string sumStif = "Summary stiffness";
var gravityCenter = GeometryOperations.GetGravityCenter(ndmCollection);
- string message = string.Format("Gravity center, x = {0}, y = {1}", gravityCenter.Cx, gravityCenter.Cy);
+ string message = string.Format("Gravity center, x = {0}(m), y = {1}(m)", gravityCenter.Cx, gravityCenter.Cy);
TraceLogger?.AddMessage(message);
if (TraceLogger is not null)
{
@@ -128,7 +205,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
var stressLogic = new StressLogic();
foreach (var item in ndmCollection)
{
- var strain = stressLogic.GetTotalStrain(strains, item);
+ var strain = stressLogic.GetSectionStrain(strains, item);
if (strain > maxStrain)
{
maxStrain = strain;
@@ -152,55 +229,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
return calculator;
}
- public void Run()
- {
- TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
- TraceLogger?.AddMessage(LoggerStrings.MethodBasedOn + "SP63.13330.2018");
- var checkResult = CheckInputData();
- if (checkResult != "")
- {
- TraceLogger?.AddMessage(checkResult, TraceLogStatuses.Error);
- Result = new ConcreteBucklingResult()
- {
- IsValid = false,
- Description = checkResult,
- EtaFactorAlongX = double.PositiveInfinity,
- EtaFactorAlongY = double.PositiveInfinity
- };
- return;
- }
- else
- {
- var phiLLogic = GetPhiLogic();
- var (DeltaLogicAboutX, DeltaLogicAboutY) = GetDeltaLogics();
- stiffnessLogicX = new RCStiffnessLogicSP63(phiLLogic, DeltaLogicAboutX);
- stiffnessLogicY = new RCStiffnessLogicSP63(phiLLogic, DeltaLogicAboutY);
- if (TraceLogger is not null)
- {
- stiffnessLogicX.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
- stiffnessLogicY.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
- }
- criticalForceLogic = new EilerCriticalForceLogic();
- if (TraceLogger is not null)
- {
- criticalForceLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
- }
-
- var (EtaFactorX, EtaFactorY) = GetBucklingCoefficients();
- var messageString = "Eta factor orbitrary {0} axis, Eta{0} = {1} (dimensionless)";
- var messageStringX = string.Format(messageString, "X", EtaFactorX);
- var messageStringY = string.Format(messageString, "Y", EtaFactorY);
- TraceLogger?.AddMessage(messageStringX);
- TraceLogger?.AddMessage(messageStringY);
- Result = new ConcreteBucklingResult()
- {
- IsValid = true,
- EtaFactorAlongX = EtaFactorX,
- EtaFactorAlongY = EtaFactorY
- };
- }
- TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
- }
+
private string CheckInputData()
{
diff --git a/StructureHelperLogics/NdmCalculations/Buckling/ForceTupleBucklingLogic.cs b/StructureHelperLogics/NdmCalculations/Buckling/ForceTupleBucklingLogic.cs
new file mode 100644
index 0000000..e3e0d09
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Buckling/ForceTupleBucklingLogic.cs
@@ -0,0 +1,136 @@
+using LoaderCalculator.Data.Ndms;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using StructureHelperCommon.Models.Sections;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using StructureHelperCommon.Models.Loggers;
+
+namespace StructureHelperLogics.NdmCalculations.Buckling
+{
+ public class ForceTupleBucklingLogic : IForceTupleBucklingLogic
+ {
+ private IProcessorLogic eccentricityLogic;
+ private BucklingInputData bucklingInputData;
+
+ public ICompressedMember CompressedMember { get; set; }
+ public IAccuracy Accuracy { get; set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public IEnumerable Primitives { get; set; }
+
+ public ForceTupleBucklingLogic(BucklingInputData inputData)
+ {
+ bucklingInputData = inputData;
+ }
+
+ public GenericResult GetForceTupleByBuckling()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+
+ var tuple = bucklingInputData.ForceTuple.Clone() as IForceTuple;
+
+ var bucklingResult = ProcessBuckling(bucklingInputData);
+
+ if (bucklingResult.IsValid != true)
+ {
+ TraceLogger?.AddMessage(bucklingResult.Description, TraceLogStatuses.Error);
+ var tupleResult = new GenericResult()
+ {
+ IsValid = false,
+ Description = $"Buckling result:\n{bucklingResult.Description}",
+ Value = tuple
+ };
+ return tupleResult;
+ }
+ else
+ {
+ tuple = CalculateBuckling(tuple, bucklingResult);
+ TraceLogger?.AddMessage(string.Intern("Force combination with considering of second order effects"));
+ TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tuple));
+ }
+ var trueTupleResult = new GenericResult()
+ {
+ IsValid = true,
+ Description = string.Empty,
+ Value = tuple
+ };
+ return trueTupleResult;
+ }
+
+ private IConcreteBucklingResult ProcessBuckling(BucklingInputData inputData)
+ {
+ IForceTuple resultTuple;
+ IForceTuple longTuple;
+ if (inputData.CalcTerm == CalcTerms.LongTerm)
+ {
+ longTuple = inputData.ForceTuple;
+ }
+ else
+ {
+ longTuple = GetLongTuple(inputData.Combination.DesignForces, inputData.LimitState);
+ }
+ TraceLogger?.AddMessage("Get eccentricity for long term load");
+ eccentricityLogic = new ProcessEccentricity(CompressedMember, inputData.Ndms, longTuple)
+ {
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ longTuple = eccentricityLogic.GetValue();
+ var bucklingCalculator = GetBucklingCalculator(inputData.LimitState, inputData.CalcTerm, inputData.ForceTuple, longTuple);
+ if (TraceLogger is not null)
+ {
+ bucklingCalculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
+ }
+ bucklingCalculator.Run();
+ var bucklingResult = bucklingCalculator.Result as IConcreteBucklingResult;
+
+ return bucklingResult;
+ }
+
+ private IForceTuple GetLongTuple(List designForces, LimitStates limitState)
+ {
+ IForceTuple longTuple;
+ try
+ {
+ longTuple = designForces
+ .Where(x => x.LimitState == limitState & x.CalcTerm == CalcTerms.LongTerm)
+ .Single()
+ .ForceTuple;
+ }
+ catch (Exception)
+ {
+ longTuple = new ForceTuple();
+ }
+ return longTuple;
+ }
+
+ private IConcreteBucklingCalculator GetBucklingCalculator(LimitStates limitStates, CalcTerms calcTerms, IForceTuple calcTuple, IForceTuple longTuple)
+ {
+ var options = new ConcreteBucklingOptions()
+ {
+ CompressedMember = CompressedMember,
+ LimitState = limitStates,
+ CalcTerm = calcTerms,
+ CalcForceTuple = calcTuple,
+ LongTermTuple = longTuple,
+ Primitives = Primitives
+ };
+ var bucklingCalculator = new ConcreteBucklingCalculator(options, Accuracy);
+ return bucklingCalculator;
+ }
+
+ private ForceTuple CalculateBuckling(IForceTuple calcTuple, IConcreteBucklingResult bucklingResult)
+ {
+ var newTuple = calcTuple.Clone() as ForceTuple;
+ newTuple.Mx *= bucklingResult.EtaFactorAlongY;
+ newTuple.My *= bucklingResult.EtaFactorAlongX;
+ return newTuple;
+ }
+
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Buckling/IForceTupleBucklingLogic.cs b/StructureHelperLogics/NdmCalculations/Buckling/IForceTupleBucklingLogic.cs
new file mode 100644
index 0000000..2fcd9f8
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Buckling/IForceTupleBucklingLogic.cs
@@ -0,0 +1,13 @@
+using LoaderCalculator.Data.Ndms;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Forces;
+
+namespace StructureHelperLogics.NdmCalculations.Buckling
+{
+ public interface IForceTupleBucklingLogic : ILogic
+ {
+ GenericResult GetForceTupleByBuckling();
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperLogics/NdmCalculations/Buckling/ProcessEccentricity.cs b/StructureHelperLogics/NdmCalculations/Buckling/ProcessEccentricity.cs
new file mode 100644
index 0000000..8932242
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Buckling/ProcessEccentricity.cs
@@ -0,0 +1,57 @@
+using LoaderCalculator.Data.Ndms;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models.Sections;
+using StructureHelperCommon.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using StructureHelperCommon.Models.Loggers;
+
+namespace StructureHelperLogics.NdmCalculations.Buckling
+{
+ public class ProcessEccentricity : IProcessorLogic
+ {
+ private IProcessorLogic eccentricityLogic;
+
+ public ICompressedMember CompressedMember { get; private set; }
+ public IEnumerable Ndms { get; private set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public IForceTuple InputForceTuple { get; set; }
+
+ private double sizeX;
+ private double sizeY;
+
+ public ProcessEccentricity(IProcessorLogic eccentricityLogic)
+ {
+ this.eccentricityLogic = eccentricityLogic;
+ }
+ public ProcessEccentricity(ICompressedMember compressedMember, IEnumerable ndms, IForceTuple initialForceTuple)
+ {
+ CompressedMember = compressedMember;
+ Ndms = ndms;
+ InputForceTuple = initialForceTuple;
+ sizeX = ndms.Max(x => x.CenterX) - ndms.Min(x => x.CenterX);
+ sizeY = ndms.Max(x => x.CenterY) - ndms.Min(x => x.CenterY);
+ eccentricityLogic = new RcEccentricityLogic()
+ {
+ InputForceTuple = InputForceTuple,
+ Length = CompressedMember.GeometryLength,
+ SizeX = sizeX,
+ SizeY = sizeY,
+ };
+ }
+
+ public IForceTuple GetValue()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ TraceLogger?.AddMessage("Get eccentricity taking into account accidental eccentricity");
+ TraceLogger?.AddMessage(string.Format("Cross-section size along x-axis dx = {0}, along y-axis dy = {1}", sizeX, sizeY));
+
+ eccentricityLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
+ var newTuple = eccentricityLogic.GetValue();
+ return newTuple;
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/AverageDiameterLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/AverageDiameterLogic.cs
deleted file mode 100644
index 23cde59..0000000
--- a/StructureHelperLogics/NdmCalculations/Cracking/AverageDiameterLogic.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using LoaderCalculator.Data.Ndms;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StructureHelperLogics.NdmCalculations.Cracking
-{
- public class AverageDiameterLogic : IAverageDiameterLogic
- {
- public IEnumerable Rebars { get; set; }
-
- public double GetAverageDiameter()
- {
- Check();
- var rebarArea = Rebars
- .Sum(x => x.Area);
- var rebarCount = Rebars.Count();
- var averageArea = rebarArea / rebarCount;
- var diameter = Math.Sqrt(averageArea / Math.PI);
- return diameter;
- }
- private void Check()
- {
- if (!Rebars.Any())
- {
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": rebars count must be greater then zero");
- }
- }
- }
-}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CheckCrackCalculatorInputDataLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CheckCrackCalculatorInputDataLogic.cs
new file mode 100644
index 0000000..676ed3e
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CheckCrackCalculatorInputDataLogic.cs
@@ -0,0 +1,119 @@
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Loggers;
+using StructureHelperCommon.Models.Materials;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ ///
+ /// Logic of checking of input data for crack calcultor
+ ///
+ public class CheckCrackCalculatorInputDataLogic : ICheckInputDataLogic
+ {
+ private string checkResult;
+ private CrackInputData inputData;
+ private bool result;
+
+ public IInputData InputData
+ {
+ get => inputData;
+ set
+ {
+ if (value is CrackInputData data)
+ {
+ inputData = data;
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(CrackInputData), value));
+ }
+ }
+ }
+
+ public string CheckResult => checkResult;
+
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public CheckCrackCalculatorInputDataLogic(CrackInputData inputData)
+ {
+ this.inputData = inputData;
+ }
+ public bool Check()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug);
+ result = true;
+ checkResult = string.Empty;
+ CheckPrimitives();
+ CheckActions();
+ return result;
+ }
+
+ private void CheckActions()
+ {
+ if (inputData.ForceActions is null || (!inputData.ForceActions.Any()))
+ {
+ result = false;
+ string message = "Calculator does not contain any actions\n";
+ checkResult += message;
+ TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
+ };
+ }
+
+ private void CheckPrimitives()
+ {
+ if (inputData.Primitives is null || (!inputData.Primitives.Any()))
+ {
+ result = false;
+ string message = "Calculator does not contain any primitives\n";
+ checkResult += message;
+ TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
+ }
+ else
+ {
+ foreach (var primitive in inputData.Primitives)
+ {
+ if (primitive is RebarPrimitive rebar)
+ {
+ CheckRebar(rebar);
+ }
+ }
+ }
+ }
+
+ private void CheckRebar(RebarPrimitive rebar)
+ {
+ if (rebar.HostPrimitive is null)
+ {
+ result = false;
+ string message = $"Primitive {rebar.Name} does not have a host\n";
+ checkResult += message;
+ TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
+ }
+ else
+ {
+ bool isPrimitivesContainRebarHost = inputData.Primitives.Contains(rebar.HostPrimitive);
+ if (isPrimitivesContainRebarHost == false)
+ {
+ result = false;
+ string message = $"Host {rebar.Name}({rebar.HostPrimitive.Name}) is not included in primitives\n";
+ checkResult += message;
+ TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
+ }
+ }
+ if (rebar.HostPrimitive.HeadMaterial.HelperMaterial is not ICrackedMaterial)
+ {
+ result = false;
+ string message = $"Material of host of {rebar.Name} does not support cracking\n";
+ checkResult += message;
+ TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
+ }
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CheckTupleCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Cracking/CheckTupleCalculatorInputData.cs
new file mode 100644
index 0000000..a22968b
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CheckTupleCalculatorInputData.cs
@@ -0,0 +1,44 @@
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Calculators;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CheckTupleCalculatorInputData : ICheckInputDataLogic
+ {
+ private string checkResult;
+ private TupleCrackInputData inputData;
+ private bool result;
+
+ public IInputData InputData
+ {
+ get => inputData; set
+ {
+ if (value is TupleCrackInputData data)
+ {
+ inputData = data;
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
+ }
+ }
+ }
+
+ public string CheckResult => checkResult;
+
+ public IShiftTraceLogger? TraceLogger { get; set; }
+
+ public bool Check()
+ {
+ result = true;
+ return result;
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs
new file mode 100644
index 0000000..3ff8f64
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs
@@ -0,0 +1,116 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Infrastructures.Settings;
+using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models.Loggers;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CrackCalculator : ICalculator
+ {
+ const LimitStates limitState = LimitStates.SLS;
+ const CalcTerms longTerm = CalcTerms.LongTerm;
+ const CalcTerms shortTerm = CalcTerms.ShortTerm;
+ private const double maxSizeOfCrossSection = 1d;
+ private CrackResult result;
+ private IGetTupleInputDatasLogic datasLogic;
+ private CrackCalculatorUpdateStrategy updateStrategy = new();
+ private ICheckInputDataLogic checkInputDataLogic;
+
+ public string Name { get; set; }
+ public CrackInputData InputData { get; set; }
+ public IResult Result => result;
+
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public CrackCalculator(CrackInputData inputData, ICheckInputDataLogic checkInputDataLogic)
+ {
+ InputData = inputData;
+ this.checkInputDataLogic = checkInputDataLogic;
+ }
+
+ public object Clone()
+ {
+ CrackInputData crackInputData = new CrackInputData();
+ var checkDataLogic = new CheckCrackCalculatorInputDataLogic(InputData);
+ var newItem = new CrackCalculator(crackInputData, checkDataLogic);
+ updateStrategy.Update(newItem, this);
+ return newItem;
+ }
+
+ public void Run()
+ {
+ PrepareNewResult();
+ CheckInputData();
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ try
+ {
+ ProcessCalculations();
+ TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
+ }
+ catch (Exception ex)
+ {
+ result.IsValid = false;
+ result.Description += ex;
+ TraceLogger?.AddMessage(LoggerStrings.CalculationError + ex, TraceLogStatuses.Error);
+ }
+ }
+
+ private void CheckInputData()
+ {
+ checkInputDataLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
+ if (checkInputDataLogic.Check() == false)
+ {
+ result.IsValid = false;
+ result.Description += checkInputDataLogic.CheckResult;
+ }
+ }
+
+ private void ProcessCalculations()
+ {
+ datasLogic = new GetTupleInputDatasLogic(InputData.Primitives, InputData.ForceActions, InputData.UserCrackInputData)
+ {
+ LimitState = limitState,
+ LongTerm = longTerm,
+ ShortTerm = shortTerm,
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ var dx = InputData.Primitives.Max(x => x.GetValuePoints().Max(y => y.Point.X)) - InputData.Primitives.Min(x => x.GetValuePoints().Min(y => y.Point.X));
+ var dy = InputData.Primitives.Max(x => x.GetValuePoints().Max(y => y.Point.Y)) - InputData.Primitives.Min(x => x.GetValuePoints().Min(y => y.Point.Y));
+ if (dx > maxSizeOfCrossSection || dy > maxSizeOfCrossSection)
+ {
+ string message = $"At least one of size of cross-section is greater than ultimate size MaxSize = {maxSizeOfCrossSection}(m)";
+ result.Description += "Warning! " + message;
+ TraceLogger?.AddMessage(message, TraceLogStatuses.Warning);
+ }
+ var datas = datasLogic.GetTupleInputDatas();
+ foreach (var data in datas)
+ {
+ var calculator = new TupleCrackCalculator()
+ {
+ InputData = data,
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ calculator.Run();
+ var calcResult = calculator.Result as TupleCrackResult;
+ result.TupleResults.Add(calcResult);
+ }
+ }
+
+ private void PrepareNewResult()
+ {
+ result = new CrackResult
+ {
+ IsValid = true,
+ Description = string.Empty
+ };
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculatorUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculatorUpdateStrategy.cs
new file mode 100644
index 0000000..72afe64
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculatorUpdateStrategy.cs
@@ -0,0 +1,24 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Services;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CrackCalculatorUpdateStrategy : IUpdateStrategy
+ {
+ private CrackInputDataUpdateStrategy crackInputDataUpdateStrategy => new();
+ public void Update(CrackCalculator targetObject, CrackCalculator sourceObject)
+ {
+ if (ReferenceEquals(targetObject, sourceObject)) { return; }
+ CheckObject.CompareTypes(targetObject, sourceObject);
+
+ targetObject.Name = sourceObject.Name;
+ targetObject.InputData ??= new();
+ crackInputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs
index b1290d7..3f09923 100644
--- a/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackForceCalculator.cs
@@ -13,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{
public class CrackForceCalculator : ICalculator
{
- static readonly CrackedLogic crackedLogic = new();
+ private CrackedLogic crackedLogic;
ExpSofteningLogic softeningLogic = new();
static readonly CrackStrainLogic crackStrainLogic = new();
static readonly SofteningFactorLogic softeningFactorLogic = new();
@@ -30,13 +30,14 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public IShiftTraceLogger? TraceLogger { get; set; }
- public CrackForceCalculator(IForceTupleCalculator forceTupleCalculator)
+ public CrackForceCalculator(CrackedLogic crackedLogic)
{
StartTuple ??= new ForceTuple();
Accuracy ??= new Accuracy() { IterationAccuracy = 0.0001d, MaxIterationCount = 10000 };
- this.forceTupleCalculator = forceTupleCalculator;
+ forceTupleCalculator = new ForceTupleCalculator();
+ this.crackedLogic = crackedLogic;
}
- public CrackForceCalculator() : this(new ForceTupleCalculator())
+ public CrackForceCalculator() : this(new CrackedLogic())
{
}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackInputData.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackInputData.cs
new file mode 100644
index 0000000..4105123
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackInputData.cs
@@ -0,0 +1,35 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CrackInputData : IInputData, IHasPrimitives, IHasForceCombinations
+ {
+ ///
+ public List Primitives { get; private set; }
+ ///
+ public List ForceActions { get; private set; }
+ public UserCrackInputData UserCrackInputData { get; private set; }
+ public CrackInputData()
+ {
+ Primitives = new();
+ ForceActions = new();
+ UserCrackInputData = new()
+ {
+ SetSofteningFactor = true,
+ SofteningFactor = 1d,
+ SetLengthBetweenCracks = true,
+ LengthBetweenCracks = 0.4d,
+ UltimateLongCrackWidth = 0.0003d,
+ UltimateShortCrackWidth = 0.0004d
+ };
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackInputDataUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackInputDataUpdateStrategy.cs
new file mode 100644
index 0000000..d018e8f
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackInputDataUpdateStrategy.cs
@@ -0,0 +1,26 @@
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Services;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CrackInputDataUpdateStrategy : IUpdateStrategy
+ {
+ private UserCrackInputDataUpdateStrategy userCrackInputDataUpdateStrategy => new();
+ public void Update(CrackInputData targetObject, CrackInputData sourceObject)
+ {
+ if (ReferenceEquals(targetObject, sourceObject)) { return; }
+ CheckObject.CompareTypes(targetObject, sourceObject);
+ targetObject.ForceActions.Clear();
+ targetObject.ForceActions.AddRange(sourceObject.ForceActions);
+ targetObject.Primitives.Clear();
+ targetObject.Primitives.AddRange(sourceObject.Primitives);
+
+ userCrackInputDataUpdateStrategy.Update(targetObject.UserCrackInputData, sourceObject.UserCrackInputData);
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorResult.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackResult.cs
similarity index 50%
rename from StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorResult.cs
rename to StructureHelperLogics/NdmCalculations/Cracking/CrackResult.cs
index 0afdafe..7775cbf 100644
--- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorResult.cs
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackResult.cs
@@ -5,17 +5,19 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
+//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
+//All rights reserved.
+
namespace StructureHelperLogics.NdmCalculations.Cracking
{
- public class CrackWidthCalculatorResult : IResult
+ public class CrackResult : IResult
{
public bool IsValid { get; set; }
- public string Description { get; set; }
- public List RebarResults { get; set; }
-
- public CrackWidthCalculatorResult()
+ public string? Description { get; set; }
+ public List TupleResults {get;set;}
+ public CrackResult()
{
- RebarResults = new List();
+ TupleResults = new();
}
}
}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculator.cs
deleted file mode 100644
index 7d1e22e..0000000
--- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculator.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-using LoaderCalculator.Data.Ndms;
-using StructureHelperCommon.Infrastructures.Exceptions;
-using StructureHelperCommon.Models;
-using StructureHelperCommon.Models.Calculators;
-using StructureHelperCommon.Models.Forces;
-using StructureHelperCommon.Services.Forces;
-using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
-using StructureHelperLogics.NdmCalculations.Primitives;
-using StructureHelperLogics.Services.NdmPrimitives;
-
-namespace StructureHelperLogics.NdmCalculations.Cracking
-{
- public class CrackWidthCalculator : ICalculator
- {
- static readonly ILengthBetweenCracksLogic lengthLogic = new LengthBetweenCracksLogicSP63();
- CrackWidthCalculatorResult result;
- private IEnumerable ndmPrimitives;
- private List? rebarPrimitives;
- private IEnumerable ndmCollection;
- private CrackForceResult crackForceResult;
- private StrainTuple strainTuple;
-
- public string Name { get; set; }
- public CrackWidthCalculatorInputData InputData { get; set; }
- public IResult Result => result;
-
- public IShiftTraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
-
- public void Run()
- {
- result = new() { IsValid = true, Description = ""};
- try
- {
- ProcessCalculations();
- }
- catch (Exception ex)
- {
- result.IsValid = false;
- result.Description += ex;
- }
-
- }
-
- private void ProcessCalculations()
- {
- CheckInputData();
- Triangulate();
- CalcStrainMatrix();
- CalcCrackForce();
- var crackInputData = GetCrackInputData();
- var calculator = new CrackWidthSimpleCalculator { InputData = crackInputData };
- foreach (var item in rebarPrimitives)
- {
- crackInputData.RebarPrimitive = item;
- calculator.Run();
- var rebarResult = calculator.Result as CrackWidthSimpleCalculatorResult;
- if (crackForceResult.IsSectionCracked == false)
- {
- rebarResult.CrackWidth = 0d;
- }
- result.RebarResults.Add(rebarResult);
- }
- }
-
- private void CalcStrainMatrix()
- {
- IForceTupleInputData inputData = new ForceTupleInputData() { NdmCollection = ndmCollection, Tuple = InputData.ForceTuple};
- IForceTupleCalculator calculator = new ForceTupleCalculator() { InputData = inputData };
- calculator.Run();
- var forceResult = calculator.Result as IForcesTupleResult;
- strainTuple = TupleConverter.ConvertToStrainTuple(forceResult.LoaderResults.StrainMatrix);
- }
-
- private CrackWidthSimpleCalculatorInputData GetCrackInputData()
- {
- lengthLogic.NdmCollection = ndmCollection;
- lengthLogic.StrainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(strainTuple);
- var length = lengthLogic.GetLength();
- var crackInputData = new CrackWidthSimpleCalculatorInputData
- {
- PsiSFactor = crackForceResult.PsiS,
- Length = length,
- LimitState = InputData.LimitState,
- StrainTuple = strainTuple
- };
- return crackInputData;
- }
-
- private void Triangulate()
- {
- ndmPrimitives = InputData.NdmPrimitives;
- rebarPrimitives = new List();
- foreach (var item in ndmPrimitives)
- {
- if (item is RebarPrimitive)
- {
- rebarPrimitives.Add(item as RebarPrimitive);
- }
- }
- ndmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, InputData.LimitState, InputData.CalcTerm);
- }
-
- private void CalcCrackForce()
- {
- var calculator = new CrackForceCalculator();
- calculator.EndTuple = InputData.ForceTuple;
- calculator.NdmCollection = ndmCollection;
- calculator.Run();
- crackForceResult = calculator.Result as CrackForceResult;
- }
-
- private void CheckInputData()
- {
- if (InputData.NdmPrimitives is null || InputData.NdmPrimitives.Count == 0)
- {
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": input data doesn't have any primitives");
- }
- }
-
- public object Clone()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorInputData.cs
deleted file mode 100644
index 607ad35..0000000
--- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculatorInputData.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Models.Forces;
-using StructureHelperLogics.NdmCalculations.Primitives;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StructureHelperLogics.NdmCalculations.Cracking
-{
- public class CrackWidthCalculatorInputData
- {
- public LimitStates LimitState { get; set; }
- public CalcTerms CalcTerm { get; set; }
- public IForceTuple ForceTuple { get; set; }
- public List NdmPrimitives {get;set;}
- }
-}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthLogicSP63.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthLogicSP63.cs
index 3a9637f..8cf70a9 100644
--- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthLogicSP63.cs
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthLogicSP63.cs
@@ -1,4 +1,6 @@
using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Loggers;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,44 +13,69 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{
CrackWidthLogicInputDataSP63 inputData;
public ICrackWidthLogicInputData InputData {get;set;}
+ public IShiftTraceLogger? TraceLogger { get; set; }
public double GetCrackWidth()
{
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ TraceLogger?.AddMessage("Method of crack width calculation based on SP 63.13330.2018");
CheckOptions();
+ TraceLogger?.AddMessage($"Term factor fi1 = {inputData.TermFactor}", TraceLogStatuses.Service);
+ TraceLogger?.AddMessage($"Bond factor fi2 = {inputData.BondFactor}", TraceLogStatuses.Service);
+ TraceLogger?.AddMessage($"Stress state factor fi3 = {inputData.StressStateFactor}", TraceLogStatuses.Service);
+ TraceLogger?.AddMessage($"PsiS factor PsiS = {inputData.PsiSFactor}", TraceLogStatuses.Service);
+ TraceLogger?.AddMessage($"Length between cracks Ls = {inputData.Length}", TraceLogStatuses.Service);
//check if strain of concrete greater than strain of rebar
- if (inputData.ConcreteStrain > inputData.RebarStrain) { return 0d; }
- double width = (inputData.RebarStrain - inputData.ConcreteStrain) * inputData.Length;
+ double rebarElongation = inputData.RebarStrain - inputData.ConcreteStrain;
+ if (rebarElongation < 0d)
+ {
+ TraceLogger?.AddMessage($"Elongation of rebar is negative, may be rebar is under compression, width of crack a,crc = 0");
+ return 0d;
+ }
+ TraceLogger?.AddMessage($"Rebar elongation Epsilon = {inputData.RebarStrain} - {inputData.ConcreteStrain} = {rebarElongation}(dimensionless)");
+ double width = rebarElongation * inputData.Length;
width *= inputData.TermFactor * inputData.BondFactor * inputData.StressStateFactor * inputData.PsiSFactor;
+ TraceLogger?.AddMessage($"Width of crack a,crc = {inputData.TermFactor} * {inputData.BondFactor} * {inputData.StressStateFactor} * {inputData.PsiSFactor} * {rebarElongation} * {inputData.Length}(m) = {width}(m)");
return width;
}
private void CheckOptions()
{
+ string errorString = string.Empty;
if (InputData is not CrackWidthLogicInputDataSP63)
{
- throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(CrackWidthLogicInputDataSP63), InputData.GetType()));
+ errorString = ErrorStrings.ExpectedWas(typeof(CrackWidthLogicInputDataSP63), InputData.GetType());
}
inputData = InputData as CrackWidthLogicInputDataSP63;
if (inputData.Length <=0d)
{
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": length between cracks L={inputData.Length} must be greate than zero");
+ errorString = ErrorStrings.DataIsInCorrect + $": length between cracks Lcrc={inputData.Length} must be greater than zero";
}
if (inputData.TermFactor <= 0d)
{
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Term factor {inputData.TermFactor} must be greate than zero");
+ errorString = ErrorStrings.DataIsInCorrect + $": Term factor fi1 {inputData.TermFactor} must be greater than zero";
+
}
if (inputData.BondFactor <= 0d)
{
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Bond factor {inputData.BondFactor} must be greate than zero");
+ errorString = ErrorStrings.DataIsInCorrect + $": Bond factor fi2 {inputData.BondFactor} must be greater than zero";
+
}
if (inputData.StressStateFactor <= 0d)
{
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Bond factor {inputData.StressStateFactor} must be greate than zero");
+ errorString = ErrorStrings.DataIsInCorrect + $": Stress factor fi3 factor {inputData.StressStateFactor} must be greater than zero";
+
}
if (inputData.PsiSFactor <= 0d)
{
- throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": PsiS factor {inputData.PsiSFactor} must be greate than zero");
+ errorString = ErrorStrings.DataIsInCorrect + $": PsiS factor {inputData.PsiSFactor} must be greater than zero";
}
+ if (errorString != string.Empty)
+ {
+ TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
+ throw new StructureHelperException(errorString);
+ }
+ TraceLogger?.AddMessage($"Checking parameters has done succefully", TraceLogStatuses.Service);
}
}
}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthRebarTupleResult.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthRebarTupleResult.cs
new file mode 100644
index 0000000..409f295
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthRebarTupleResult.cs
@@ -0,0 +1,18 @@
+using StructureHelperCommon.Models.Forces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CrackWidthRebarTupleResult : ICrackWidthTupleResult
+ {
+ public double CrackWidth { get; set; }
+ public double UltimateCrackWidth { get; set; }
+ public bool IsCrackLessThanUltimate => CrackWidth <= UltimateCrackWidth;
+ public RebarStressResult RebarStressResult { get; set; }
+ public double SofteningFactor { get; set; }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculator.cs
deleted file mode 100644
index 03b423c..0000000
--- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculator.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using StructureHelperCommon.Models;
-using StructureHelperCommon.Models.Calculators;
-
-namespace StructureHelperLogics.NdmCalculations.Cracking
-{
- public class CrackWidthSimpleCalculator : ICalculator
- {
- ICrackWidthLogic crackWidthLogic = new CrackWidthLogicSP63();
- CrackWidthSimpleCalculatorResult result;
- public string Name { get; set; }
- public ICrackWidthSimpleCalculatorInputData InputData { get; set; }
- public IResult Result => result;
-
- public Action ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
- public IShiftTraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
-
- public void Run()
- {
- result = new() { IsValid = true};
- var crackWidthLogicType = CrackWidthLogicType.SP63;
- var logicInputData = CrackWidthLogicInputDataFactory.GetCrackWidthLogicInputData(crackWidthLogicType, InputData);
- crackWidthLogic.InputData = logicInputData;
- double crackWidth = 0d;
- try
- {
- crackWidth = crackWidthLogic.GetCrackWidth();
- }
- catch (Exception ex)
- {
- result.IsValid = false;
- result.Description += "\n" + ex;
- }
- result.RebarPrimitive = InputData.RebarPrimitive;
- result.CrackWidth = crackWidth;
- result.RebarStrain = logicInputData.RebarStrain;
- result.ConcreteStrain = logicInputData.ConcreteStrain;
- }
- public object Clone()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculatorInputData.cs
deleted file mode 100644
index 73980a6..0000000
--- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthSimpleCalculatorInputData.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Models.Forces;
-using StructureHelperLogics.NdmCalculations.Primitives;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StructureHelperLogics.NdmCalculations.Cracking
-{
- public class CrackWidthSimpleCalculatorInputData : ICrackWidthSimpleCalculatorInputData
- {
- public LimitStates LimitState { get; set; }
- public CalcTerms CalcTerm { get; set; }
- public StrainTuple StrainTuple { get; set; }
- public double PsiSFactor { get; set; }
- public double Length { get; set; }
- public SectionStressStates StressState { get; set; }
- public RebarPrimitive RebarPrimitive { get; set; }
- }
-}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthTupleResult.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthTupleResult.cs
new file mode 100644
index 0000000..895de46
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthTupleResult.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CrackWidthTupleResult : ICrackWidthTupleResult
+ {
+ public double CrackWidth { get; set; }
+ public double UltimateCrackWidth { get; set; }
+ public bool IsCrackLessThanUltimate => CrackWidth <= UltimateCrackWidth;
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackedConcreteNdmLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackedConcreteNdmLogic.cs
new file mode 100644
index 0000000..cb0b48d
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackedConcreteNdmLogic.cs
@@ -0,0 +1,24 @@
+using LoaderCalculator.Data.Ndms;
+using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Forces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CrackedConcreteNdmLogic : ISectionCrackedLogic
+ {
+ public INdm ConcreteNdm { get; set; }
+ public IForceTuple Tuple { get; set; }
+ public IEnumerable NdmCollection { get;set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+
+ public bool IsSectionCracked()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackedLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackedLogic.cs
index 8ca8d87..4124ca3 100644
--- a/StructureHelperLogics/NdmCalculations/Cracking/CrackedLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackedLogic.cs
@@ -11,9 +11,9 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
- internal class CrackedLogic : ICrackedLogic
+ public class CrackedLogic : ICrackedLogic
{
- ISectionCrackedLogic sectionCrackedLogic;
+ private ISectionCrackedLogic sectionCrackedLogic;
public IForceTuple StartTuple { get; set; }
public IForceTuple EndTuple { get; set; }
public IEnumerable NdmCollection { get; set; }
@@ -23,16 +23,14 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{
sectionCrackedLogic = sectionLogic;
}
- public CrackedLogic() : this (new HoleSectionCrackedLogic())
+ public CrackedLogic() : this (new SectionCrackedLogic())
{
}
public bool IsSectionCracked(double factor)
{
- if (TraceLogger is not null)
- {
- sectionCrackedLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
- }
+ sectionCrackedLogic.TraceLogger ??= TraceLogger?.GetSimilarTraceLogger(50);
+
var actualTuple = ForceTupleService.InterpolateTuples(EndTuple, StartTuple, factor);
sectionCrackedLogic.Tuple = actualTuple;
sectionCrackedLogic.NdmCollection = NdmCollection;
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs
new file mode 100644
index 0000000..6f0c4f6
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs
@@ -0,0 +1,96 @@
+using LoaderCalculator.Data.Ndms;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Loggers;
+using StructureHelperLogics.Models.Primitives;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using StructureHelperLogics.Services.NdmPrimitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class CrackedSectionTriangulationLogic : ICrackedSectionTriangulationLogic
+ {
+ const LimitStates limitState = LimitStates.SLS;
+ const CalcTerms shortTerm = CalcTerms.ShortTerm;
+
+ private ITriangulatePrimitiveLogic triangulateLogic;
+ private string ndmPrimitiveCountMessage;
+
+ public IEnumerable NdmPrimitives { get; private set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public CrackedSectionTriangulationLogic(IEnumerable ndmPrimitives)
+ {
+ NdmPrimitives = ndmPrimitives;
+ ndmPrimitiveCountMessage = $"Source collection containes {NdmPrimitives.Count()} primitives";
+ triangulateLogic = new TriangulatePrimitiveLogic
+ {
+ Primitives = NdmPrimitives,
+ LimitState = limitState,
+ CalcTerm = shortTerm,
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ }
+ public List GetNdmCollection()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
+ triangulateLogic = new TriangulatePrimitiveLogic()
+ {
+ LimitState = limitState,
+ CalcTerm = shortTerm,
+ Primitives = NdmPrimitives,
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ return triangulateLogic.GetNdms();
+ }
+ public List GetCrackedNdmCollection()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
+ triangulateLogic = new TriangulatePrimitiveLogic(new MeshCrackedConcreteLogic())
+ {
+ LimitState = limitState,
+ CalcTerm = shortTerm,
+ Primitives = NdmPrimitives,
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ return triangulateLogic.GetNdms();
+ }
+
+ public List GetRebarPrimitives()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
+ List rebarPrimitives = new();
+ foreach (var item in NdmPrimitives)
+ {
+ if (item is RebarPrimitive rebar)
+ {
+ TraceLogger?.AddMessage($"Primitive {rebar.Name} is rebar primitive", TraceLogStatuses.Service);
+ rebarPrimitives.Add(rebar);
+ }
+ }
+ TraceLogger?.AddMessage($"Obtained {rebarPrimitives.Count} rebar primitives");
+ return rebarPrimitives;
+ }
+
+ public List GetElasticNdmCollection()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
+ triangulateLogic = new TriangulatePrimitiveLogic(new MeshElasticLogic())
+ {
+ LimitState = limitState,
+ CalcTerm = shortTerm,
+ Primitives = NdmPrimitives,
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ return triangulateLogic.GetNdms();
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/EquivalentDiameterLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/EquivalentDiameterLogic.cs
new file mode 100644
index 0000000..5e1515f
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/EquivalentDiameterLogic.cs
@@ -0,0 +1,43 @@
+using LoaderCalculator.Data.Ndms;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models.Loggers;
+using StructureHelperCommon.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class EquivalentDiameterLogic : IAverageDiameterLogic
+ {
+ public IEnumerable Rebars { get; set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+
+ public double GetAverageDiameter()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+ Check();
+ var rebarArea = Rebars
+ .Sum(x => x.Area);
+ TraceLogger?.AddMessage($"Summary rebar area As = {rebarArea}(m^2)");
+ var rebarCount = Rebars.Count();
+ TraceLogger?.AddMessage($"Rebar count n = {rebarCount}");
+ var averageArea = rebarArea / rebarCount;
+ TraceLogger?.AddMessage($"Equivalent rebar area As,eq = {averageArea}");
+ var diameter = 2d * Math.Sqrt(averageArea / Math.PI);
+ TraceLogger?.AddMessage($"Equivalent rebar diameter ds,eq = 2 * Sqrt( PI / As,eq) = 2 * Sqrt( PI / {averageArea}) = {diameter}(m)");
+ return diameter;
+ }
+ private void Check()
+ {
+ if (!Rebars.Any())
+ {
+ string errorString = ErrorStrings.DataIsInCorrect + $": rebars count must be greater then zero";
+ TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
+ throw new StructureHelperException(errorString);
+ }
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/Factories/CrackWidthLogicInputDataFactory.cs b/StructureHelperLogics/NdmCalculations/Cracking/Factories/CrackWidthLogicInputDataFactory.cs
index a3d8b7a..08bed13 100644
--- a/StructureHelperLogics/NdmCalculations/Cracking/Factories/CrackWidthLogicInputDataFactory.cs
+++ b/StructureHelperLogics/NdmCalculations/Cracking/Factories/CrackWidthLogicInputDataFactory.cs
@@ -1,53 +1,67 @@
-using LoaderCalculator.Logics;
+using LoaderCalculator.Data.Ndms;
+using LoaderCalculator.Logics;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models;
+using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Services.Forces;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperCommon.Models.Loggers;
+using LoaderCalculator.Data.Materials;
+using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
- internal enum CrackWidthLogicType
+ internal class CrackWidthLogicInputDataFactory : ILogic
{
- SP63
- }
- internal static class CrackWidthLogicInputDataFactory
- {
- static IStressLogic stressLogic => new StressLogic();
- public static ICrackWidthLogicInputData GetCrackWidthLogicInputData(CrackWidthLogicType logicType, ICrackWidthSimpleCalculatorInputData inputData)
+ private const double longTermFactor = 1.4d;
+ private const double shortTermFactor = 1d;
+ private IStressStateFactorLogic stressStateFactorLogic;
+ private ICrackSofteningLogic softeningLogic;
+
+ public double RebarStrain { get; set; }
+ public double ConcreteStrain { get; set;}
+
+ public CalcTerms CalcTerm { get; set; }
+ public RebarCrackInputData InputData { get; set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+
+ public CrackWidthLogicInputDataFactory(ICrackSofteningLogic softeningLogic)
{
- if (logicType == CrackWidthLogicType.SP63)
+ this.softeningLogic = softeningLogic;
+ }
+
+ public ICrackWidthLogicInputData GetCrackWidthLogicInputData()
+ {
+ stressStateFactorLogic = new StressStateFactorLogic()
{
- CrackWidthLogicInputDataSP63 data = new();
- ProcessBaseProps(inputData, data);
- if (inputData.CalcTerm == CalcTerms.LongTerm) { data.TermFactor = 1.4d; }
- else { data.TermFactor = 1d; }
- data.PsiSFactor = inputData.PsiSFactor;
- data.StressStateFactor = inputData.StressState is SectionStressStates.Tension ? 1.2d : 1.0d;
- data.BondFactor = 0.5;
- return data;
+ ForceTuple = InputData.ForceTuple,
+ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
+ };
+ CrackWidthLogicInputDataSP63 data = new();
+ if (CalcTerm == CalcTerms.LongTerm)
+ {
+ data.TermFactor = longTermFactor;
}
else
{
- throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
+ data.TermFactor = shortTermFactor;
}
-
- }
-
- private static void ProcessBaseProps(ICrackWidthSimpleCalculatorInputData inputData, ICrackWidthLogicInputData data)
- {
- var strainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(inputData.StrainTuple);
- var triangulationOptions = new TriangulationOptions { LimiteState = inputData.LimitState, CalcTerm = inputData.CalcTerm };
- var ndms = inputData.RebarPrimitive.GetNdms(triangulationOptions).ToArray();
- var concreteNdm = ndms[0];
- var rebarNdm = ndms[1];
- data.ConcreteStrain = concreteNdm.Prestrain;// stressLogic.GetTotalStrain(strainMatrix, concreteNdm) - stressLogic.GetTotalStrainWithPresrain(strainMatrix, concreteNdm);
- data.RebarStrain = stressLogic.GetTotalStrainWithPresrain(strainMatrix, rebarNdm);
- data.Length = inputData.Length;
+ data.PsiSFactor = softeningLogic.GetSofteningFactor();
+ data.StressStateFactor = stressStateFactorLogic.GetStressStateFactor();
+ data.BondFactor = 0.5d;
+ data.Length = InputData.Length;
+ data.ConcreteStrain = ConcreteStrain;
+ data.RebarStrain = RebarStrain;
+ return data;
}
}
}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/GetTupleInputDatasLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/GetTupleInputDatasLogic.cs
new file mode 100644
index 0000000..82c15a2
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/GetTupleInputDatasLogic.cs
@@ -0,0 +1,105 @@
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models.Calculators;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperCommon.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using StructureHelperCommon.Models.Loggers;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using StructureHelperCommon.Infrastructures.Interfaces;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public class GetTupleInputDatasLogic : IGetTupleInputDatasLogic
+ {
+ public List ForceActions { get; set; }
+ public List Primitives { get; set; }
+ public IShiftTraceLogger? TraceLogger { get; set; }
+ public LimitStates LimitState { get; set; }
+ public CalcTerms LongTerm { get; set; }
+ public CalcTerms ShortTerm { get; set; }
+ public UserCrackInputData UserCrackInputData { get; set; }
+
+ public GetTupleInputDatasLogic(List primitives, List forceActions, UserCrackInputData userCrackInputData)
+ {
+ Primitives = primitives;
+ ForceActions = forceActions;
+ UserCrackInputData = userCrackInputData;
+ }
+
+ public List GetTupleInputDatas()
+ {
+ TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
+
+ List resultList = new();
+ CheckInputData();
+ foreach (var action in ForceActions)
+ {
+ var tuple = GetTuplesByActions(action);
+ if (tuple.isValid == false)
+ {
+ resultList.Add(new TupleCrackInputData()
+ {
+ IsValid = false,
+ });
+ }
+ else
+ {
+ resultList.Add(new TupleCrackInputData()
+ {
+ IsValid = true,
+ TupleName = action.Name,
+ LongTermTuple = tuple.LongTuple,
+ ShortTermTuple = tuple.ShortTuple,
+ Primitives = Primitives,
+ UserCrackInputData = UserCrackInputData
+ });
+ }
+ }
+ TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
+ return resultList;
+ }
+
+ private void CheckInputData()
+ {
+ if (ForceActions is null)
+ {
+ TraceLogger?.AddMessage("Force action list is null", TraceLogStatuses.Error);
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": {nameof(ForceActions)} is null");
+ }
+ }
+
+ private (bool isValid, IForceTuple? LongTuple, IForceTuple? ShortTuple) GetTuplesByActions(IForceAction action)
+ {
+ IForceTuple longTuple, shortTuple;
+ var combinations = action.GetCombinations().DesignForces;
+ try
+ {
+ longTuple = GetTupleByCombination(combinations, LimitState, LongTerm);
+ TraceLogger?.AddMessage("Long term force combination");
+ TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(longTuple));
+ shortTuple = GetTupleByCombination(combinations, LimitState, ShortTerm);
+ TraceLogger?.AddMessage("Short term force combination");
+ TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(shortTuple));
+ }
+ catch (Exception ex)
+ {
+ TraceLogger?.AddMessage("Force combination is not obtained: \n" + ex, TraceLogStatuses.Error);
+ return (false, null, null);
+ }
+ return (true, longTuple, shortTuple);
+ }
+
+ private static IForceTuple GetTupleByCombination(List combinations, LimitStates limitState, CalcTerms calcTerm)
+ {
+ return combinations
+ .Where(x => x.LimitState == limitState & x.CalcTerm == calcTerm)
+ .Single()
+ .ForceTuple;
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/IAverageDiameterLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/IAverageDiameterLogic.cs
index 8ff8be3..573d15e 100644
--- a/StructureHelperLogics/NdmCalculations/Cracking/IAverageDiameterLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Cracking/IAverageDiameterLogic.cs
@@ -1,4 +1,5 @@
using LoaderCalculator.Data.Ndms;
+using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -7,7 +8,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
- public interface IAverageDiameterLogic
+ public interface IAverageDiameterLogic : ILogic
{
IEnumerable Rebars { get; set; }
double GetAverageDiameter();
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthLogic.cs
index 532995f..df024c5 100644
--- a/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthLogic.cs
@@ -1,4 +1,5 @@
-using System;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,7 +10,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
///
/// Logic for calculating width of crack
///
- public interface ICrackWidthLogic
+ public interface ICrackWidthLogic : ILogic
{
ICrackWidthLogicInputData InputData { get; set; }
///
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthSimpleCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthSimpleCalculatorInputData.cs
deleted file mode 100644
index 739e4a4..0000000
--- a/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthSimpleCalculatorInputData.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using StructureHelperCommon.Infrastructures.Enums;
-using StructureHelperCommon.Models.Forces;
-using StructureHelperLogics.NdmCalculations.Primitives;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace StructureHelperLogics.NdmCalculations.Cracking
-{
- public interface ICrackWidthSimpleCalculatorInputData
- {
- LimitStates LimitState { get; set; }
- CalcTerms CalcTerm { get; set; }
- StrainTuple StrainTuple { get; set; }
- double PsiSFactor { get; set; }
- ///
- /// Length between cracks in meters
- ///
- double Length { get; set; }
- SectionStressStates StressState { get; set; }
- RebarPrimitive RebarPrimitive { get; set; }
- }
-}
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthTupleResult.cs b/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthTupleResult.cs
new file mode 100644
index 0000000..19cdf81
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/ICrackWidthTupleResult.cs
@@ -0,0 +1,12 @@
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ public interface ICrackWidthTupleResult
+ {
+ ///
+ /// Calculated crack width
+ ///
+ double CrackWidth { get; set; }
+ bool IsCrackLessThanUltimate { get; }
+ double UltimateCrackWidth { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ICrackedSectionTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/ICrackedSectionTriangulationLogic.cs
new file mode 100644
index 0000000..6511dc3
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Cracking/ICrackedSectionTriangulationLogic.cs
@@ -0,0 +1,42 @@
+using LoaderCalculator.Data.Ndms;
+using StructureHelperCommon.Infrastructures.Interfaces;
+using StructureHelperLogics.NdmCalculations.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Cracking
+{
+ ///
+ /// Logic for obtaining of collection of nms elementary part for regular and fully cracked section
+ ///
+ public interface ICrackedSectionTriangulationLogic : ILogic
+ {
+ ///
+ /// Source collection of ndm primitives
+ ///
+ IEnumerable NdmPrimitives { get; }
+ ///
+ /// Returns collection of ndm elementary parts
+ ///
+ ///
+ List GetNdmCollection();
+ ///
+ /// Returns collection of ndm elementary parts where concrete doesn't work in tension
+ ///
+ ///
+ List GetCrackedNdmCollection();
+ ///
+ /// Returns collection of ndm elementary parts where all material are elastic ones
+ ///
+ ///
+ List GetElasticNdmCollection();
+ ///