MeshKernel
Loading...
Searching...
No Matches
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 <map>
31#include <memory>
32#include <vector>
33
34#include "MeshKernel/Contacts.hpp"
35#include "MeshKernel/CurvilinearGrid/CurvilinearGridFromSplines.hpp"
36#include "MeshKernel/CurvilinearGrid/CurvilinearGridLineShift.hpp"
37#include "MeshKernel/CurvilinearGrid/CurvilinearGridOrthogonalization.hpp"
38#include "MeshKernel/CurvilinearGrid/CurvilinearGridSmoothing.hpp"
39#include "MeshKernel/Mesh1D.hpp"
40#include "MeshKernel/Mesh2D.hpp"
41#include "MeshKernel/OrthogonalizationAndSmoothing.hpp"
42
43#include "MeshKernelApi/ApiCache/CurvilinearBoundariesAsPolygonCache.hpp"
44#include "MeshKernelApi/ApiCache/FacePolygonPropertyCache.hpp"
45#include "MeshKernelApi/ApiCache/HangingEdgeCache.hpp"
46#include "MeshKernelApi/ApiCache/NodeInPolygonCache.hpp"
47#include "MeshKernelApi/ApiCache/ObtuseTriangleCentreCache.hpp"
48#include "MeshKernelApi/ApiCache/PolygonRefinementCache.hpp"
49#include "MeshKernelApi/ApiCache/SmallFlowEdgeCentreCache.hpp"
50#include "MeshKernelApi/PropertyCalculator.hpp"
51
52#include "ApiCache/MeshBoundariesAsPolygonCache.hpp"
53
54namespace meshkernelapi
55{
56
59 {
60
62 MeshKernelState() = default;
63
65 explicit MeshKernelState(meshkernel::Projection projection) : m_projection(projection)
66 {
67 m_mesh1d = std::make_shared<meshkernel::Mesh1D>(projection);
68 m_mesh2d = std::make_shared<meshkernel::Mesh2D>(projection);
69 m_network1d = std::make_shared<meshkernel::Network1D>(projection);
70 m_contacts = std::make_shared<meshkernel::Contacts>(*m_mesh1d, *m_mesh2d);
71 m_curvilinearGrid = std::make_shared<meshkernel::CurvilinearGrid>(projection);
73 }
74
75 // Geometrical entities instances
76 std::shared_ptr<meshkernel::Mesh1D> m_mesh1d;
77 std::shared_ptr<meshkernel::Network1D> m_network1d;
78 std::shared_ptr<meshkernel::Mesh2D> m_mesh2d;
79 std::shared_ptr<meshkernel::Contacts> m_contacts;
80 std::shared_ptr<meshkernel::CurvilinearGrid> m_curvilinearGrid;
81
82 // Algorithms instances (interactivity)
83 std::shared_ptr<meshkernel::OrthogonalizationAndSmoothing> m_meshOrthogonalization;
84 std::shared_ptr<meshkernel::CurvilinearGridFromSplines> m_curvilinearGridFromSplines;
85 std::shared_ptr<meshkernel::CurvilinearGridLineShift> m_curvilinearGridLineShift;
86 std::shared_ptr<meshkernel::CurvilinearGridOrthogonalization> m_curvilinearGridOrthogonalization;
87 std::map<int, std::shared_ptr<PropertyCalculator>> m_propertyCalculators;
88 std::unordered_map<meshkernel::UInt, std::pair<meshkernel::Point, meshkernel::Point>> m_frozenLines;
90
91 // Exclusively owned state
92 meshkernel::Projection m_projection{meshkernel::Projection::cartesian};
93
94 // Cached values, used when dimensions are computed first, followed by values being retrieved in a separate call
95 std::shared_ptr<FacePolygonPropertyCache> m_facePropertyCache;
96 std::shared_ptr<CurvilinearBoundariesAsPolygonCache> m_boundariesAsPolygonCache;
97 std::shared_ptr<MeshBoundariesAsPolygonCache> m_meshBoundariesAsPolygonCache;
98 std::shared_ptr<PolygonRefinementCache> m_polygonRefinementCache;
99 std::shared_ptr<NodeInPolygonCache> m_nodeInPolygonCache;
100 std::shared_ptr<SmallFlowEdgeCentreCache> m_smallFlowEdgeCentreCache;
101 std::shared_ptr<HangingEdgeCache> m_hangingEdgeCache;
102 std::shared_ptr<ObtuseTriangleCentreCache> m_obtuseTriangleCentreCache;
103 };
104
105} // namespace meshkernelapi
Projection
Enumerator describing the supported projections.
Definition Definitions.hpp:43
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition Definitions.hpp:39
Contains all structs and functions exposed at the API level.
Definition BoundingBox.hpp:33
The class holding the state of the C API library.
Definition State.hpp:59
meshkernel::UInt m_frozenLinesCounter
An increasing counter for returning the id of frozen lines to the client.
Definition State.hpp:89
std::map< int, std::shared_ptr< PropertyCalculator > > m_propertyCalculators
Property calculators for the mesh2d.
Definition State.hpp:87
std::shared_ptr< SmallFlowEdgeCentreCache > m_smallFlowEdgeCentreCache
small flow edge centres cache
Definition State.hpp:100
std::shared_ptr< CurvilinearBoundariesAsPolygonCache > m_boundariesAsPolygonCache
boundaries as polygon cache
Definition State.hpp:96
std::shared_ptr< meshkernel::Network1D > m_network1d
Shared pointer to meshkernel::Network1D instance.
Definition State.hpp:77
std::shared_ptr< NodeInPolygonCache > m_nodeInPolygonCache
node in polygon cache
Definition State.hpp:99
std::shared_ptr< meshkernel::Mesh1D > m_mesh1d
Shared pointer to meshkernel::Mesh1D instance.
Definition State.hpp:76
std::shared_ptr< meshkernel::CurvilinearGridOrthogonalization > m_curvilinearGridOrthogonalization
Shared pointer to meshkernel::CurvilinearGridOrthogonalization instance.
Definition State.hpp:86
std::shared_ptr< meshkernel::CurvilinearGridFromSplines > m_curvilinearGridFromSplines
Shared pointer to meshkernel::CurvilinearGridFromSplines instance.
Definition State.hpp:84
MeshKernelState()=default
Default constructor.
meshkernel::Projection m_projection
Projection used by the meshes.
Definition State.hpp:92
std::shared_ptr< meshkernel::OrthogonalizationAndSmoothing > m_meshOrthogonalization
Shared pointer to meshkernel::OrthogonalizationAndSmoothing instance.
Definition State.hpp:83
std::shared_ptr< HangingEdgeCache > m_hangingEdgeCache
hanging edge id cache
Definition State.hpp:101
std::shared_ptr< ObtuseTriangleCentreCache > m_obtuseTriangleCentreCache
centre of obtuse triangles cache
Definition State.hpp:102
MeshKernelState(meshkernel::Projection projection)
Simple constructor.
Definition State.hpp:65
std::shared_ptr< meshkernel::CurvilinearGrid > m_curvilinearGrid
Shared pointer to meshkernel::CurvilinearGrid instance.
Definition State.hpp:80
std::shared_ptr< meshkernel::Mesh2D > m_mesh2d
Shared pointer to meshkernel::Mesh2D instance.
Definition State.hpp:78
std::shared_ptr< meshkernel::Contacts > m_contacts
Shared pointer to meshkernel::Contacts instance.
Definition State.hpp:79
std::shared_ptr< PolygonRefinementCache > m_polygonRefinementCache
polygon refinement cache
Definition State.hpp:98
std::shared_ptr< meshkernel::CurvilinearGridLineShift > m_curvilinearGridLineShift
Shared pointer to meshkernel::CurvilinearGridLineShift instance.
Definition State.hpp:85
std::unordered_map< meshkernel::UInt, std::pair< meshkernel::Point, meshkernel::Point > > m_frozenLines
Map for string the frozen lines.
Definition State.hpp:88
std::shared_ptr< FacePolygonPropertyCache > m_facePropertyCache
face property cache
Definition State.hpp:95
std::shared_ptr< MeshBoundariesAsPolygonCache > m_meshBoundariesAsPolygonCache
boundaries as polygon cache
Definition State.hpp:97