MeshKernel
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
meshkernel::Mesh2D Class Referencefinal

A class derived from Mesh, which describes unstructures 2d meshes. More...

#include <Mesh2D.hpp>

Inheritance diagram for meshkernel::Mesh2D:
meshkernel::Mesh

Public Types

enum  DeleteMeshOptions { InsideNotIntersected = 0, InsideAndIntersected = 1, FacesWithIncludedCircumcenters = 2 }
 Enumerator describing the different options to delete a mesh.
 
enum  NodeTypes {
  internalNode, onRing, cornerNode, hangingNode,
  other
}
 Enumerator describing the different node types.
 
enum  Property { Orthogonality = 0, EdgeLength = 1 }
 Enumerator for different properties on a 2D mesh.
 
- Public Types inherited from meshkernel::Mesh
enum  Type { Type::Mesh1D, Type::Mesh2D }
 Enumerator describing the different mesh types. More...
 

Public Member Functions

 ~Mesh2D () override=default
 Default destructor.
 
 Mesh2D ()
 Default constructor.
 
 Mesh2D (Projection projection)
 Construct a mesh2d using only the projection. More...
 
 Mesh2D (const std::vector< Edge > &edges, const std::vector< Point > &nodes, Projection projection)
 Construct a mesh2d starting from the edges and nodes. More...
 
 Mesh2D (const std::vector< Edge > &edges, const std::vector< Point > &nodes, const std::vector< std::vector< UInt >> &faceNodes, const std::vector< UInt > &numFaceNodes, Projection projection)
 Construct a mesh2d from face nodes and num face nodes. More...
 
 Mesh2D (const std::vector< Point > &nodes, const Polygons &polygons, Projection projection)
 Create triangular grid from nodes (triangulatesamplestonetwork) More...
 
void Administrate (CompoundUndoAction *undoAction=nullptr) override
 Perform complete administration.
 
void ComputeCircumcentersMassCentersAndFaceAreas (bool computeMassCenters=false)
 Compute face circumcenters.
 
void FindFaces ()
 Constructs the face nodes mapping, face mass centers and areas.
 
void FindFacesGivenFaceNodesMapping (const std::vector< std::vector< UInt >> &faceNodes, const std::vector< UInt > &numFaceNodes)
 Find remaining face information given the face nodes mapping. More...
 
std::unique_ptr< SphericalCoordinatesOffsetAction > OffsetSphericalCoordinates (double minx, double maxx)
 Offset the x coordinates if m_projection is spherical. More...
 
void CommitAction (const SphericalCoordinatesOffsetAction &undoAction)
 Apply the coordinate offset action.
 
void RestoreAction (const SphericalCoordinatesOffsetAction &undoAction)
 Undo the coordinate offset action. More...
 
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) More...
 
void ComputeFaceClosedPolygon (UInt faceIndex, std::vector< Point > &polygonNodesCache) const
 For a face create a closed polygon. More...
 
Point ComputeFaceCircumenter (std::vector< Point > &polygon, const std::vector< UInt > &edgesNumFaces) const
 For a closed polygon, compute the circumcenter of a face (getcircumcenter) More...
 
std::vector< PointGetObtuseTrianglesCenters ()
 Gets the mass centers of obtuse triangles. More...
 
std::vector< UIntGetEdgesCrossingSmallFlowEdges (double smallFlowEdgesThreshold)
 Gets the edges crossing the small flow edges. More...
 
std::vector< PointGetFlowEdgesCenters (const std::vector< UInt > &edges) const
 Gets the flow edges centers from the crossing edges. More...
 
std::unique_ptr< meshkernel::UndoAction > DeleteSmallFlowEdges (double smallFlowEdgesThreshold)
 Deletes small flow edges (removesmallflowlinks, part 1) More...
 
std::unique_ptr< UndoAction > DeleteSmallTrianglesAtBoundaries (double minFractionalAreaTriangles)
 Deletes small triangles at the boundaries (removesmallflowlinks, part 2) More...
 
void ComputeNodeNeighbours ()
 Computes m_nodesNodes, see class members.
 
std::vector< double > GetOrthogonality () const
 Get the orthogonality values, the inner product of edges and segments connecting the face circumcenters. More...
 
std::vector< double > GetSmoothness () const
 Gets the smoothness values, ratios of the face areas. More...
 
void ComputeAspectRatios (std::vector< double > &aspectRatios)
 Gets the aspect ratios (the ratios edges lengths to flow edges lengths) More...
 
void ClassifyNodes ()
 Classifies the nodes (makenetnodescoding)
 
std::unique_ptr< UndoAction > DeleteDegeneratedTriangles ()
 Deletes coinciding triangles.
 
std::unique_ptr< UndoAction > TriangulateFaces ()
 Transform non-triangular faces in triangular faces.
 
void MakeDualFace (UInt node, double enlargementFactor, std::vector< Point > &dualFace)
 Make a dual face around the node, enlarged by a factor. More...
 
