// Copyright (C) Stichting Deltares 2018. 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.Geometry; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.FailureMechanism { /// /// This class represents a sub section of a in which similar /// characteristics can be found to allow for 1 calculation to determine a result that /// applies to the whole section. /// public class FailureMechanismSection { /// /// Initializes a new instance of the class. /// /// The name of the section. /// The geometry points of the section. /// Thrown when: /// is null. /// is null. /// Thrown when: /// does not have at least one geometry point. /// One or more elements are null. /// public FailureMechanismSection(string name, IEnumerable geometryPoints) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (geometryPoints == null) { throw new ArgumentNullException(nameof(geometryPoints)); } if (!geometryPoints.Any()) { throw new ArgumentException(Resources.FailureMechanismSection_Section_must_have_at_least_1_geometry_point, nameof(geometryPoints)); } if (geometryPoints.Any(p => p == null)) { throw new ArgumentException(@"One or multiple elements are null.", nameof(geometryPoints)); } Name = name; Points = geometryPoints; StartPoint = geometryPoints.First(); EndPoint = geometryPoints.Last(); Length = Math2D.Length(geometryPoints); } /// /// Gets the name of the section. /// public string Name { get; } /// /// Gets the 2D points describing the geometry of the section. /// public IEnumerable Points { get; } /// /// Gets the start point of the section. /// public Point2D StartPoint { get; } /// /// Gets the end point of the section. /// public Point2D EndPoint { get; } /// /// Gets the length of the section. /// [m] /// public double Length { get; } } }