-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split row/column for unstructured meshes (#345 | GRIDEDIT-1244)
- Loading branch information
1 parent
c00c123
commit 7ff5b90
Showing
14 changed files
with
1,293 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
122 changes: 122 additions & 0 deletions
122
libs/MeshKernel/include/MeshKernel/SplitRowColumnOfMesh.hpp
This file contains 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 |
---|---|---|
@@ -0,0 +1,122 @@ | ||
//---- GPL --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) Stichting Deltares, 2011-2024. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation version 3. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
// contact: [email protected] | ||
// Stichting Deltares | ||
// P.O. Box 177 | ||
// 2600 MH Delft, The Netherlands | ||
// | ||
// All indications and logos of, and references to, "Delft3D" and "Deltares" | ||
// are registered trademarks of Stichting Deltares, and remain the property of | ||
// Stichting Deltares. All rights reserved. | ||
// | ||
//------------------------------------------------------------------------------ | ||
|
||
#pragma once | ||
#include <array> | ||
#include <memory> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "MeshKernel/Definitions.hpp" | ||
#include "MeshKernel/Mesh2D.hpp" | ||
#include "MeshKernel/UndoActions/CompoundUndoAction.hpp" | ||
#include "MeshKernel/UndoActions/UndoAction.hpp" | ||
|
||
namespace meshkernel | ||
{ | ||
/// @brief Split the row or column connected to the given edge. | ||
class SplitRowColumnOfMesh final | ||
{ | ||
public: | ||
/// @brief Split the row or column connected to the given edge. | ||
/// | ||
/// The splitting will occur upto either the boundary (next elememnt is null value), | ||
/// when the next element is not a quadrilateral, or | ||
/// when the next element is the same as the first element, i.e. a loop has been detected | ||
/// @param mesh Mesh for which a row or column is to be split | ||
/// @param edgeId The starting edges for the splitting | ||
/// @return The undo action, enabling undoing of the splitting, may be null if no splitting can occur, | ||
/// e.g. invalid edgeId, neither element connected to the edge is a quadrilateral. | ||
[[nodiscard]] std::unique_ptr<UndoAction> Compute(Mesh2D& mesh, const UInt edgeId) const; | ||
|
||
private: | ||
/// @brief Split an edge in the middle, into two edges half the size returning the ID of the new node. | ||
/// | ||
/// The two half size edges are each connected to the new (mid point) node and the | ||
/// node on the respective end of the original edge. | ||
UInt SplitEdge(Mesh2D& mesh, const UInt edgeId, std::vector<UInt>& edgesToDelete, CompoundUndoAction& undoActions) const; | ||
|
||
/// @brief Split the element | ||
/// | ||
/// How the element is refined will be determined by the elements that come before and after in the sequence. | ||
void SplitElement(Mesh2D& mesh, | ||
const UInt elementId, | ||
const UInt edgeId, | ||
UInt& newNode, | ||
CompoundUndoAction& undoActions, | ||
std::vector<UInt>& edgesToDelete) const; | ||
|
||
/// @brief Split the first element of a loop of elements | ||
void SplitFirstLoopElement(Mesh2D& mesh, | ||
const UInt elementId, | ||
const UInt edgeId, | ||
UInt& firstNode, | ||
UInt& secondNode, | ||
CompoundUndoAction& undoActions, | ||
std::vector<UInt>& edgesToDelete) const; | ||
|
||
/// @brief Split the elements and edges along the row or column | ||
void SplitAlongRow(Mesh2D& mesh, | ||
const std::vector<UInt>& elementIds, | ||
const std::vector<UInt>& edgeIds, | ||
CompoundUndoAction& undoActions, | ||
std::vector<UInt>& edgesToDelete) const; | ||
|
||
/// @brief Collect the ID's of elements and edges for the partial row/column starting at the edgeId in the direction of the "whichSide" index. | ||
void CollectElementsOneSideOfEdge(const Mesh2D& mesh, | ||
const UInt edgeId, | ||
const UInt whichSide, | ||
std::vector<UInt>& partialElementIds, | ||
std::vector<UInt>& partialEdgeIds, | ||
bool& loopDetected) const; | ||
|
||
/// @brief Collect the ID's of the elements and edges to be split. | ||
void CollectElementsToSplit(const Mesh2D& mesh, const UInt edgeId, std::vector<UInt>& elementIds, std::vector<UInt>& edgeIds) const; | ||
|
||
/// @brief Determine if it may be possible to split the edge | ||
/// | ||
/// If two elements are attached to edge then either must be a quadrilateral, | ||
/// otherwise the single attached element must be quadrilateral. | ||
bool CanBeSplit(const Mesh2D& mesh, const UInt edgeId) const; | ||
|
||
/// @brief Determine is the edge is a valid edge or not. | ||
bool IsValidEdge(const Mesh2D& mesh, const UInt edgeId) const; | ||
|
||
/// @brief Get the ID of the next edge | ||
UInt OppositeEdgeId(const Mesh2D& mesh, const UInt elementId, const UInt edgeId) const; | ||
|
||
/// @brief Determine is the element is a quadrilateral or not | ||
bool IsQuadrilateral(const Mesh2D& mesh, const UInt elementId) const; | ||
|
||
/// @brief Get the element along the opposite edge | ||
UInt GetNextElement(const Mesh2D& mesh, const UInt elementId, const UInt edgeId) const; | ||
|
||
/// @brief Get the next edge. | ||
void GetNextEdge(const Mesh2D& mesh, UInt& elementId, UInt& edgeId) const; | ||
}; | ||
|
||
} // namespace meshkernel |
This file contains 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 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 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 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.