// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the DAM Engine. // // The DAM Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero 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 Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Standard; namespace Deltares.DamEngine.Calculators.General { 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"); } } } } } }