forked from rolker/bagViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBagIO.h
106 lines (84 loc) · 2.09 KB
/
BagIO.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef BAGIO_H
#define BAGIO_H
#include <QOpenGLContext>
#include <vector>
#include <memory>
#include <QVector3D>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QImage>
#include "bag.h"
#include "Bounds.h"
struct TileGL;
struct TileData
{
std::vector<GLfloat> elevations;
QImage normalMap;
std::vector<GLfloat> uncertainties;
};
typedef std::shared_ptr<TileData> TileDataPtr;
typedef std::pair<u32,u32> TileIndex2D;
struct Tile
{
TileIndex2D index;
Bounds bounds;
uint ncols,nrows;
float dx,dy;
TileDataPtr data;
std::shared_ptr<TileGL> gl;
TileIndex2D lowerLeftIndex;
std::map<TileIndex2D,std::shared_ptr<Tile> > subTiles;
std::shared_ptr<Tile> north;
std::shared_ptr<Tile> east;
std::shared_ptr<Tile> northEast;
};
typedef std::shared_ptr<Tile> TilePtr;
typedef std::map<TileIndex2D,TilePtr> TileMap;
class BagIO: public QThread
{
Q_OBJECT
public:
struct MetaData
{
float minElevation, maxElevation;
QVector3D size;
QVector3D swBottomCorner;
u32 ncols,nrows;
double dx,dy;
bool variableResolution;
MetaData():
minElevation(0.0),
maxElevation(0.0),
ncols(0),
nrows(0),
dx(0.0),
dy(0.0)
{
}
};
BagIO(QObject *parent = 0);
~BagIO();
bool open(QString const &bagFileName);
void close();
u32 getTileSize() const;
//std::vector<TilePtr> getOverviewTiles();
MetaData getMeta();
signals:
void metaLoaded();
void tileLoaded(TilePtr tile, bool isVR);
protected:
void run() Q_DECL_OVERRIDE;
private:
TilePtr loadTile(bagHandle &bag, TileIndex2D tileIndex, MetaData &meta) const;
TilePtr loadVarResTile(bagHandle &bag, TileIndex2D const tileIndex, MetaData const &meta, Tile const &parentTile) const;
QMutex mutex;
QWaitCondition condition;
bool restart;
bool abort;
u32 tileSize;
//TileMap overviewTiles;
MetaData meta;
QString filename;
};
#endif