MeshKernel
State.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 #include <string>
32 
33 #include <MeshKernel/Contacts.hpp>
34 #include <MeshKernel/CurvilinearGrid/CurvilinearGridFromSplines.hpp>
35 #include <MeshKernel/CurvilinearGrid/CurvilinearGridLineShift.hpp>
36 #include <MeshKernel/CurvilinearGrid/CurvilinearGridOrthogonalization.hpp>
37 #include <MeshKernel/Mesh1D.hpp>
38 #include <MeshKernel/Mesh2D.hpp>
39 #include <MeshKernel/OrthogonalizationAndSmoothing.hpp>
40 
41 #include "MeshKernelApi/ApiCache/BoundariesAsPolygonCache.hpp"
42 #include "MeshKernelApi/ApiCache/CachedPointValues.hpp"
43 #include "MeshKernelApi/ApiCache/FacePolygonPropertyCache.hpp"
44 #include "MeshKernelApi/ApiCache/HangingEdgeCache.hpp"
45 #include "MeshKernelApi/ApiCache/NodeInPolygonCache.hpp"
46 #include "MeshKernelApi/ApiCache/ObtuseTriangleCentreCache.hpp"
47 #include "MeshKernelApi/ApiCache/PolygonRefinementCache.hpp"
48 #include "MeshKernelApi/ApiCache/SmallFlowEdgeCentreCache.hpp"
49 
50 namespace meshkernelapi
51 {
52 
55  {
56 
58  MeshKernelState() = default;
59 
61  explicit MeshKernelState(meshkernel::Projection projection) : m_projection(projection)
62  {
63  m_mesh1d = std::make_shared<meshkernel::Mesh1D>(projection);
64  m_mesh2d = std::make_shared<meshkernel::Mesh2D>(projection);
65  m_network1d = std::make_shared<meshkernel::Network1D>(projection);
66  m_contacts = std::make_shared<meshkernel::Contacts>(*m_mesh1d, *m_mesh2d);
67  m_curvilinearGrid = std::make_shared<meshkernel::CurvilinearGrid>(projection);
68  }
69 
70  // Geometrical entities instances
71  std::shared_ptr<meshkernel::Mesh1D> m_mesh1d;
72  std::shared_ptr<meshkernel::Network1D> m_network1d;
73  std::shared_ptr<meshkernel::Mesh2D> m_mesh2d;
74  std::shared_ptr<meshkernel::Contacts> m_contacts;
75  std::shared_ptr<meshkernel::CurvilinearGrid> m_curvilinearGrid;
76 
77  // Algorithms instances (interactivity)
78  std::shared_ptr<meshkernel::OrthogonalizationAndSmoothing> m_meshOrthogonalization;
79  std::shared_ptr<meshkernel::CurvilinearGridFromSplines> m_curvilinearGridFromSplines;
80  std::shared_ptr<meshkernel::CurvilinearGridOrthogonalization> m_curvilinearGridOrthogonalization;
81  std::shared_ptr<meshkernel::CurvilinearGridLineShift> m_curvilinearGridLineShift;
82 
83  // Exclusively owned state
84  meshkernel::Projection m_projection{meshkernel::Projection::cartesian};
85 
86  // Cached values, used when dimensions are computed first, followed by values being retrieved in a separate call
87  std::shared_ptr<FacePolygonPropertyCache> m_facePropertyCache;
88  std::shared_ptr<BoundariesAsPolygonCache> m_boundariesAsPolygonCache;
89  std::shared_ptr<PolygonRefinementCache> m_polygonRefinementCache;
90  std::shared_ptr<NodeInPolygonCache> m_nodeInPolygonCache;
91  std::shared_ptr<SmallFlowEdgeCentreCache> m_smallFlowEdgeCentreCache;
92  std::shared_ptr<HangingEdgeCache> m_hangingEdgeCache;
93  std::shared_ptr<ObtuseTriangleCentreCache> m_obtuseTriangleCentreCache;
94  };
95 
96 } // namespace meshkernelapi
meshkernel::Projection
Projection
Enumerator describing the supported projections.
Definition: Definitions.hpp:41
meshkernelapi::MeshKernelState::m_contacts
std::shared_ptr< meshkernel::Contacts > m_contacts
Shared pointer to meshkernel::Contacts instance.
Definition: State.hpp:74
meshkernelapi::MeshKernelState::MeshKernelState
MeshKernelState()=default
Default constructor.
meshkernelapi::MeshKernelState
The class holding the state of the C API library.
Definition: State.hpp:54
meshkernelapi::MeshKernelState::m_boundariesAsPolygonCache
std::shared_ptr< BoundariesAsPolygonCache > m_boundariesAsPolygonCache
boundaries as polygon cache
Definition: State.hpp:88
meshkernelapi::MeshKernelState::m_smallFlowEdgeCentreCache
std::shared_ptr< SmallFlowEdgeCentreCache > m_smallFlowEdgeCentreCache
small flow edge centres cache
Definition: State.hpp:91
meshkernelapi::MeshKernelState::m_curvilinearGridOrthogonalization
std::shared_ptr< meshkernel::CurvilinearGridOrthogonalization > m_curvilinearGridOrthogonalization
Shared pointer to meshkernel::CurvilinearGridOrthogonalization instance.
Definition: State.hpp:80
meshkernelapi::MeshKernelState::m_polygonRefinementCache
std::shared_ptr< PolygonRefinementCache > m_polygonRefinementCache
polygon refinement cache
Definition: State.hpp:89
meshkernelapi::MeshKernelState::m_curvilinearGridLineShift
std::shared_ptr< meshkernel::CurvilinearGridLineShift > m_curvilinearGridLineShift
Shared pointer to meshkernel::CurvilinearGridLineShift instance.
Definition: State.hpp:81
meshkernelapi::MeshKernelState::m_hangingEdgeCache
std::shared_ptr< HangingEdgeCache > m_hangingEdgeCache
hanging edge id cache
Definition: State.hpp:92
meshkernelapi::MeshKernelState::MeshKernelState
MeshKernelState(meshkernel::Projection projection)
Simple constructor.
Definition: State.hpp:61
meshkernelapi::MeshKernelState::m_meshOrthogonalization
std::shared_ptr< meshkernel::OrthogonalizationAndSmoothing > m_meshOrthogonalization
Shared pointer to meshkernel::OrthogonalizationAndSmoothing instance.
Definition: State.hpp:78
meshkernelapi::MeshKernelState::m_mesh2d
std::shared_ptr< meshkernel::Mesh2D > m_mesh2d
Shared pointer to meshkernel::Mesh2D instance.
Definition: State.hpp:73
meshkernelapi::MeshKernelState::m_mesh1d
std::shared_ptr< meshkernel::Mesh1D > m_mesh1d
Shared pointer to meshkernel::Mesh1D instance.
Definition: State.hpp:71
meshkernelapi
Contains all structs and functions exposed at the API level.
Definition: BoundingBox.hpp:32
meshkernelapi::MeshKernelState::m_network1d
std::shared_ptr< meshkernel::Network1D > m_network1d
Shared pointer to meshkernel::Network1D instance.
Definition: State.hpp:72
meshkernelapi::MeshKernelState::m_curvilinearGridFromSplines
std::shared_ptr< meshkernel::CurvilinearGridFromSplines > m_curvilinearGridFromSplines
Shared pointer to meshkernel::CurvilinearGridFromSplines instance.
Definition: State.hpp:79
meshkernelapi::MeshKernelState::m_projection
meshkernel::Projection m_projection
Projection used by the meshes.
Definition: State.hpp:84
meshkernelapi::MeshKernelState::m_nodeInPolygonCache
std::shared_ptr< NodeInPolygonCache > m_nodeInPolygonCache
node in polygon cache
Definition: State.hpp:90
meshkernelapi::MeshKernelState::m_obtuseTriangleCentreCache
std::shared_ptr< ObtuseTriangleCentreCache > m_obtuseTriangleCentreCache
centre of obtuse triangles cache
Definition: State.hpp:93
meshkernelapi::MeshKernelState::m_curvilinearGrid
std::shared_ptr< meshkernel::CurvilinearGrid > m_curvilinearGrid
Shared pointer to meshkernel::CurvilinearGrid instance.
Definition: State.hpp:75
meshkernelapi::MeshKernelState::m_facePropertyCache
std::shared_ptr< FacePolygonPropertyCache > m_facePropertyCache
face property cache
Definition: State.hpp:87