| 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 <string> |
| 14 |
#include <vector> |
| 15 |
|
| 16 |
#include "atlas/util/Point.h" |
| 17 |
|
| 18 |
// forward declarations |
| 19 |
namespace eckit { |
| 20 |
class PathName; |
| 21 |
} |
| 22 |
|
| 23 |
namespace atlas { |
| 24 |
class Field; |
| 25 |
class FieldSet; |
| 26 |
} // namespace atlas |
| 27 |
|
| 28 |
namespace atlas { |
| 29 |
namespace grid { |
| 30 |
class Grid; |
| 31 |
class Unstructured; |
| 32 |
} // namespace grid |
| 33 |
} // namespace atlas |
| 34 |
|
| 35 |
namespace atlas { |
| 36 |
class Mesh; |
| 37 |
} |
| 38 |
namespace atlas { |
| 39 |
namespace functionspace { |
| 40 |
class NodeColumns; |
| 41 |
} |
| 42 |
} // namespace atlas |
| 43 |
|
| 44 |
namespace atlas { |
| 45 |
namespace output { |
| 46 |
namespace detail { |
| 47 |
|
| 48 |
/** |
| 49 |
* @brief PointCloudIO supports: |
| 50 |
* - reading Mesh |
| 51 |
* - writing of Mesh |
| 52 |
* @warning only supports reading/writing doubles scalar fields |
| 53 |
*/ |
| 54 |
class PointCloudIO { |
| 55 |
public: |
| 56 |
/** |
| 57 |
* @brief Read PointCloudIO file into a Mesh |
| 58 |
* @param path input file path |
| 59 |
* @param Grid data structure pointer to use |
| 60 |
* @return Grid data structure pointer |
| 61 |
*/ |
| 62 |
static Mesh read(const eckit::PathName& path); |
| 63 |
|
| 64 |
/** |
| 65 |
* @brief Read PointCloudIO file into a Mesh |
| 66 |
* @param path input file path |
| 67 |
* @param vfnames names of fields to read |
| 68 |
* @return Mesh pointer |
| 69 |
*/ |
| 70 |
static Mesh read(const eckit::PathName& path, std::vector<std::string>& vfnames); |
| 71 |
|
| 72 |
/** |
| 73 |
* @brief Write Grid to PointCloudIO file (overwrites possibly existing file) |
| 74 |
* @param path output file path |
| 75 |
* @param grid Grid data structure |
| 76 |
*/ |
| 77 |
static void write(const eckit::PathName& path, const Mesh& mesh); |
| 78 |
|
| 79 |
/** |
| 80 |
* @brief Write FieldSet to PointCloudIO file (overwrites possibly existing |
| 81 |
* file) |
| 82 |
* @param path output file path |
| 83 |
* @param fieldset FieldSet data structure |
| 84 |
*/ |
| 85 |
static void write(const eckit::PathName& path, const FieldSet& fieldset, |
| 86 |
const functionspace::NodeColumns& function_space); |
| 87 |
|
| 88 |
/** |
| 89 |
* @brief Write lan/lon to PointCloudIO file (overwrites possibly existing file) |
| 90 |
* @note length of vectors lat and lon should be the same |
| 91 |
* @param path output file path |
| 92 |
* @param lon vector containing longitude values |
| 93 |
* @param lat vector containing latitude values |
| 94 |
*/ |
| 95 |
static void write(const eckit::PathName& path, const std::vector<PointLonLat>& pts); |
| 96 |
|
| 97 |
/** |
| 98 |
* @brief Write lan/lon and fields to PointCloudIO file (overwrites possibly |
| 99 |
* existing file) |
| 100 |
* @param path output file path |
| 101 |
* @param nb_pts number of points in unstructured grid |
| 102 |
* @param lon array (of length nb_pts) pointer containing longitude |
| 103 |
* @param lat array (of length nb_pts) pointer containing latitude |
| 104 |
* @param nb_fld number of fields (default none) |
| 105 |
* @param afvalues array (of length nb_fld) of arrays (of length nb_pts), |
| 106 |
* containing field values |
| 107 |
* @param afnames array (of length nb_fld) of field names |
| 108 |
*/ |
| 109 |
static void write(const eckit::PathName& path, const int& nb_pts, const double* lon, const double* lat, |
| 110 |
const int& nb_fld = 0, const double** afvalues = NULL, const char** afnames = NULL); |
| 111 |
|
| 112 |
/** |
| 113 |
* @brief Write lan/lon and fields to PointCloudIO file (overwrites possibly |
| 114 |
* existing file) |
| 115 |
* @note length of vectors lat, lon and *vfvalues[] (each pointee) should be the |
| 116 |
* same |
| 117 |
* @note length of vectors vfvalues and vfnames should be the same |
| 118 |
* @param path output file path |
| 119 |
* @param lon vector containing longitude values |
| 120 |
* @param lat vector containing latitude values |
| 121 |
* @param vfvalues vector of vector pointers, each pointing to field values |
| 122 |
* vectors |
| 123 |
* @param vfnames vector of field names |
| 124 |
*/ |
| 125 |
static void write(const eckit::PathName& path, const std::vector<double>& lon, const std::vector<double>& lat, |
| 126 |
const std::vector<std::vector<double>*>& vfvalues = std::vector<std::vector<double>*>(), |
| 127 |
const std::vector<std::string>& vfnames = std::vector<std::string>()); |
| 128 |
}; |
| 129 |
|
| 130 |
// C wrapper interfaces to C++ routines |
| 131 |
extern "C" { |
| 132 |
// PointCloudIO* atlas__pointcloud__new (); |
| 133 |
// void atlas__pointcloud__delete(PointCloudIO* This); |
| 134 |
// mesh::Mesh* atlas__pointcloud__read(PointCloudIO* This, char* file_path); |
| 135 |
// mesh::Mesh* atlas__read_pointcloud(char* file_path); |
| 136 |
// void atlas__write_pointcloud_fieldset(char* file_path, const |
| 137 |
// field::FieldImpl* fieldset, const functionspace::FunctionSpaceImpl* |
| 138 |
// functionspace); |
| 139 |
// void atlas__write_pointcloud_field(char* file_path, const field::FieldImpl* |
| 140 |
// field, const functionspace::FunctionSpaceImpl* functionspace); |
| 141 |
} |
| 142 |
|
| 143 |
} // namespace detail |
| 144 |
} // namespace output |
| 145 |
} // namespace atlas |