std::vector< UIntSortedFacesAroundNode (UInt node) const
 Sorts the faces around a node, sorted in counter clock wise order. More...
 
std::vector< PointComputeBoundaryPolygons (const std::vector< Point > &polygon)
 Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) More...
 
void WalkBoundaryFromNode (const Polygon &polygon, std::vector< bool > &isVisited, UInt &currentNode, std::vector< Point > &meshBoundaryPolygon) const
 Constructs a polygon from the meshboundary, by walking through the mesh. More...
 
std::vector< UIntGetHangingEdges () const
 Gets the hanging edges. More...
 
std::unique_ptr< UndoAction > DeleteHangingEdges ()
 Deletes the hanging edges.
 
std::vector< UIntPointFaceIndices (const std::vector< Point > &points)
 For a collection of points, compute the face indices including them. More...
 
std::unique_ptr< UndoAction > DeleteMesh (const Polygons &polygon, DeleteMeshOptions deletionOption, bool invertDeletion)
 Deletes a mesh in a polygon, using several options (delnet) More...
 
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 metric. More...
 
std::tuple< UInt, UIntIsSegmentCrossingABoundaryEdge (const Point &firstPoint, const Point &secondPoint) const
 Inquire if a segment is crossing a face. More...
 
std::vector< int > MaskEdgesOfFacesInPolygon (const Polygons &polygons, bool invertSelection, bool includeIntersected) const
 Masks the edges of all faces entirely included in all polygons. More...
 
std::vector< int > NodeMaskFromEdgeMask (std::vector< int > const &edgeMask) const
 From the edge mask compute the node mask. More...
 
std::vector< int > NodeMaskFromPolygon (const Polygons &polygons, bool inside) const
 Mask all nodes included in all polygons. More...
 
UInt FindOppositeEdge (const UInt faceId, const UInt edgeId) const
 Find edge on the opposite side of the element. More...
 
UInt NextFace (const UInt faceId, const UInt edgeId) const
 Get the next face adjacent to the edge on the opposite side. More...
 
BoundingBox GetBoundingBox () const
 Get the mesh bounding box. More...
 
std::vector< BoundingBoxGetEdgesBoundingBoxes () const
 Get the bounding boxes of the mesh edges. More...
 
void FindFacesConnectedToNode (UInt nodeIndex, std::vector< UInt > &sharedFaces) const
 Find all faces that have the given node as a vertex. More...
 
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. More...
 
void FindNodesSharedByFaces (UInt nodeIndex, const std::vector< UInt > &sharedFaces, std::vector< UInt > &connectedNodes, std::vector< std::vector< UInt >> &faceNodeMapping) const
 Find all unique nodes. More...
 
UInt IsStartOrEnd (const UInt edgeId, const UInt nodeId) const
 Determine if the node is at the start or end of the edge. More...
 
UInt IsLeftOrRight (const UInt elementId, const UInt edgeId) const
 Determine if the element lies on the left or right side of the edge. More...
 
UInt FindCommonFace (const UInt edge1, const UInt edge2) const
 Find the id of the element that is common to both edges. More...
 
void CommitAction (const ResetNodeAction &undoAction)
 Apply the reset node action.
 
void CommitAction (const AddNodeAction &undoAction)
 Apply the add node action.
 
void CommitAction (const AddEdgeAction &undoAction)
 Apply the add edge action.
 
void CommitAction (const ResetEdgeAction &undoAction)
 Apply the reset edge action.
 
void CommitAction (const DeleteNodeAction &undoAction)
 Apply the delete node action.
 
void CommitAction (NodeTranslationAction &undoAction)
 Apply the node translation action.
 
void CommitAction (MeshConversionAction &undoAction)
 Apply the node translation action.
 
void CommitAction (const DeleteEdgeAction &undoAction)
 Apply the delete edge action.
 
void CommitAction (FullUnstructuredGridUndo &undoAction)
 Set the node and edge values.
 
void RestoreAction (const ResetNodeAction &undoAction)
 Undo the reset node action. More...
 
void RestoreAction (const AddNodeAction &undoAction)
 Undo the add node action. More...
 
void RestoreAction (const AddEdgeAction &undoAction)
 Undo the add edge action. More...
 
void RestoreAction (const ResetEdgeAction &undoAction)
 Undo the reset edge action. More...
 
void RestoreAction (const DeleteNodeAction &undoAction)
 Undo the delete node action. More...
 
void RestoreAction (NodeTranslationAction &undoAction)
 Undo the node translation action. More...
 
void RestoreAction (MeshConversionAction &undoAction)
 Undo the node translation action. More...
 
void RestoreAction (const DeleteEdgeAction &undoAction)
 Undo the delete edge action. More...
 
void RestoreAction (FullUnstructuredGridUndo &undoAction)
 Undo entire node and edge values. More...
 
