Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions meshkernel/meshkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_mesh2d_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down