// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using Core.Common.Base.Data; using Ringtoets.MacroStabilityInwards.Data.Properties; namespace Ringtoets.MacroStabilityInwards.Data { /// /// A grid used in the macro stability calculation. /// public class MacroStabilityInwardsGrid : ICloneable { private static readonly Range numberOfPointsValidityRange = new Range(1, 100); private RoundedDouble xLeft; private RoundedDouble xRight; private RoundedDouble zTop; private RoundedDouble zBottom; private int numberOfHorizontalPoints; private int numberOfVerticalPoints; /// /// Creates a new instance of . /// /// The x left of the grid. /// The x right of the grid. /// The z top of the grid. /// The z bottom of the grid. public MacroStabilityInwardsGrid(double xLeft, double xRight, double zTop, double zBottom) { this.xLeft = new RoundedDouble(2, xLeft); this.xRight = new RoundedDouble(2, xRight); this.zTop = new RoundedDouble(2, zTop); this.zBottom = new RoundedDouble(2, zBottom); NumberOfHorizontalPoints = 5; NumberOfVerticalPoints = 5; } /// /// Gets or sets the x left of the grid. /// [m] /// public RoundedDouble XLeft { get { return xLeft; } set { xLeft = value.ToPrecision(xLeft.NumberOfDecimalPlaces); } } /// /// Gets or sets the x right of the grid. /// [m] /// public RoundedDouble XRight { get { return xRight; } set { xRight = value.ToPrecision(xRight.NumberOfDecimalPlaces); } } /// /// Gets or sets the z top of the grid. /// [m+NAP] /// public RoundedDouble ZTop { get { return zTop; } set { zTop = value.ToPrecision(zTop.NumberOfDecimalPlaces); } } /// /// Gets or sets the z bottom of the grid. /// [m+NAP] /// public RoundedDouble ZBottom { get { return zBottom; } set { zBottom = value.ToPrecision(zBottom.NumberOfDecimalPlaces); } } /// /// Gets or set the number of horizontal points. /// /// Thrown when value is not in range [1, 100]. public int NumberOfHorizontalPoints { get { return numberOfHorizontalPoints; } set { if (!numberOfPointsValidityRange.InRange(value)) { string message = string.Format(Resources.NumberOfHorizontalPoints_must_be_in_Range_0_, numberOfPointsValidityRange); throw new ArgumentOutOfRangeException(nameof(value), message); } numberOfHorizontalPoints = value; } } /// /// Gets or sets the number of vertical points. /// /// Thrown when value is not in range [1, 100]. public int NumberOfVerticalPoints { get { return numberOfVerticalPoints; } set { if (!numberOfPointsValidityRange.InRange(value)) { string message = string.Format(Resources.NumberOfVerticalPoints_must_be_in_Range_0_, numberOfPointsValidityRange); throw new ArgumentOutOfRangeException(nameof(value), message); } numberOfVerticalPoints = value; } } public object Clone() { return MemberwiseClone(); } } }