| 1 |
/* |
| 2 |
* (C) Copyright 2013 ECMWF. |
| 3 |
* |
| 4 |
* This software is licensed under the terms of the Apache Licence Version 2.0 |
| 5 |
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 7 |
* granted to it by virtue of its status as an intergovernmental organisation |
| 8 |
* nor does it submit to any jurisdiction. |
| 9 |
*/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include <initializer_list> |
| 14 |
|
| 15 |
#include "atlas/grid/Grid.h" |
| 16 |
#include "atlas/grid/detail/grid/Unstructured.h" |
| 17 |
|
| 18 |
|
| 19 |
namespace atlas { |
| 20 |
|
| 21 |
//--------------------------------------------------------------------------------------------------------------------- |
| 22 |
// Further grid interpretation classes defined in this file |
| 23 |
|
| 24 |
class UnstructuredGrid; |
| 25 |
|
| 26 |
/* |
| 27 |
Grid |
| 28 |
| |
| 29 |
+----------+----------+ |
| 30 |
| | |
| 31 |
StructuredGrid UnstructuredGrid |
| 32 |
|
| 33 |
*/ |
| 34 |
|
| 35 |
//--------------------------------------------------------------------------------------------------------------------- |
| 36 |
|
| 37 |
class UnstructuredGrid : public Grid { |
| 38 |
public: |
| 39 |
using grid_t = grid::detail::grid::Unstructured; |
| 40 |
|
| 41 |
public: |
| 42 |
UnstructuredGrid(); |
| 43 |
UnstructuredGrid(const Grid&); |
| 44 |
UnstructuredGrid(const Config&); |
| 45 |
UnstructuredGrid(const Grid::Implementation*); |
| 46 |
UnstructuredGrid(std::vector<PointXY>*); // takes ownership |
| 47 |
UnstructuredGrid(std::initializer_list<PointXY>); |
| 48 |
UnstructuredGrid(const Grid&, const Domain&); // Create a new unstructured grid! |
| 49 |
|
| 50 |
operator bool() const { return valid(); } |
| 51 |
UnstructuredGrid(std::vector<PointXY>&&); // move constructor |
| 52 |
UnstructuredGrid(const std::vector<PointXY>&); // creates copy |
| 53 |
|
| 54 |
bool valid() const { return grid_; } |
| 55 |
|
| 56 |
using Grid::lonlat; |
| 57 |
using Grid::xy; |
| 58 |
|
| 59 |
// @brief Copy coordinates x,y of point `n` into xy[2] |
| 60 |
void xy(idx_t n, double xy[]) const { grid_->xy(n, xy); } |
| 61 |
|
| 62 |
// @brief Copy coordinates lon,lat of point `n` into lonlat[2] |
| 63 |
void lonlat(idx_t n, double lonlat[]) const { grid_->lonlat(n, lonlat); } |
| 64 |
|
| 65 |
// @brief Create PointXY at grid index `n` |
| 66 |
PointXY xy(idx_t n) const { return grid_->xy(n); } |
| 67 |
|
| 68 |
// @brief Create PointLonLat at grid index `n` |
| 69 |
PointLonLat lonlat(idx_t n) const { return grid_->lonlat(n); } |
| 70 |
|
| 71 |
private: |
| 72 |
const grid_t* grid_; |
| 73 |
}; |
| 74 |
|
| 75 |
//--------------------------------------------------------------------------------------------------------------------- |
| 76 |
|
| 77 |
} // namespace atlas |