// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU 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 General Public License for more details. // // You should have received a copy of the GNU 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; using Deltares.DamEngine.Io.XmlOutput; using Deltares.Geometry; using Deltares.Geotechnics.GeotechnicalGeometry; using Deltares.Geotechnics.SurfaceLines; using Deltares.Standard.EventPublisher; using SurfaceLine = Deltares.DamEngine.Io.XmlOutput.SurfaceLine; namespace Deltares.Dam.Data.DamEngineIo { /// /// Class to support the conversion of XmlOutput (as provided by the Engine) to DamUI objects. /// public class FillDamUiFromXmlOutput { /// /// Adds the output to dam project data. /// Precondition is that dam project data is filled and contains all relevant data that is referred to in the Output. /// /// The dam project data. /// The output. /// public static DamProjectData AddOutputToDamProjectData(DamProjectData damProjectData, Output output) { if (output != null && output.Results != null && output.Results.CalculationResults != null && output.Results.CalculationResults.DesignResults != null) { DataEventPublisher.InvokeWithoutPublishingEvents(() => { CreateDesignResultsOutput(output, damProjectData); } ); } return damProjectData; } private static void CreateDesignResultsOutput(Output output, DamProjectData damProjectData) { if (damProjectData.WaterBoard.Dikes[0] != null) { // Design results damProjectData.DesignCalculations = new List(); for (int i = 0; i < output.Results.CalculationResults.DesignResults.Length; i++) { var designResult = output.Results.CalculationResults.DesignResults[i]; var desResult = new CsvExportData(designResult.LocationName, designResult.ScenarioName) { DamFailureMechanismeCalculation = damProjectData.DamProjectCalculationSpecification.CurrentSpecification, // hoort uit echo invoer te komen, niet uit invoer zelf SelectedStabilityKernelType = StabilityKernelType.DamClassic, // de enige die we nu doen AnalysisType = DamProjectCalculationSpecification.SelectedAnalysisType, //is nu vanuit invoer, niet echo invoer tenzij damproject de echo is! ProbabilisticType = ProbabilisticType.Deterministic, // is dit de enige voor nu ? Dike = damProjectData.WaterBoard.Dikes[0], // is de enige voor nu CalculationResult = ConversionHelper.ConvertToCalculationResult(designResult.CalculationResult), BaseFileName = designResult.BaseFileName, ProfileName = designResult.ProfileName }; desResult.CalculationResult = ConversionHelper.ConvertToCalculationResult(designResult.CalculationResult); desResult.Scenario = GetScenarioByName(damProjectData, designResult.LocationName, designResult.ScenarioName); if (designResult.PipingDesignResults != null) { CreateDesignResultsPipingOutput(designResult, desResult); } if (designResult.StabilityDesignResults != null) { desResult.NumberOfIterations = designResult.StabilityDesignResults.NumberOfIterations; //Vullen daar waar beschikbaar CreateDesignResultsStbilityOutput } desResult.Scenario.CalculationResult = desResult.CalculationResult; desResult.Scenario.CalculationResults.Add(desResult); damProjectData.DesignCalculations.Add(desResult); } } } private static void CreateDesignResultsPipingOutput(DesignResult designResult, CsvExportData desResult) { desResult.ResultMessage = designResult.PipingDesignResults.ResultMessage; if (designResult.PipingDesignResults.RedesignedSurfaceLine != null) { desResult.RedesignedSurfaceLine2Piping = new SurfaceLine2(); var surfaceLine = ConvertXmlSurfaceLineToSurfaceLine2(designResult.PipingDesignResults.RedesignedSurfaceLine); desResult.RedesignedSurfaceLine2Piping = surfaceLine; } if (designResult.PipingDesignResults.UpliftFactorSpecified) desResult.UpliftFactor = designResult.PipingDesignResults.UpliftFactor; if (designResult.PipingDesignResults.HeaveFactorSpecified) desResult.HeaveFactor = designResult.PipingDesignResults.HeaveFactor; if (designResult.PipingDesignResults.BlighFactorSpecified) desResult.BlighPipingFactor = designResult.PipingDesignResults.BlighFactor; if (designResult.PipingDesignResults.BlighHcriticalSpecified) desResult.BlighHCritical = designResult.PipingDesignResults.BlighHcritical; if (designResult.PipingDesignResults.Sellmeijer4ForcesFactorSpecified) desResult.Sellmeijer4ForcesPipingFactor = designResult.PipingDesignResults.Sellmeijer4ForcesFactor; if (designResult.PipingDesignResults.Sellmeijer4ForcesHcriticalSpecified) desResult.Sellmeijer4ForcesHCritical = designResult.PipingDesignResults.Sellmeijer4ForcesHcritical; if (designResult.PipingDesignResults.SellmeijerVnkFactorSpecified) desResult.SellmeijerPipingFactor= designResult.PipingDesignResults.SellmeijerVnkFactor; if (designResult.PipingDesignResults.SellmeijerVnkHcriticalSpecified) desResult.SellmeijerHCritical = designResult.PipingDesignResults.SellmeijerVnkHcritical; if (designResult.PipingDesignResults.Wbi2017FactorSpecified) desResult.Wti2017PipingFactor = designResult.PipingDesignResults.Wbi2017Factor; if (designResult.PipingDesignResults.Wbi2017HcriticalSpecified) desResult.Wti2017HCritical = designResult.PipingDesignResults.Wbi2017Hcritical; if (designResult.PipingDesignResults.ExitPointXSpecified) desResult.LocalPipingExitPointX = designResult.PipingDesignResults.ExitPointX; if (designResult.PipingDesignResults.UpliftSituation != null) { var uplift = designResult.PipingDesignResults.UpliftSituation; desResult.IsUplift = uplift.IsUplift; desResult.Pl3MinUplift = uplift.Pl3MinUplift; desResult.Pl3HeadAdjusted = uplift.Pl3HeadAdjusted; desResult.Pl3LocalLocationXMinUplift = uplift.Pl3LocationXMinUplift; desResult.Pl4MinUplift = uplift.Pl4MinUplift; desResult.Pl4HeadAdjusted = uplift.Pl4HeadAdjusted; desResult.Pl4LocalLocationXMinUplift = uplift.Pl4LocationXMinUplift; } } private static Scenario GetScenarioByName(DamProjectData damProjectData, string locationName, string scenarioName) { var locations = damProjectData.Locations; foreach (var location in locations) { if (location.Name == locationName) { foreach (var scenario in location.Scenarios) { if (scenario.LocationScenarioID == scenarioName) { return scenario; } } } } return null; } private static SurfaceLine2 ConvertXmlSurfaceLineToSurfaceLine2(SurfaceLine inputSurfaceLine) { var surfaceLine = new SurfaceLine2 { Name = inputSurfaceLine.Name }; surfaceLine.CharacteristicPoints.Geometry = surfaceLine.Geometry; AddPointsToSurfaceLine(inputSurfaceLine, surfaceLine); return surfaceLine; } private static void AddPointsToSurfaceLine(SurfaceLine inputSurfaceLine, SurfaceLine2 surfaceLine) { surfaceLine.Geometry = new LocalizedGeometryPointString(); for (int j = 0; j < inputSurfaceLine.Points.Length; j++) { var inputPoint = inputSurfaceLine.Points[j]; var geometryPoint = new GeometryPoint() { X = inputPoint.X, Y = 0.0, Z = inputPoint.Z }; surfaceLine.AddCharacteristicPoint(geometryPoint, ConversionHelper.ConvertToDamPointType(inputPoint.PointType)); } } } }