// Copyright (C) Stichting Deltares 2024. 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 System.Linq; using Components.Persistence.Stability.Version2.Data; using Deltares.Dam.StixFileReader.Tests.TestUtils; using Deltares.Geometry; using Deltares.Geotechnics.Soils; using NUnit.Framework; namespace Deltares.Dam.StixFileReader.Tests; [TestFixture] public class SoilProfile2DDataModelTest { [Test] public void WhenDataModelWithMultipleScenarioAndStagesIsCreated_ThenGeometryFromLastScenarioAndStageIsRetrieved() { PersistableDataModel dataModel = PersistableDataModelFactory.CreateSimpleDataModelWithMultipleScenarioAndStages(); SoilProfile2D soilProfile2D = new SoilProfile2DDataModel().Create(dataModel); Assert.That(soilProfile2D.Geometry.MinGeometryPointsX, Is.EqualTo(-500)); Assert.That(soilProfile2D.Geometry.MaxGeometryPointsX, Is.EqualTo(500)); Assert.That(soilProfile2D.Geometry.MinGeometryPointsZ, Is.EqualTo(-100)); Assert.That(soilProfile2D.Geometry.MaxGeometryPointsZ, Is.EqualTo(100)); } [Test] public void WhenDataModelWithMultipleLayersIsCreated_ThenSoilProfile2DIsAsExpected() { PersistableDataModel dataModel = PersistableDataModelFactory.CreateSimpleDataModelWithMultipleLayers(); SoilProfile2D soilProfile2D = new SoilProfile2DDataModel().Create(dataModel); Assert.That(soilProfile2D.Geometry.Points, Is.EqualTo(new List { new(12, 0, -5), new(12, 0, 5), new(15, 0, 5), new(15, 0, -5), new(10, 0, -10), new(10, 0, 10), new(20, 0, 10), new(20, 0, -10), new(18, 0, 5), new(18, 0, -5) }).Using(new GeometryPointEqualityComparer())); Assert.That(soilProfile2D.Geometry.Surfaces.Count, Is.EqualTo(3)); GeometrySurface surface = soilProfile2D.Surfaces.ElementAt(0).GeometrySurface; Assert.That(surface.OuterLoop.CurveList, Is.EqualTo(new List { new(new GeometryPoint(12, 0, -5), new GeometryPoint(12, 0, 5)), new(new GeometryPoint(12, 0, 5), new GeometryPoint(15, 0, 5)), new(new GeometryPoint(15, 0, 5), new GeometryPoint(15, 0, -5)), new(new GeometryPoint(15, 0, -5), new GeometryPoint(12, 0, -5)) }).Using(new GeometryCurveEqualityComparer())); surface = soilProfile2D.Surfaces.ElementAt(1).GeometrySurface; Assert.That(surface.OuterLoop.CurveList, Is.EqualTo(new List { new(new GeometryPoint(10, 0, -10), new GeometryPoint(10, 0, 10)), new(new GeometryPoint(10, 0, 10), new GeometryPoint(20, 0, 10)), new(new GeometryPoint(20, 0, 10), new GeometryPoint(20, 0, -10)), new(new GeometryPoint(20, 0, -10), new GeometryPoint(10, 0, -10)) }).Using(new GeometryCurveEqualityComparer())); surface = soilProfile2D.Surfaces.ElementAt(2).GeometrySurface; Assert.That(surface.OuterLoop.CurveList, Is.EqualTo(new List { new(new GeometryPoint(15, 0, 5), new GeometryPoint(18, 0, 5)), new(new GeometryPoint(18, 0, 5), new GeometryPoint(18, 0, -5)), new(new GeometryPoint(18, 0, -5), new GeometryPoint(15, 0, 5)), new(new GeometryPoint(15, 0, 5), new GeometryPoint(15, 0, 5)) }).Using(new GeometryCurveEqualityComparer())); Assert.That(soilProfile2D.Geometry.SurfaceLine.Points, Is.EqualTo(new List { new(20, 0, 10), new(10, 0, 10) }).Using(new GeometryPointEqualityComparer())); Assert.That(soilProfile2D.Geometry.Curves, Is.EqualTo(new List { new(new GeometryPoint(12, 0, -5), new GeometryPoint(12, 0, 5)), new(new GeometryPoint(12, 0, 5), new GeometryPoint(15, 0, 5)), new(new GeometryPoint(15, 0, 5), new GeometryPoint(15, 0, -5)), new(new GeometryPoint(15, 0, -5), new GeometryPoint(12, 0, -5)), new(new GeometryPoint(10, 0, -10), new GeometryPoint(10, 0, 10)), new(new GeometryPoint(10, 0, 10), new GeometryPoint(20, 0, 10)), new(new GeometryPoint(20, 0, 10), new GeometryPoint(20, 0, -10)), new(new GeometryPoint(20, 0, -10), new GeometryPoint(10, 0, -10)), new(new GeometryPoint(15, 0, 5), new GeometryPoint(18, 0, 5)), new(new GeometryPoint(18, 0, 5), new GeometryPoint(18, 0, -5)), new(new GeometryPoint(18, 0, -5), new GeometryPoint(15, 0, 5)), new(new GeometryPoint(15, 0, 5), new GeometryPoint(15, 0, 5)) }).Using(new GeometryCurveEqualityComparer())); } }