// Copyright (C) Stichting Deltares 2024. 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.Linq; using Deltares.DamEngine.Data.Geometry; namespace Deltares.DamEngine.Data.GeometryExport; /// /// Helper class for exporting geometry /// public static class GeometryExporterHelper { /// /// Create a persistable geometry object from a GeometryData object /// /// /// public static PersistableGeometry CreateFromGeometryData(GeometryData geometry) { var persistableGeometry = new PersistableGeometry { Surfaces = [] }; foreach (GeometrySurface surface in geometry.Surfaces) { persistableGeometry.Surfaces.Add(new PersistableSurface { OuterLoop = new PersistableOuterLoop { Curves = surface.OuterLoop.CurveList.Select(curve => new PersistableCurve { HeadPoint = new PersistablePoint { X = curve.HeadPoint.X, Z = curve.HeadPoint.Z }, EndPoint = new PersistablePoint { X = curve.EndPoint.X, Z = curve.EndPoint.Z } }).ToList() } }); } return persistableGeometry; } /// /// Create a persistable geometry object from a GeometryData object /// /// /// public static PersistableSurfaceLine CreateFromGeometryPointString(GeometryPointString surfaceLine) { if (surfaceLine == null) { return null; } return new PersistableSurfaceLine { Points = surfaceLine.Points.Select(point => new PersistablePoint() { X = point.X, Z = point.Z }).ToList() }; } }