// Copyright (C) Stichting Deltares 2025. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI 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 System.Xml.Serialization; using Deltares.Geometry; using Deltares.Standard; namespace Deltares.Dam.Data; public class PLLinePoint : GeometryPoint { public PLLinePoint() : this(0, 0) {} public PLLinePoint(double aX, double aZ) : base(aX, 0, aZ) {} } public class PLLine : PolyLine, ICloneable { private PLLineType plLineType; [XmlIgnore] public PLLineType PLLineType { get { return plLineType; } set { plLineType = value; PLLineTypeSpecified = true; } } [XmlIgnore] public bool PLLineTypeSpecified { get; private set; } public bool IsPhreatic { get; set; } public int BoundaryLayer { get; set; } /// /// Gets the points in the segment between starting x and ending x /// /// /// /// /// /// public IEnumerable GetPointSegmentBetween(double startX, double endX) { if (endX < startX) { throw new ArgumentException("End value is smaller then the start value"); } return from point in PointsOrderdByX where point != null && (point.X > startX && point.X < endX) orderby point.X select point; } /// /// Determines whether the given point is above, beneath or on the surfaceline. /// /// /// public PLLinePointPositionXzType PositionXzOfPointRelatedToPLLine(GeometryPoint point) { // if point is out of scope of the surface line, return beyond if ((point.X < points[0].X) || (point.X > points[points.Count - 1].X)) { return PLLinePointPositionXzType.BeyondPLLine; } double z = ZFromX(point.X); if (Math.Abs(point.Z - z) < GeometryPoint.Precision) { return PLLinePointPositionXzType.OnPLLine; } if (point.Z > z) { return PLLinePointPositionXzType.AbovePLLine; } return PLLinePointPositionXzType.BelowPLLine; } public PLLine Clone() { var plLine = new PLLine { IsPhreatic = IsPhreatic, BoundaryLayer = BoundaryLayer }; foreach (PLLinePoint point in Points) { var newPoint = new PLLinePoint { X = point.X, Y = point.Y, Z = point.Z }; plLine.Points.Add(newPoint); } return plLine; } private IEnumerable PointsOrderdByX { get { return Points.OrderBy(p => p.X); } } }