Skip to content

Commit

Permalink
Merge tag 'v4.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-el-sayed committed Feb 19, 2024
2 parents 69067f2 + 982e765 commit 340d92d
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyTitle>$(MSBuildProjectName)</AssemblyTitle>

<BuildNumber>0</BuildNumber>
<MeshKernelNETVersion>4.0.0</MeshKernelNETVersion>
<MeshKernelNETVersion>4.1.0</MeshKernelNETVersion>
<Version>$(MeshKernelNETVersion).$(BuildNumber)</Version>
<FileVersion>$(Version)</FileVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Deltares.MeshKernel" Version="4.0.1.2835" />
<PackageVersion Include="Deltares.MeshKernel" Version="4.1.0.2909" />
<PackageVersion Include="DHYDRO.SharedConfigurations" Version="1.0.0.27" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageVersion Include="NetTopologySuite" Version="1.15.0" />
Expand Down
2 changes: 1 addition & 1 deletion nuget/MeshKernelNET.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MeshKernelNET</id>
<version>4.0.0</version>
<version>4.1.0</version>
<title>Deltares meshing library</title>
<authors>Deltares</authors>
<owners>Deltares</owners>
Expand Down
5 changes: 4 additions & 1 deletion src/MeshKernelNET/Api/DeleteMeshInsidePolygonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public enum DeleteMeshInsidePolygonOptions
NotIntersecting = 0,

[Description("Intersecting")]
Intersecting = 1
Intersecting = 1,

[Description("Faces with included circumcenters")]
FacesWithIncludedCircumcenters = 2
}
}
159 changes: 133 additions & 26 deletions test/MeshKernelNETTest/Api/MeshKernelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2311,24 +2311,131 @@ public void Mesh2dCountHangingEdgesThroughAPI()
}

