// Copyright (C) Stichting Deltares 2016. 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 System.Collections.Generic; using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Ringtoets.GrassCoverErosionInwards.Data.Properties; namespace Ringtoets.GrassCoverErosionInwards.Data { /// /// Definition for a dike profile for the Grass Cover Erosion Inwards failure mechanism. /// public class DikeProfile { private RoundedDouble orientation; private RoundedDouble dikeHeight; /// /// Creates a new instance of the class. /// /// worldCoordinate">The value for . /// The geometry of the dike. /// The geometry of the dike foreshore. /// Thrown when /// or is null. /// Thrown when any element of /// or is null. public DikeProfile(Point2D worldCoordinate, RoughnessPoint[] dikeGeometry, Point2D[] foreshoreGeometry) { if (worldCoordinate == null) { throw new ArgumentNullException("worldCoordinate"); } SetGeometry(dikeGeometry); SetForeshoreGeometry(foreshoreGeometry); orientation = new RoundedDouble(2); dikeHeight = new RoundedDouble(2); Name = Resources.DikeProfile_DefaultName; Memo = ""; WorldReferencePoint = worldCoordinate; } /// /// Gets or sets the name of the dike profile. /// public string Name { get; set; } /// /// Gets or sets the optional notes about this instance. /// public string Memo { get; set; } /// /// Gets the reference point in world coordinates corresponding to the local coordinate . /// public Point2D WorldReferencePoint { get; private set; } /// /// Gets or sets the local x-coordinate corresponding to the world reference point . /// public double X0 { get; set; } /// /// Gets or sets the orientation of the dike profile geometry with respect to North /// in degrees. A positive value equals a clockwise rotation. /// public RoundedDouble Orientation { get { return orientation; } set { orientation = value.ToPrecision(orientation.NumberOfDecimalPlaces); } } /// /// Indicates if there is a break water object available for this instance or not. /// public bool HasBreakWater { get { return BreakWater != null; } } /// /// Gets or sets the break water object of the dike profile, if any. /// public BreakWater BreakWater { get; set; } /// /// Gets the geometry of the foreshore. /// public Point2D[] ForeshoreGeometry { get; private set; } /// /// Gets the geometry of the dike with roughness data. /// /// /// The roughness of a in the list represents /// the roughness of the section between this /// and the succeeding . The roughness of the last /// point is irrelevant. /// public RoughnessPoint[] DikeGeometry { get; private set; } /// /// Gets or sets the height of the dike [m+NAP]. /// public RoundedDouble DikeHeight { get { return dikeHeight; } set { dikeHeight = value.ToPrecision(dikeHeight.NumberOfDecimalPlaces); } } public override string ToString() { return Name; } private void SetGeometry(IEnumerable points) { if (points == null) { throw new ArgumentNullException("points", Resources.DikeProfile_SetGeometry_Collection_of_points_for_geometry_is_null); } if (points.Any(p => p == null)) { throw new ArgumentException(Resources.DikeProfile_SetGeometry_A_point_in_the_collection_is_null); } DikeGeometry = points.ToArray(); } private void SetForeshoreGeometry(IEnumerable points) { if (points == null) { throw new ArgumentNullException("points", Resources.DikeProfile_SetForeshoreGeometry_Collection_of_points_for_foreshore_geometry_is_null); } if (points.Any(p => p == null)) { throw new ArgumentException(Resources.DikeProfile_SetForeshoreGeometry_A_point_in_the_collection_is_null); } ForeshoreGeometry = points.ToArray(); } } }