diff --git a/meshkernel/meshkernel.py b/meshkernel/meshkernel.py index 6c6c0dfa..acfc8e62 100644 --- a/meshkernel/meshkernel.py +++ b/meshkernel/meshkernel.py @@ -282,6 +282,39 @@ def mesh2d_delete( c_int(invert_deletion), ) + def mesh2d_get_mesh_inner_boundaries_as_polygons(self) -> GeometryList: + """Gets the inner boundary polygons from the MeshKernel. + + Returns: + Mesh2d: A copy of the inner boundary polygons. + """ + + c_geometry_list_dimension = c_int() + + self._execute_function( + self.lib.mkernel_mesh2d_get_mesh_inner_boundaries_as_polygons_dimension, + self._meshkernelid, + byref(c_geometry_list_dimension), + ) + + n_coordinates = c_geometry_list_dimension.value + x_coordinates = np.empty(n_coordinates, dtype=np.double) + y_coordinates = np.empty(n_coordinates, dtype=np.double) + + face_polygons = GeometryList( + x_coordinates=x_coordinates, y_coordinates=y_coordinates + ) + + c_face_polygons = CGeometryList.from_geometrylist(face_polygons) + + self._execute_function( + self.lib.mkernel_mesh2d_get_mesh_inner_boundaries_as_polygons_data, + self._meshkernelid, + byref(c_face_polygons), + ) + + return face_polygons + def mesh2d_delete_faces_in_polygons( self, geometry_list: GeometryList, diff --git a/tests/test_mesh2d_basics.py b/tests/test_mesh2d_basics.py index 1c6576bf..ea48b41d 100644 --- a/tests/test_mesh2d_basics.py +++ b/tests/test_mesh2d_basics.py @@ -142,6 +142,9 @@ def test_mesh2d_set_and_mesh2d_get_with_holes(): assert len(mk.mesh2d_get().face_x) == 318 assert len(mk2.mesh2d_get().face_x) == 318 + innerPolygon = mk2.mesh2d_get_mesh_inner_boundaries_as_polygons() + assert innerPolygon.x_coordinates.size == 7 + def test_mesh2d_add(): """Test adding a 2d mesh"""