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
70 LandBoundaries(const std::vector<Point>& landBoundary,
71 Mesh2D& mesh,
72 const Polygons& polygons);
73
81
84 void FindNearestMeshBoundary(ProjectToLandBoundaryOption projectToLandBoundaryOption);
85
87 [[nodiscard]] std::unique_ptr<UndoAction> SnapMeshToLandBoundaries() const;
88
91 auto GetNumNodes() const { return m_landBoundary.GetNumNodes(); }
92
94
95 private:
101 void AssignLandBoundaryPolylineToMeshNodes(UInt edgeIndex,
102 bool initialize,
103 const std::vector<UInt>& nodes,
104 UInt numNodes);
105
110 void AddLandBoundary(const std::vector<UInt>& nodesLoc,
111 UInt numNodesLoc,
112 UInt nodeIndex);
113
121 bool MakePath(UInt landBoundaryIndex, UInt& numNodesInPath, UInt& numRejectedNodesInPath);
122
125 void ComputeMeshNodeMask(UInt landBoundaryIndex);
126
138 void ComputeMask(UInt segmentIndex,
139 bool meshBoundOnly,
140 UInt startLandBoundaryIndex,
141 UInt endLandBoundaryIndex,
142 UInt& leftIndex,
143 UInt& rightIndex,
144 double& leftEdgeRatio,
145 double& rightEdgeRatio);
146
150 void MaskMeshFaceMask(UInt landBoundaryIndex, const std::vector<UInt>& initialFaces);
151
156 [[nodiscard]] UInt IsMeshEdgeCloseToLandBoundaries(UInt landBoundaryIndex, UInt edge);
157
164 std::tuple<UInt, UInt> FindStartEndMeshNodesDijkstraAlgorithm(UInt landBoundaryIndex);
165
171 UInt FindStartEndMeshNodesFromEdges(UInt edge, Point point) const;
172
177 std::vector<UInt> ShortestPath(UInt landBoundaryIndex, UInt startMeshNode);
178
184 std::tuple<double, Point, UInt, double> NearestLandBoundarySegment(UInt landBoundaryIndex, const Point& node) const;
185
189 bool InitialiseNodeLocations(const bool initialize,
190 const UInt edgeIndex,
191 const std::vector<UInt>& nodes,
192 const UInt numNodes,
193 std::vector<UInt>& nodesLoc,
194 UInt& numNodesLoc) const;
195
197 UInt GetSegmentIndex(const UInt nearestLandBoundaryNodeIndex) const;
198
200 bool StopPathSearch(const UInt landBoundaryIndex, const UInt currentNode);
201
203 bool ContainsCrossedFace(const UInt landBoundaryIndex, const UInt otherFace);
204
206 void MaskFacesCloseToBoundary(const UInt landBoundaryIndex);
207
209 void GetLandBoundaryNode(const double closeDistance,
210 const Point& firstMeshNode,
211 const Point& secondMeshNode,
212 const UInt currentNode,
213 UInt& landBoundaryNode,
214 bool& isWithinSegment) const;
215
216 Mesh2D& m_mesh;
217 const Polygons m_polygons;
218 LandBoundary m_landBoundary;
219 std::vector<Point> m_polygonNodesCache;
220 std::vector<std::pair<UInt, UInt>> m_validLandBoundaries;
221 std::vector<UInt> m_nodeFaceIndices;
222
223 std::vector<UInt> m_nodeMask;
224 std::vector<bool> m_faceMask;
225 std::vector<UInt> m_edgeMask;
226
227 bool m_landMask = true;
228 bool m_addLandboundaries = true;
229
230 // caches
231 std::vector<double> m_nodesMinDistances;
232
233 // Parameters
234 const double m_closeToLandBoundaryFactor = 5.0;
235 const double m_closeWholeMeshFactor = 1.0;
236 const double m_minDistanceFromLandFactor = 2.0;
237
238 // findOnlyOuterMeshBoundary
239 bool m_findOnlyOuterMeshBoundary = false;
240 };
241
242} // 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:91
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:93
void Administrate()
The portion of the boundary segments close enough to the mesh boundary are flagged (admin_landboundar...
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