[Test]
public void Mesh2dDeleteInsidePolygonAndIntersectedThroughApi()
{
// Before After
// 30--31--32--33--34--35 30--31--32--33--34--35
// | | | | | | | | | | | |
// 24--25--26--27--28--29 24--25--26--27--28--29
// | | * | | * | | | | | |
// 18--19--20--12--22--23 18--19 22--23
// | | | | | | | | | |
// 12--13--14--15--16--17 12--13 16--17
// | | * | | * | | | | | |
// 6---7---8---9---10--11 6---7---8---9---10--11
// | | | | | | | | | | | |
// 0---1---2---3---4---5 0---1---2---3---4---5
// nodes 6 * 6 = 36 36 - 4 = 32
// edges 2 * 5 = 60 60 - 12 = 48
// faces 5 * 5 = 25 25 - (3 * 3) = 16

// The starting mesh looks as shown below. The grid spacing is uniform and equal to 1.
// The asterisks represent the vertices of a polygon. See the body of the test for the
// actual position of the vertices (they do not coincide with the cell centers).
// 30--31--32--33--34--35
// | | | | | |
// 24--25--26--27--28--29
// | | * | | * | |
// 18--19--20--12--22--23
// | | | | | |
// 12--13--14--15--16--17
// | | * | | * | |
// 6---7---8---9---10--11
// | | | | | |
// 0---1---2---3---4---5
// nodes 6 * 6 = 36
// edges 2 * 5 = 60
// faces 5 * 5 = 25
// The test is parametrized by all possible combinations of deletion options and selection inversion
[TestCase(DeleteMeshInsidePolygonOptions.NotIntersecting,
true,
4,
4,
1)]
// Case 1: should keep the central cell
// 20--21
// | |
// 14--15
// nodes = 4
// edges = 1
// faces = 1
[TestCase(DeleteMeshInsidePolygonOptions.Intersecting,
true,
16,
24,
9)]
// Case 2: should keep 3x3 central cells
// 25--26--27--28
// | | | |
// 19--20--21--22
// | | | |
// 13--14--15--16
// | | | |
// 7---8---9---10
// nodes = 4 * 4 = 16
// edges = 2 * (3 * 4) = 24
// faces = 1
[TestCase(DeleteMeshInsidePolygonOptions.FacesWithIncludedCircumcenters,
true,
16,
24,
9)]
// Case 3: should deletes all the outer cells
// 25--26--27--28
// | | | |
// 19--20--21--22
// | | | |
// 13--14--15--16
// | | | |
// 7---8---9---10
// nodes = 16
// faces = 9
[TestCase(DeleteMeshInsidePolygonOptions.NotIntersecting,
false,
36,
60,
25)]
// Case 4: should keep all cells but the central cell, i.e. delete the central face
// 30--31--32--33--34--35
// | | | | | |
// 24--25--26--27--28--29
// | | | | | |
// 18--19--20--21--22--23
// | | | / | | |
// 12--13--14--15--16--17
// | | | | | |
// 6---7---8---9---10--11
// | | | | | |
// 0---1---2---3---4---5
// nodes = 6 * 6 = 36 (no change)
// edges = 2 * (5 * 6) = 60 (no change)
// faces = 5 * 5 - 1 = 24
[TestCase(DeleteMeshInsidePolygonOptions.Intersecting,
false,
32,
48,
16)]
// Case 5: should delete 3x3 central cells
// 30--31--32--33--34--35
// | | | | | |
// 24--25--26--27--28--29
// | | | |
// 18--19 22--23
// | | | |
// 12--13 16--17
// | | | |
// 6---7---8---9---10--11
// | | | | | |
// 0---1---2---3---4---5
// nodes = 6 * 6 - 4 (central cell) = 32
// faces = 25 - (3 * 3) = 16
[TestCase(DeleteMeshInsidePolygonOptions.FacesWithIncludedCircumcenters,
false,
32,
48,
16)]
// Case 6: should delete 3x3 central cells
// 30--31--32--33--34--35
// | | | | | |
// 24--25--26--27--28--29
// | | | |
// 18--19 22--23
// | | | |
// 12--13 16--17
// | | | |
// 6---7---8---9---10--11
// | | | | | |
// 0---1---2---3---4---5
// nodes = 6 * 6 - 4 (central cell) = 32
// faces = 25 - (3 * 3) = 16
public void Mesh2dDeleteInsidePolygon(DeleteMeshInsidePolygonOptions deleteMeshInsidePolygonOptions,
bool invertSelection,
int expectedNumNodes,
int expectedNunEdges,
int expectedNumFaces)
{
// Setup
using (DisposableMesh2D mesh = CreateMesh2D(5, 5, 1, 1))
using (var api = new MeshKernelApi())
Expand All @@ -2339,19 +2446,19 @@ public void Mesh2dDeleteInsidePolygonAndIntersectedThroughApi()
try
{
polygon.NumberOfCoordinates = 5;
polygon.XCoordinates = new[] { 1.5, 3.5, 3.5, 1.5, 1.5 };
polygon.XCoordinates = new[] { 1.5, 1.5, 3.5, 3.5, 1.5 };
polygon.XCoordinates = new[] { 1.25, 3.75, 3.75, 1.25, 1.25 };
polygon.XCoordinates = new[] { 1.25, 1.25, 3.75, 3.75, 1.25 };

id = api.AllocateState(0);
Assert.AreEqual(0, api.Mesh2dSet(id, mesh));
Assert.AreEqual(0, api.Mesh2dDelete(id,
in polygon,
DeleteMeshInsidePolygonOptions.Intersecting,
false));
deleteMeshInsidePolygonOptions,
invertSelection));
Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh2d));
Assert.AreNotEqual(32, mesh.NumNodes);
Assert.AreNotEqual(48, mesh.NumEdges);
Assert.AreNotEqual(16, mesh.NumFaces);
Assert.AreNotEqual(expectedNumNodes, mesh.NumNodes);
Assert.AreNotEqual(expectedNunEdges, mesh.NumEdges);
Assert.AreNotEqual(expectedNumFaces, mesh.NumFaces);
}
finally
{
Expand All @@ -2375,7 +2482,7 @@ public void Mesh2dMakeGlobaThroughApi()
{
int projectionType = 1;
id = api.AllocateState(projectionType);
Assert.AreEqual(0, api.Mesh2dMakeGlobal(id, 19,25));
Assert.AreEqual(0, api.Mesh2dMakeGlobal(id, 19, 25));

Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh2d));
Assert.AreEqual(1233, mesh2d.NumEdges);
Expand Down

0 comments on commit 340d92d

Please sign in to comment.