//-----------------------------------------------------------------------
//
// Copyright (c) 2009 Deltares. All rights reserved.
//
// B.S.T.I.M. The
// tom.the@deltares.nl
// 18-05-2009
// Contains PL-Line class
//-----------------------------------------------------------------------
using System.Linq;
using System.Xml.Serialization;
using Deltares.Geometry;
namespace Deltares.Dam.Data
{
using System.Collections.Generic;
using System;
using Deltares.Standard;
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; }
public PLLine Clone()
{
PLLine plLine = new PLLine() { IsPhreatic = this.IsPhreatic, BoundaryLayer = this.BoundaryLayer };
foreach (PLLinePoint point in this.Points)
{
PLLinePoint newPoint = new PLLinePoint() { X = point.X, Y = point.Y, Z = point.Z };
plLine.Points.Add(newPoint);
}
return plLine;
}
///
/// 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 this.PointsOrderdByX
where point != null && (point.X > startX && point.X < endX)
orderby point.X ascending
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;
}
else
{
if (point.Z > z)
{
return PLLinePointPositionXzType.AbovePLLine;
}
else
{
return PLLinePointPositionXzType.BelowPLLine;
}
}
}
private IEnumerable PointsOrderdByX
{
get { return this.Points.OrderBy(p => p.X); }
}
}
}