1 /* 2 MDAL - Mesh Data Abstraction Library (MIT License) 3 Copyright (C) 2018 Peter Petrik (zilolv at gmail dot com) 4 */ 5 6 #ifndef MDAL_3DI_HPP 7 #define MDAL_3DI_HPP 8 9 #include <map> 10 #include <string> 11 #include <stddef.h> 12 13 #include "mdal_config.hpp" 14 #include "mdal_cf.hpp" 15 #include "mdal_driver.hpp" 16 17 namespace MDAL 18 { 19 20 /** 21 * Driver of 3Di file format. 22 * 23 * The result 3Di NetCDF file is based on CF-conventions with some additions. 24 * It is unstructured grid with data stored in NetCDF/HDF5 file format. 25 * A division is made between a 1D and 2D which can be distinguished through 26 * the prefixes “MESH2D” and “MESH1D”. For both meshes the information is present 27 * in coordinate, id, and type variables. 28 * 29 * A version of the data scheme is not present yet. 30 * 31 * The 2D Mesh consists of calculation Nodes that represents centers of Faces. 32 * There is no concept of Vertices in the file. The vertices that forms a face 33 * are specified by X,Y coordinates in the "Face Contours" arrays. The "lines" 34 * represent the face's edges and are again specified by X,Y coordinate of the 35 * line center. Data is specified on calculation nodes (i.e. dataset defined on faces) 36 * and on lines (i.e. dataset defined on edges - not implemented yet) 37 * 38 * The 1D Mesh is present too, but not parsed yet. 39 */ 40 class Driver3Di: public DriverCF 41 { 42 public: 43 Driver3Di(); 44 ~Driver3Di() override = default; 45 Driver3Di *create() override; 46 std::string buildUri( const std::string &meshFile ) override; 47 private: 48 CFDimensions populateDimensions( ) override; 49 void populate2DMeshDimensions( MDAL::CFDimensions &dims ); 50 void populateElements( Vertices &vertices, Edges &edges, Faces &faces ) override; 51 void populateMesh2DElements( Vertices &vertices, Faces &faces ); 52 void addBedElevation( MemoryMesh *mesh ) override; 53 std::string getCoordinateSystemVariableName() override; 54 std::string getTimeVariableName() const override; 55 std::set<std::string> ignoreNetCDFVariables() override; 56 void parseNetCDFVariableMetadata( int varid, 57 std::string &variableName, 58 std::string &name, 59 bool *is_vector, 60 bool *isPolar, 61 bool *invertedDirection, 62 bool *is_x ) override; 63 std::vector<std::pair<double, double>> parseClassification( int varid ) const override; 64 65 //! Returns number of vertices 66 size_t parse2DMesh(); 67 68 void addBedElevationDatasetOnFaces(); 69 70 void populate1DMeshDimensions( MDAL::CFDimensions &dims ); 71 void populateMesh1DElements( Vertices &vertices, Edges &edges ); 72 bool check1DConnection( std::string fileName ); 73 void parse1DConnection( const std::vector<int> &nodesId, const std::vector<int> &edgesId, Edges &edges ); 74 }; 75 76 } // namespace MDAL 77 78 #endif // MDAL_3DI_HPP 79