MeshKernel
Mesh.hpp
1 //---- GPL ---------------------------------------------------------------------
2 //
3 // Copyright (C) Stichting Deltares, 2011-2021.
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation version 3.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // contact: delft3d.support@deltares.nl
18 // Stichting Deltares
19 // P.O. Box 177
20 // 2600 MH Delft, The Netherlands
21 //
22 // All indications and logos of, and references to, "Delft3D" and "Deltares"
23 // are registered trademarks of Stichting Deltares, and remain the property of
24 // Stichting Deltares. All rights reserved.
25 //
26 //------------------------------------------------------------------------------
27 
28 #pragma once
29 #include <memory>
30 
31 #include "MeshKernel/BoundingBox.hpp"
32 #include "MeshKernel/Definitions.hpp"
33 #include "MeshKernel/Entities.hpp"
34 #include "MeshKernel/Exceptions.hpp"
35 #include "MeshKernel/UndoActions/AddEdgeAction.hpp"
36 #include "MeshKernel/UndoActions/AddNodeAction.hpp"
37 #include "MeshKernel/UndoActions/CompoundUndoAction.hpp"
38 #include "MeshKernel/UndoActions/DeleteEdgeAction.hpp"
39 #include "MeshKernel/UndoActions/DeleteNodeAction.hpp"
40 #include "MeshKernel/UndoActions/FullUnstructuredGridUndo.hpp"
41 #include "MeshKernel/UndoActions/MeshConversionAction.hpp"
42 #include "MeshKernel/UndoActions/NodeTranslationAction.hpp"
43 #include "MeshKernel/UndoActions/ResetEdgeAction.hpp"
44 #include "MeshKernel/UndoActions/ResetNodeAction.hpp"
45 #include "MeshKernel/UndoActions/UndoAction.hpp"
46 #include "Utilities/RTreeBase.hpp"
47 
50 namespace meshkernel
51 {
52  class Polygons;
53 
98  class Mesh
99  {
100  public:
102  enum class Type
103  {
104  Mesh1D,
105  Mesh2D
106  };
107 
109  virtual ~Mesh() = default;
110 
112  Mesh();
113 
115  Mesh& operator=(const Mesh& mesh) = delete;
116 
118  Mesh& operator=(Mesh&& mesh) = delete;
119 
121  Mesh(const Mesh& mesh) = delete;
122 
124  Mesh(Mesh&& mesh) = delete;
125 
128  explicit Mesh(Projection projection);
129 
134  Mesh(const std::vector<Edge>& edges,
135  const std::vector<Point>& nodes,
136  Projection projection);
137 
141  [[nodiscard]] bool IsNodeOnBoundary(UInt node) const { return m_nodesNumEdges[node] == 1; }
142 
145  [[nodiscard]] auto GetNumNodes() const { return static_cast<UInt>(m_nodes.size()); }
146 
149  [[nodiscard]] auto GetNumEdges() const { return static_cast<UInt>(m_edges.size()); }
150 
153  [[nodiscard]] auto GetNumFaces() const { return static_cast<UInt>(m_facesNodes.size()); }
154 
157  [[nodiscard]] UInt GetNumValidNodes() const;
158 
161  [[nodiscard]] UInt GetNumValidEdges() const;
162 
166  [[nodiscard]] auto GetNumFaceEdges(UInt faceIndex) const { return m_numFacesNodes[faceIndex]; }
167 
171  [[nodiscard]] auto GetNumEdgesFaces(UInt edgeIndex) const { return m_edgesNumFaces[edgeIndex]; }
172 
174  // TODO add unit test and with all failing cases
175  [[nodiscard]] UInt GetEdgeIndex(const UInt elementId, const UInt edgeId) const;
176 
178  // TODO add unit test and with all failing cases
179  [[nodiscard]] UInt GetNodeIndex(const UInt elementId, const UInt nodeId) const;
180 
184  [[nodiscard]] bool IsEdgeOnBoundary(UInt edge) const { return m_edgesNumFaces[edge] == 1; }
185 
189  [[nodiscard]] bool IsFaceOnBoundary(UInt face) const;
190 
192  // TODO Can this be removed?
193  const std::vector<Point>& Nodes() const;
194 
196  const Point& Node(const UInt index) const;
197 
199  void SetNodes(const std::vector<Point>& newValues);
200 
202  void SetNode(const UInt index, const Point& newValue);
203 
205  [[nodiscard]] std::unique_ptr<ResetNodeAction> ResetNode(const UInt index, const Point& newValue);
206 
208  // TODO get rid of this function
209  const std::vector<Edge>& Edges() const;
210 
212  const Edge& GetEdge(const UInt index) const;
213 
215  void SetEdges(const std::vector<Edge>& newValues);
216 
218  void SetEdge(const UInt index, const Edge& edge);
219 
221  [[nodiscard]] std::unique_ptr<ResetEdgeAction> ResetEdge(UInt edgeId, const Edge& edge);
222 
226  UInt GetLocalFaceNodeIndex(const UInt faceIndex, const UInt nodeIndex) const;
227 
231  [[nodiscard]] std::unique_ptr<UndoAction> MergeTwoNodes(UInt startNode, UInt endNode);
232 
236  [[nodiscard]] std::unique_ptr<UndoAction> MergeNodesInPolygon(const Polygons& polygons, double mergingDistance);
237 
241  [[nodiscard]] std::tuple<UInt, std::unique_ptr<AddNodeAction>> InsertNode(const Point& newPoint);
242 
248  [[nodiscard]] std::tuple<UInt, std::unique_ptr<AddEdgeAction>> ConnectNodes(UInt startNode, UInt endNode);
249 
253  [[nodiscard]] std::unique_ptr<DeleteNodeAction> DeleteNode(UInt node);
254 
259  [[nodiscard]] UInt FindEdge(UInt firstNodeIndex, UInt secondNodeIndex) const;
260 
265  [[nodiscard]] UInt FindEdgeWithLinearSearch(UInt firstNodeIndex, UInt secondNodeIndex) const;
266 
270  [[nodiscard]] std::unique_ptr<UndoAction> MoveNode(Point newPoint, UInt nodeindex);
271 
278  [[nodiscard]] UInt FindLocationIndex(Point point,
279  Location location,
280  const std::vector<bool>& locationMask = {},
281  const BoundingBox& boundingBox = {});
282 
287  [[nodiscard]] UInt FindNodeCloseToAPoint(Point const& point, double searchRadius);
288 
292  [[nodiscard]] std::unique_ptr<DeleteEdgeAction> DeleteEdge(UInt edge);
293 
299  [[nodiscard]] UInt FindCommonNode(UInt firstEdgeIndex, UInt secondEdgeIndex) const;
300 
302  void ComputeEdgesLengths();
303 
308  [[nodiscard]] double ComputeMinEdgeLength(const Polygons& polygon) const;
309 
311  void ComputeEdgesCenters();
312 
315  bool NodeAdministration();
316 
319 
321  virtual void Administrate(CompoundUndoAction* undoAction = nullptr);
322 
324  void AdministrateNodesEdges(CompoundUndoAction* undoAction = nullptr);
325 
329  void SortEdgesInCounterClockWiseOrder(UInt startNode, UInt endNode);
330 
335 
339  void BuildTree(Location location, const BoundingBox& boundingBox = {});
340 
345  [[nodiscard]] std::vector<Point> ComputeLocations(Location location) const;
346 
351  [[nodiscard]] std::vector<bool> IsLocationInPolygon(const Polygons& polygon, Location location) const;
352 
357  Mesh& operator+=(Mesh const& rhs);
358 
363  std::unique_ptr<UndoAction> Join(const Mesh& rhs);
364 
366  std::vector<UInt> GetValidNodeMapping() const;
367 
369  std::vector<UInt> GetValidEdgeMapping() const;
370 
377  bool IsValidEdge(const UInt edgeId) const;
378 
380  void CommitAction(const ResetNodeAction& undoAction);
381 
383  void CommitAction(const AddNodeAction& undoAction);
384 
386  void CommitAction(const AddEdgeAction& undoAction);
387 
389  void CommitAction(const ResetEdgeAction& undoAction);
390 
392  void CommitAction(const DeleteNodeAction& undoAction);
393 
395  void CommitAction(NodeTranslationAction& undoAction);
396 
398  void CommitAction(MeshConversionAction& undoAction);
399 
401  void CommitAction(const DeleteEdgeAction& undoAction);
402 
404  void CommitAction(FullUnstructuredGridUndo& undoAction);
405 
409  void RestoreAction(const ResetNodeAction& undoAction);
410 
414  void RestoreAction(const AddNodeAction& undoAction);
415 
419  void RestoreAction(const AddEdgeAction& undoAction);
420 
424  void RestoreAction(const ResetEdgeAction& undoAction);
425 
429  void RestoreAction(const DeleteNodeAction& undoAction);
430 
434  void RestoreAction(NodeTranslationAction& undoAction);
435 
439  void RestoreAction(MeshConversionAction& undoAction);
440 
444  void RestoreAction(const DeleteEdgeAction& undoAction);
445 
449  void RestoreAction(FullUnstructuredGridUndo& undoAction);
450 
452  RTreeBase& GetRTree(Location location) const { return *m_RTrees.at(location); }
453 
456  void SetNodesRTreeRequiresUpdate(bool value) { m_nodesRTreeRequiresUpdate = value; }
457 
460  void SetEdgesRTreeRequiresUpdate(bool value) { m_edgesRTreeRequiresUpdate = value; }
461 
464  void SetFacesRTreeRequiresUpdate(bool value) { m_facesRTreeRequiresUpdate = value; }
465 
466  // nodes
467  std::vector<std::vector<UInt>> m_nodesEdges;
468  std::vector<UInt> m_nodesNumEdges;
469  std::vector<std::vector<UInt>> m_nodesNodes;
470  std::vector<int> m_nodesTypes;
471 
472  // edges
473  std::vector<std::array<UInt, 2>> m_edgesFaces;
474  std::vector<UInt> m_edgesNumFaces;
475  std::vector<double> m_edgeLengths;
476  std::vector<Point> m_edgesCenters;
477 
478  // faces
479  std::vector<std::vector<UInt>> m_facesNodes;
480  std::vector<UInt> m_numFacesNodes;
481  std::vector<std::vector<UInt>> m_facesEdges;
482  std::vector<Point> m_facesCircumcenters;
483  std::vector<Point> m_facesMassCenters;
484  std::vector<double> m_faceArea;
485 
487 
488  // constants
489  static constexpr UInt m_maximumNumberOfEdgesPerNode = 16;
490  static constexpr UInt m_maximumNumberOfEdgesPerFace = 6;
491  static constexpr UInt m_maximumNumberOfNodesPerFace = 6;
493 
494  protected:
496  bool AdministrationRequired() const;
497 
499  void SetAdministrationRequired(const bool value);
500 
501  // Make private
502  std::vector<Point> m_nodes;
503  std::vector<Edge> m_edges;
504 
505  private:
506  static double constexpr m_minimumDeltaCoordinate = 1e-14;
507 
508  // RTrees
509  bool m_nodesRTreeRequiresUpdate = true;
510  bool m_edgesRTreeRequiresUpdate = true;
511  bool m_facesRTreeRequiresUpdate = true;
512  bool m_administrationRequired = true;
513  std::unordered_map<Location, std::unique_ptr<RTreeBase>> m_RTrees;
514  BoundingBox m_boundingBoxCache;
515 
517  void SetUnConnectedNodesAndEdgesToInvalid(CompoundUndoAction* undoAction);
518 
523  void FindConnectedNodes(std::vector<bool>& connectedNodes,
524  UInt& numInvalidEdges) const;
525 
527  void InvalidateUnConnectedNodes(const std::vector<bool>& connectedNodes,
528  UInt& numInvalidNodes,
529  CompoundUndoAction* undoAction = nullptr);
530  };
531 } // namespace meshkernel
532 
533 inline const std::vector<meshkernel::Point>& meshkernel::Mesh::Nodes() const
534 {
535  return m_nodes;
536 }
537 
538 inline const meshkernel::Point& meshkernel::Mesh::Node(const UInt index) const
539 {
540  if (index >= GetNumNodes())
541  {
542  throw ConstraintError("The node index, {}, is not in range.", index);
543  }
544 
545  return m_nodes[index];
546 }
547 
548 inline void meshkernel::Mesh::SetNodes(const std::vector<Point>& newValues)
549 {
550  m_nodes = newValues;
551  m_nodesRTreeRequiresUpdate = true;
552  m_edgesRTreeRequiresUpdate = true;
553  m_facesRTreeRequiresUpdate = true;
554  m_administrationRequired = true;
555 }
556 
557 inline const meshkernel::Edge& meshkernel::Mesh::GetEdge(const UInt index) const
558 {
559  if (index >= GetNumEdges())
560  {
561  throw ConstraintError("The edge index, {}, is not in range.", index);
562  }
563 
564  return m_edges[index];
565 }
566 
567 inline void meshkernel::Mesh::SetEdge(const UInt index, const Edge& edge)
568 {
569  if (index >= GetNumEdges())
570  {
571  throw ConstraintError("The edge index, {}, is not in range.", index);
572  }
573 
574  m_administrationRequired = true;
575  m_edges[index] = edge;
576 }
577 
578 inline const std::vector<meshkernel::Edge>& meshkernel::Mesh::Edges() const
579 {
580  return m_edges;
581 }
582 
583 inline void meshkernel::Mesh::SetEdges(const std::vector<Edge>& newValues)
584 {
585  m_edges = newValues;
586  m_nodesRTreeRequiresUpdate = true;
587  m_edgesRTreeRequiresUpdate = true;
588  m_facesRTreeRequiresUpdate = true;
589  m_administrationRequired = true;
590 }
591 
593 {
594  return m_administrationRequired;
595 }
meshkernel::Mesh::m_edgesCenters
std::vector< Point > m_edgesCenters
The edges centers.
Definition: Mesh.hpp:476
meshkernel::Mesh::FindCommonNode
UInt FindCommonNode(UInt firstEdgeIndex, UInt secondEdgeIndex) const
Find the common node two edges share This method uses return parameters since the success is evaluate...
meshkernel::Mesh::DeleteEdge
std::unique_ptr< DeleteEdgeAction > DeleteEdge(UInt edge)
Deletes an edge.
meshkernel::Projection
Projection
Enumerator describing the supported projections.
Definition: Definitions.hpp:41
meshkernel::Mesh::m_edgesFaces
std::vector< std::array< UInt, 2 > > m_edgesFaces
For each edge, the shared face index (lne)
Definition: Mesh.hpp:473
meshkernel::Mesh::SortEdgesInCounterClockWiseOrder
void SortEdgesInCounterClockWiseOrder(UInt startNode, UInt endNode)
Sort mesh edges around a node in counterclockwise order (Sort_links_ccw)
meshkernel::Mesh::Edges
const std::vector< Edge > & Edges() const
Get all edges.
Definition: Mesh.hpp:578
meshkernel::Mesh::Join
std::unique_ptr< UndoAction > Join(const Mesh &rhs)
Add meshes: result is a mesh composed of the additions firstMesh += secondmesh results in the second ...
meshkernel::Mesh::GetValidEdgeMapping
std::vector< UInt > GetValidEdgeMapping() const
Get the mapping/indexing from the edge array mapped to valid edges.
meshkernel::Mesh::SetEdge
void SetEdge(const UInt index, const Edge &edge)
Set the edge to a new value, bypassing the undo action.
Definition: Mesh.hpp:567
meshkernel::Mesh::m_faceArea
std::vector< double > m_faceArea
The face area.
Definition: Mesh.hpp:484
meshkernel::Mesh::ComputeMinEdgeLength
double ComputeMinEdgeLength(const Polygons &polygon) const
Compute the minimum edge length of the edges included in the polygon. An edge is considered included ...
meshkernel::Mesh::DeleteInvalidNodesAndEdges
void DeleteInvalidNodesAndEdges()
Removes all invalid nodes and edges.
meshkernel::Mesh::IsLocationInPolygon
std::vector< bool > IsLocationInPolygon(const Polygons &polygon, Location location) const
Computes if a location is in polygon.
meshkernel::Mesh::Nodes
const std::vector< Point > & Nodes() const
Get vector of all nodes.
Definition: Mesh.hpp:533
meshkernel::Mesh::GetEdgeIndex
UInt GetEdgeIndex(const UInt elementId, const UInt edgeId) const
Get the local edge number for an element edge.
meshkernel::Mesh::m_nodesNumEdges
std::vector< UInt > m_nodesNumEdges
For each node, the number of connected edges (nmk)
Definition: Mesh.hpp:468
meshkernel::Mesh::RestoreAction
void RestoreAction(const ResetNodeAction &undoAction)
Undo the reset node action.
meshkernel::Mesh::m_maximumNumberOfConnectedNodes
static constexpr UInt m_maximumNumberOfConnectedNodes
Maximum number of connected nodes.
Definition: Mesh.hpp:492
meshkernel::Mesh::m_edges
std::vector< Edge > m_edges
The edges, defined as first and second node(kn)
Definition: Mesh.hpp:503
meshkernel::Mesh::Administrate
virtual void Administrate(CompoundUndoAction *undoAction=nullptr)
Perform complete administration.
meshkernel::Mesh::m_facesCircumcenters
std::vector< Point > m_facesCircumcenters
The face circumcenters the face circumcenter (xz, yz)
Definition: Mesh.hpp:482
meshkernel::Mesh::SetNodesRTreeRequiresUpdate
void SetNodesRTreeRequiresUpdate(bool value)
Set the m_nodesRTreeRequiresUpdate flag.
Definition: Mesh.hpp:456
meshkernel::Mesh::GetNumNodes
auto GetNumNodes() const
Get the number of valid nodes.
Definition: Mesh.hpp:145
meshkernel::Mesh::Mesh
Mesh()
Default constructor, setting a cartesian projection.
meshkernel::Mesh2D
A class derived from Mesh, which describes unstructures 2d meshes.
Definition: Mesh2D.hpp:55
meshkernel::Mesh::Type
Type
Enumerator describing the different mesh types.
Definition: Mesh.hpp:102
meshkernel::Mesh::ComputeEdgesCenters
void ComputeEdgesCenters()
Computes the edges centers in one go.
meshkernel::Mesh::IsValidEdge
bool IsValidEdge(const UInt edgeId) const
Indicate if the edge-id is a valid edge.
meshkernel::BoundingBox
A class defining a bounding box.
Definition: BoundingBox.hpp:39
meshkernel::Mesh::ResetEdge
std::unique_ptr< ResetEdgeAction > ResetEdge(UInt edgeId, const Edge &edge)
Change the nodes referenced by the edge.
meshkernel::Mesh::~Mesh
virtual ~Mesh()=default
Define virtual destructor.
meshkernel::Mesh::SetAdministrationRequired
void SetAdministrationRequired(const bool value)
Determine if a administration is required.
meshkernel::Mesh::m_maximumNumberOfEdgesPerNode
static constexpr UInt m_maximumNumberOfEdgesPerNode
Maximum number of edges per node.
Definition: Mesh.hpp:489
meshkernel::Point
A struct describing a point in a two-dimensional space.
Definition: Point.hpp:40
meshkernel::Mesh::ComputeMaxLengthSurroundingEdges
double ComputeMaxLengthSurroundingEdges(UInt node)
Compute the max length of the edges connected to a node.
meshkernel::Mesh::GetNumFaceEdges
auto GetNumFaceEdges(UInt faceIndex) const
Get the number of edges for a face.
Definition: Mesh.hpp:166
meshkernel::Mesh::m_numFacesNodes
std::vector< UInt > m_numFacesNodes
The number of nodes composing the face (netcellN)
Definition: Mesh.hpp:480
meshkernel::Mesh::BuildTree
void BuildTree(Location location, const BoundingBox &boundingBox={})
Build the rtree for the corresponding location, using only the locations inside the bounding box.
meshkernel::Mesh::ComputeEdgesLengths
void ComputeEdgesLengths()
Compute the lengths of all edges in one go.
meshkernel::Mesh::NodeAdministration
bool NodeAdministration()
Node administration (setnodadmin)
meshkernel::Mesh::MergeNodesInPolygon
std::unique_ptr< UndoAction > MergeNodesInPolygon(const Polygons &polygons, double mergingDistance)
Merge close mesh nodes inside a polygon (MERGENODESINPOLYGON)
meshkernel::Location
Location
Mesh locations enumeration.
Definition: Definitions.hpp:74
meshkernel::Mesh::m_edgeLengths
std::vector< double > m_edgeLengths
The edge lengths.
Definition: Mesh.hpp:475
meshkernel::Mesh::Node
const Point & Node(const UInt index) const
Get the node at the position.
Definition: Mesh.hpp:538
meshkernel::Mesh::GetEdge
const Edge & GetEdge(const UInt index) const
Get constant reference to an edge.
Definition: Mesh.hpp:557
meshkernel::Mesh::AdministrationRequired
bool AdministrationRequired() const
Determine if a administration is required.
Definition: Mesh.hpp:592
meshkernel::Mesh::GetNumValidEdges
UInt GetNumValidEdges() const
Get the number of valid edges.
meshkernel::Mesh::IsEdgeOnBoundary
bool IsEdgeOnBoundary(UInt edge) const
Inquire if an edge is on boundary.
Definition: Mesh.hpp:184
meshkernel::Mesh::m_facesEdges
std::vector< std::vector< UInt > > m_facesEdges
The edge indices composing the face (netcelllin)
Definition: Mesh.hpp:481
meshkernel::Mesh::MergeTwoNodes
std::unique_ptr< UndoAction > MergeTwoNodes(UInt startNode, UInt endNode)
Merges two mesh nodes.
meshkernel::Mesh::SetNodes
void SetNodes(const std::vector< Point > &newValues)
Set all nodes to a new set of values.
Definition: Mesh.hpp:548
meshkernel::Mesh::GetNumValidNodes
UInt GetNumValidNodes() const
Get the number of valid nodes.
meshkernel::Mesh::SetFacesRTreeRequiresUpdate
void SetFacesRTreeRequiresUpdate(bool value)
Set the m_facesRTreeRequiresUpdate flag.
Definition: Mesh.hpp:464
meshkernel::Mesh::MoveNode
std::unique_ptr< UndoAction > MoveNode(Point newPoint, UInt nodeindex)
Move a node to a new location.
meshkernel::Mesh::IsNodeOnBoundary
bool IsNodeOnBoundary(UInt node) const
Inquire if a node is on boundary.
Definition: Mesh.hpp:141
meshkernel::Mesh::m_projection
Projection m_projection
The projection used.
Definition: Mesh.hpp:486
meshkernel::Mesh::m_facesMassCenters
std::vector< Point > m_facesMassCenters
The faces centers of mass (xzw, yzw)
Definition: Mesh.hpp:483
meshkernel::Mesh::SetEdges
void SetEdges(const std::vector< Edge > &newValues)
Set all edges to a new set of values.
Definition: Mesh.hpp:583
meshkernel::Mesh::FindEdgeWithLinearSearch
UInt FindEdgeWithLinearSearch(UInt firstNodeIndex, UInt secondNodeIndex) const
Find the edge using a linear search, without connectivity information (much slower than FindEdge)
meshkernel::Mesh::GetNodeIndex
UInt GetNodeIndex(const UInt elementId, const UInt nodeId) const
Get the local node number for an element node.
meshkernel::Mesh::FindEdge
UInt FindEdge(UInt firstNodeIndex, UInt secondNodeIndex) const
Find the edge sharing two nodes.
meshkernel::Mesh::IsFaceOnBoundary
bool IsFaceOnBoundary(UInt face) const
Inquire if a face is on boundary.
meshkernel::Mesh::GetNumEdgesFaces
auto GetNumEdgesFaces(UInt edgeIndex) const
Get the number of faces an edges shares.
Definition: Mesh.hpp:171
meshkernel
Contains the logic of the C++ static library.
Definition: AveragingInterpolation.hpp:36
meshkernel::Mesh::m_edgesNumFaces
std::vector< UInt > m_edgesNumFaces
For each edge, the number of shared faces(lnn)
Definition: Mesh.hpp:474
meshkernel::Mesh::m_nodesNodes
std::vector< std::vector< UInt > > m_nodesNodes
For each node, its neighbors.
Definition: Mesh.hpp:469
meshkernel::Mesh::GetNumFaces
auto GetNumFaces() const
Get the number of valid faces.
Definition: Mesh.hpp:153
meshkernel::Mesh::m_maximumNumberOfNodesPerFace
static constexpr UInt m_maximumNumberOfNodesPerFace
Maximum number of nodes per face.
Definition: Mesh.hpp:491
meshkernel::Mesh::ResetNode
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.
meshkernel::Mesh::FindNodeCloseToAPoint
UInt FindNodeCloseToAPoint(Point const &point, double searchRadius)
Get the index of a node close to a point.
meshkernel::UInt
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition: Definitions.hpp:38
meshkernel::Mesh::DeleteNode
std::unique_ptr< DeleteNodeAction > DeleteNode(UInt node)
Deletes a node and removes any connected edges.
meshkernel::Mesh::AdministrateNodesEdges
void AdministrateNodesEdges(CompoundUndoAction *undoAction=nullptr)
Perform node and edges administration.
meshkernel::Polygons
A class containing a list of polygonaly enclosed regions.
Definition: Polygons.hpp:44
meshkernel::Mesh::GetValidNodeMapping
std::vector< UInt > GetValidNodeMapping() const
Get the mapping/indexing from the node array mapped to valid nodes.
meshkernel::Edge
std::pair< UInt, UInt > Edge
Describes an edge with two indices.
Definition: Entities.hpp:50
meshkernel::Mesh::GetRTree
RTreeBase & GetRTree(Location location) const
Get a reference to the RTree for a specific location.
Definition: Mesh.hpp:452
meshkernel::Mesh::GetLocalFaceNodeIndex
UInt GetLocalFaceNodeIndex(const UInt faceIndex, const UInt nodeIndex) const
Get the local index of the node belong to a face.
meshkernel::Mesh::m_maximumNumberOfEdgesPerFace
static constexpr UInt m_maximumNumberOfEdgesPerFace
Maximum number of edges per face.
Definition: Mesh.hpp:490
meshkernel::Mesh::CommitAction
void CommitAction(const ResetNodeAction &undoAction)
Apply the reset node action.
meshkernel::Mesh::SetNode
void SetNode(const UInt index, const Point &newValue)
Set a node to a new value, bypassing the undo action.
meshkernel::Mesh::operator+=
Mesh & operator+=(Mesh const &rhs)
Add meshes: result is a mesh composed of the additions firstMesh += secondmesh results in the second ...
meshkernel::Mesh::FindLocationIndex
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.
meshkernel::Mesh::ConnectNodes
std::tuple< UInt, std::unique_ptr< AddEdgeAction > > ConnectNodes(UInt startNode, UInt endNode)
Connect two existing nodes, checking if the nodes are already connected. If the nodes are not connect...
meshkernel::Mesh::m_nodes
std::vector< Point > m_nodes
The mesh nodes (xk, yk)
Definition: Mesh.hpp:502
meshkernel::Mesh::InsertNode
std::tuple< UInt, std::unique_ptr< AddNodeAction > > InsertNode(const Point &newPoint)
Insert a new node in the mesh (setnewpoint)
meshkernel::Mesh::operator=
Mesh & operator=(const Mesh &mesh)=delete
Delete assignment operator.
meshkernel::Mesh::m_nodesTypes
std::vector< int > m_nodesTypes
The node types (nb)
Definition: Mesh.hpp:470
meshkernel::Mesh::ComputeLocations
std::vector< Point > ComputeLocations(Location location) const
Computes a vector with the mesh locations coordinates (nodes, edges or faces coordinates).
meshkernel::ConstraintError
An exception class thrown when an attempt is made that violates a range constraint.
Definition: Exceptions.hpp:266
meshkernel::Mesh::SetEdgesRTreeRequiresUpdate
void SetEdgesRTreeRequiresUpdate(bool value)
Set the m_edgesRTreeRequiresUpdate flag.
Definition: Mesh.hpp:460
meshkernel::Mesh
A class describing an unstructured mesh. This class contains the shared functionality between 1d or 2...
Definition: Mesh.hpp:98
meshkernel::Mesh::m_nodesEdges
std::vector< std::vector< UInt > > m_nodesEdges
For each node, the indices of connected edges (nodlin)
Definition: Mesh.hpp:467
meshkernel::Mesh::Type::Mesh1D
@ Mesh1D
Mesh1D.
meshkernel::Mesh::m_facesNodes
std::vector< std::vector< UInt > > m_facesNodes
The nodes composing the faces, in ccw order (netcellNod)
Definition: Mesh.hpp:479
meshkernel::Mesh::GetNumEdges
auto GetNumEdges() const
Get the number of valid edges.
Definition: Mesh.hpp:149