- Public Member Functions inherited from meshkernel::Mesh
virtual ~Mesh ()=default
 Define virtual destructor.
 
 Mesh ()
 Default constructor, setting a cartesian projection.
 
Meshoperator= (const Mesh &mesh)=delete
 Delete assignment operator.
 
Meshoperator= (Mesh &&mesh)=delete
 Delete move assignment operator.
 
 Mesh (const Mesh &mesh)=delete
 Copy constructor taking only a mesh.
 
 Mesh (Mesh &&mesh)=delete
 Move constructor taking only a mesh.
 
 Mesh (Projection projection)
 Constructs an empty mesh, sets only the projection. More...
 
 Mesh (const std::vector< Edge > &edges, const std::vector< Point > &nodes, Projection projection)
 Construct a mesh starting from the edges and nodes. More...
 
bool IsNodeOnBoundary (UInt node) const
 Inquire if a node is on boundary. More...
 
auto GetNumNodes () const
 Get the number of valid nodes. More...
 
auto GetNumEdges () const
 Get the number of valid edges. More...
 
auto GetNumFaces () const
 Get the number of valid faces. More...
 
UInt GetNumValidNodes () const
 Get the number of valid nodes. More...
 
UInt GetNumValidEdges () const
 Get the number of valid edges. More...
 
auto GetNumFaceEdges (UInt faceIndex) const
 Get the number of edges for a face. More...
 
auto GetNumEdgesFaces (UInt edgeIndex) const
 Get the number of faces an edges shares. More...
 
UInt GetEdgeIndex (const UInt elementId, const UInt edgeId) const
 Get the local edge number for an element edge.
 
UInt GetNodeIndex (const UInt elementId, const UInt nodeId) const
 Get the local node number for an element node.
 
bool IsEdgeOnBoundary (UInt edge) const
 Inquire if an edge is on boundary. More...
 
bool IsFaceOnBoundary (UInt face) const
 Inquire if a face is on boundary. More...
 
const std::vector< Point > & Nodes () const
 Get vector of all nodes.
 
const PointNode (const UInt index) const
 Get the node at the position.
 
void SetNodes (const std::vector< Point > &newValues)
 Set all nodes to a new set of values.
 
void SetNode (const UInt index, const Point &newValue)
 Set a node to a new value, bypassing the undo action.
 
std::unique_ptr< ResetNodeAction > ResetNode (const UInt index, const Point &newValue)
 Set the node to a new value, this value may be the in-valid value.
 
const std::vector< Edge > & Edges () const
 Get all edges.
 
const EdgeGetEdge (const UInt index) const
 Get constant reference to an edge.
 
void SetEdges (const std::vector< Edge > &newValues)
 Set all edges to a new set of values.
 
void SetEdge (const UInt index, const Edge &edge)
 Set the edge to a new value, bypassing the undo action.
 
std::unique_ptr< ResetEdgeAction > ResetEdge (UInt edgeId, const Edge &edge)
 Change the nodes referenced by the edge.
 
UInt GetLocalFaceNodeIndex (const UInt faceIndex, const UInt nodeIndex) const
 Get the local index of the node belong to a face. More...
 
std::unique_ptr< UndoAction > MergeTwoNodes (UInt startNode, UInt endNode)
 Merges two mesh nodes. More...
 
std::unique_ptr< UndoAction > MergeNodesInPolygon (const Polygons &polygons, double mergingDistance)
 Merge close mesh nodes inside a polygon (MERGENODESINPOLYGON) More...
 
std::tuple< UInt, std::unique_ptr< AddNodeAction > > InsertNode (const Point &newPoint)
 Insert a new node in the mesh (setnewpoint) More...
 
std::tuple< UInt, std::unique_ptr< AddEdgeAction > > ConnectNodes (UInt startNode, UInt endNode, const bool collectUndo=true)
 Connect two existing nodes, checking if the nodes are already connected. If the nodes are not connected a new edge is formed, otherwise UInt invalid value is returned. (connectdbn) More...
 
std::unique_ptr< DeleteNodeAction > DeleteNode (UInt node, const bool collectUndo=true)
 Deletes a node and removes any connected edges. More...
 
UInt FindEdge (UInt firstNodeIndex, UInt secondNodeIndex) const
 Find the edge sharing two nodes. More...
 
UInt FindEdgeWithLinearSearch (UInt firstNodeIndex, UInt secondNodeIndex) const
 Find the edge using a linear search, without connectivity information (much slower than FindEdge) More...
 
std::unique_ptr< UndoAction > MoveNode (Point newPoint, UInt nodeindex)
 Move a node to a new location. More...
 
UInt FindLocationIndex (Point point, Location location, const std::vector< bool > &locationMask={}, const BoundingBox &boundingBox={})
 Get the index of a location (node/edge or face) close to a point. More...
 
UInt FindNodeCloseToAPoint (Point const &point, double searchRadius)
 Get the index of a node close to a point. More...
 
std::unique_ptr< DeleteEdgeAction > DeleteEdge (UInt edge, const bool collectUndo=true)
 Deletes an edge. More...
 
