34 #include <MeshKernel/Entities.hpp>
35 #include <MeshKernel/Mesh.hpp>
36 #include <MeshKernel/Polygon.hpp>
37 #include <MeshKernel/UndoActions/CompoundUndoAction.hpp>
38 #include <MeshKernel/UndoActions/SphericalCoordinatesOffsetAction.hpp>
39 #include <MeshKernel/UndoActions/UndoAction.hpp>
46 class CurvilinearGrid;
64 InsideNotIntersected = 0,
65 InsideAndIntersected = 1,
66 FacesWithIncludedCircumcenters = 2
100 Mesh2D(
const std::vector<Edge>& edges,
101 const std::vector<Point>& nodes,
110 Mesh2D(
const std::vector<Edge>& edges,
111 const std::vector<Point>& nodes,
112 const std::vector<std::vector<UInt>>& faceNodes,
113 const std::vector<UInt>& numFaceNodes,
123 void Administrate(CompoundUndoAction* undoAction =
nullptr)
override;
135 const std::vector<UInt>& numFaceNodes);
143 void CommitAction(
const SphericalCoordinatesOffsetAction& undoAction);
148 void RestoreAction(
const SphericalCoordinatesOffsetAction& undoAction);
156 std::vector<Point>& polygonNodesCache,
157 std::vector<UInt>& localNodeIndicesCache,
158 std::vector<UInt>& globalEdgeIndicesCache)
const;
170 const std::vector<UInt>& edgesNumFaces)
const;
184 [[nodiscard]] std::vector<Point>
GetFlowEdgesCenters(
const std::vector<UInt>& edges)
const;
208 [[nodiscard]] std::unique_ptr<meshkernel::UndoAction>
DeleteSmallFlowEdges(
double smallFlowEdgesThreshold);
257 void MakeDualFace(
UInt node,
double enlargementFactor, std::vector<Point>& dualFace);
275 std::vector<bool>& isVisited,
277 std::vector<Point>& meshBoundaryPolygon)
const;
289 [[nodiscard]] std::vector<UInt>
PointFaceIndices(
const std::vector<Point>& points);
379 void FindNodesSharedByFaces(
UInt nodeIndex,
const std::vector<UInt>& sharedFaces, std::vector<UInt>& connectedNodes, std::vector<std::vector<UInt>>& faceNodeMapping)
const;
400 static constexpr
double m_minimumEdgeLength = 1e-4;
401 static constexpr
double m_curvilinearToOrthogonalRatio = 0.5;
402 static constexpr
double m_minimumCellArea = 1e-12;
403 static constexpr
double m_weightCircumCenter = 1.0;
404 static constexpr
UInt m_maximumNumberOfHangingNodesAlongEdge = 5;
407 using HangingNodeIndexArray = std::array<UInt, m_maximumNumberOfHangingNodesAlongEdge>;
413 [[nodiscard]] std::unique_ptr<UndoAction> DeleteMeshFaces(
const Polygons& polygon,
bool invertDeletion);
425 void FindFacesRecursive(
UInt startNode,
428 UInt numClosingEdges,
429 std::vector<UInt>& edges,
430 std::vector<UInt>& nodes,
431 std::vector<UInt>& sortedEdges,
432 std::vector<UInt>& sortedNodes,
433 std::vector<Point>& nodalValues);
439 [[nodiscard]]
bool HasTriangleNoAcuteAngles(
const std::vector<UInt>& faceNodes,
const std::vector<Point>& nodes)
const;
444 bool HasDuplicateNodes(
const UInt numClosingEdges,
const std::vector<UInt>& node, std::vector<UInt>& sortedNodes)
const;
449 bool HasDuplicateEdgeFaces(
const UInt numClosingEdges,
const std::vector<UInt>& edges, std::vector<UInt>& sortedEdgesFaces)
const;
452 void ResizeAndInitializeFaceVectors();
457 void DoAdministrationGivenFaceNodesMapping(
const std::vector<std::vector<UInt>>& faceNodes,
458 const std::vector<UInt>& numFaceNodes);
462 void DoAdministration(CompoundUndoAction* undoAction =
nullptr);
Projection
Enumerator describing the supported projections.
Definition: Definitions.hpp:41
std::unique_ptr< UndoAction > DeleteHangingEdges()
Deletes the hanging edges.
NodeTypes
Enumerator describing the different node types.
Definition: Mesh2D.hpp:70
UInt IsLeftOrRight(const UInt elementId, const UInt edgeId) const
Determine if the element lies on the left or right side of the edge.
std::vector< UInt > GetHangingEdges() const
Gets the hanging edges.
std::unique_ptr< UndoAction > TriangulateFaces()
Transform non-triangular faces in triangular faces.
void RestoreAction(const ResetNodeAction &undoAction)
Undo the reset node action.
Point ComputeFaceCircumenter(std::vector< Point > &polygon, const std::vector< UInt > &edgesNumFaces) const
For a closed polygon, compute the circumcenter of a face (getcircumcenter)
std::unique_ptr< UndoAction > DeleteDegeneratedTriangles()
Deletes coinciding triangles.
void MakeDualFace(UInt node, double enlargementFactor, std::vector< Point > &dualFace)
Make a dual face around the node, enlarged by a factor.
DeleteMeshOptions
Enumerator describing the different options to delete a mesh.
Definition: Mesh2D.hpp:62
UInt NextFace(const UInt faceId, const UInt edgeId) const
Get the next face adjacent to the edge on the opposite side.
A class derived from Mesh, which describes unstructures 2d meshes.
Definition: Mesh2D.hpp:55
void ComputeNodeNeighbours()
Computes m_nodesNodes, see class members.
A class defining a bounding box.
Definition: BoundingBox.hpp:39
void ComputeFaceClosedPolygon(UInt faceIndex, std::vector< Point > &polygonNodesCache) const
For a face create a closed polygon.
void FindNodesSharedByFaces(UInt nodeIndex, const std::vector< UInt > &sharedFaces, std::vector< UInt > &connectedNodes, std::vector< std::vector< UInt >> &faceNodeMapping) const
Find all unique nodes.
A struct describing a point in a two-dimensional space.
Definition: Point.hpp:40
Location
Mesh locations enumeration.
Definition: Definitions.hpp:74
std::tuple< UInt, UInt > IsSegmentCrossingABoundaryEdge(const Point &firstPoint, const Point &secondPoint) const
Inquire if a segment is crossing a face.
void CommitAction(const SphericalCoordinatesOffsetAction &undoAction)
Apply the coordinate offset action.
void FindFacesConnectedToNode(UInt nodeIndex, std::vector< UInt > &sharedFaces) const
Find all faces that have the given node as a vertex.
std::vector< double > GetOrthogonality() const
Get the orthogonality values, the inner product of edges and segments connecting the face circumcente...
A closed polygon.
Definition: Polygon.hpp:45
UInt IsStartOrEnd(const UInt edgeId, const UInt nodeId) const
Determine if the node is at the start or end of the edge.
void ClassifyNodes()
Classifies the nodes (makenetnodescoding)
std::unique_ptr< UndoAction > DeleteMesh(const Polygons &polygon, DeleteMeshOptions deletionOption, bool invertDeletion)
Deletes a mesh in a polygon, using several options (delnet)
std::unique_ptr< meshkernel::UndoAction > DeleteSmallFlowEdges(double smallFlowEdgesThreshold)
Deletes small flow edges (removesmallflowlinks, part 1)
void RestoreAction(const SphericalCoordinatesOffsetAction &undoAction)
Undo the coordinate offset action.
std::vector< int > MaskEdgesOfFacesInPolygon(const Polygons &polygons, bool invertSelection, bool includeIntersected) const
Masks the edges of all faces entirely included in all polygons.
std::vector< BoundingBox > GetEdgesBoundingBoxes() const
Get the bounding boxes of the mesh edges.
std::vector< Point > GetObtuseTrianglesCenters()
Gets the mass centers of obtuse triangles.
Contains the logic of the C++ static library.
Definition: AveragingInterpolation.hpp:36
Property
Enumerator for different properties on a 2D mesh.
Definition: Mesh2D.hpp:80
std::vector< int > NodeMaskFromPolygon(const Polygons &polygons, bool inside) const
Mask all nodes included in all polygons.
std::unique_ptr< UndoAction > DeleteSmallTrianglesAtBoundaries(double minFractionalAreaTriangles)
Deletes small triangles at the boundaries (removesmallflowlinks, part 2)
std::unique_ptr< SphericalCoordinatesOffsetAction > OffsetSphericalCoordinates(double minx, double maxx)
Offset the x coordinates if m_projection is spherical.
void ComputeCircumcentersMassCentersAndFaceAreas(bool computeMassCenters=false)
Compute face circumcenters.
UInt FindOppositeEdge(const UInt faceId, const UInt edgeId) const
Find edge on the opposite side of the element.
void FindFacesGivenFaceNodesMapping(const std::vector< std::vector< UInt >> &faceNodes, const std::vector< UInt > &numFaceNodes)
Find remaining face information given the face nodes mapping.
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition: Definitions.hpp:38
void Administrate(CompoundUndoAction *undoAction=nullptr) override
Perform complete administration.
BoundingBox GetBoundingBox() const
Get the mesh bounding box.
void ComputeAspectRatios(std::vector< double > &aspectRatios)
Gets the aspect ratios (the ratios edges lengths to flow edges lengths)
std::vector< UInt > GetEdgesCrossingSmallFlowEdges(double smallFlowEdgesThreshold)
Gets the edges crossing the small flow edges.
static std::unique_ptr< Mesh2D > Merge(const Mesh2D &mesh1, const Mesh2D &mesh2)
Merges mesh connectivity.
A class containing a list of polygonaly enclosed regions.
Definition: Polygons.hpp:44
void FindFaces()
Constructs the face nodes mapping, face mass centers and areas.
UInt FindCommonFace(const UInt edge1, const UInt edge2) const
Find the id of the element that is common to both edges.
void WalkBoundaryFromNode(const Polygon &polygon, std::vector< bool > &isVisited, UInt ¤tNode, std::vector< Point > &meshBoundaryPolygon) const
Constructs a polygon from the meshboundary, by walking through the mesh.
~Mesh2D() override=default
Default destructor.
void GetConnectingNodes(UInt nodeIndex, std::vector< UInt > &connectedNodes) const
Get indices of all nodes that are connected directly to a give node along connected edges.
void CommitAction(const ResetNodeAction &undoAction)
Apply the reset node action.
std::vector< UInt > PointFaceIndices(const std::vector< Point > &points)
For a collection of points, compute the face indices including them.
std::vector< Point > GetFlowEdgesCenters(const std::vector< UInt > &edges) const
Gets the flow edges centers from the crossing edges.
std::vector< Point > ComputeBoundaryPolygons(const std::vector< Point > &polygon)
Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol)
std::vector< bool > FilterBasedOnMetric(Location location, Property property, double minValue, double maxValue) const
This method generates a mask indicating which locations are within the specified range of the given m...
std::vector< UInt > SortedFacesAroundNode(UInt node) const
Sorts the faces around a node, sorted in counter clock wise order.
A class describing an unstructured mesh. This class contains the shared functionality between 1d or 2...
Definition: Mesh.hpp:98
Mesh2D()
Default constructor.
void ComputeFaceClosedPolygonWithLocalMappings(UInt faceIndex, std::vector< Point > &polygonNodesCache, std::vector< UInt > &localNodeIndicesCache, std::vector< UInt > &globalEdgeIndicesCache) const
For a face create a closed polygon and fill local mapping caches (get_cellpolygon)
UInt m_maxNumNeighbours
Maximum number of neighbours.
Definition: Mesh2D.hpp:342
std::vector< double > GetSmoothness() const
Gets the smoothness values, ratios of the face areas.
std::vector< int > NodeMaskFromEdgeMask(std::vector< int > const &edgeMask) const
From the edge mask compute the node mask.