using System; using System.ComponentModel; using System.Xml.Serialization; using Deltares.Geometry; using Deltares.Geotechnics; using Deltares.Geotechnics.GeotechnicalGeometry; using Deltares.Standard; using Deltares.Standard.Attributes; using Deltares.Standard.Units; namespace Deltares.DeltaModel { /// /// A is a which's Z is dependent on a /// . /// public abstract class SurfaceLineRevetmentSegment : RevetmentSegment { private IHasSurfaceLine surfaceLineProvider; protected SurfaceLineRevetmentSegment() {} /// /// Constructor. /// /// protected SurfaceLineRevetmentSegment(IHasSurfaceLine surfaceLineProvider) { SurfaceLineProvider = surfaceLineProvider; } /// /// The parent dike location. /// /// Surface line provider must be set by owner (during deserialization). [Browsable(false)] [ReadOnly(true)] public IHasSurfaceLine SurfaceLineProvider { get { return surfaceLineProvider; } set { surfaceLineProvider = value; } } /// /// The X coordinate of the start point. /// /// /// Gets the Z coordinate of the start point based on and . /// [Format("F2")] [Unit(UnitType.Length)] [PropertyOrder(1, 2)] [XmlIgnore] public double StartZ { get { return null == SurfaceLineProvider || null == SurfaceLineProvider.SurfaceLine ? Double.NaN : SurfaceLineProvider.SurfaceLine.GetZAtX(StartX); } } /// /// Gets the Z coordinate of the end point based on and . /// [Format("F2")] [Unit(UnitType.Length)] [PropertyOrder(1, 4)] [XmlIgnore] public double EndZ { get { return null == SurfaceLineProvider || null == SurfaceLineProvider.SurfaceLine ? Double.NaN : SurfaceLineProvider.SurfaceLine.GetZAtX(EndX); } } public LocalizedGeometryPointString GetSurfaceLine() { return SurfaceLineProvider != null ? SurfaceLineProvider.SurfaceLine : null; } /// /// Returns the geometry bounds. /// public override GeometryBounds GetGeometryBounds() { GeometryBounds bounds = null; if (!Double.IsNaN(StartX) && !Double.IsNaN(EndX)) { var beginPoint = new GeometryPoint(StartX, 0, StartZ); var endPoint = new GeometryPoint(EndX, 0, EndZ); bounds = beginPoint.GetGeometryBounds() + endPoint.GetGeometryBounds(); } if (Double.IsNaN(StartX) && !Double.IsNaN(EndX)) { bounds = new GeometryPoint(EndX, 0, EndZ).GetGeometryBounds(); } if (Double.IsNaN(EndX) && !Double.IsNaN(StartX)) { bounds = new GeometryPoint(StartX, 0, StartZ).GetGeometryBounds(); } return bounds; } } }