-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvtkSQLiteReader.h
370 lines (296 loc) · 10.2 KB
/
vtkSQLiteReader.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
/*=========================================================================
Program: AstroViz plugin for ParaView
Module: $RCSfile: vtkSQLiteReader.h,v $
Copyright (c) Rafael Kueng
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkSQLiteReader - Read points from a SQLite database
// .SECTION Description
// Reads points from a SQLite DB and displays them on screen
#ifndef __vtkSQLiteReader_h
#define __vtkSQLiteReader_h
#include "vtkPolyDataAlgorithm.h" // superclass
#include "sqlitelib/sqlite3.h" // sqlite headerfile
#include "vtkObjectFactory.h"
#include "vtkSmartPointer.h"
#include "vtkPolyData.h"
#include "vtkPoints.h"
#include "vtkCellArray.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include <vtkstd/vector>
class vtkPolyData;
class vtkCharArray;
class vtkIdTypeArray;
class vtkFloatArray;
class vtkPoints;
class vtkCellArray;
class vtkDataArraySelection;
class VTK_EXPORT vtkSQLiteReader : public vtkPolyDataAlgorithm
{
public:
static vtkSQLiteReader* New();
vtkTypeRevisionMacro(vtkSQLiteReader,vtkPolyDataAlgorithm);
// Set/Get the name of the file from which to read points.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
vtkSetMacro(DisplayColliding,bool);
vtkGetMacro(DisplayColliding,bool);
vtkSetMacro(DisplayMerging,bool);
vtkGetMacro(DisplayMerging,bool);
vtkSetMacro(DisplayInverted,bool);
vtkGetMacro(DisplayInverted,bool);
vtkSetMacro(UpperLimit,double);
vtkGetMacro(UpperLimit,double);
vtkSetMacro(LowerLimit,double);
vtkGetMacro(LowerLimit,double);
/*
vtkSetMacro(DisplayOnlySelectedData,bool);
vtkGetMacro(DisplayOnlySelectedData,bool);
vtkSetMacro(DisplaySelected,bool);
vtkGetMacro(DisplaySelected,bool);
vtkSetMacro(DisplaySelectedSnapshot,bool);
vtkGetMacro(DisplaySelectedSnapshot,bool);
vtkSetMacro(DisplaySelectedSnapshotNr,int);
vtkGetMacro(DisplaySelectedSnapshotNr,int);
vtkSetMacro(DisplaySelectedTrack,bool);
vtkGetMacro(DisplaySelectedTrack,bool);
vtkSetMacro(DisplaySelectedTrackNr,int);
vtkGetMacro(DisplaySelectedTrackNr,int);
vtkSetMacro(DisplayCalculated,bool);
vtkGetMacro(DisplayCalculated,bool);
vtkSetMacro(CalculationImpactParameter,double);
vtkGetMacro(CalculationImpactParameter,double);
vtkSetMacro(calcHighlightCollisionPoints,bool);
vtkGetMacro(calcHighlightCollisionPoints,bool);
vtkSetMacro(calcHighlightTrack,bool);
vtkGetMacro(calcHighlightTrack,bool);
vtkSetMacro(calcHighlightSnapshot,bool);
vtkGetMacro(calcHighlightSnapshot,bool);
vtkSetMacro(calcHighlightPoint,bool);
vtkGetMacro(calcHighlightPoint,bool);
vtkSetMacro(calcHighlightTrackNr,int);
vtkGetMacro(calcHighlightTrackNr,int);
vtkSetMacro(calcHighlightSnapshotNr,int);
vtkGetMacro(calcHighlightSnapshotNr,int);
vtkSetMacro(calcHighlightPointNr,int);
vtkGetMacro(calcHighlightPointNr,int);
vtkSetMacro(DisplayEstimateTolerance,bool);
vtkGetMacro(DisplayEstimateTolerance,bool);
*/
//BTX
protected:
//functions
vtkSQLiteReader();
~vtkSQLiteReader();
int RequestInformation(vtkInformation*, vtkInformationVector**,
vtkInformationVector*);
int RequestData(vtkInformation*,vtkInformationVector**,
vtkInformationVector*);
//structs
struct SnapshotInfo {
vtkIdType Offset; //stores the id where this snapshot starts
int lenght; // stores the amount of halos in this snapshot
std::vector<int> PointId; //allocates gid to new id (PointId.at(gid) = id+offset) maybee save here some mem, by using smaller datatype..
int snapshotNr; // snapshot Nr from simulation (this is not the id!)
double redshift;
double time;
int npart;
double CvAverage;
};
struct Track {
int nPoints;
//int StartSnap;
//int EndSnap;
std::vector<vtkIdType> PointsIds; //v of length nSnaps, entry of -1 if this track doesnt have a point in this snap
};
struct DataInformation {
bool dataIsRead;
int nPoints;
int nTracks;
int nSnapshots;
double hubble;
/*
int nSelectedPoints; //-1 means all, single points selected to display
int nSelectedTracks; // -1 means all
int nSelectedSnapshots;
int nAllSelectedPoints; // # of all points (inkl tracks, snaps) to display
std::vector<int> selectedPoints; // holds globalids from points to display
std::vector<int> selectedSnapshots; //holds snapids of points from snapshot to display
std::vector<int> selectedTracks; //holds trackid from points to display
std::vector<int> idMap1; //mapps ids from read in data to displayed data
std::vector<int> idMap2; //mapps ids from displayed data to read in data
*/
};
struct GuiStruct {
bool * DisplayColliding;
bool * DisplayMerging;
bool * DisplayInverted;
double * LowerLimit;
double * UpperLimit;
/*
bool * DisplayOnlySelectedData;
bool * DisplaySelected;
bool * DisplaySelectedSnapshot;
int * DisplaySelectedSnapshotNr;
bool * DisplaySelectedTrack;
int * DisplaySelectedTrackNr;
bool * DisplayCalculated;
double * CalculationImpactParameter;
bool * calcHighlightCollisionPoints;
bool * calcHighlightTrack;
bool * calcHighlightSnapshot;
bool * calcHighlightPoint;
int * calcHighlightTrackNr;
int * calcHighlightSnapshotNr;
int * calcHighlightPointNr;
bool * DisplayEstimateTolerance;
*/
};
struct Data {
vtkSmartPointer<vtkPoints> Position;
vtkSmartPointer<vtkFloatArray> Velocity;
vtkSmartPointer<vtkCellArray> Cells;
vtkSmartPointer<vtkCellArray> Tracks;
vtkSmartPointer<vtkIntArray> TrackId;
vtkSmartPointer<vtkIntArray> GId;
vtkSmartPointer<vtkIntArray> SnapId;
vtkSmartPointer<vtkFloatArray> Mvir;
vtkSmartPointer<vtkFloatArray> Rvir;
vtkSmartPointer<vtkFloatArray> Vmax;
vtkSmartPointer<vtkFloatArray> Rmax;
vtkSmartPointer<vtkFloatArray> Redshift;
vtkSmartPointer<vtkFloatArray> Time;
vtkSmartPointer<vtkFloatArray> Cv;
vtkSmartPointer<vtkFloatArray> CvAverage;
vtkSmartPointer<vtkFloatArray> RGc;
vtkSmartPointer<vtkUnsignedCharArray> CollisionTypePoint;
vtkSmartPointer<vtkUnsignedCharArray> CollisionTypeTrack;
};
struct CalculationSettings {
// OLD dont use this
bool calcDone;
double tolerance;
int nCollisions;
int nSelectedPoints; //-1 means all, single points selected to display
int nSelectedTracks; // -1 means all
int nAllSelectedPoints; // # of all points (inkl tracks, snaps) to display
std::vector<int> selectedPoints; // stores globalids from points to display
std::vector<int> selectedTracks; //stores trackid from points to display
};
struct CollisionResultStruct{
int nEvents;
int nPoints;
std::vector<int> vPointIds;
int nTracks;
std::vector<int> vTrackIds;
};
struct CollisionCalculationStruct{
bool isDone;
double upperTolerance;
double lowerTolerance;
CollisionResultStruct Colliding;
CollisionResultStruct Merging;
};
struct SelectionStruct{
int nSelectedPoints;
int nSelectedTracks;
int nSelectedSnapshots;
std::vector<int> vPointIds;
std::vector<int> vTrackIds;
std::vector<int> vSnapshotIds;
std::vector<int> vPointIdMap;
std::vector<int> vPointIdMapReverse; // equal to vPointIds!!
std::vector<int> vTrackIdMap;
};
struct ResultOfEsimationOfTolerance {
int goal;
double parameter;
int nCollisions;
};
//variables (not used!)
/*
vtkSmartPointer<vtkPoints> Position;
vtkSmartPointer<vtkFloatArray> Velocity;
vtkSmartPointer<vtkCellArray> Cells;
vtkSmartPointer<vtkCellArray> Tracks;
vtkSmartPointer<vtkIdTypeArray> TrackId;
vtkSmartPointer<vtkIdTypeArray> GId;
vtkSmartPointer<vtkIdTypeArray> SnapId;
vtkSmartPointer<vtkFloatArray> RVir;
vtkSmartPointer<vtkUnsignedCharArray> colors;
*/
//vtkSmartPointer<vtkUnsignedCharArray> opacity;
DataInformation dataInfo;
GuiStruct Gui;
Data allData, selectedData, emptyData;
CalculationSettings calcInfo;
SelectionStruct selection;
CollisionCalculationStruct collisionCalc;
std::vector<ResultOfEsimationOfTolerance> calcEstTol;
vtkSmartPointer<vtkFloatArray> calcEstTol2;
std::vector<SnapshotInfo> SnapInfo;
std::vector<Track> TracksInfo;
//gui variables
char* FileName;
bool DisplayColliding;
bool DisplayMerging;
bool DisplayInverted;
double LowerLimit;
double UpperLimit;
/*
bool DisplayOnlySelectedData;
bool DisplaySelected;
bool DisplaySelectedSnapshot;
int DisplaySelectedSnapshotNr;
bool DisplaySelectedTrack;
int DisplaySelectedTrackNr;
bool DisplayCalculated;
double CalculationImpactParameter;
bool calcHighlightCollisionPoints;
bool calcHighlightTrack;
bool calcHighlightSnapshot;
bool calcHighlightPoint;
int calcHighlightTrackNr;
int calcHighlightSnapshotNr;
int calcHighlightPointNr;
bool DisplayEstimateTolerance;
*/
private:
vtkSQLiteReader(const vtkSQLiteReader&); // Not implemented.
void operator=(const vtkSQLiteReader&); // Not implemented.
//variables
sqlite3 * db;
bool dataIsRead;
//functions
int ReadHeader(); // reads the database header information
int readSnapshots(); // reads the snapshots
int readSnapshotInfo();
int readTracks();
int calculateAdditionalData();
int generateColors();
int findCollisions(CollisionCalculationStruct*);
//int doCalculations(double,int);
int calcTolerance();
int generateSelection(CollisionCalculationStruct*, SelectionStruct*);
int fillIdList(std::vector<int>*, int*,
std::vector<int>*, int*,
CollisionResultStruct*, int);
int generateIdMap();
int generatePoints(SelectionStruct*, Data*);
int generateTracks(SelectionStruct*, Data*);
int reset();
// helper
int openDB(char*);
vtkStdString Int2Str(int);
double getDistance2(int, int);
double getDistanceToO(int);
// old stuff - not yet, or not anymore needed
int RequestDataDemo(vtkInformationVector*);
int SQLQuery(vtkStdString, sqlite3_stmt*);
//ETX
};
#endif