-
Notifications
You must be signed in to change notification settings - Fork 12
Gridedit 2292 eliminate internal element boundaries from invalid cells polygons #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BillSenior
wants to merge
14
commits into
master
Choose a base branch
from
feature/GRIDEDIT-2292_eliminate_internal_element_boundaries
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2a44019
GRIDEDIT-2292 Removed debugging output when saving vtk files
BillSenior 4b0f376
GRIDEDIT-2292 Reconstructed the invalid cell polygons to unify polygo…
BillSenior a1e171f
GRIDEDIT-2292 Fixed doxygen and clang formatting warnings
BillSenior 9a178cf
GRIDEDIT-2292 Refactored method for determining enclosing and non-enc…
BillSenior 6bdf186
GRIDEDIT-2292 Fix windows build
BillSenior 3f22acc
GRIDEDIT-2292 Fixed doxygen spelling warning
BillSenior d50466d
GRIDEDIT-2292 Fixed doxygen warning
BillSenior 58c7e9d
GRIDEDIT-2292 Fixed spelling errors
BillSenior 9e6ac00
GRIDEDIT-2292 Fix compilation under macos
BillSenior 341e376
GRIDEDIT-2292 Fix compilation under macos
BillSenior 2145a3e
GRIDEDIT-2292 Fix compilation under macos
BillSenior f07e205
GRIDEDIT-2292 Fix compilation under macos
BillSenior 9de9c59
GRIDEDIT-2292 Fix compilation under macos
BillSenior 2cfb1c3
GRIDEDIT-2292 Better way of handling adding of a compiler flag
BillSenior File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1511,13 +1511,20 @@ std::vector<meshkernel::UInt> Mesh2D::SortedFacesAroundNode(UInt node) const | |
| } | ||
|
|
||
| std::vector<meshkernel::Point> Mesh2D::ComputeBoundaryPolygons(const std::vector<Point>& polygonNodes) | ||
| { | ||
| Administrate(); | ||
| auto [boundaryPoints, isEnclosingBoundary] = GetAllBoundaryPolygons(polygonNodes); | ||
| return boundaryPoints; | ||
| } | ||
|
|
||
| std::tuple<std::vector<meshkernel::Point>, std::vector<bool>> Mesh2D::GetAllBoundaryPolygons(const std::vector<Point>& polygonNodes) | ||
| { | ||
| const Polygon polygon(polygonNodes, m_projection); | ||
|
|
||
| // Find faces | ||
| Administrate(); | ||
| std::vector<bool> isVisited(GetNumEdges(), false); | ||
| std::vector<Point> meshBoundaryPolygon; | ||
| std::vector<bool> isEnclosingBoundary; | ||
|
|
||
| meshBoundaryPolygon.reserve(GetNumNodes()); | ||
|
|
||
| for (UInt e = 0; e < GetNumEdges(); e++) | ||
|
|
@@ -1527,10 +1534,10 @@ std::vector<meshkernel::Point> 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]); | ||
|
|
@@ -1546,9 +1553,12 @@ std::vector<meshkernel::Point> 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 | ||
|
|
@@ -1571,8 +1581,17 @@ std::vector<meshkernel::Point> 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<const Point> currentPolygonSpan(std::span<const Point>(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<meshkernel::Point> Mesh2D::ComputeInnerBoundaryPolygons() const | ||
|
|
@@ -2183,6 +2202,45 @@ std::unique_ptr<meshkernel::UndoAction> Mesh2D::DeleteMeshFacesInPolygon(const P | |
| return UpdateFaceInformation(faceIndices, appendDeletedFaces); | ||
| } | ||
|
|
||
| void Mesh2D::ReconstructInvalidCellsPolygon() | ||
| { | ||
| auto [boundaryPoints, isEnclosingBoundary] = GetAllBoundaryPolygons(std::vector<meshkernel::Point>()); | ||
|
|
||
| Polygons polygons(boundaryPoints, m_projection); | ||
|
|
||
| if (polygons.GetNumPolygons() <= 1) | ||
| { | ||
| // There are no interior boundary polygons | ||
| return; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't |
||
| } | ||
|
Comment on lines
+2211
to
+2215
|
||
|
|
||
| std::vector<Point> innerBoundaryPolygons; | ||
| innerBoundaryPolygons.reserve(m_invalidCellPolygons.size()); | ||
| bool firstElement = true; | ||
|
|
||
| for (UInt p = 0; p < polygons.GetNumPolygons(); ++p) | ||
| { | ||
| if (isEnclosingBoundary[p]) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| if (!firstElement) | ||
| { | ||
| innerBoundaryPolygons.push_back(Point(constants::missing::doubleValue, constants::missing::doubleValue)); | ||
| } | ||
| else | ||
| { | ||
| firstElement = false; | ||
| } | ||
|
|
||
| const std::vector<Point>& polygonPoints(polygons.Enclosure(p).Outer().Nodes()); | ||
| innerBoundaryPolygons.insert(innerBoundaryPolygons.end(), polygonPoints.begin(), polygonPoints.end()); | ||
| } | ||
|
|
||
| m_invalidCellPolygons = std::move(innerBoundaryPolygons); | ||
| } | ||
|
|
||
| std::unique_ptr<meshkernel::UndoAction> Mesh2D::UpdateFaceInformation(const std::vector<UInt>& faceIndices, const bool appendDeletedFaces) | ||
| { | ||
| std::vector<UInt> facesToDelete; | ||
|
|
@@ -2273,6 +2331,8 @@ std::unique_ptr<meshkernel::UndoAction> Mesh2D::UpdateFaceInformation(const std: | |
| m_faceArea.erase(m_faceArea.begin() + faceId); | ||
| } | ||
|
|
||
| ReconstructInvalidCellsPolygon(); | ||
|
|
||
| return deleteMeshAction; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.