OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
SpatialFrame.hpp
Go to the documentation of this file.
1
27#ifndef OPENSWMM_ENGINE_SPATIAL_FRAME_HPP
28#define OPENSWMM_ENGINE_SPATIAL_FRAME_HPP
29
30#include <string>
31#include <vector>
32#include <cstdint>
33
34namespace openswmm {
35
36// ============================================================================
37// Forward declarations for 2D coupling (R30)
38// ============================================================================
39
50public:
51 virtual ~ICouplingPoint() = default;
52
54 virtual int object_index() const noexcept = 0;
55
57 virtual const char* object_type() const noexcept = 0;
58
60 virtual void exchange_to_2d(double value) = 0;
61
63 virtual double receive_from_2d() const = 0;
64};
65
66// ============================================================================
67// SpatialFrame
68// ============================================================================
69
83 // -----------------------------------------------------------------------
84 // Coordinate reference system
85 // -----------------------------------------------------------------------
86
100 std::string crs;
101
106 bool is_geographic = false;
107
108 // -----------------------------------------------------------------------
109 // Map extents (from [MAP] DIMENSIONS)
110 // -----------------------------------------------------------------------
111
113 double map_x1 = 0.0;
114
116 double map_y1 = 0.0;
117
119 double map_x2 = 0.0;
120
122 double map_y2 = 0.0;
123
128 std::string map_units;
129
130 // -----------------------------------------------------------------------
131 // Node coordinates (indexed parallel to NodeData)
132 // -----------------------------------------------------------------------
133
135 std::vector<double> node_x;
136
138 std::vector<double> node_y;
139
140 // -----------------------------------------------------------------------
141 // Link coordinates (one point per link — nominal centroid or from-node)
142 // -----------------------------------------------------------------------
143
145 std::vector<double> link_x;
146
148 std::vector<double> link_y;
149
150 // -----------------------------------------------------------------------
151 // Subcatchment centroid coordinates
152 // -----------------------------------------------------------------------
153
155 std::vector<double> subcatch_x;
156
158 std::vector<double> subcatch_y;
159
160 // -----------------------------------------------------------------------
161 // Link vertices (polyline points between from-node and to-node)
162 // -----------------------------------------------------------------------
163
165 std::vector<std::vector<double>> link_vertices_x;
166
168 std::vector<std::vector<double>> link_vertices_y;
169
170 // -----------------------------------------------------------------------
171 // Subcatchment polygon vertices
172 // -----------------------------------------------------------------------
173
175 std::vector<std::vector<double>> subcatch_polygon_x;
176
178 std::vector<std::vector<double>> subcatch_polygon_y;
179
180 // -----------------------------------------------------------------------
181 // Gage coordinates
182 // -----------------------------------------------------------------------
183
185 std::vector<double> gage_x;
186
188 std::vector<double> gage_y;
189
190 // -----------------------------------------------------------------------
191 // 2D coupling interface (R30)
192 // -----------------------------------------------------------------------
193
204 std::vector<ICouplingPoint*> coupling_points;
205
211 if (point) coupling_points.push_back(point);
212 }
213
217 bool has_2d_coupling() const noexcept {
218 return !coupling_points.empty();
219 }
220
225 node_x.shrink_to_fit();
226 node_y.shrink_to_fit();
227 link_x.shrink_to_fit();
228 link_y.shrink_to_fit();
229 subcatch_x.shrink_to_fit();
230 subcatch_y.shrink_to_fit();
231 gage_x.shrink_to_fit();
232 gage_y.shrink_to_fit();
233
234 link_vertices_x.shrink_to_fit();
235 for (auto& v : link_vertices_x) v.shrink_to_fit();
236 link_vertices_y.shrink_to_fit();
237 for (auto& v : link_vertices_y) v.shrink_to_fit();
238
239 subcatch_polygon_x.shrink_to_fit();
240 for (auto& v : subcatch_polygon_x) v.shrink_to_fit();
241 subcatch_polygon_y.shrink_to_fit();
242 for (auto& v : subcatch_polygon_y) v.shrink_to_fit();
243 }
244};
245
246} /* namespace openswmm */
247
248#endif /* OPENSWMM_ENGINE_SPATIAL_FRAME_HPP */
Abstract coupling point between a 1D SWMM object and a 2D mesh cell.
Definition SpatialFrame.hpp:49
virtual ~ICouplingPoint()=default
virtual void exchange_to_2d(double value)=0
Exchange 1D state to the 2D component at this point.
virtual int object_index() const noexcept=0
Index of the 1D SWMM object (node, link, or subcatch index).
virtual double receive_from_2d() const =0
Receive 2D state from the 2D component at this point.
virtual const char * object_type() const noexcept=0
Type: "NODE", "LINK", or "SUBCATCH".
Definition NodeCoupling.cpp:15
Spatial frame containing CRS and georeferenced coordinates.
Definition SpatialFrame.hpp:82
std::vector< double > link_x
Link centroid X coordinates.
Definition SpatialFrame.hpp:145
void shrink_to_fit()
Release excess vector capacity accumulated during parsing.
Definition SpatialFrame.hpp:224
void register_coupling_point(ICouplingPoint *point)
Register a 2D coupling point.
Definition SpatialFrame.hpp:210
std::vector< double > subcatch_x
Subcatchment centroid X.
Definition SpatialFrame.hpp:155
std::vector< double > node_x
Node X coordinates (easting or longitude).
Definition SpatialFrame.hpp:135
std::vector< double > gage_x
Gage X coordinates.
Definition SpatialFrame.hpp:185
std::vector< double > gage_y
Gage Y coordinates.
Definition SpatialFrame.hpp:188
std::string crs
CRS specification string.
Definition SpatialFrame.hpp:100
std::vector< std::vector< double > > subcatch_polygon_y
Per-subcatchment polygon Y vertices.
Definition SpatialFrame.hpp:178
bool has_2d_coupling() const noexcept
Returns true if any 2D coupling points are registered.
Definition SpatialFrame.hpp:217
std::vector< std::vector< double > > link_vertices_x
Per-link X vertices. link_vertices_x[link_idx] is a vector of X coords.
Definition SpatialFrame.hpp:165
std::vector< double > link_y
Link centroid Y coordinates.
Definition SpatialFrame.hpp:148
std::vector< std::vector< double > > subcatch_polygon_x
Per-subcatchment polygon X vertices.
Definition SpatialFrame.hpp:175
std::vector< double > node_y
Node Y coordinates (northing or latitude).
Definition SpatialFrame.hpp:138
std::string map_units
Map units string from [MAP] UNITS keyword.
Definition SpatialFrame.hpp:128
std::vector< double > subcatch_y
Subcatchment centroid Y.
Definition SpatialFrame.hpp:158
std::vector< std::vector< double > > link_vertices_y
Per-link Y vertices. link_vertices_y[link_idx] is a vector of Y coords.
Definition SpatialFrame.hpp:168
std::vector< ICouplingPoint * > coupling_points
Registered 2D coupling points.
Definition SpatialFrame.hpp:204