33 #include "MeshKernel/Mesh2D.hpp"
34 #include "MeshKernel/Polygons.hpp"
35 #include "MeshKernel/UndoActions/UndoAction.hpp"
46 [[nodiscard]]
static std::unique_ptr<UndoAction>
Compute(
Mesh2D& mesh);
61 static constexpr
UInt maxIterationCount = 1000;
64 static constexpr
UInt maximumSize = 1000;
71 enum class ElementType
82 enum class ResultIndicator
90 static bool ElementIsSeed(
const Mesh2D& mesh,
91 const std::vector<int>& nodeTypes,
95 static UInt FindElementSeedIndex(
const Mesh2D& mesh,
96 const std::vector<int>& nodeTypes);
99 static void FindDirectlyConnectedFaces(
const Mesh2D& mesh,
100 const UInt elementId,
101 std::vector<UInt>& connected);
104 static void FindIndirectlyConnectedFaces(
const Mesh2D& mesh,
105 const UInt elementId,
106 const std::vector<UInt>& directlyConnected,
107 std::vector<UInt>& indirectlyConnected);
110 static void AssignDirectlyConnected(
const std::vector<UInt>& directlyConnected,
111 std::array<int, 2>& edgeFaces,
112 UInt& neighbouringElementId);
115 static void AssignIndirectlyConnected(
const std::vector<UInt>& indirectlyConnected,
116 std::array<int, 2>& edgeFaces,
117 const UInt neighbouringElementId);
120 static void FindAdjacentFaces(
const Mesh2D& mesh,
121 const std::vector<UInt>& directlyConnected,
122 const std::vector<UInt>& indirectlyConnected,
123 std::vector<std::array<int, 2>>& edgeFaces);
126 static void FindSurroundingFaces(
const Mesh2D& mesh,
127 const UInt elementId,
128 std::vector<UInt>& directlyConnected,
129 std::vector<UInt>& indirectlyConnected,
130 std::vector<std::array<int, 2>>& edgeFaces);
133 static void UpdateFaceMaskDirectlyConnectedNodeFirst(
const std::vector<UInt>& directlyConnected,
135 const std::vector<UInt>& frontIndex,
136 std::vector<UInt>& frontIndexCopy,
137 std::vector<ElementType>& faceMask);
140 static void UpdateFaceMaskIndirectlyConnectedNodeFirst(
const std::vector<UInt>& directlyConnected,
142 std::vector<ElementType>& faceMask);
145 static void UpdateFaceMaskDirectlyConnectedEdgeFirst(
const std::vector<UInt>& directlyConnected,
147 const std::vector<UInt>& frontIndex,
148 std::vector<UInt>& frontIndexCopy,
149 std::vector<ElementType>& faceMask);
152 static void UpdateFaceMaskIndirectlyConnectedEdgeFirst(
const std::vector<UInt>& indirectlyConnected,
154 const std::vector<UInt>& frontIndex,
155 std::vector<UInt>& frontIndexCopy,
156 std::vector<ElementType>& faceMask);
159 static std::vector<ElementType> InitialiseElementType(
const Mesh2D& mesh,
160 const std::vector<int>& nodeTypes);
163 static bool ElementCannotBeDeleted(
const Mesh2D& mesh,
164 const std::vector<int>& nodeTypes,
166 const UInt elementId);
169 static Point ComputeNewNodeCoordinates(
const Mesh2D& mesh,
170 const std::vector<int>& nodeTypes,
174 static UInt GetElementIndex(
const std::array<int, 2>& edgeFaces,
178 static std::tuple<UInt, UInt> FindCommonEdge(
Mesh2D& mesh,
179 const UInt leftElementId,
180 const UInt rightElementId,
181 const UInt connectedElementId);
184 [[nodiscard]]
static bool UpdateDirectlyConnectedElements(
Mesh2D& mesh,
185 const UInt elementId,
186 const std::vector<UInt>& directlyConnected,
187 const std::vector<std::array<int, 2>>& edgeFaces);
190 static bool UpdateDirectlyConnectedTriangleElements(
Mesh2D& mesh,
192 const UInt connectedElementId,
193 const std::vector<std::array<int, 2>>& edgeFaces);
198 static void UpdateDirectlyConnectedNonTriangleElements(
Mesh2D& mesh,
200 const UInt elementId,
201 const UInt connectedElementId);
204 static int GetNodeCode(
const Mesh2D& mesh,
205 const std::vector<int>& nodeTypes,
206 const UInt elementId);
211 static void AddElementToList(
const Mesh& mesh,
212 const std::vector<UInt>& frontList,
213 std::vector<UInt>& frontListCopy,
214 const UInt elementId);
217 static void RedirectNodesOfConnectedElements(
Mesh2D& mesh,
218 const UInt elementId,
220 const std::vector<UInt>& indirectlyConnected);
223 static ResultIndicator RemoveBoundaryNodeAndEdge(
Mesh2D& mesh,
225 const std::vector<int>& nodeTypes,
226 const UInt faceNodeIndex,
227 const UInt connectedElementId,
229 const UInt previousEdgeId,
233 [[nodiscard]]
static bool RemoveUnwantedBoundaryNodes(
Mesh2D& mesh,
234 const std::vector<int>& nodeTypes,
236 const std::vector<UInt>& indirectlyConnected);
239 [[nodiscard]]
static bool DeleteElement(
Mesh2D& mesh,
240 std::vector<int>& nodeTypes,
242 const UInt elementId,
243 const std::vector<UInt>& directlyConnected,
244 const std::vector<UInt>& indirectlyConnected,
245 const std::vector<std::array<int, 2>>& edgeFaces);
250 [[nodiscard]]
static bool CleanUpEdge(
Mesh2D& mesh,
const UInt edgeId);
253 [[nodiscard]]
static bool DoDeRefinement(
Mesh2D& mesh,
const Polygons& polygon);
258 static std::vector<int> ComputeNodeTypes(
const Mesh2D& mesh,
const Polygons& polygon);