UInt FindCommonNode (UInt firstEdgeIndex, UInt secondEdgeIndex) const
 Find the common node two edges share This method uses return parameters since the success is evaluated in a hot loop. More...
 
void ComputeEdgesLengths ()
 Compute the lengths of all edges in one go.
 
double ComputeMinEdgeLength (const Polygons &polygon) const
 Compute the minimum edge length of the edges included in the polygon. An edge is considered included if one of the two nodes is inside the polygon. More...
 
void ComputeEdgesCenters ()
 Computes the edges centers in one go.
 
bool NodeAdministration ()
 Node administration (setnodadmin) More...
 
void DeleteInvalidNodesAndEdges ()
 Removes all invalid nodes and edges.
 
void AdministrateNodesEdges (CompoundUndoAction *undoAction=nullptr)
 Perform node and edges administration.
 
void SortEdgesInCounterClockWiseOrder (UInt startNode, UInt endNode)
 Sort mesh edges around a node in counterclockwise order (Sort_links_ccw) More...
 
double ComputeMaxLengthSurroundingEdges (UInt node)
 Compute the max length of the edges connected to a node. More...
 
void BuildTree (Location location, const BoundingBox &boundingBox={})
 Build the rtree for the corresponding location, using only the locations inside the bounding box. More...
 
std::vector< PointComputeLocations (Location location) const
 Computes a vector with the mesh locations coordinates (nodes, edges or faces coordinates). More...
 
std::vector< bool > IsLocationInPolygon (const Polygons &polygon, Location location) const
 Computes if a location is in polygon. More...
 
Meshoperator+= (Mesh const &rhs)
 Add meshes: result is a mesh composed of the additions firstMesh += secondmesh results in the second mesh being added to firstMesh. More...
 
std::unique_ptr< UndoAction > Join (const Mesh &rhs)
 Add meshes: result is a mesh composed of the additions firstMesh += secondmesh results in the second mesh being added to firstMesh. More...
 
std::vector< UIntGetValidNodeMapping () const
 Get the mapping/indexing from the node array mapped to valid nodes.
 
std::vector< UIntGetValidEdgeMapping () const
 Get the mapping/indexing from the edge array mapped to valid edges.
 
bool IsValidEdge (const UInt edgeId) const
 Indicate if the edge-id is a valid edge. More...
 
void CommitAction (const ResetNodeAction &undoAction)
 Apply the reset node action.
 
void CommitAction (const AddNodeAction &undoAction)
 Apply the add node action.
 
void CommitAction (const AddEdgeAction &undoAction)
 Apply the add edge action.
 
void CommitAction (const ResetEdgeAction &undoAction)
 Apply the reset edge action.
 
void CommitAction (const DeleteNodeAction &undoAction)
 Apply the delete node action.
 
void CommitAction (NodeTranslationAction &undoAction)
 Apply the node translation action.
 
void CommitAction (MeshConversionAction &undoAction)
 Apply the node translation action.
 
void CommitAction (const DeleteEdgeAction &undoAction)
 Apply the delete edge action.
 
void CommitAction (FullUnstructuredGridUndo &undoAction)
 Set the node and edge values.
 
void RestoreAction (const ResetNodeAction &undoAction)
 Undo the reset node action. More...
 
void RestoreAction (const AddNodeAction &undoAction)
 Undo the add node action. More...
 
void RestoreAction (const AddEdgeAction &undoAction)
 Undo the add edge action. More...
 
void RestoreAction (const ResetEdgeAction &undoAction)
 Undo the reset edge action. More...
 
void RestoreAction (const DeleteNodeAction &undoAction)
 Undo the delete node action. More...
 
void RestoreAction (NodeTranslationAction &undoAction)
 Undo the node translation action. More...
 
void RestoreAction (MeshConversionAction &undoAction)
 Undo the node translation action. More...
 
void RestoreAction (const DeleteEdgeAction &undoAction)
 Undo the delete edge action. More...
 
void RestoreAction (FullUnstructuredGridUndo &undoAction)
 Undo entire node and edge values. More...
 
RTreeBase & GetRTree (Location location) const
 Get a reference to the RTree for a specific location.
 
void SetNodesRTreeRequiresUpdate (bool value)
 Set the m_nodesRTreeRequiresUpdate flag. More...
 
void SetEdgesRTreeRequiresUpdate (bool value)
 Set the m_edgesRTreeRequiresUpdate flag. More...
 
void SetFacesRTreeRequiresUpdate (bool value)
 Set the m_facesRTreeRequiresUpdate flag. More...
 

Static Public Member Functions

static std::unique_ptr< Mesh2DMerge (const Mesh2D &mesh1, const Mesh2D &mesh2)
 Merges mesh connectivity. More...
 

Public Attributes

UInt m_maxNumNeighbours = 0
 Maximum number of neighbours.
 
