From 2a44019ca525bca03dff8861096086fd7d1a55dd Mon Sep 17 00:00:00 2001 From: BillSenior Date: Thu, 2 Jul 2026 17:49:51 +0200 Subject: [PATCH 01/14] GRIDEDIT-2292 Removed debugging output when saving vtk files --- libs/MeshKernel/src/Utilities/Utilities.cpp | 24 --------------------- 1 file changed, 24 deletions(-) diff --git a/libs/MeshKernel/src/Utilities/Utilities.cpp b/libs/MeshKernel/src/Utilities/Utilities.cpp index 28cdec407..ada3a13b1 100644 --- a/libs/MeshKernel/src/Utilities/Utilities.cpp +++ b/libs/MeshKernel/src/Utilities/Utilities.cpp @@ -103,9 +103,6 @@ void meshkernel::SaveVtk(const std::vector& nodes, const std::vector unsavedElements; - - unsavedElements.fill(0); UInt numberOfElements = 0; @@ -116,16 +113,8 @@ void meshkernel::SaveVtk(const std::vector& nodes, const std::vector& nodesX, const std::vector unsavedElements; - - unsavedElements.fill(0); UInt numberOfElements = 0; @@ -270,16 +256,6 @@ void meshkernel::SaveVtk(const std::vector& nodesX, const std::vector Date: Thu, 2 Jul 2026 17:50:48 +0200 Subject: [PATCH 02/14] GRIDEDIT-2292 Reconstructed the invalid cell polygons to unify polygons that are covering the same patch --- libs/MeshKernel/include/MeshKernel/Mesh2D.hpp | 8 ++- libs/MeshKernel/src/Mesh2D.cpp | 53 ++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp index f1f163975..b24cdc645 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp @@ -252,7 +252,7 @@ namespace meshkernel /// @brief Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) /// @param[in] polygon The polygon where the operation is performed; only boundary segments intersecting the polygon are included /// @return The resulting polygon mesh boundary - [[nodiscard]] std::vector ComputeBoundaryPolygons(const std::vector& polygon); + [[nodiscard]] std::vector ComputeBoundaryPolygons(const std::vector& polygon, const bool doAdministrate = true); /// @brief Convert all mesh boundaries to a vector of polygon nodes /// @return The resulting set of polygons, describing interior mesh boundaries @@ -461,6 +461,12 @@ namespace meshkernel std::vector& subSequence, std::vector& illegalCells) const; + /// @brief Reconstruct the invalid cell polygons + /// + /// When constructing the invalid cell polygons, they can be compujted with many smaller polygons. + /// If these smaller polygons form a single patch on the domain, then they need to be combined + void ReconstructInvalidCellsPolygon(); + /// @brief Ensure that all polynomials are orientated in the ACW direction. void OrientatePolygonsAntiClockwise(std::vector& polygonNodes) const; diff --git a/libs/MeshKernel/src/Mesh2D.cpp b/libs/MeshKernel/src/Mesh2D.cpp index e5fa3f6c7..51314ade4 100644 --- a/libs/MeshKernel/src/Mesh2D.cpp +++ b/libs/MeshKernel/src/Mesh2D.cpp @@ -1510,12 +1510,16 @@ std::vector Mesh2D::SortedFacesAroundNode(UInt node) const return result; } -std::vector Mesh2D::ComputeBoundaryPolygons(const std::vector& polygonNodes) +std::vector Mesh2D::ComputeBoundaryPolygons(const std::vector& polygonNodes, const bool doAdministrate) { const Polygon polygon(polygonNodes, m_projection); // Find faces - Administrate(); + if (doAdministrate) + { + Administrate(); + } + std::vector isVisited(GetNumEdges(), false); std::vector meshBoundaryPolygon; meshBoundaryPolygon.reserve(GetNumNodes()); @@ -1572,6 +1576,7 @@ std::vector Mesh2D::ComputeBoundaryPolygons(const std::vector meshBoundaryPolygon.push_back(meshBoundaryPolygon.front()); } } + return meshBoundaryPolygon; } @@ -2183,6 +2188,48 @@ std::unique_ptr Mesh2D::DeleteMeshFacesInPolygon(const P return UpdateFaceInformation(faceIndices, appendDeletedFaces); } +void Mesh2D::ReconstructInvalidCellsPolygon() +{ + std::vector allBoundaries(ComputeBoundaryPolygons(std::vector(), false)); + + if (allBoundaries.GetNumPolygons() <= 1) + { + // There are no interior boundary polygons + return; + } + + Polygons polygons(allBoundaries, m_projection); + std::vector polygonAreas(polygons.GetNumPolygons(), 0.0); + + for (UInt p = 0; p < polygons.GetNumPolygons(); ++p) + { + auto [area, centre, direction] = polygons.Enclosure(p).Outer().FaceAreaAndCenterOfMass(); + polygonAreas[p] = area; + } + + auto maxAreaIter = std::ranges::max_element(polygonAreas); + size_t maxAreaIndex = std::distance(polygonAreas.begin(), maxAreaIter); + + std::vector innerBoundaryPolygons; + innerBoundaryPolygons.reserve(m_invalidCellPolygons.size()); + + for (size_t p = 0; p < polygons.GetNumPolygons(); ++p) + { + if (p != maxAreaIndex) + { + const std::vector& polygonPoints(polygons.Enclosure(p).Outer().Nodes()); + innerBoundaryPolygons.insert(innerBoundaryPolygons.end(), polygonPoints.begin(), polygonPoints.end()); + + if ((p < maxAreaIndex && ((maxAreaIndex + 1) != polygons.GetNumPolygons())) || (p > maxAreaIndex && (p + 1) != polygons.GetNumPolygons())) + { + innerBoundaryPolygons.push_back(Point(constants::missing::doubleValue, constants::missing::doubleValue)); + } + } + } + + m_invalidCellPolygons = innerBoundaryPolygons; +} + std::unique_ptr Mesh2D::UpdateFaceInformation(const std::vector& faceIndices, const bool appendDeletedFaces) { std::vector facesToDelete; @@ -2262,6 +2309,8 @@ std::unique_ptr Mesh2D::UpdateFaceInformation(const std: } } + ReconstructInvalidCellsPolygon(); + // Shift face connectivity in arrays where deleted faces have been removed from arrays // Loop must be iterated in reverse order, from highest face id value to lowest. for (UInt faceId : facesToDelete | std::views::reverse) From a1e171ff260c9df3e69eb09cb1e08758b9b0b2d9 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Thu, 2 Jul 2026 17:59:26 +0200 Subject: [PATCH 03/14] GRIDEDIT-2292 Fixed doxygen and clang formatting warnings --- libs/MeshKernel/include/MeshKernel/Mesh2D.hpp | 1 + libs/MeshKernel/src/Utilities/Utilities.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp index b24cdc645..61206cac7 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp @@ -251,6 +251,7 @@ namespace meshkernel /// @brief Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) /// @param[in] polygon The polygon where the operation is performed; only boundary segments intersecting the polygon are included + /// @param[in] doAdministrate Indicate that an adminstrate is required. /// @return The resulting polygon mesh boundary [[nodiscard]] std::vector ComputeBoundaryPolygons(const std::vector& polygon, const bool doAdministrate = true); diff --git a/libs/MeshKernel/src/Utilities/Utilities.cpp b/libs/MeshKernel/src/Utilities/Utilities.cpp index ada3a13b1..32151435e 100644 --- a/libs/MeshKernel/src/Utilities/Utilities.cpp +++ b/libs/MeshKernel/src/Utilities/Utilities.cpp @@ -112,10 +112,8 @@ void meshkernel::SaveVtk(const std::vector& nodes, const std::vector Date: Mon, 6 Jul 2026 13:27:21 +0200 Subject: [PATCH 04/14] GRIDEDIT-2292 Refactored method for determining enclosing and non-enclosing polygons --- libs/MeshKernel/include/MeshKernel/Mesh2D.hpp | 8 +- .../MeshKernel/include/MeshKernel/Polygon.hpp | 5 ++ libs/MeshKernel/src/Mesh2D.cpp | 83 +++++++++++-------- libs/MeshKernel/src/Polygon.cpp | 6 ++ .../tests/src/MeshRefinementTests.cpp | 68 +++------------ .../tests/src/InvalidCellsPolygonsTests.cpp | 16 +++- 6 files changed, 90 insertions(+), 96 deletions(-) diff --git a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp index 61206cac7..04a156888 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp @@ -253,7 +253,7 @@ namespace meshkernel /// @param[in] polygon The polygon where the operation is performed; only boundary segments intersecting the polygon are included /// @param[in] doAdministrate Indicate that an adminstrate is required. /// @return The resulting polygon mesh boundary - [[nodiscard]] std::vector ComputeBoundaryPolygons(const std::vector& polygon, const bool doAdministrate = true); + [[nodiscard]] std::vector ComputeBoundaryPolygons(const std::vector& polygon); /// @brief Convert all mesh boundaries to a vector of polygon nodes /// @return The resulting set of polygons, describing interior mesh boundaries @@ -468,6 +468,12 @@ namespace meshkernel /// If these smaller polygons form a single patch on the domain, then they need to be combined void ReconstructInvalidCellsPolygon(); + /// @brief Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) + /// + /// @return a sequence of boundary points, which may be separated by the invalid point, and a matching sequence of Boolean values indicating which + /// polygnal sub-sequence forms a external boudary + [[nodiscard]] std::tuple, std::vector> GetAllBoundaryPolygons(const std::vector& polygon); + /// @brief Ensure that all polynomials are orientated in the ACW direction. void OrientatePolygonsAntiClockwise(std::vector& polygonNodes) const; diff --git a/libs/MeshKernel/include/MeshKernel/Polygon.hpp b/libs/MeshKernel/include/MeshKernel/Polygon.hpp index 2c390c295..8b7edb995 100644 --- a/libs/MeshKernel/include/MeshKernel/Polygon.hpp +++ b/libs/MeshKernel/include/MeshKernel/Polygon.hpp @@ -27,6 +27,7 @@ #pragma once +#include #include #include "MeshKernel/BoundingBox.hpp" @@ -54,6 +55,10 @@ namespace meshkernel /// @brief Default move constructor. Polygon(Polygon&& copy) = default; + /// @brief Constructor + Polygon(std::span points, + Projection projection); + /// @brief Constructor Polygon(const std::vector& points, Projection projection); diff --git a/libs/MeshKernel/src/Mesh2D.cpp b/libs/MeshKernel/src/Mesh2D.cpp index 51314ade4..631e48f1b 100644 --- a/libs/MeshKernel/src/Mesh2D.cpp +++ b/libs/MeshKernel/src/Mesh2D.cpp @@ -1510,18 +1510,21 @@ std::vector Mesh2D::SortedFacesAroundNode(UInt node) const return result; } -std::vector Mesh2D::ComputeBoundaryPolygons(const std::vector& polygonNodes, const bool doAdministrate) +std::vector Mesh2D::ComputeBoundaryPolygons(const std::vector& polygonNodes) { - const Polygon polygon(polygonNodes, m_projection); + Administrate(); + auto [boundaryPoints, isEnclosingBoundary] = GetAllBoundaryPolygons(polygonNodes); + return boundaryPoints; +} - // Find faces - if (doAdministrate) - { - Administrate(); - } +std::tuple, std::vector> Mesh2D::GetAllBoundaryPolygons(const std::vector& polygonNodes) +{ + const Polygon polygon(polygonNodes, m_projection); std::vector isVisited(GetNumEdges(), false); std::vector meshBoundaryPolygon; + std::vector isEnclosingBoundary; + meshBoundaryPolygon.reserve(GetNumNodes()); for (UInt e = 0; e < GetNumEdges(); e++) @@ -1531,10 +1534,10 @@ std::vector Mesh2D::ComputeBoundaryPolygons(const std::vector continue; } - const auto firstNodeIndex = m_edges[e].first; - const auto secondNodeIndex = m_edges[e].second; - const auto firstNode = m_nodes[firstNodeIndex]; - const auto secondNode = m_nodes[secondNodeIndex]; + const UInt firstNodeIndex = m_edges[e].first; + const UInt secondNodeIndex = m_edges[e].second; + const Point firstNode = m_nodes[firstNodeIndex]; + const Point secondNode = m_nodes[secondNodeIndex]; bool firstNodeInPolygon = polygon.Contains(m_nodes[firstNodeIndex]); bool secondNodeInPolygon = polygon.Contains(m_nodes[secondNodeIndex]); @@ -1550,9 +1553,12 @@ std::vector Mesh2D::ComputeBoundaryPolygons(const std::vector meshBoundaryPolygon.emplace_back(constants::missing::doubleValue, constants::missing::doubleValue); } + const size_t boundaryPolygonStartIndex = meshBoundaryPolygon.size(); + // Put the current edge on the mesh boundary, mark it as visited meshBoundaryPolygon.emplace_back(firstNode); meshBoundaryPolygon.emplace_back(secondNode); + isVisited[e] = true; // walk the current mesh boundary @@ -1575,9 +1581,17 @@ std::vector Mesh2D::ComputeBoundaryPolygons(const std::vector std::reverse(meshBoundaryPolygon.begin() + numNodesFirstTail, meshBoundaryPolygon.end()); meshBoundaryPolygon.push_back(meshBoundaryPolygon.front()); } + + const size_t boundaryPolygonEndIndex = meshBoundaryPolygon.size(); + + std::span currentPolygonSpan(std::span(meshBoundaryPolygon.data() + boundaryPolygonStartIndex, + meshBoundaryPolygon.data() + boundaryPolygonEndIndex)); + Polygon currentPolygon(currentPolygonSpan, m_projection); + + isEnclosingBoundary.push_back(currentPolygon.Contains(m_facesMassCenters[m_edgesFaces[e][0]])); } - return meshBoundaryPolygon; + return {meshBoundaryPolygon, isEnclosingBoundary}; } std::vector Mesh2D::ComputeInnerBoundaryPolygons() const @@ -2190,44 +2204,41 @@ std::unique_ptr Mesh2D::DeleteMeshFacesInPolygon(const P void Mesh2D::ReconstructInvalidCellsPolygon() { - std::vector allBoundaries(ComputeBoundaryPolygons(std::vector(), false)); + auto [boundaryPoints, isEnclosingBoundary] = GetAllBoundaryPolygons(std::vector()); + + Polygons polygons(boundaryPoints, m_projection); - if (allBoundaries.GetNumPolygons() <= 1) + if (polygons.GetNumPolygons() <= 1) { // There are no interior boundary polygons return; } - Polygons polygons(allBoundaries, m_projection); - std::vector polygonAreas(polygons.GetNumPolygons(), 0.0); - - for (UInt p = 0; p < polygons.GetNumPolygons(); ++p) - { - auto [area, centre, direction] = polygons.Enclosure(p).Outer().FaceAreaAndCenterOfMass(); - polygonAreas[p] = area; - } - - auto maxAreaIter = std::ranges::max_element(polygonAreas); - size_t maxAreaIndex = std::distance(polygonAreas.begin(), maxAreaIter); - std::vector innerBoundaryPolygons; innerBoundaryPolygons.reserve(m_invalidCellPolygons.size()); + bool firstElement = true; for (size_t p = 0; p < polygons.GetNumPolygons(); ++p) { - if (p != maxAreaIndex) + if (isEnclosingBoundary[p]) { - const std::vector& polygonPoints(polygons.Enclosure(p).Outer().Nodes()); - innerBoundaryPolygons.insert(innerBoundaryPolygons.end(), polygonPoints.begin(), polygonPoints.end()); + continue; + } - if ((p < maxAreaIndex && ((maxAreaIndex + 1) != polygons.GetNumPolygons())) || (p > maxAreaIndex && (p + 1) != polygons.GetNumPolygons())) - { - innerBoundaryPolygons.push_back(Point(constants::missing::doubleValue, constants::missing::doubleValue)); - } + if (!firstElement) + { + innerBoundaryPolygons.push_back(Point(constants::missing::doubleValue, constants::missing::doubleValue)); } + else + { + firstElement = false; + } + + const std::vector& polygonPoints(polygons.Enclosure(p).Outer().Nodes()); + innerBoundaryPolygons.insert(innerBoundaryPolygons.end(), polygonPoints.begin(), polygonPoints.end()); } - m_invalidCellPolygons = innerBoundaryPolygons; + m_invalidCellPolygons = std::move(innerBoundaryPolygons); } std::unique_ptr Mesh2D::UpdateFaceInformation(const std::vector& faceIndices, const bool appendDeletedFaces) @@ -2309,8 +2320,6 @@ std::unique_ptr Mesh2D::UpdateFaceInformation(const std: } } - ReconstructInvalidCellsPolygon(); - // Shift face connectivity in arrays where deleted faces have been removed from arrays // Loop must be iterated in reverse order, from highest face id value to lowest. for (UInt faceId : facesToDelete | std::views::reverse) @@ -2322,6 +2331,8 @@ std::unique_ptr Mesh2D::UpdateFaceInformation(const std: m_faceArea.erase(m_faceArea.begin() + faceId); } + ReconstructInvalidCellsPolygon(); + return deleteMeshAction; } diff --git a/libs/MeshKernel/src/Polygon.cpp b/libs/MeshKernel/src/Polygon.cpp index f72fd156a..119a9186d 100644 --- a/libs/MeshKernel/src/Polygon.cpp +++ b/libs/MeshKernel/src/Polygon.cpp @@ -42,6 +42,12 @@ meshkernel::Polygon::Polygon(const std::vector& points, Initialise(); } +meshkernel::Polygon::Polygon(std::span points, + Projection projection) : m_nodes(points.begin(), points.end()), m_projection(projection) +{ + Initialise(); +} + meshkernel::Polygon::Polygon(std::vector&& points, Projection projection) : m_nodes(points), m_projection(projection) { diff --git a/libs/MeshKernel/tests/src/MeshRefinementTests.cpp b/libs/MeshKernel/tests/src/MeshRefinementTests.cpp index e22d177eb..948780dd8 100644 --- a/libs/MeshKernel/tests/src/MeshRefinementTests.cpp +++ b/libs/MeshKernel/tests/src/MeshRefinementTests.cpp @@ -3082,67 +3082,23 @@ TEST(MeshRefinement, MeshWithHole_ShouldConstructMeshWithInteriorBoundaryPolygon std::vector innerBoundaryPoints = mesh2.GetInnerBoundaryPolygons(); // The expected number of points, should not include any land boundary points - UInt expectedNumberOfNodes = 26; + constexpr UInt expectedNumberOfNodes = 22; ASSERT_EQ(expectedNumberOfNodes, innerBoundaryPoints.size()); // The edge of one of the deleted elements lies on the boundary, so will be not be part of the // interior set of polygons - std::vector expectedXPoints{ - 95.0, - 105.0, - 100.0, - 95.0, - constants::missing::doubleValue, - 85.0, - 85.0, - 95.0, - 95.0, - 85.0, - constants::missing::doubleValue, - 80.0, - 75.0, - 85.0, - 80.0, - constants::missing::doubleValue, - 120.0, - 115.0, - 125.0, - 120.0, - constants::missing::doubleValue, - 125.0, - 125.0, - 135.0, - 135.0, - 125.0}; - - std::vector expectedYPoints{ - 15.0, - 15.0, - 0.0, - 15.0, - constants::missing::doubleValue, - 15.0, - 25.0, - 25.0, - 15.0, - 15.0, - constants::missing::doubleValue, - 0.0, - 15.0, - 15.0, - 0.0, - constants::missing::doubleValue, - 0.0, - 15.0, - 15.0, - 0.0, - constants::missing::doubleValue, - 125.0, - 135.0, - 135.0, - 125.0, - 125.0}; + std::vector expectedXPoints{80.0, 85.0, 95.0, 100.0, 105.0, 95.0, 95.0, 85.0, 85.0, 75.0, 80.0, + constants::missing::doubleValue, + 120.0, 125.0, 115.0, 120.0, + constants::missing::doubleValue, + 125.0, 125.0, 135.0, 135.0, 125.0}; + + std::vector expectedYPoints{0.0, 15.0, 15.0, 0.0, 15.0, 15.0, 25.0, 25.0, 15.0, 15.0, 0.0, + constants::missing::doubleValue, + 0.0, 15.0, 15.0, 0.0, + constants::missing::doubleValue, + 125.0, 135.0, 135.0, 125.0, 125.0}; for (size_t i = 0; i < expectedXPoints.size(); ++i) { diff --git a/libs/MeshKernelApi/tests/src/InvalidCellsPolygonsTests.cpp b/libs/MeshKernelApi/tests/src/InvalidCellsPolygonsTests.cpp index 33c5987c4..97d77b1fd 100644 --- a/libs/MeshKernelApi/tests/src/InvalidCellsPolygonsTests.cpp +++ b/libs/MeshKernelApi/tests/src/InvalidCellsPolygonsTests.cpp @@ -191,15 +191,25 @@ TEST(InvalidCellsPolygonsTests, MeshHolesAreMainainedAfterRefinement) //----------------------- // Check the inner boundary polygon are correct - std::vector expectedInnerX{80.0, 85.0, 75.0, 80.0, -999.0, 100.0, 105.0, 95.0, 100.0, -999.0, 120.0, 125.0, 115.0, 120.0, -999.0, 180.0, 200.0, 200.0, 180.0, 180.0, -999.0, 95.0, 95.0, 85.0, 85.0, 95.0, -999.0, 125.0, 135.0, 135.0, 125.0, 125.0}; - std::vector expectedInnerY{0.0, 15.0, 15.0, 0.0, -999.0, 0.0, 15.0, 15.0, 0.0, -999.0, 0.0, 15.0, 15.0, 0.0, -999.0, 140.0, 140.0, 160.0, 160.0, 140.0, -999.0, 15.0, 25.0, 25.0, 15.0, 15.0, -999.0, 125.0, 125.0, 135.0, 135.0, 125.0}; + std::vector expectedInnerX{80.0, 85.0, 95.0, 100.0, 105.0, 95.0, 95.0, 85.0, 85.0, 75.0, 80.0, + meshkernel::constants::missing::doubleValue, + 120.0, 125.0, 115.0, 120.0, + meshkernel::constants::missing::doubleValue, + 125.0, 125.0, 135.0, 135.0, 125.0}; + + std::vector expectedInnerY{0.0, 15.0, 15.0, 0.0, 15.0, 15.0, 25.0, 25.0, 15.0, 15.0, 0.0, + meshkernel::constants::missing::doubleValue, + 0.0, 15.0, 15.0, 0.0, + meshkernel::constants::missing::doubleValue, + 125.0, 135.0, 135.0, 125.0, 125.0}; int innerPolygonSize = 0; meshkernelapi::GeometryList innerPolygon; errorCode = meshkernelapi::mkernel_mesh2d_get_mesh_inner_boundaries_as_polygons_dimension(meshKernelId, innerPolygonSize); ASSERT_EQ(meshkernel::ExitCode::Success, errorCode); - ASSERT_EQ(innerPolygonSize, 32); + + ASSERT_EQ(innerPolygonSize, 22); innerPolygon.num_coordinates = innerPolygonSize; std::vector xInner(innerPolygon.num_coordinates); From 6bdf18625779f40262a0cb0e9eceafb5dae082ef Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 6 Jul 2026 15:01:12 +0200 Subject: [PATCH 05/14] GRIDEDIT-2292 Fix windows build --- libs/MeshKernel/src/Mesh2D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/MeshKernel/src/Mesh2D.cpp b/libs/MeshKernel/src/Mesh2D.cpp index 631e48f1b..f763b0ba2 100644 --- a/libs/MeshKernel/src/Mesh2D.cpp +++ b/libs/MeshKernel/src/Mesh2D.cpp @@ -2218,7 +2218,7 @@ void Mesh2D::ReconstructInvalidCellsPolygon() innerBoundaryPolygons.reserve(m_invalidCellPolygons.size()); bool firstElement = true; - for (size_t p = 0; p < polygons.GetNumPolygons(); ++p) + for (UInt p = 0; p < polygons.GetNumPolygons(); ++p) { if (isEnclosingBoundary[p]) { From 3f22acc8777fca912f8f2ec916defc3f0e3abed0 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 6 Jul 2026 15:08:26 +0200 Subject: [PATCH 06/14] GRIDEDIT-2292 Fixed doxygen spelling warning --- libs/MeshKernel/include/MeshKernel/Mesh2D.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp index 04a156888..795cf0ac6 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp @@ -251,7 +251,7 @@ namespace meshkernel /// @brief Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) /// @param[in] polygon The polygon where the operation is performed; only boundary segments intersecting the polygon are included - /// @param[in] doAdministrate Indicate that an adminstrate is required. + /// @param[in] doAdministrate Indicate that an administrate is required. /// @return The resulting polygon mesh boundary [[nodiscard]] std::vector ComputeBoundaryPolygons(const std::vector& polygon); @@ -471,7 +471,7 @@ namespace meshkernel /// @brief Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) /// /// @return a sequence of boundary points, which may be separated by the invalid point, and a matching sequence of Boolean values indicating which - /// polygnal sub-sequence forms a external boudary + /// polygnal sub-sequence forms a external boundary [[nodiscard]] std::tuple, std::vector> GetAllBoundaryPolygons(const std::vector& polygon); /// @brief Ensure that all polynomials are orientated in the ACW direction. From d50466dc880f7996deaabfa574159cfea423ce66 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 6 Jul 2026 15:09:13 +0200 Subject: [PATCH 07/14] GRIDEDIT-2292 Fixed doxygen warning --- libs/MeshKernel/include/MeshKernel/Mesh2D.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp index 795cf0ac6..233770424 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp @@ -251,7 +251,6 @@ namespace meshkernel /// @brief Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) /// @param[in] polygon The polygon where the operation is performed; only boundary segments intersecting the polygon are included - /// @param[in] doAdministrate Indicate that an administrate is required. /// @return The resulting polygon mesh boundary [[nodiscard]] std::vector ComputeBoundaryPolygons(const std::vector& polygon); From 58c7e9d12608f473a292305f520c548739169151 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 6 Jul 2026 15:30:04 +0200 Subject: [PATCH 08/14] GRIDEDIT-2292 Fixed spelling errors --- libs/MeshKernel/include/MeshKernel/Mesh2D.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp index 233770424..899188f22 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp @@ -463,14 +463,14 @@ namespace meshkernel /// @brief Reconstruct the invalid cell polygons /// - /// When constructing the invalid cell polygons, they can be compujted with many smaller polygons. + /// When constructing the invalid cell polygons, they can be computed with many smaller polygons. /// If these smaller polygons form a single patch on the domain, then they need to be combined void ReconstructInvalidCellsPolygon(); /// @brief Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) /// /// @return a sequence of boundary points, which may be separated by the invalid point, and a matching sequence of Boolean values indicating which - /// polygnal sub-sequence forms a external boundary + /// polygonal sub-sequence forms a external boundary [[nodiscard]] std::tuple, std::vector> GetAllBoundaryPolygons(const std::vector& polygon); /// @brief Ensure that all polynomials are orientated in the ACW direction. From 9e6ac001f64a50f4ad2ee91544075e324b3c2f58 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 13 Jul 2026 11:28:44 +0200 Subject: [PATCH 09/14] GRIDEDIT-2292 Fix compilation under macos --- libs/MeshKernel/tests/CMakeLists.txt | 4 ++++ libs/MeshKernelApi/tests/CMakeLists.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libs/MeshKernel/tests/CMakeLists.txt b/libs/MeshKernel/tests/CMakeLists.txt index 81cca6b35..4d85973e8 100644 --- a/libs/MeshKernel/tests/CMakeLists.txt +++ b/libs/MeshKernel/tests/CMakeLists.txt @@ -67,6 +67,10 @@ set( # add sources to target target_sources(${TARGET_NAME} PRIVATE ${SRC_LIST}) +if(APPLE) + add_compile_options("-Wnocharacter-conversion") +endif () + # Should be linked to the main library, as well as the google test library target_link_libraries( ${TARGET_NAME} diff --git a/libs/MeshKernelApi/tests/CMakeLists.txt b/libs/MeshKernelApi/tests/CMakeLists.txt index ab1e61d99..0b793a809 100644 --- a/libs/MeshKernelApi/tests/CMakeLists.txt +++ b/libs/MeshKernelApi/tests/CMakeLists.txt @@ -71,6 +71,10 @@ add_test( COMMAND ${TARGET_NAME} ) +if(APPLE) + add_compile_options("-Wnocharacter-conversion") +endif () + # Copy the MeshKernel shared library to the target directory add_custom_command( TARGET ${TARGET_NAME} From 341e37687fc6ab3c70596b80218d5dd30c097f69 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 13 Jul 2026 12:24:47 +0200 Subject: [PATCH 10/14] GRIDEDIT-2292 Fix compilation under macos --- libs/MeshKernel/tests/CMakeLists.txt | 2 +- libs/MeshKernelApi/tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/MeshKernel/tests/CMakeLists.txt b/libs/MeshKernel/tests/CMakeLists.txt index 4d85973e8..6b6eecb96 100644 --- a/libs/MeshKernel/tests/CMakeLists.txt +++ b/libs/MeshKernel/tests/CMakeLists.txt @@ -68,7 +68,7 @@ set( target_sources(${TARGET_NAME} PRIVATE ${SRC_LIST}) if(APPLE) - add_compile_options("-Wnocharacter-conversion") + add_compile_options("-Wno-character-conversion") endif () # Should be linked to the main library, as well as the google test library diff --git a/libs/MeshKernelApi/tests/CMakeLists.txt b/libs/MeshKernelApi/tests/CMakeLists.txt index 0b793a809..e370121a7 100644 --- a/libs/MeshKernelApi/tests/CMakeLists.txt +++ b/libs/MeshKernelApi/tests/CMakeLists.txt @@ -72,7 +72,7 @@ add_test( ) if(APPLE) - add_compile_options("-Wnocharacter-conversion") + add_compile_options("-Wno-character-conversion") endif () # Copy the MeshKernel shared library to the target directory From 2145a3ea68b54c6fa03bccf2214758c3baaf51e3 Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 13 Jul 2026 12:27:59 +0200 Subject: [PATCH 11/14] GRIDEDIT-2292 Fix compilation under macos --- cmake/compiler_config.cmake | 2 +- libs/MeshKernel/tests/CMakeLists.txt | 4 ---- libs/MeshKernelApi/tests/CMakeLists.txt | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cmake/compiler_config.cmake b/cmake/compiler_config.cmake index ad5a12ff5..813a987a3 100644 --- a/cmake/compiler_config.cmake +++ b/cmake/compiler_config.cmake @@ -14,7 +14,7 @@ if(APPLE) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") message(STATUS "Configuring build for macOS with ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER_VERSION}).") # Common warning and visibility flags - add_compile_options("-fvisibility=hidden;-Wall;-Wextra;-pedantic;-Werror;-Wno-unused-function") + add_compile_options("-fvisibility=hidden;-Wall;-Wextra;-pedantic;-Werror;-Wno-unused-function;-Wno-character-conversion") # Conditionally suppress unused parameter warnings (used for platform-specific compiler issues) if(SUPPRESS_UNUSED_PARAMETER_WARNING) add_compile_options("-Wno-unused-parameter") diff --git a/libs/MeshKernel/tests/CMakeLists.txt b/libs/MeshKernel/tests/CMakeLists.txt index 6b6eecb96..81cca6b35 100644 --- a/libs/MeshKernel/tests/CMakeLists.txt +++ b/libs/MeshKernel/tests/CMakeLists.txt @@ -67,10 +67,6 @@ set( # add sources to target target_sources(${TARGET_NAME} PRIVATE ${SRC_LIST}) -if(APPLE) - add_compile_options("-Wno-character-conversion") -endif () - # Should be linked to the main library, as well as the google test library target_link_libraries( ${TARGET_NAME} diff --git a/libs/MeshKernelApi/tests/CMakeLists.txt b/libs/MeshKernelApi/tests/CMakeLists.txt index e370121a7..ab1e61d99 100644 --- a/libs/MeshKernelApi/tests/CMakeLists.txt +++ b/libs/MeshKernelApi/tests/CMakeLists.txt @@ -71,10 +71,6 @@ add_test( COMMAND ${TARGET_NAME} ) -if(APPLE) - add_compile_options("-Wno-character-conversion") -endif () - # Copy the MeshKernel shared library to the target directory add_custom_command( TARGET ${TARGET_NAME} From f07e20584e036cd2689b0aa3b50500fa929227cc Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 13 Jul 2026 12:38:12 +0200 Subject: [PATCH 12/14] GRIDEDIT-2292 Fix compilation under macos --- cmake/compiler_config.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/compiler_config.cmake b/cmake/compiler_config.cmake index 813a987a3..35642f87e 100644 --- a/cmake/compiler_config.cmake +++ b/cmake/compiler_config.cmake @@ -14,7 +14,12 @@ if(APPLE) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") message(STATUS "Configuring build for macOS with ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER_VERSION}).") # Common warning and visibility flags - add_compile_options("-fvisibility=hidden;-Wall;-Wextra;-pedantic;-Werror;-Wno-unused-function;-Wno-character-conversion") + add_compile_options("-fvisibility=hidden;-Wall;-Wextra;-pedantic;-Werror;-Wno-unused-function") + + if(os_release VERSION_GREATER_EQUAL "26.0") + add_compile_options("-Wno-character-conversion") + endif() + # Conditionally suppress unused parameter warnings (used for platform-specific compiler issues) if(SUPPRESS_UNUSED_PARAMETER_WARNING) add_compile_options("-Wno-unused-parameter") From 9de9c595164db9c70830ab1957eb77cc1ff2007b Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 13 Jul 2026 12:38:46 +0200 Subject: [PATCH 13/14] GRIDEDIT-2292 Fix compilation under macos --- cmake/compiler_config.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/compiler_config.cmake b/cmake/compiler_config.cmake index 35642f87e..0e8a1a8e0 100644 --- a/cmake/compiler_config.cmake +++ b/cmake/compiler_config.cmake @@ -16,6 +16,8 @@ if(APPLE) # Common warning and visibility flags add_compile_options("-fvisibility=hidden;-Wall;-Wextra;-pedantic;-Werror;-Wno-unused-function") + cmake_host_system_information(RESULT os_release QUERY OS_RELEASE) + if(os_release VERSION_GREATER_EQUAL "26.0") add_compile_options("-Wno-character-conversion") endif() From 2cfb1c3207e3a78d1ce687894554f39a7ec1746e Mon Sep 17 00:00:00 2001 From: Bill Senior Date: Thu, 16 Jul 2026 14:38:31 +0200 Subject: [PATCH 14/14] GRIDEDIT-2292 Better way of handling adding of a compiler flag --- cmake/compiler_config.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/compiler_config.cmake b/cmake/compiler_config.cmake index 0e8a1a8e0..93907562a 100644 --- a/cmake/compiler_config.cmake +++ b/cmake/compiler_config.cmake @@ -18,7 +18,10 @@ if(APPLE) cmake_host_system_information(RESULT os_release QUERY OS_RELEASE) - if(os_release VERSION_GREATER_EQUAL "26.0") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("-Wno-character-conversion" SUPPORTS_WNO_CHARACTER_CONVERSION) + + if(SUPPORTS_WNO_CHARACTER_CONVERSION) add_compile_options("-Wno-character-conversion") endif()