From 8acebc91481937571333a32ec831bc8366a4280c Mon Sep 17 00:00:00 2001 From: BillSenior Date: Mon, 6 Jan 2025 11:09:38 +0100 Subject: [PATCH] GRIDEDIT-1566 Fixed a number of sonar cloud warnings --- libs/MeshKernel/src/Mesh2D.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/libs/MeshKernel/src/Mesh2D.cpp b/libs/MeshKernel/src/Mesh2D.cpp index 4f0060a55..0df6bef2b 100644 --- a/libs/MeshKernel/src/Mesh2D.cpp +++ b/libs/MeshKernel/src/Mesh2D.cpp @@ -2485,26 +2485,37 @@ std::unique_ptr Mesh2D::Merge(const std::span& std::vector mergedNodes(mesh1Nodes.size() + mesh2Nodes.size()); std::vector mergedEdges(mesh1Edges.size() + mesh2Edges.size()); - if (mesh1Nodes.size() > 0) + if (!mesh1Nodes.empty()) { // Merge node array from mesh1 nodes - std::copy(mesh1Nodes.begin(), mesh1Nodes.end(), mergedNodes.begin()); + std::ranges::copy(mesh1Nodes, mergedNodes.begin()); // Merge edge array from mesh1 edges - std::copy(mesh1Edges.begin(), mesh1Edges.end(), mergedEdges.begin()); + std::ranges::copy(mesh1Edges, mergedEdges.begin()); + + // std::copy(mesh1Nodes.begin(), mesh1Nodes.end(), mergedNodes.begin()); + + // // Merge edge array from mesh1 edges + // std::copy(mesh1Edges.begin(), mesh1Edges.end(), mergedEdges.begin()); } - if (mesh2Nodes.size() > 0) + if (!mesh2Nodes.empty()) { // Merge node array from mesh2 nodes - std::copy(mesh2Nodes.begin(), mesh2Nodes.end(), mergedNodes.begin() + mesh1Nodes.size()); + std::ranges::copy(mesh2Nodes, mergedNodes.begin() + mesh1Nodes.size()); // Merge edge array from mesh2 edges - std::copy(mesh2Edges.begin(), mesh2Edges.end(), mergedEdges.begin() + mesh1Edges.size()); + std::ranges::copy(mesh2Edges, mergedEdges.begin() + mesh1Edges.size()); + + // // Merge node array from mesh2 nodes + // std::copy(mesh2Nodes.begin(), mesh2Nodes.end(), mergedNodes.begin() + mesh1Nodes.size()); + + // // Merge edge array from mesh2 edges + // std::copy(mesh2Edges.begin(), mesh2Edges.end(), mergedEdges.begin() + mesh1Edges.size()); - if (mesh1Nodes.size() > 0) + if (!mesh1Nodes.empty()) { - const UInt nodeOffset = mesh1Nodes.size(); + const UInt nodeOffset = static_cast(mesh1Nodes.size()); // Re-assign the node ids for the second mesh data set for (size_t i = mesh1Edges.size(); i < mergedEdges.size(); ++i)