- Public Attributes inherited from meshkernel::Mesh
std::vector< std::vector< UInt > > m_nodesEdges
 For each node, the indices of connected edges (nodlin)
 
std::vector< UIntm_nodesNumEdges
 For each node, the number of connected edges (nmk)
 
std::vector< std::vector< UInt > > m_nodesNodes
 For each node, its neighbors.
 
std::vector< int > m_nodesTypes
 The node types (nb)
 
std::vector< std::array< UInt, 2 > > m_edgesFaces
 For each edge, the shared face index (lne)
 
std::vector< UIntm_edgesNumFaces
 For each edge, the number of shared faces(lnn)
 
std::vector< double > m_edgeLengths
 The edge lengths.
 
std::vector< Pointm_edgesCenters
 The edges centers.
 
std::vector< std::vector< UInt > > m_facesNodes
 The nodes composing the faces, in ccw order (netcellNod)
 
std::vector< UIntm_numFacesNodes
 The number of nodes composing the face (netcellN)
 
std::vector< std::vector< UInt > > m_facesEdges
 The edge indices composing the face (netcelllin)
 
std::vector< Pointm_facesCircumcenters
 The face circumcenters the face circumcenter (xz, yz)
 
std::vector< Pointm_facesMassCenters
 The faces centers of mass (xzw, yzw)
 
std::vector< double > m_faceArea
 The face area.
 
Projection m_projection
 The projection used.
 

Additional Inherited Members

- Static Public Attributes inherited from meshkernel::Mesh
static constexpr UInt m_maximumNumberOfEdgesPerNode = 16
 Maximum number of edges per node.
 
static constexpr UInt m_maximumNumberOfEdgesPerFace = 6
 Maximum number of edges per face.
 
static constexpr UInt m_maximumNumberOfNodesPerFace = 6
 Maximum number of nodes per face.
 
static constexpr UInt m_maximumNumberOfConnectedNodes = m_maximumNumberOfEdgesPerNode * 4
 Maximum number of connected nodes.
 
- Protected Member Functions inherited from meshkernel::Mesh
bool AdministrationRequired () const
 Determine if a administration is required.
 
void SetAdministrationRequired (const bool value)
 Determine if a administration is required.
 
- Protected Attributes inherited from meshkernel::Mesh
std::vector< Pointm_nodes
 The mesh nodes (xk, yk)
 
std::vector< Edgem_edges
 The edges, defined as first and second node(kn)
 

Detailed Description

A class derived from Mesh, which describes unstructures 2d meshes.

When communicating with the client only unstructured meshes are used. Some algorithms generate curvilinear grids, but these are converted to a mesh instance when communicating with the client.

Constructor & Destructor Documentation

◆ Mesh2D() [1/4]

meshkernel::Mesh2D::Mesh2D ( Projection  projection)
explicit

Construct a mesh2d using only the projection.

Parameters
[in]projectionThe projection to use

◆ Mesh2D() [2/4]

meshkernel::Mesh2D::Mesh2D ( const std::vector< Edge > &  edges,
const std::vector< Point > &  nodes,
Projection  projection 
)

Construct a mesh2d starting from the edges and nodes.

Parameters
[in]edgesThe input edges
[in]nodesThe input nodes
[in]projectionThe projection to use

◆ Mesh2D() [3/4]

meshkernel::Mesh2D::Mesh2D ( const std::vector< Edge > &  edges,
const std::vector< Point > &  nodes,
const std::vector< std::vector< UInt >> &  faceNodes,
const std::vector< UInt > &  numFaceNodes,
Projection  projection 
)

Construct a mesh2d from face nodes and num face nodes.

Parameters
[in]edgesThe input edges
[in]nodesThe input nodes
[in]faceNodesThe input face nodes
[in]numFaceNodesFor each face, the number of nodes
[in]projectionThe mesh projection

◆ Mesh2D() [4/4]

meshkernel::Mesh2D::Mesh2D ( const std::vector< Point > &  nodes,
const Polygons polygons,
Projection  projection 
)

Create triangular grid from nodes (triangulatesamplestonetwork)

Parameters
[in]nodesInput nodes
[in]polygonsSelection polygon
[in]projectionThe projection to use

Member Function Documentation

◆ ComputeAspectRatios()

void meshkernel::Mesh2D::ComputeAspectRatios ( std::vector< double > &  aspectRatios)

Gets the aspect ratios (the ratios edges lengths to flow edges lengths)

Parameters
[in,out]aspectRatiosThe aspect ratios (passed as reference to avoid re-allocation)

◆ ComputeBoundaryPolygons()

std::vector<Point> meshkernel::Mesh2D::ComputeBoundaryPolygons ( const std::vector< Point > &  polygon)

Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol)

Parameters
[in]polygonThe polygon where the operation is performed
Returns
The resulting polygon mesh boundary

◆ ComputeFaceCircumenter()

