Index: DamEngine/trunk/src/Deltares.DamEngine.Data/General/Segment.cs =================================================================== diff -u -r4000 -r4052 --- DamEngine/trunk/src/Deltares.DamEngine.Data/General/Segment.cs (.../Segment.cs) (revision 4000) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/General/Segment.cs (.../Segment.cs) (revision 4052) @@ -25,115 +25,114 @@ using System.Text; using Deltares.DamEngine.Data.Geotechnics; -namespace Deltares.DamEngine.Data.General +namespace Deltares.DamEngine.Data.General; + +/// +/// Class holding all soilprofiles (1D/2D) and their probabilities as segment. +/// +public class Segment { + private readonly List soilGeometryProbabilities = new List(); + /// - /// Class holding all soilprofiles (1D/2D) and their probabilities as segment. + /// Gets or sets the name. /// - public class Segment - { - private readonly List soilGeometryProbabilities = new List(); + /// + /// The name. + /// + public virtual string Name { get; set; } - /// - /// Gets or sets the name. - /// - /// - /// The name. - /// - public virtual string Name { get; set; } - - /// - /// Gets the soil probalilities for this segment - /// - public virtual List SoilProfileProbabilities + /// + /// Gets the soil probalilities for this segment + /// + public virtual List SoilProfileProbabilities + { + get { - get - { - return soilGeometryProbabilities; - } + return soilGeometryProbabilities; } + } - /// - /// Gets the most probable profile1D. - /// - /// Type of the segment failure mechanism. - /// - public SoilProfile1D GetMostProbableProfile1D(SegmentFailureMechanismType? segmentFailureMechanismType) + /// + /// Gets the most probable profile1D. + /// + /// Type of the segment failure mechanism. + /// + public SoilProfile1D GetMostProbableProfile1D(SegmentFailureMechanismType? segmentFailureMechanismType) + { + SoilGeometryProbability mostProbableSoilGeometryProbability = GetMostProbableSoilGeometryProbability(segmentFailureMechanismType); + if (mostProbableSoilGeometryProbability != null && mostProbableSoilGeometryProbability.SoilProfileType == SoilProfileType.ProfileType1D) { - SoilGeometryProbability mostProbableSoilGeometryProbability = GetMostProbableSoilGeometryProbability(segmentFailureMechanismType); - if (mostProbableSoilGeometryProbability != null && mostProbableSoilGeometryProbability.SoilProfileType == SoilProfileType.ProfileType1D) - { - return mostProbableSoilGeometryProbability?.SoilProfile1D; - } - - return null; + return mostProbableSoilGeometryProbability?.SoilProfile1D; } - /// - /// Gets the name of the most probable sti filename (name of MStab .sti file). - /// - /// Type of the segment failure mechanism. - /// - public string GetMostProbableProfile2DStiFileName(SegmentFailureMechanismType? segmentFailureMechanismType) - { - SoilGeometryProbability mostProbableSoilGeometryProbability = GetMostProbableSoilGeometryProbability(segmentFailureMechanismType); - if (mostProbableSoilGeometryProbability != null && mostProbableSoilGeometryProbability.SoilProfileType == SoilProfileType.ProfileTypeStiFile) - { - return mostProbableSoilGeometryProbability?.FullStiFileName; - } + return null; + } - return null; + /// + /// Gets the name of the most probable sti filename (name of MStab .sti file). + /// + /// Type of the segment failure mechanism. + /// + public string GetMostProbableProfile2DStiFileName(SegmentFailureMechanismType? segmentFailureMechanismType) + { + SoilGeometryProbability mostProbableSoilGeometryProbability = GetMostProbableSoilGeometryProbability(segmentFailureMechanismType); + if (mostProbableSoilGeometryProbability != null && mostProbableSoilGeometryProbability.SoilProfileType == SoilProfileType.ProfileTypeStiFile) + { + return mostProbableSoilGeometryProbability?.FullStiFileName; } - /// - /// Gets the most probable soil geometry probability. - /// - /// Type of the segment failure mechanism. - /// - public SoilGeometryProbability GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType? segmentFailureMechanismType) - { - IEnumerable spps = from SoilGeometryProbability spp in soilGeometryProbabilities - where !spp.SegmentFailureMechanismType.HasValue || !segmentFailureMechanismType.HasValue || spp.SegmentFailureMechanismType == segmentFailureMechanismType - orderby spp.Probability descending - select spp; - if (spps.Any()) - { - return spps.First(); - } + return null; + } - return null; + /// + /// Gets the most probable soil geometry probability. + /// + /// Type of the segment failure mechanism. + /// + public SoilGeometryProbability GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType? segmentFailureMechanismType) + { + IEnumerable spps = from SoilGeometryProbability spp in soilGeometryProbabilities + where !spp.SegmentFailureMechanismType.HasValue || !segmentFailureMechanismType.HasValue || spp.SegmentFailureMechanismType == segmentFailureMechanismType + orderby spp.Probability descending + select spp; + if (spps.Any()) + { + return spps.First(); } - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() + return null; + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append(Name); + sb.Append(": "); + foreach (SegmentFailureMechanismType type in Enum.GetValues(typeof(SegmentFailureMechanismType))) { - var sb = new StringBuilder(); - sb.Append(Name); + sb.Append(type.ToString()); sb.Append(": "); - foreach (SegmentFailureMechanismType type in Enum.GetValues(typeof(SegmentFailureMechanismType))) + foreach (SoilGeometryProbability spp in SoilProfileProbabilities.Where(x => x.SegmentFailureMechanismType == null || x.SegmentFailureMechanismType == type)) { - sb.Append(type.ToString()); - sb.Append(": "); - foreach (SoilGeometryProbability spp in SoilProfileProbabilities.Where(x => x.SegmentFailureMechanismType == null || x.SegmentFailureMechanismType == type)) + if (spp.SoilProfile1D != null) { - if (spp.SoilProfile1D != null) - { - sb.Append(String.Format("(1D) {0} ({1}%) ", spp.SoilProfile1D.Name, spp.Probability)); - } - else - { - sb.Append(String.Format("(2D) {0} ({1}%) ", spp.StiFileName, spp.Probability)); - } - //#Bka: should be adapted for WtiStability where 2D profiles are used. + sb.Append(String.Format("(1D) {0} ({1}%) ", spp.SoilProfile1D.Name, spp.Probability)); } + else + { + sb.Append(String.Format("(2D) {0} ({1}%) ", spp.StiFileName, spp.Probability)); + } + //#Bka: should be adapted for WtiStability where 2D profiles are used. } - - return sb.ToString(); } + + return sb.ToString(); } } \ No newline at end of file