// Copyright (C) Stichting Deltares 2025. 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; using Deltares.Dam.Data; using Deltares.Dam.Data.DataPlugins.Configuration; namespace Deltares.Dam.TestHelper { public class ProjectLoader { private const string currentTestVersion = "19.1"; public static DamProjectData LoadProjectData(string dataFileOrPath) { if (dataFileOrPath.EndsWith(".damx")) { DamProject.SetTestProgramVersion(currentTestVersion); using (var damProject = new DamProject()) { return (damProject.OpenXMLProject(dataFileOrPath) as DamProjectData); } } return LoadProjectData(dataFileOrPath, CreateDefaultFailureMechanismeCalculationSpecification); } public static DamFailureMechanismeCalculationSpecification CreateDefaultFailureMechanismeCalculationSpecification( DamProjectData damProjectData) { MStabParameters mstabParameters = FactoryForStabilityTests.CreateMStabParameters(); mstabParameters.SearchMethod = StabilitySearchMethod.Grid; var damCalculationSpecification = new DamFailureMechanismeCalculationSpecification { FailureMechanismSystemType = FailureMechanismSystemType.StabilityOutside, StabilityParameters = new StabilityParameters { MStabParameters = mstabParameters } }; DamProjectCalculationSpecification.SelectedAnalysisType = AnalysisType.AdaptGeometry; return damCalculationSpecification; } private static DamProjectData LoadDike(string projectDataFolder) { var damProject = new DamProject { DamProjectData = new DamProjectData() }; var container = new DataSourceContainer { DataSourceList = { new DataSource { DataSourceType = DataSourceType.CsvFiles, DataLocation = "" } } }; damProject.Import(projectDataFolder, container, "Dike from CSV", DamProjectType.Design, null); return damProject.DamProjectData; } private static DamProjectData LoadProjectData(string projectDataFolder, Func failureMechanismCalculationSpecificationFactoryMethod) { DamProjectData damProjectData = LoadDike(projectDataFolder); // Specify calculation DamFailureMechanismeCalculationSpecification damCalculationSpecification = failureMechanismCalculationSpecificationFactoryMethod(damProjectData); damProjectData.DamProjectCalculationSpecification.DamCalculationSpecifications.Add(damCalculationSpecification); return damProjectData; } } }