namespace Deltares.Stability.Calculation2 { /// /// Checks whether the minimum depth and legth of a sliding curve aren't violated /// public class StabilityModelSlidingCurveValidator : ISlidingCurveValidator { private StabilityModel stabilityModel = null; public StabilityModelSlidingCurveValidator(StabilityModel stabilityModel) { this.stabilityModel = stabilityModel; } public bool IsValid(SlidingCurve slidingCurve) { bool depthOk = true; if (stabilityModel.SlipPlaneConstraints.SlipPlaneMinDepth > Constants.CGeoAccu) { depthOk = false; foreach (var slice in slidingCurve.Slices) { if ((slice.ZCenterTop - slice.ZCenterBottom) > (stabilityModel.SlipPlaneConstraints.SlipPlaneMinDepth + Constants.CGeoAccu)) { depthOk = true; break; } } } if (!depthOk) { return false; } bool minLengthOk = true; if (stabilityModel.SlipPlaneConstraints.SlipPlaneMinLength > Constants.CGeoAccu) { double som = 0; foreach (var slice in slidingCurve.Slices) { som = som + slice.ArcLength; } minLengthOk = (stabilityModel.SlipPlaneConstraints.SlipPlaneMinLength < som); } if (!minLengthOk) { return false; } // TODO ROB ? // test of centre point not in geometry ZCentre > surface.getzatx(x centre point) // Test if z centre point above zentry and z exit bool minUsedOk = slidingCurve.LeftPoint.X >= stabilityModel.Geometry.Left; bool maxUsedOk = slidingCurve.LeftPoint.X <= stabilityModel.Geometry.Right; return maxUsedOk && minUsedOk; } public bool SlicesMustBeFilled() { return false; } } }