Skip to content

Commit

Permalink
Fix some sonar cloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacarniato committed Oct 10, 2023
1 parent 3e058cc commit fe75306
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion libs/MeshKernel/include/MeshKernel/Mesh2DIntersections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace meshkernel
{
public:
/// @brief Constructor
Mesh2DIntersections(Mesh2D& mesh);
explicit Mesh2DIntersections(Mesh2D& mesh);

/// @brief Compute intersection with a polygon, possibly containing multiple polylines
/// @param[in] polygon An input polygon
Expand Down
12 changes: 6 additions & 6 deletions libs/MeshKernel/src/Mesh2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,8 +1531,8 @@ void Mesh2D::DeleteMesh(const Polygons& polygon, int deletionOption, bool invert
// Find crossed faces
Mesh2DIntersections mesh2DIntersections(*this);
mesh2DIntersections.Compute(polygon);
const auto edgeIntersections = mesh2DIntersections.EdgeIntersections();
const auto faceIntersections = mesh2DIntersections.FaceIntersections();
const auto& edgeIntersections = mesh2DIntersections.EdgeIntersections();
const auto& faceIntersections = mesh2DIntersections.FaceIntersections();

// Find faces with all nodes inside the polygon
std::vector<bool> isNodeInsidePolygon(GetNumNodes(), false);
Expand Down Expand Up @@ -1562,22 +1562,22 @@ void Mesh2D::DeleteMesh(const Polygons& polygon, int deletionOption, bool invert
std::function<bool(UInt)> excludedFace;
if (deletionOption == InsideNotIntersected && !invertDeletion)
{
excludedFace = [&](UInt f)
excludedFace = [&isFaceCompletlyIncludedInPolygon, &faceIntersections](UInt f)
{ return !isFaceCompletlyIncludedInPolygon[f] || faceIntersections[f].faceIndex != constants::missing::uintValue; };
}
else if (deletionOption == InsideNotIntersected && invertDeletion)
{
excludedFace = [&](UInt f)
excludedFace = [&isFaceCompletlyIncludedInPolygon, &faceIntersections](UInt f)
{ return isFaceCompletlyIncludedInPolygon[f] && faceIntersections[f].faceIndex == constants::missing::uintValue; };
}
else if (deletionOption == InsideAndIntersected && !invertDeletion)
{
excludedFace = [&](UInt f)
excludedFace = [&isFaceCompletlyIncludedInPolygon, &faceIntersections](UInt f)
{ return !isFaceCompletlyIncludedInPolygon[f] && faceIntersections[f].faceIndex == constants::missing::uintValue; };
}
else if (deletionOption == InsideAndIntersected && invertDeletion)
{
excludedFace = [&](UInt f)
excludedFace = [&isFaceCompletlyIncludedInPolygon, &faceIntersections](UInt f)
{ return isFaceCompletlyIncludedInPolygon[f] || faceIntersections[f].faceIndex != constants::missing::uintValue; };
}

Expand Down
4 changes: 1 addition & 3 deletions libs/MeshKernel/src/Mesh2DIntersections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ void Mesh2DIntersections::Compute(const std::vector<Point>& polyLine)
auto [currentCrossingEdge, segmentIndex, nextSegmentIndex] = crossingEdges.front();
crossingEdges.pop();

for (UInt f = 0; f < m_mesh.m_edgesFaces[currentCrossingEdge].size(); ++f)
for (const auto currentFaceIndex : m_mesh.m_edgesFaces[currentCrossingEdge])
{
const auto currentFaceIndex = m_mesh.m_edgesFaces[currentCrossingEdge][f];

if (currentFaceIndex == constants::missing::uintValue)
{
continue;
Expand Down

0 comments on commit fe75306

Please sign in to comment.