Point meshkernel::Mesh2D::ComputeFaceCircumenter ( std::vector< Point > &  polygon,
const std::vector< UInt > &  edgesNumFaces 
) const

For a closed polygon, compute the circumcenter of a face (getcircumcenter)

Parameters
[in,out]polygonCache storing the face nodes
[in]edgesNumFacesFor meshes, the number of faces sharing the edges
Returns
The computed circumcenter

◆ ComputeFaceClosedPolygon()

void meshkernel::Mesh2D::ComputeFaceClosedPolygon ( UInt  faceIndex,
std::vector< Point > &  polygonNodesCache 
) const

For a face create a closed polygon.

Parameters
[in]faceIndexThe face index
[in,out]polygonNodesCacheThe cache array to be filled with the nodes values

◆ ComputeFaceClosedPolygonWithLocalMappings()

void meshkernel::Mesh2D::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)

Parameters
[in]faceIndexThe face index
[out]polygonNodesCacheThe node cache array filled with the nodes values
[out]localNodeIndicesCacheThe consecutive node index in polygonNodesCache (0, 1, 2,...)
[out]globalEdgeIndicesCacheThe edge cache array filled with the global edge indices

◆ DeleteMesh()

std::unique_ptr<UndoAction> meshkernel::Mesh2D::DeleteMesh ( const Polygons polygon,
DeleteMeshOptions  deletionOption,
bool  invertDeletion 
)

Deletes a mesh in a polygon, using several options (delnet)

Parameters
[in]polygonThe polygon where to perform the operation If this Polygons instance contains multiple polygons, the first one will be taken.
[in]deletionOptionThe deletion option
[in]invertDeletionInverts the selected node to delete (instead of outside the polygon, inside the polygon)

◆ DeleteSmallFlowEdges()

std::unique_ptr<meshkernel::UndoAction> meshkernel::Mesh2D::DeleteSmallFlowEdges ( double  smallFlowEdgesThreshold)

Deletes small flow edges (removesmallflowlinks, part 1)

An unstructured mesh can be used to calculate water flow. This involves a pressure gradient between the circumcenters of neighbouring faces. That procedure is numerically unreliable when the distance between face circumcenters (flow edges) becomes too small. Let's consider the following figure

Coincide circumcenter

The algorithm works as follow:

  • Any degenerated triangle (e.g. those having a coinciding node) is removed by collapsing the second and third node into the first one.
  • The edges crossing small flow edges are found. The flow edge length is computed from the face circumcenters and compared to an estimated cut off distance. The cutoff distance is computed using the face areas as follow:

    \(\textrm{cutOffDistance} = \textrm{threshold} \cdot 0.5 \cdot (\sqrt{\textrm{Area}_I}+\sqrt{\textrm{Area}_{II}})\)

  • All small flow edges are flagged with invalid indices and removed from the mesh. Removal occors in the Mesh2D::Administrate method.
    Parameters
    [in]smallFlowEdgesThresholdThe configurable threshold for detecting the small flow edges

◆ DeleteSmallTrianglesAtBoundaries()

std::unique_ptr<UndoAction> meshkernel::Mesh2D::DeleteSmallTrianglesAtBoundaries ( double  minFractionalAreaTriangles)

Deletes small triangles at the boundaries (removesmallflowlinks, part 2)

This algorithm removes triangles having the following properties:

  • The are at mesh boundary.
  • One or more neighboring faces are non-triangles.
  • The ratio of the face area to the average area of neighboring non triangles is less than a minimum ratio (defaults to 0.2).
  • The absolute cosine of one internal angle is less than 0.2.

These triangles having the above properties are merged by collapsing the face nodes to the node having the minimum absolute cosine (e.g. the node where the internal angle is closer to 90 degrees).

Parameters
[in]minFractionalAreaTrianglesSmall triangles at the boundaries will be eliminated. This threshold is the ration of the face area to the average area of neighboring faces.

◆ FilterBasedOnMetric()

std::vector<bool> meshkernel::Mesh2D::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 metric.

Parameters
[in]locationThe location representing the location where to filter the object.
[in]propertyThe property by which to filter locations.
[in]minValueThe minimum value of the metric for filtering.
[in]maxValueThe maximum value of the metric for filtering. @ return A vector of boolean values. Each element corresponds to a location and is true if the location's metric is within the specified range, and false otherwise.

◆ FindCommonFace()

UInt meshkernel::Mesh2D::FindCommonFace ( const UInt  edge1,
const UInt  edge2 
) const

Find the id of the element that is common to both edges.

If no such element can be found then the null value will be returned.

◆ FindFacesConnectedToNode()

void meshkernel::Mesh2D::FindFacesConnectedToNode ( UInt  nodeIndex,
std::vector< UInt > &  sharedFaces 
) const

Find all faces that have the given node as a vertex.

Parameters
[in]nodeIndexIndex of the node
[out]sharedFacesOn exit will contain only indices of faces that contain nodeIndex as a node.

◆ FindFacesGivenFaceNodesMapping()

