From df321e909de887f9ee82e5477755f0886aa0ca98 Mon Sep 17 00:00:00 2001 From: RStolkerDeltares Date: Wed, 11 Mar 2026 15:20:07 +0100 Subject: [PATCH] GRIDEDIT-2228: Extended API for retrieving facebounds --- src/MeshKernelNET/Api/PropertyType.cs | 7 +++- .../Api/MeshKernelApiTest.cs | 42 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/MeshKernelNET/Api/PropertyType.cs b/src/MeshKernelNET/Api/PropertyType.cs index 4dea3e8..da5eb48 100644 --- a/src/MeshKernelNET/Api/PropertyType.cs +++ b/src/MeshKernelNET/Api/PropertyType.cs @@ -18,6 +18,11 @@ public enum PropertyType /// /// The circumcenter of the mesh faces. /// - FaceCircumcenter = 2 + FaceCircumcenter = 2, + + /// + /// The bounding box of the mesh faces. + /// + FaceBounds = 4 } } \ No newline at end of file diff --git a/test/MeshKernelNETTest/Api/MeshKernelApiTest.cs b/test/MeshKernelNETTest/Api/MeshKernelApiTest.cs index 6586709..368db3f 100644 --- a/test/MeshKernelNETTest/Api/MeshKernelApiTest.cs +++ b/test/MeshKernelNETTest/Api/MeshKernelApiTest.cs @@ -2639,6 +2639,46 @@ public void Mesh2dGetPropertyFaceCircumcenterThroughApi() } } + [Test] + public void Mesh2dGetPropertyFaceBoundsThroughApi() + { + // Setup + using (var api = new MeshKernelApi()) + using (DisposableMesh2D mesh = CreateMesh2D(4, 4, 100, 200)) + { + var propertyValues = new DisposableGeometryList(); + try + { + // Prepare + int id = api.AllocateState(0); + Assert.That(api.Mesh2dSet(id, mesh), Is.EqualTo(0)); + + // Execute + Assert.That(api.Mesh2dGetProperty(id, PropertyType.FaceBounds, LocationType.Faces, out propertyValues), Is.EqualTo(0)); + + // Assert + Assert.That(propertyValues.NumberOfCoordinates, Is.EqualTo(54)); + Assert.That(propertyValues.XCoordinates[0], Is.EqualTo(0.0)); + Assert.That(propertyValues.YCoordinates[0], Is.EqualTo(0.0)); + Assert.That(propertyValues.XCoordinates[1], Is.EqualTo(100.0)); + Assert.That(propertyValues.YCoordinates[1], Is.EqualTo(0.0)); + Assert.That(propertyValues.XCoordinates[2], Is.EqualTo(100.0)); + Assert.That(propertyValues.YCoordinates[2], Is.EqualTo(200.0)); + Assert.That(propertyValues.XCoordinates[3], Is.EqualTo(0.0)); + Assert.That(propertyValues.YCoordinates[3], Is.EqualTo(200.0)); + Assert.That(propertyValues.XCoordinates[4], Is.EqualTo(-999.0)); + Assert.That(propertyValues.YCoordinates[4], Is.EqualTo(-999.0)); + Assert.That(propertyValues.XCoordinates[5], Is.EqualTo(-999.0)); + Assert.That(propertyValues.YCoordinates[5], Is.EqualTo(-999.0)); + } + finally + { + api.ClearState(); + propertyValues.Dispose(); + } + } + } + [Test] [TestCase(PropertyType.Orthogonality, LocationType.Faces)] [TestCase(PropertyType.Orthogonality, LocationType.Nodes)] @@ -2646,6 +2686,8 @@ public void Mesh2dGetPropertyFaceCircumcenterThroughApi() [TestCase(PropertyType.EdgeLength, LocationType.Nodes)] [TestCase(PropertyType.FaceCircumcenter, LocationType.Nodes)] [TestCase(PropertyType.FaceCircumcenter, LocationType.Edges)] + [TestCase(PropertyType.FaceBounds, LocationType.Edges)] + [TestCase(PropertyType.FaceBounds, LocationType.Nodes)] public void Mesh2dGetPropertyWithInvalidLocationThroughApi(PropertyType propertyType, LocationType locationType) { // Setup