77 static constexpr double EdgeLengthTolerance = 1.0e-10;
80 static constexpr UInt m_maximumNumberOfIrregularElementsAlongEdge = 5;
83 enum class MergeIndicator
91 using BoundedIntegerArray = std::array<UInt, m_maximumNumberOfIrregularElementsAlongEdge>;
94 using NodesToMerge = std::pair<UInt, UInt>;
97 struct IrregularEdgeInfo
100 BoundedIntegerArray hangingNodes{constants::missing::uintValue,
101 constants::missing::uintValue,
102 constants::missing::uintValue,
103 constants::missing::uintValue,
104 constants::missing::uintValue};
108 UInt startNode = constants::missing::uintValue;
110 UInt endNode = constants::missing::uintValue;
114 using IrregularEdgeInfoArray = std::vector<IrregularEdgeInfo>;
126 static void AreEdgesAdjacent(
const Mesh2D& mesh,
127 const double separationFraction,
133 const std::vector<double>& edgeLengths);
142 static void GetQuadrilateralElementsOnDomainBoundary(
const Mesh2D& mesh,
143 const std::vector<Boolean>& nodeInsidePolygon,
144 std::vector<UInt>& elementsOnDomainBoundary,
145 std::vector<UInt>& edgesOnDomainBoundary,
146 std::vector<double>& edgeLengths);
155 static void GetOrderedDistanceFromPoint(
const Mesh2D& mesh,
156 const std::vector<UInt>& nodeIndices,
157 const UInt numberOfNodes,
159 BoundedIntegerArray& nearestNeighbours);
166 static std::unique_ptr<meshkernel::UndoAction> MergeNodes(Mesh2D& mesh,
const std::vector<NodesToMerge>& nodesToMerge, std::vector<MergeIndicator>& mergeIndicator);
174 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeOneHangingNode(Mesh2D& mesh,
175 const BoundedIntegerArray& hangingNodes,
176 const UInt startNode,
187 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeTwoHangingNodes(Mesh2D& mesh,
190 const BoundedIntegerArray& hangingNodes,
191 const UInt startNode,
202 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeThreeHangingNodes(Mesh2D& mesh,
205 const BoundedIntegerArray& hangingNodes,
206 const UInt startNode,
217 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeFourHangingNodes(Mesh2D& mesh,
220 const BoundedIntegerArray& hangingNodes,
221 const UInt startNode,
233 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeHangingNodes(Mesh2D& mesh,
234 const UInt numberOfHangingNodes,
235 const std::vector<UInt>& hangingNodesOnEdge,
237 const Edge& boundaryEdge,
238 const Point& boundaryNode,
248 static void GatherHangingNodeIds(
const Mesh2D& mesh,
249 const double separationFraction,
250 const std::vector<UInt>& edgesOnDomainBoundary,
251 const std::vector<double>& edgeLengths,
252 IrregularEdgeInfoArray& irregularEdges);
263 static void GatherNodesToMerge(
const UInt startNode,
265 const Edge& boundaryEdge,
266 std::vector<NodesToMerge>& nodesToMerge,
267 std::vector<MergeIndicator>& mergeIndicator);
277 static void GatherHangingNodes(
const UInt primaryStartNode,
278 const UInt primaryEndNode,
279 const Edge& irregularEdge,
280 std::vector<UInt>& hangingNodesOnEdge,
281 UInt& numberOfHangingNodes,
282 std::vector<MergeIndicator>& mergeIndicator);