-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvtkSQLiteReader2.h
425 lines (340 loc) · 11.4 KB
/
vtkSQLiteReader2.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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
/*=========================================================================
Program: AstroViz plugin for ParaView
Module: $RCSfile: vtkSQLiteReader2.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 vtkSQLiteReader2 - Read points from a SQLite database
// .SECTION Description
// Reads points from a SQLite DB and displays them on screen
#ifndef __vtkSQLiteReader2_h
#define __vtkSQLiteReader2_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 vtkSQLiteReader2 : public vtkPolyDataAlgorithm
{
public:
static vtkSQLiteReader2* New();
vtkTypeRevisionMacro(vtkSQLiteReader2,vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// 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);
//BTX
protected:
//functions
vtkSQLiteReader2();
~vtkSQLiteReader2();
virtual int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info);
int RequestInformation(vtkInformation*, vtkInformationVector**,
vtkInformationVector*);
int RequestData(vtkInformation*,vtkInformationVector**,
vtkInformationVector*);
/* OUTDATED use vtkIdList instead
struct Track2{
int nPoints;
vtkstd::vector<vtkIdType> PointIds;
};
struct Snap2{
vtkstd::vector<vtkIdType> PointIds;
};
vtkstd::vector<Snap2> SnapInfo2;
vtkstd::vector<Track2> TrackInfo2;
*/
vtkstd::vector< vtkSmartPointer<vtkIdList> > SnapInfo2;
vtkstd::vector< vtkSmartPointer<vtkIdList> > TrackInfo2;
//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..
// dont store data in structs anymore...
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 InitComplete;
bool dataIsRead;
int nPoints;
int nTracks;
int nSnapshots;
int gidmax;
double Omega0;
double OmegaLambda;
double Hubble;
vtkstd::vector<int> SnapinfoDataColumns; // witch columns in db contain relevant data?
vtkstd::vector<int> StatDataColumns; // witch columns in db contain relevant data?
vtkstd::vector<int> StatCordinateColumns; // witch columns in db contain relevant data?
//vtkstd::vector<int> StatVelocityColumns; // NOT USED witch columns in db contain relevant data?
// these save witch column in the according table in db contains the vital ids
int SnapinfoSnapidColumn;
int StatSnapidColumn;
int StatGidColumn;
int TracksTrackidColumn;
int TracksSnapidColumn;
int TracksGidColumn;
// pointer to important dataarrays
vtkSmartPointer<vtkIdTypeArray> pGIdArray;
vtkSmartPointer<vtkIdTypeArray> pTrackIdArray;
vtkSmartPointer<vtkIdTypeArray> pSnapIdArray;
int dataArrayOffset;
};
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;
*/
};
// very old, dont use this
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
};
/* old
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 CollisionCalculation{
bool CalcIsDone;
double CollisionTolerance;
double MergingTolerance;
vtkSmartPointer<vtkIdList> CollisionPointIds;
vtkSmartPointer<vtkIdList> CollisionTrackIds;
vtkSmartPointer<vtkIdList> MergingPointIds;
vtkSmartPointer<vtkIdList> MergingTrackIds;
};
/* 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 SelectionStruct {
vtkSmartPointer<vtkIdList> Points;
vtkSmartPointer<vtkIdList> Tracks;
};
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;
CollisionCalculation collisionCalc;
//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:
vtkSQLiteReader2(const vtkSQLiteReader2&); // Not implemented.
void operator=(const vtkSQLiteReader2&); // Not implemented.
//variables
sqlite3 * db;
vtkSmartPointer<vtkPolyData> AllData;
vtkSmartPointer<vtkPolyData> SelectedData;
vtkSmartPointer<vtkPolyData> EmptyData;
vtkSmartPointer<vtkPolyData> TrackData;
vtkSmartPointer<vtkPolyData> SnapshotData;
//functions
int ReadHeader(); // reads the database header information
int readSnapshots(); // reads the snapshots
int readSnapshotInfo();
int readTracks();
int calculatePointData();
//int generateColors();
int findCollisions(CollisionCalculation*);
//int doCalculations(double,int);
int calcTolerance();
int generateSelection(
CollisionCalculation*, SelectionStruct*);
int generateSelectedData(
vtkSmartPointer<vtkPolyData>, 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
vtkSmartPointer<vtkIdList> IdListUnion (
vtkSmartPointer<vtkIdList>, vtkSmartPointer<vtkIdList>);
vtkSmartPointer<vtkIdList> IdListUnionUnique (
vtkSmartPointer<vtkIdList>, vtkSmartPointer<vtkIdList>);
vtkSmartPointer<vtkIdList> IdListIntersect (
vtkSmartPointer<vtkIdList>, vtkSmartPointer<vtkIdList>);
vtkSmartPointer<vtkIdList> IdListComplement (
vtkSmartPointer<vtkIdList>, vtkSmartPointer<vtkIdList>);
int IdTypeArray2IdList(vtkIdList* destination, vtkIdTypeArray* source);
int openDB(char*);
vtkStdString Int2Str(int);
double getDistance2(int, int);
//double getDistanceToO(int);
vtkSmartPointer<vtkFloatArray> CreateArray(
vtkDataSet *output, const char* arrayName, int numComponents=1);
vtkSmartPointer<vtkIntArray> CreateIntArray(
vtkDataSet *output, const char* arrayName, int numComponents=1);
vtkSmartPointer<vtkIdTypeArray> CreateIdTypeArray(
vtkDataSet *output, const char* arrayName, int numComponents=1);
int InitAllArrays(vtkDataSet *output, unsigned long numTuples);
struct timings{
double tot;
double main;
double init;
double read;
double calc;
double refresh;
double generateSelect;
double executeSelect;
} timing;
struct initData{
int nPoints;
int nTracks;
int nSnapshots;
} initData;
//ETX
};
#endif