QGIS/external/mdal/mdal_data_model.hpp

116 lines
2.3 KiB
C++
Raw Normal View History

/*
MDAL - Mesh Data Abstraction Library (MIT License)
Copyright (C) 2018 Peter Petrik (zilolv at gmail dot com)
*/
#ifndef MDAL_DEFINES_HPP
#define MDAL_DEFINES_HPP
#include <stddef.h>
#include <vector>
2018-05-16 11:20:25 +02:00
#include <memory>
#include <map>
2018-09-10 23:12:00 +02:00
#include <string>
2018-07-18 09:00:34 +02:00
namespace MDAL
{
2018-07-18 09:00:34 +02:00
class DatasetGroup;
struct BBox
{
BBox() {}
BBox( double lx, double ux, double ly, double uy ): minX( lx ), maxX( ux ), minY( ly ), maxY( uy ) {}
double minX;
double maxX;
double minY;
double maxY;
};
typedef struct
{
double x;
double y;
2018-08-29 12:10:03 +02:00
double z; // Bed elevation
} Vertex;
typedef std::vector<size_t> Face;
typedef std::vector<Vertex> Vertices;
typedef std::vector<Face> Faces;
2018-05-16 11:20:25 +02:00
typedef struct
{
double x;
double y;
bool noData = false;
} Value; //Dataset Value
2018-07-18 09:00:34 +02:00
typedef std::vector< std::pair< std::string, std::string > > Metadata;
2018-05-16 11:20:25 +02:00
class Dataset
{
public:
2018-07-18 09:00:34 +02:00
double time;
2018-05-16 11:20:25 +02:00
2018-07-18 09:00:34 +02:00
/**
* size - face count if !isOnVertices
* size - vertex count if isOnVertices
*/
std::vector<Value> values;
2018-05-16 11:20:25 +02:00
std::vector<bool> active; // size - face count. Whether the output for this is active...
bool isValid = true;
2018-07-18 09:00:34 +02:00
DatasetGroup *parent = nullptr;
2018-05-16 11:20:25 +02:00
2018-07-18 09:00:34 +02:00
bool isActive( size_t faceIndex );
};
2018-05-16 11:20:25 +02:00
2018-07-18 09:00:34 +02:00
typedef std::vector<std::shared_ptr<Dataset>> Datasets;
2018-05-16 11:20:25 +02:00
2018-07-18 09:00:34 +02:00
class DatasetGroup
{
public:
std::string getMetadata( const std::string &key );
void setMetadata( const std::string &key, const std::string &val );
std::string name();
void setName( const std::string &name );
Metadata metadata;
bool isScalar = true;
bool isOnVertices = true;
Datasets datasets;
std::string uri; // file/uri from where it came
2018-05-16 11:20:25 +02:00
};
2018-07-18 09:00:34 +02:00
typedef std::vector<std::shared_ptr<DatasetGroup>> DatasetGroups;
struct Mesh
{
2018-05-16 11:20:25 +02:00
std::string uri; // file/uri from where it came
std::string crs;
2018-05-16 11:20:25 +02:00
Vertices vertices;
2018-05-16 11:20:25 +02:00
std::map<size_t, size_t> vertexIDtoIndex; // only for 2DM and DAT files
Faces faces;
2018-05-16 11:20:25 +02:00
std::map<size_t, size_t> faceIDtoIndex; // only for 2DM and DAT files
2018-07-18 09:00:34 +02:00
DatasetGroups datasetGroups;
void setSourceCrs( const std::string &str );
void setSourceCrsFromWKT( const std::string &wkt );
void setSourceCrsFromEPSG( int code );
2018-08-29 12:10:03 +02:00
void addBedElevationDataset();
2018-05-16 11:20:25 +02:00
};
} // namespace MDAL
#endif //MDAL_DEFINES_HPP