diff --git a/src/MeshKernelNET/Api/PropertyType.cs b/src/MeshKernelNET/Api/PropertyType.cs index 4dea3e8..c85ed0f 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 control volume polygons around mesh edges. + /// + NetlinkContourPolygon = 3 } } \ No newline at end of file diff --git a/test/MeshKernelNETTest/Api/MeshKernelApiTest.cs b/test/MeshKernelNETTest/Api/MeshKernelApiTest.cs index 6586709..20155d1 100644 --- a/test/MeshKernelNETTest/Api/MeshKernelApiTest.cs +++ b/test/MeshKernelNETTest/Api/MeshKernelApiTest.cs @@ -2639,6 +2639,51 @@ public void Mesh2dGetPropertyFaceCircumcenterThroughApi() } } + [Test] + public void Mesh2dGetPropertyNetlinkContourPolygonThroughApi() + { + // Setup + using (var api = new MeshKernelApi()) + using (DisposableMesh2D mesh = CreateMesh2D(3, 2, 1, 1)) + { + var propertyValues = new DisposableGeometryList(); + try + { + // Prepare - a 2-cell mesh with different cell widths + // 3----4------5 + // | | | + // 0----1------2 + mesh.NumNodes = 6; + mesh.NumEdges = 7; + mesh.NodeX = new[] { 0.0, 2.0, 5.0, 0.0, 2.0, 5.0 }; + mesh.NodeY = new[] { 0.0, 0.0, 0.0, 3.0, 3.0, 3.0 }; + mesh.EdgeNodes = new[] { 0, 1, 1, 2, 3, 4, 4, 5, 0, 3, 1, 4, 2, 5 }; + + int id = api.AllocateState(0); + Assert.That(api.Mesh2dSet(id, mesh), Is.EqualTo(0)); + + // Execute + Assert.That(api.Mesh2dGetProperty(id, PropertyType.NetlinkContourPolygon, LocationType.Edges, out propertyValues), Is.EqualTo(0)); + + // Assert + Assert.That(propertyValues.NumberOfCoordinates, Is.EqualTo(28)); + Assert.That(propertyValues.XCoordinates[20], Is.EqualTo(1.0)); + Assert.That(propertyValues.YCoordinates[20], Is.EqualTo(3.0)); + Assert.That(propertyValues.XCoordinates[21], Is.EqualTo(1.0)); + Assert.That(propertyValues.YCoordinates[21], Is.EqualTo(0.0)); + Assert.That(propertyValues.XCoordinates[22], Is.EqualTo(3.5)); + Assert.That(propertyValues.YCoordinates[22], Is.EqualTo(0.0)); + Assert.That(propertyValues.XCoordinates[23], Is.EqualTo(3.5)); + Assert.That(propertyValues.YCoordinates[23], Is.EqualTo(3.0)); + } + finally + { + api.ClearState(); + propertyValues.Dispose(); + } + } + } + [Test] [TestCase(PropertyType.Orthogonality, LocationType.Faces)] [TestCase(PropertyType.Orthogonality, LocationType.Nodes)] @@ -2646,6 +2691,8 @@ public void Mesh2dGetPropertyFaceCircumcenterThroughApi() [TestCase(PropertyType.EdgeLength, LocationType.Nodes)] [TestCase(PropertyType.FaceCircumcenter, LocationType.Nodes)] [TestCase(PropertyType.FaceCircumcenter, LocationType.Edges)] + [TestCase(PropertyType.NetlinkContourPolygon, LocationType.Faces)] + [TestCase(PropertyType.NetlinkContourPolygon, LocationType.Nodes)] public void Mesh2dGetPropertyWithInvalidLocationThroughApi(PropertyType propertyType, LocationType locationType) { // Setup