void meshkernel::Mesh2D::FindFacesGivenFaceNodesMapping ( const std::vector< std::vector< UInt >> &  faceNodes,
const std::vector< UInt > &  numFaceNodes 
)

Find remaining face information given the face nodes mapping.

Parameters
[in]faceNodesThe input face nodes
[in]numFaceNodesFor each face, the number of nodes

◆ FindNodesSharedByFaces()

void meshkernel::Mesh2D::FindNodesSharedByFaces ( UInt  nodeIndex,
const std::vector< UInt > &  sharedFaces,
std::vector< UInt > &  connectedNodes,
std::vector< std::vector< UInt >> &  faceNodeMapping 
) const

Find all unique nodes.

Parameters
[in]nodeIndexIndex of the node
[in]sharedFacesList of faces that share the nodeIndex as a common node
[in,out]connectedNodesList of nodes that are in the patch of shared faces
[out]faceNodeMappingMapping from node index to the position in connectedNodes list.

◆ FindOppositeEdge()

UInt meshkernel::Mesh2D::FindOppositeEdge ( const UInt  faceId,
const UInt  edgeId 
) const

Find edge on the opposite side of the element.

Note
Currently only valid of quadrilateral elements. Will throw exception NotImplementedError for non-quadrilateral element shapes.

◆ GetBoundingBox()

BoundingBox meshkernel::Mesh2D::GetBoundingBox ( ) const

Get the mesh bounding box.

Returns
The mesh bounding box

◆ GetConnectingNodes()

void meshkernel::Mesh2D::GetConnectingNodes ( UInt  nodeIndex,
std::vector< UInt > &  connectedNodes 
) const

Get indices of all nodes that are connected directly to a give node along connected edges.

Parameters
[in]nodeIndexIndex of the node
[out]connectedNodes

◆ GetEdgesBoundingBoxes()

std::vector<BoundingBox> meshkernel::Mesh2D::GetEdgesBoundingBoxes ( ) const

Get the bounding boxes of the mesh edges.

Returns
The mesh edges bounding boxes

◆ GetEdgesCrossingSmallFlowEdges()

std::vector<UInt> meshkernel::Mesh2D::GetEdgesCrossingSmallFlowEdges ( double  smallFlowEdgesThreshold)

Gets the edges crossing the small flow edges.

Parameters
[in]smallFlowEdgesThresholdThe configurable threshold for detecting the small flow edges
Returns
The indices of the edges crossing small flow edges

◆ GetFlowEdgesCenters()

std::vector<Point> meshkernel::Mesh2D::GetFlowEdgesCenters ( const std::vector< UInt > &  edges) const

Gets the flow edges centers from the crossing edges.

Parameters
[in]edgesThe crossing edges indices
Returns
The centers of the flow edges

◆ GetHangingEdges()

std::vector<UInt> meshkernel::Mesh2D::GetHangingEdges ( ) const

Gets the hanging edges.

Returns
A vector with the indices of the hanging edges

◆ GetObtuseTrianglesCenters()

std::vector<Point> meshkernel::Mesh2D::GetObtuseTrianglesCenters ( )

Gets the mass centers of obtuse triangles.

Returns
The center of obtuse triangles

◆ GetOrthogonality()

std::vector<double> meshkernel::Mesh2D::GetOrthogonality ( ) const

Get the orthogonality values, the inner product of edges and segments connecting the face circumcenters.

Returns
The edge orthogonality

◆ GetSmoothness()

std::vector<double> meshkernel::Mesh2D::GetSmoothness ( ) const

Gets the smoothness values, ratios of the face areas.

Returns
The smoothness at the edges

◆ IsLeftOrRight()

UInt meshkernel::Mesh2D::IsLeftOrRight ( const UInt  elementId,
const UInt  edgeId 
) const

Determine if the element lies on the left or right side of the edge.

Returns 0 when the element is on the left and 1 when it is on the right. If one or other edge is not connected to the element then a null value will be returned.

◆ IsSegmentCrossingABoundaryEdge()

std::tuple<UInt, UInt> meshkernel::Mesh2D::IsSegmentCrossingABoundaryEdge ( const Point firstPoint,
const Point secondPoint 
) const

Inquire if a segment is crossing a face.

Parameters
[in]firstPointThe first point of the segment
[in]secondPointThe second point of the segment
Returns
A tuple with the intersectedFace face index and intersected edge index

◆ IsStartOrEnd()

UInt meshkernel::Mesh2D::IsStartOrEnd ( const UInt  edgeId,
const UInt  nodeId 
) const

Determine if the node is at the start or end of the edge.

Returns 0 when the node is at the start of the edge, 1 when it is at the end and the null value when the edge is not connected to the node.

◆ MakeDualFace()

void meshkernel::Mesh2D::MakeDualFace ( UInt  node,
double  enlargementFactor,
std::vector< Point > &  dualFace 
)

Make a dual face around the node, enlarged by a factor.

