// 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 Io data to Xml data
public static class FillXmlDamMStabDocFromIo
{
/// Fills the XML dam m stab document.
/// The io dam m stab dam document.
///
public static tnsPrefixDamMStabDoc FillXmlDamMStabDoc(IoMStabDamDoc ioDamMStabDamDoc)
{
var xmlDamMStabDoc = new tnsPrefixDamMStabDoc();
xmlDamMStabDoc.tnsPrefixDamMStabInput = new tnsPrefixDamMStabDocTnsPrefixDamMStabInput();
xmlDamMStabDoc.tnsPrefixDamMStabInput.tnsbPrefixGeometryCreationOptions = new tnsbPrefixGeometryCreationOptions();
TransferGeometryCreationOptions(ioDamMStabDamDoc.MStabInput.GeometryCreationOptions, xmlDamMStabDoc.tnsPrefixDamMStabInput.tnsbPrefixGeometryCreationOptions);
xmlDamMStabDoc.tnsPrefixDamMStabInput.tnsbPrefixModel = new tnsbPrefixModel();
TransferModel(ioDamMStabDamDoc.MStabInput.Model, xmlDamMStabDoc.tnsPrefixDamMStabInput.tnsbPrefixModel);
xmlDamMStabDoc.tnsPrefixDamMStabInput.tnsbPrefixSurfaceLine = new tnsbPrefixSurfaceLineTnsbPrefixSurfacePoint[ioDamMStabDamDoc.MStabInput.SurfaceLine.Count];
TransferSurfaceline(ioDamMStabDamDoc.MStabInput.SurfaceLine, xmlDamMStabDoc.tnsPrefixDamMStabInput.tnsbPrefixSurfaceLine);
xmlDamMStabDoc.tnsPrefixDamMStabInput.tnsbPrefixCharacteristicPoints =
new tnsbPrefixCharacteristicPointsTnsbPrefixCharacteristicPoint[ioDamMStabDamDoc.MStabInput.CharacteristicPoints.Count];
TransferCharacteristicPoints(ioDamMStabDamDoc.MStabInput.CharacteristicPoints, xmlDamMStabDoc.tnsPrefixDamMStabInput.tnsbPrefixCharacteristicPoints);
return xmlDamMStabDoc;
}
private static void TransferCharacteristicPoints(List ioCharacteristicPoints,
tnsbPrefixCharacteristicPointsTnsbPrefixCharacteristicPoint[] xmlCharacteristicPoints)
{
for (int i = 0; i < ioCharacteristicPoints.Count; i++)
{
xmlCharacteristicPoints[i] = new tnsbPrefixCharacteristicPointsTnsbPrefixCharacteristicPoint()
{
XCoord = ioCharacteristicPoints[i].X,
YCoord = ioCharacteristicPoints[i].Y,
CharacteristicPointType = ioCharacteristicPoints[i].CharacteristicPointType
};
}
}
private static void TransferSurfaceline(List ioSurfaceLine, tnsbPrefixSurfaceLineTnsbPrefixSurfacePoint[] xmlSurfaceLine)
{
for (int i = 0; i < ioSurfaceLine.Count; i++)
{
xmlSurfaceLine[i] = new tnsbPrefixSurfaceLineTnsbPrefixSurfacePoint()
{
XCoord = ioSurfaceLine[i].X,
YCoord = ioSurfaceLine[i].Y
};
}
}
private static void TransferModel(IoModel ioModel, tnsbPrefixModel xmlModel)
{
xmlModel.CalculationModel = ioModel.CalculationModel;
xmlModel.GridPosition = ioModel.GridPosition;
xmlModel.Probabilistic = ioModel.Probabilistic;
xmlModel.SearchMethod = ioModel.SearchMethod;
xmlModel.ShearStrength = ioModel.ShearStrength;
}
private static void TransferGeometryCreationOptions(IoGeometryCreationOptions ioGeometryCreationOptions,
tnsbPrefixGeometryCreationOptions xmlGeometryCreationOptions)
{
xmlGeometryCreationOptions.MaterialForDike = ioGeometryCreationOptions.MaterialForDike;
xmlGeometryCreationOptions.SoilGeometry2DFilename = ioGeometryCreationOptions.SoilGeometry2DFilename;
xmlGeometryCreationOptions.SoilGeometryType = ioGeometryCreationOptions.SoilGeometryType;
xmlGeometryCreationOptions.XOffsetSoilGeometry2DOrigin = ioGeometryCreationOptions.XOffsetSoilGeometry2DOrigin;
}
}
}