GridXY¶
Overview¶
-
struct GridXY¶
Structure to hold 2D grid data.
The
omdi::GridXYstruct stores and owns vectors for the X and Y coordinate axes of a regular 2D grid, along with the grid dimensions and a vector for the associated scalar dataz.Data is copied into the struct on construction, so the caller does not need to keep the source arrays alive after creating a
omdi::GridXYinstance.
Usage example¶
Basic usage with std::vector arrays:
constexpr size_t nx = 3;
constexpr size_t ny = 2;
auto xs = std::vector<float> { 0.0f, 1.0f, 2.0f };
auto ys = std::vector<float> { 0.0f, 1.0f };
auto zs = std::vector<float> {
0.0f, 1.0f,
2.0f, 3.0f,
4.0f, 5.0f
};
auto grid = omdi::GridXY(xs, ys, nx, ny, zs);
// grid owns its own copies of xs, ys, and zs.
Data members¶
-
std::vector<float> GridXY::x¶
Vector of X coordinates.
Typically contains
omdi::GridXY::nxmonotonically increasing X coordinates.
-
std::vector<float> GridXY::y¶
Vector of Y coordinates.
Typically contains
omdi::GridXY::nymonotonically increasing Y coordinates.
Constructor¶
-
GridXY::GridXY(const std::vector<float> &x, const std::vector<float> &y, size_t nx, size_t ny, const std::vector<float> &z)¶
Construct a
omdi::GridXYfrom coordinate vectors and sizes.- Parameters:
x – Vector of X coordinates (length
nx).y – Vector of Y coordinates (length
ny).nx – Number of grid points along the X axis.
ny – Number of grid points along the Y axis.
z – Vector of scalar grid data (typically of size
nx * ny).
All vectors are copied into the struct; the caller is free to modify or destroy the originals after construction.
Notes¶
omdi::GridXYowns its coordinate and scalar data; no external arrays need to remain alive after construction.The layout (row-major vs. column-major) of
omdi::GridXY::zis application-defined and should be documented wherever the grid is used.