MeshKernel
FlipEdges.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/Constants.hpp"
33 #include <MeshKernel/UndoActions/UndoAction.hpp>
34 
35 namespace meshkernel
36 {
37  // Forward declarations
38  class Mesh2D;
39  class LandBoundaries;
40 
47  class FlipEdges
48  {
49  public:
55  FlipEdges(Mesh2D& mesh,
56  LandBoundaries& landBoundary,
57  bool triangulateFaces,
58  bool projectToLandBoundary);
59 
61  [[nodiscard]] std::unique_ptr<UndoAction> Compute() const;
62 
63  private:
69  int ComputeTopologyFunctional(UInt edge,
70  UInt& nodeLeft,
71  UInt& nodeRight) const;
72 
76  [[nodiscard]] UInt OptimalNumberOfConnectedNodes(UInt nodeIndex) const;
77 
81  [[nodiscard]] int DifferenceFromOptimum(UInt nodeIndex, UInt firstNode, UInt secondNode) const;
82 
86  void DeleteEdgeFromNode(UInt edgeIndex, UInt nodeIndex) const;
87 
88  Mesh2D& m_mesh;
89  LandBoundaries& m_landBoundaries;
90 
91  bool m_triangulateFaces = false;
92  bool m_projectToLandBoundary = false;
93  };
94 
95 } // namespace meshkernel
meshkernel::FlipEdges
A class used to improve mesh connectivity.
Definition: FlipEdges.hpp:47
meshkernel::Mesh2D
A class derived from Mesh, which describes unstructures 2d meshes.
Definition: Mesh2D.hpp:55
meshkernel::FlipEdges::FlipEdges
FlipEdges(Mesh2D &mesh, LandBoundaries &landBoundary, bool triangulateFaces, bool projectToLandBoundary)
Constructor.
meshkernel
Contains the logic of the C++ static library.
Definition: AveragingInterpolation.hpp:36
meshkernel::UInt
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition: Definitions.hpp:38
meshkernel::LandBoundaries
A class describing land boundaries. These are used to visualise the land-water interface.
Definition: LandBoundaries.hpp:49
meshkernel::FlipEdges::Compute
std::unique_ptr< UndoAction > Compute() const
Flip the edges.