Loading [MathJax]/extensions/tex2jax.js
MeshKernel
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages Concepts
LandBoundaries.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
30#include <memory>
31
32#include <MeshKernel/Entities.hpp>
33#include <MeshKernel/LandBoundary.hpp>
34#include <MeshKernel/UndoActions/UndoAction.hpp>
35
36#include <memory>
37
38namespace meshkernel
39{
40 class Polygons;
41 class Mesh2D;
42
50 {
51
52 public:
55 {
56 DoNotProjectToLandBoundary = 0,
57 ToOriginalNetBoundary = 1,
58 OuterMeshBoundaryToLandBoundary = 2,
59 InnerAndOuterMeshBoundaryToLandBoundary = 3,
60 WholeMesh = 4
61 };
62
64 LandBoundaries() = default;
65
69 LandBoundaries(const std::vector<Point>& landBoundary,
70 Mesh2D& mesh);
71
76 LandBoundaries(const std::vector<Point>& landBoundary,
77 Mesh2D& mesh,
78 const Polygons& polygons);
79
87
90 void FindNearestMeshBoundary(ProjectToLandBoundaryOption projectToLandBoundaryOption);
91
93 [[nodiscard]] std::unique_ptr<UndoAction> SnapMeshToLandBoundaries() const;
94
97 auto GetNumNodes() const { return m_landBoundary.GetNumNodes(); }
98
100
101 private:
107 void AssignLandBoundaryPolylineToMeshNodes(UInt edgeIndex,
108 bool initialize,
109 const std::vector<UInt>& nodes,
110 UInt numNodes);
111
116 void AddLandBoundary(const std::vector<UInt>& nodesLoc,
117 UInt numNodesLoc,
118 UInt nodeIndex);
119
127 bool MakePath(UInt landBoundaryIndex, UInt& numNodesInPath, UInt& numRejectedNodesInPath);
128
131 void ComputeMeshNodeMask(UInt landBoundaryIndex);
132
144 void ComputeMask(UInt segmentIndex,
145 bool meshBoundOnly,
146 UInt startLandBoundaryIndex,
147 UInt endLandBoundaryIndex,
148 UInt& leftIndex,
149 UInt& rightIndex,
150 double& leftEdgeRatio,
151 double& rightEdgeRatio);
152
156 void MaskMeshFaceMask(UInt landBoundaryIndex, const std::vector<UInt>& initialFaces);
157
162 [[nodiscard]] UInt IsMeshEdgeCloseToLandBoundaries(UInt landBoundaryIndex, UInt edge);
163
170 std::tuple<UInt, UInt> FindStartEndMeshNodesDijkstraAlgorithm(UInt landBoundaryIndex);
171
177 UInt FindStartEndMeshNodesFromEdges(UInt edge, Point point) const;
178
183 std::vector<UInt> ShortestPath(UInt landBoundaryIndex, UInt startMeshNode);
184
190 std::tuple<double, Point, UInt, double> NearestLandBoundarySegment(UInt landBoundaryIndex, const Point& node) const;
191
195 bool InitialiseNodeLocations(const bool initialize,
196 const UInt edgeIndex,
197 const std::vector<UInt>& nodes,
198 const UInt numNodes,
199 std::vector<UInt>& nodesLoc,
200 UInt& numNodesLoc) const;
201
203 UInt GetSegmentIndex(const UInt nearestLandBoundaryNodeIndex) const;
204
206 bool StopPathSearch(const UInt landBoundaryIndex, const UInt currentNode);
207
209 bool ContainsCrossedFace(const UInt landBoundaryIndex, const UInt otherFace);
210
212 void MaskFacesCloseToBoundary(const UInt landBoundaryIndex);
213
215 void GetLandBoundaryNode(const double closeDistance,
216 const Point& firstMeshNode,
217 const Point& secondMeshNode,
218 const UInt currentNode,
219 UInt& landBoundaryNode,
220 bool& isWithinSegment) const;
221
222 Mesh2D& m_mesh;
223 const Polygons m_polygons;
224 LandBoundary m_landBoundary;
225 std::vector<Point> m_polygonNodesCache;
226 std::vector<std::pair<UInt, UInt>> m_validLandBoundaries;
227 std::vector<UInt> m_nodeFaceIndices;
228
229 std::vector<UInt> m_nodeMask;
230 std::vector<bool> m_faceMask;
231 std::vector<UInt> m_edgeMask;
232
233 bool m_landMask = true;
234 bool m_addLandboundaries = true;
235
236 // caches
237 std::vector<double> m_nodesMinDistances;
238
239 // Parameters
240 const double m_closeToLandBoundaryFactor = 5.0;
241 const double m_closeWholeMeshFactor = 1.0;
242 const double m_minDistanceFromLandFactor = 2.0;
243
244 // findOnlyOuterMeshBoundary
245 bool m_findOnlyOuterMeshBoundary = false;
246 };
247
248} // namespace meshkernel
A class describing land boundaries. These are used to visualise the land-water interface.
Definition LandBoundaries.hpp:50
std::unique_ptr< UndoAction > SnapMeshToLandBoundaries() const
Snap the mesh nodes to land boundaries (snap_to_landboundary)
auto GetNumNodes() const
Gets the number of land boundary nodes.
Definition LandBoundaries.hpp:97
LandBoundaries(const std::vector< Point > &landBoundary, Mesh2D &mesh, const Polygons &polygons)
Default constructor.
LandBoundaries()=default
Default constructor.
std::vector< UInt > m_meshNodesLandBoundarySegments
Mesh nodes to land boundary mapping (lanseg_map)
Definition LandBoundaries.hpp:99
void Administrate()
The portion of the boundary segments close enough to the mesh boundary are flagged (admin_landboundar...
LandBoundaries(const std::vector< Point > &landBoundary, Mesh2D &mesh)
Constructor.
void FindNearestMeshBoundary(ProjectToLandBoundaryOption projectToLandBoundaryOption)
Find the mesh boundary line closest to the land boundary (find_nearest_meshline).
ProjectToLandBoundaryOption
Enumerator describing the options how to project to the land boundary.
Definition LandBoundaries.hpp:55
A class containing the land boundary polylines.
Definition LandBoundary.hpp:40
size_t GetNumNodes() const
Gets the number of land boundary nodes.
Definition LandBoundary.hpp:94
A class derived from Mesh, which describes unstructures 2d meshes.
Definition Mesh2D.hpp:58
A struct describing a point in a two-dimensional space.
Definition Point.hpp:41
A class containing a list of polygonaly enclosed regions.
Definition Polygons.hpp:45
Contains the logic of the C++ static library.
Definition AveragingInterpolation.hpp:37
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition Definitions.hpp:39