From a46b1e29dcef9f76dc907874bdffb8b16654352f Mon Sep 17 00:00:00 2001 From: lorinczandrea Date: Mon, 26 Aug 2024 10:57:20 +0200 Subject: [PATCH] :bug: add missing range check for punching parameters #1077 --- .../GenericClasses/RestrictedDouble.cs | 16 +++++++++++ .../Reinforcement/PunchingReinforcement.cs | 27 ++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/FemDesign.Core/GenericClasses/RestrictedDouble.cs b/FemDesign.Core/GenericClasses/RestrictedDouble.cs index 1c48128c8..d2ddfecb7 100644 --- a/FemDesign.Core/GenericClasses/RestrictedDouble.cs +++ b/FemDesign.Core/GenericClasses/RestrictedDouble.cs @@ -126,6 +126,22 @@ internal static double NonNegMax_10(double val) { return RestrictedDouble.ValueInClosedInterval(val, 0, 10); } + + /// + /// non_zero_max_10_1 + /// + internal static double NonZeroMax_10_1(double val) + { + return RestrictedDouble.ValueInClosedInterval(val, 0.02, 10); + } + + /// + /// non_zero_max_10_1 + /// + internal static double NonZeroMax_10_2(double val) + { + return RestrictedDouble.ValueInClosedInterval(val, 0.03, 10); + } /// /// non_neg_max_10 diff --git a/FemDesign.Core/Reinforcement/PunchingReinforcement.cs b/FemDesign.Core/Reinforcement/PunchingReinforcement.cs index 155b4eadb..85724fcbf 100644 --- a/FemDesign.Core/Reinforcement/PunchingReinforcement.cs +++ b/FemDesign.Core/Reinforcement/PunchingReinforcement.cs @@ -133,13 +133,34 @@ public partial class StudRails public string Patter { get; set; } [XmlAttribute("s0")] - public double S0 { get; set; } + public double _s0 { get; set; } + + [XmlIgnore] + public double S0 + { + get => _s0; + set => _s0 = RestrictedDouble.NonZeroMax_10_1(value); + } [XmlAttribute("s1")] - public double S1 { get; set; } + public double _s1 { get; set; } + + [XmlIgnore] + public double S1 + { + get => _s1; + set => _s1 = RestrictedDouble.NonZeroMax_10_2(value); + } [XmlAttribute("s2")] - public double S2 { get; set; } + public double _s2 { get; set; } + + [XmlIgnore] + public double S2 + { + get => _s2; + set => _s2 = RestrictedDouble.NonZeroMax_10_2(value); + } [XmlAttribute("rails_on_circle")] public string _railsOnCircle;