//----------------------------------------------------------------------- // // Copyright (c) 2011 Deltares. All rights reserved. // // B.S.T.I.M. The // tom.the@deltares.nl // 13-05-2011 // Data object to hold 2D geometry as is used by the old D-Serie programs (like MStab) //----------------------------------------------------------------------- using System.Collections.Generic; using Deltares.Standard.Extensions; namespace Deltares.Dam.Data { using System; using Standard; public struct Geometry2DLayer { public Geometry2DBoundaryLine boundaryLine; public String soilName; public LayerType layerType; } public class Geometry2DDataException : ApplicationException { public Geometry2DDataException(string message): base(message) { } } public class Geometry2DData { private List layers = new List(); private double tolerance = 0.0000000001; public Geometry2DData() { } public int LayerCount { get { return layers.Count; } } public double Tolerance { get { return tolerance; } set { tolerance = value; } } public void AddLayer(Geometry2DLayer layer) { layers.Add(layer); } public Geometry2DLayer GetLayer(int index) { return layers[index]; } public void SetLayertype(int layerIndex, LayerType layerType) { Geometry2DLayer layer = layers[layerIndex]; layer.layerType = layerType; layers[layerIndex] = layer; } public void Validate() { if (layers.Count > 1) { double limitLeft = layers[0].boundaryLine.Points[0].X; double limitRight = layers[0].boundaryLine.Points[layers[0].boundaryLine.Points.Count - 1].X; foreach (Geometry2DLayer layer in layers) { if (!layer.boundaryLine.Points[0].X.AlmostEquals(limitLeft, tolerance) || !layer.boundaryLine.Points[layer.boundaryLine.Points.Count - 1].X.AlmostEquals(limitRight, tolerance)) { throw new Geometry2DDataException("Boundary lines are not aligned"); } } } } } }