// Copyright (C) Stichting Deltares 2020. 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.Collections.Generic; namespace Deltares.LayerOnSlopeTool.Io { /// Class for transferring Xml data to Io data public static class FillIoDamMStabDocFromXml { /// Fills the io dam m stab document. /// The XML dam m stab dam document. /// public static IoMStabDamDoc FillIoDamMStabDoc(tnsPrefixDamMStabDoc xmlMStabDamDoc) { var ioMStabDamDoc = new IoMStabDamDoc(); TransferGeometryCreationOptions(xmlMStabDamDoc.tnsPrefixDamMStabInput.tnsbPrefixGeometryCreationOptions, ioMStabDamDoc.MStabInput.GeometryCreationOptions); TransferModel(xmlMStabDamDoc.tnsPrefixDamMStabInput.tnsbPrefixModel, ioMStabDamDoc.MStabInput.Model); TransferSurfaceLine(xmlMStabDamDoc.tnsPrefixDamMStabInput.tnsbPrefixSurfaceLine, ioMStabDamDoc.MStabInput.SurfaceLine); TransferCharacteristicPoints(xmlMStabDamDoc.tnsPrefixDamMStabInput.tnsbPrefixCharacteristicPoints, ioMStabDamDoc.MStabInput.CharacteristicPoints); TransferPlLines(xmlMStabDamDoc.tnsPrefixDamMStabInput.tnsbPrefixExternalPLLines, ioMStabDamDoc.MStabInput.ExternalPlLines); return ioMStabDamDoc; } private static void TransferPlLines(tnsbPrefixExternalPLLinesTnsbPrefixPLLine[] xmlPlLines, List ioPlLines) { for (int plLineIndex = 0; plLineIndex < xmlPlLines.Length; plLineIndex++) { var xmlPlLine = xmlPlLines[plLineIndex]; ioPlLines.Add(new IoPlLine() { IsPhreatic = xmlPlLine.IsPhreatic, BoundaryLayer = xmlPlLine.BoundaryLayer }); if (xmlPlLine.tnsbPrefixPLPoint != null) { for (int pointIndex = 0; pointIndex < xmlPlLine.tnsbPrefixPLPoint.Length; pointIndex++) { ioPlLines[plLineIndex].Points.Add(new IoGeometryPoint() { X = xmlPlLine.tnsbPrefixPLPoint[pointIndex].XCoord, Y = xmlPlLine.tnsbPrefixPLPoint[pointIndex].YCoord }); } } } } private static void TransferCharacteristicPoints(tnsbPrefixCharacteristicPointsTnsbPrefixCharacteristicPoint[] xmlCharacteristicPoints, List ioCharacteristicPoints) { for (int i = 0; i < xmlCharacteristicPoints.Length; i++) { ioCharacteristicPoints.Add(new IoCharacteristicPoint() { X = xmlCharacteristicPoints[i].XCoord, Y = xmlCharacteristicPoints[i].YCoord, CharacteristicPointType = xmlCharacteristicPoints[i].CharacteristicPointType }); } } private static void TransferSurfaceLine(tnsbPrefixSurfaceLineTnsbPrefixSurfacePoint[] xmlSurfaceLine, List ioSurfaceLine) { for (int i = 0; i < xmlSurfaceLine.Length; i++) { ioSurfaceLine.Add(new IoGeometryPoint() { X = xmlSurfaceLine[i].XCoord, Y = xmlSurfaceLine[i].YCoord }); } } private static void TransferModel(tnsbPrefixModel xmlModel, IoModel ioModel) { ioModel.CalculationModel = xmlModel.CalculationModel; ioModel.GridPosition = xmlModel.GridPosition; ioModel.Probabilistic = xmlModel.Probabilistic; ioModel.SearchMethod = xmlModel.SearchMethod; ioModel.ShearStrength = xmlModel.ShearStrength; } private static void TransferGeometryCreationOptions(tnsbPrefixGeometryCreationOptions xmlGeometryCreationOptions, IoGeometryCreationOptions geometryCreationOptions) { geometryCreationOptions.MaterialForDike = xmlGeometryCreationOptions.MaterialForDike; geometryCreationOptions.SoilGeometry2DFilename = xmlGeometryCreationOptions.SoilGeometry2DFilename; geometryCreationOptions.SoilGeometryType = xmlGeometryCreationOptions.SoilGeometryType; geometryCreationOptions.XOffsetSoilGeometry2DOrigin = xmlGeometryCreationOptions.XOffsetSoilGeometry2DOrigin; } } }