Parameters
[in]nodeThe node index
[in]enlargementFactorThe factor by which the dual face is enlarged
[out]dualFaceThe dual face to be calculated

◆ MaskEdgesOfFacesInPolygon()

std::vector<int> meshkernel::Mesh2D::MaskEdgesOfFacesInPolygon ( const Polygons polygons,
bool  invertSelection,
bool  includeIntersected 
) const

Masks the edges of all faces entirely included in all polygons.

Parameters
[in]polygonsThe selection polygon
[in]invertSelectionInvert selection
[in]includeIntersectedIncluded the edges intersected by the polygon
Returns
The edge mask

◆ Merge()

static std::unique_ptr<Mesh2D> meshkernel::Mesh2D::Merge ( const Mesh2D mesh1,
const Mesh2D mesh2 
)
static

Merges mesh connectivity.

Only merges the mesh connectivity graphs and updates indices.

Note
Does not do any administration on the node, edges or elements, it may be required to call Administrate after merging

◆ NextFace()

UInt meshkernel::Mesh2D::NextFace ( const UInt  faceId,
const UInt  edgeId 
) const

Get the next face adjacent to the edge on the opposite side.

Parameters
[in]faceIdThe starting face
[in]edgeIdThe starting edge
Returns
Id of neighbour face along the edge

◆ NodeMaskFromEdgeMask()

std::vector<int> meshkernel::Mesh2D::NodeMaskFromEdgeMask ( std::vector< int > const &  edgeMask) const

From the edge mask compute the node mask.

Parameters
[in]edgeMaskThe edge mask
Returns
The node mask

◆ NodeMaskFromPolygon()

std::vector<int> meshkernel::Mesh2D::NodeMaskFromPolygon ( const Polygons polygons,
bool  inside 
) const

Mask all nodes included in all polygons.

Parameters
[in]polygonsThe input polygon
[in]insideInside or outside option
Returns
The node mask

◆ OffsetSphericalCoordinates()

std::unique_ptr<SphericalCoordinatesOffsetAction> meshkernel::Mesh2D::OffsetSphericalCoordinates ( double  minx,
double  maxx 
)

Offset the x coordinates if m_projection is spherical.

Parameters
[in]minx
[in]maxx

◆ PointFaceIndices()

std::vector<UInt> meshkernel::Mesh2D::PointFaceIndices ( const std::vector< Point > &  points)

For a collection of points, compute the face indices including them.

Parameters
[in]pointsThe input point vector.
Returns
The face indices including the points.

◆ RestoreAction() [1/10]

void meshkernel::Mesh::RestoreAction

Undo the add edge action.

Restore mesh to state before edge was added

◆ RestoreAction() [2/10]

void meshkernel::Mesh::RestoreAction

Undo the add node action.

Restore mesh to state before node was added

◆ RestoreAction() [3/10]

void meshkernel::Mesh::RestoreAction

Undo the delete edge action.

Restore mesh to state before edge was deleted

◆ RestoreAction() [4/10]

void meshkernel::Mesh::RestoreAction

Undo the delete node action.

Restore mesh to state before node was deleted

◆ RestoreAction() [5/10]

void meshkernel::Mesh::RestoreAction

Undo the reset edge action.

Restore mesh to state before edge was reset

◆ RestoreAction() [6/10]

void meshkernel::Mesh::RestoreAction

Undo the reset node action.

Restore mesh to state before node was reset

◆ RestoreAction() [7/10]

void meshkernel::Mesh2D::RestoreAction ( const SphericalCoordinatesOffsetAction &  undoAction)

Undo the coordinate offset action.

Restore mesh to state before coordinate offset action was applied

◆ RestoreAction() [8/10]

void meshkernel::Mesh::RestoreAction

Undo entire node and edge values.

Restore mesh to previous state.

◆ RestoreAction() [9/10]

void meshkernel::Mesh::RestoreAction

Undo the node translation action.

Restore mesh to state before node was translated

◆ RestoreAction() [10/10]

void meshkernel::Mesh::RestoreAction

Undo the node translation action.

Restore mesh to state before node was translated

◆ SortedFacesAroundNode()

std::vector<UInt> meshkernel::Mesh2D::SortedFacesAroundNode ( UInt  node) const

Sorts the faces around a node, sorted in counter clock wise order.

Parameters
[in]nodeThe node index
Returns
The face indexses

◆ WalkBoundaryFromNode()

void meshkernel::Mesh2D::WalkBoundaryFromNode ( const Polygon polygon,
std::vector< bool > &  isVisited,
UInt currentNode,
std::vector< Point > &  meshBoundaryPolygon 
) const

Constructs a polygon from the meshboundary, by walking through the mesh.

Parameters
[in]polygonThe input polygon
[in,out]isVisitedthe visited mesh nodes
[in,out]currentNodethe current node
[out]meshBoundaryPolygonThe resulting polygon points

The documentation for this class was generated from the following file: