File: vtkPGenericIOReader.h

package info (click to toggle)
paraview 5.1.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 221,108 kB
  • ctags: 236,092
  • sloc: cpp: 2,416,026; ansic: 190,891; python: 99,856; xml: 81,001; tcl: 46,915; yacc: 5,039; java: 4,413; perl: 3,108; sh: 1,974; lex: 1,926; f90: 748; asm: 471; pascal: 228; makefile: 198; objc: 83; fortran: 31
file content (296 lines) | stat: -rw-r--r-- 9,203 bytes parent folder | download
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
/*=========================================================================

 Program:   Visualization Toolkit
 Module:    vtkPGenericIOReader.h

 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
 All rights reserved.
 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

 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 vtkPGenericIOReader.h -- Read GenericIO formatted data
//
// .SECTION Description
//  Creates a vtkUnstructuredGrid instance from a GenericIO file.

#ifndef vtkPGenericIOReader_h
#define vtkPGenericIOReader_h

// VTK includes
#include "vtkUnstructuredGridAlgorithm.h"
#include "vtkPVVTKExtensionsCosmoToolsModule.h" // For export macro

#include <set> // for std::set in protected methods

// Forward Declarations
class vtkCallbackCommand;
class vtkDataArray;
class vtkDataArraySelection;
class vtkGenericIOMetaData;
class vtkIdList;
class vtkInformation;
class vtkInformationVector;
class vtkMultiProcessController;
class vtkStdString;
class vtkStringArray;
class vtkUnstructuredGrid;

// GenericIO Forward Declarations
namespace gio {
  class GenericIOReader;
}

class VTKPVVTKEXTENSIONSCOSMOTOOLS_EXPORT vtkPGenericIOReader :
  public vtkUnstructuredGridAlgorithm
{
public:

enum IOType {
  IOTYPEMPI,
  IOTYPEPOSIX
};

enum BlockAssignment {
  ROUND_ROBIN,
  RCB
};


  static vtkPGenericIOReader *New();
  vtkTypeMacro(vtkPGenericIOReader,vtkUnstructuredGridAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // Specify the name of the cosmology particle binary file to read
  vtkSetStringMacro(FileName);
  vtkGetStringMacro(FileName);

  // Description:
  // Set/Get the variable name to be used as the x-axis for plotting particles.
  vtkSetStringMacro(XAxisVariableName);
  vtkGetStringMacro(XAxisVariableName);

  // Description:
  // Set/Get the variable name to be used as the x-axis for plotting particles.
  vtkSetStringMacro(YAxisVariableName);
  vtkGetStringMacro(YAxisVariableName);

  // Description:
  // Set/Get the variable name to be used as the x-axis for plotting particles.
  vtkSetStringMacro(ZAxisVariableName);
  vtkGetStringMacro(ZAxisVariableName);

  // Description:
  // Set/Get the underlying IO method the reader will employ, i.e., MPI or POSIX.
  vtkSetMacro(GenericIOType,int);
  vtkGetMacro(GenericIOType,int);

  // Description:
  // Set/Get the underlying block-assignment strategy to use, i.e., ROUND_ROBIN,
  // or RCB.
  vtkSetMacro(BlockAssignment,int);
  vtkGetMacro(BlockAssignment,int);

  // Description:
  // Set/Get the RankInQuery. Used in combination with SetQueryRankNeighbors(1)
  // tells the reader to render only the data of the RankInQuery and its
  // neighbors.
  vtkSetMacro(RankInQuery,int);
  vtkGetMacro(RankInQuery,int);

  // Description:
  // Set/Get whether the reader should read/render only the data of the
  // user-supplied rank, via SetRankInQuery(),
  vtkSetMacro(QueryRankNeighbors,int);
  vtkGetMacro(QueryRankNeighbors,int);

  // Description:
  // Set/Get whether the reader should append the coordinates of the block each
  // point was read from as a point data array.  Defaults to false (Off).
  vtkSetMacro(AppendBlockCoordinates,bool);
  vtkBooleanMacro(AppendBlockCoordinates,bool);
  vtkGetMacro(AppendBlockCoordinates,bool);

  // Description:
  // Returns the list of arrays used to select the variables to be used
  // for the x,y and z axis.
  vtkGetObjectMacro(ArrayList,vtkStringArray);

  // Description:
  // Get the data array selection tables used to configure which data
  // arrays are loaded by the reader.
  vtkGetObjectMacro(PointDataArraySelection,vtkDataArraySelection);

  // Description:
  // Set/Get a multiprocess-controller for reading in parallel.
  // By default this parameter is set to NULL by the constructor.
  vtkSetMacro(Controller,vtkMultiProcessController*);
  vtkGetMacro(Controller,vtkMultiProcessController*);

  // Description:
  // Returns the number of arrays in the file, i.e., the number of columns.
  int GetNumberOfPointArrays();

  // Description:
  // Returns the name of the ith array.
  const char* GetPointArrayName(int i);

  // Description:
  // Returns the status of the array corresponding to the given name.
  int GetPointArrayStatus(const char* name);

  // Description:
  // Sets the status of the array named.  If the status is 1, the array
  // will be read in on the resulting dataset.
  void SetPointArrayStatus(const char* name, int status);

  // Description:
  // Gets/Sets the variable name for the halo id of the particle.
  // This is used by the requested halo selector to select only the
  // points in the desired halos.
  vtkSetStringMacro(HaloIdVariableName);
  vtkGetStringMacro(HaloIdVariableName);

  // Description:
  // Gets the ith requested halo id.
  // If the number of requested halo ids is
  // greater than 0, only points with those halo ids will be read in.
  // Otherwise all points will be read in.
  vtkIdType GetRequestedHaloId(vtkIdType i);

  // Description:
  // Gets the number of requested halo ids.
  // If the number of requested halo ids is
  // greater than 0, only points with those halo ids will be read in.
  // Otherwise all points will be read in.
  vtkIdType GetNumberOfRequestedHaloIds();

  // Description:
  // Sets the number of requested halo ids.
  // Use SetRequestedHaloId() to se the ids after this is called
  // If the number of requested halo ids is
  // greater than 0, only points with those halo ids will be read in.
  // Otherwise all points will be read in.
  void SetNumberOfRequestedHaloIds(vtkIdType numIds);

  // Description:
  // Adds the given halo id to the list of halo ids to request.
  // If the number of requested halo ids is
  // greater than 0, only points with those halo ids will be read in.
  // Otherwise all points will be read in.
  void AddRequestedHaloId(vtkIdType haloId);

  // Description:
  // Clears the list of requested halo ids.
  // If the number of requested halo ids is
  // greater than 0, only points with those halo ids will be read in.
  // Otherwise all points will be read in.
  void ClearRequestedHaloIds();

  // Description:
  // Sets the ith requested halo id to the given haloId.
  // If the number of requested halo ids is
  // greater than 0, only points with those halo ids will be read in.
  // Otherwise all points will be read in.
  void SetRequestedHaloId(vtkIdType i, vtkIdType haloId);

protected:
  vtkPGenericIOReader();
  virtual ~vtkPGenericIOReader();

  // Pipeline methods
  virtual int RequestInformation(
      vtkInformation*,vtkInformationVector**,vtkInformationVector*);
  virtual int RequestData(
      vtkInformation*,vtkInformationVector**,vtkInformationVector*);

  // Description:
  // Loads the GenericIO metadata from the file.
  void LoadMetaData();

  // Description:
  // This method checks if the internal reader parameters have changed.
  // Namely, if the I/O method or filename have changed, the method returns
  // true.
  bool ReaderParametersChanged();

  // Description:
  // Returns the internal reader instance according to IOType.
  gio::GenericIOReader* GetInternalReader();


  // Description:
  // Return the point from the raw data.
  void GetPointFromRawData(
          int xType, void* xBuffer,
          int yType, void* yBuffer,
          int zType, void* zBuffer,
          vtkIdType idx,
          double pnt[3]);

  // Description:
  // Loads the variable with the given name
  void LoadRawVariableData(std::string varName);

  // Description:
  // Loads the Raw data
  void LoadRawData();

  // Description:
  // Loads the particle coordinates
  void LoadCoordinates(vtkUnstructuredGrid *grid,
                       std::set< vtkIdType >& pointsInSelectedHalos);

  // Description:
  // Loads the particle data arrays
  void LoadData(vtkUnstructuredGrid *grid,
                const std::set< vtkIdType >& pointsInSelectedHalos);

  // Description:
  // Finds the neighbors of the user-supplied rank
  void FindRankNeighbors();

  // Descriptions
  // Call-back registered with the SelectionObserver.
  static void SelectionModifiedCallback(
    vtkObject *caller,unsigned long eid,
    void *clientdata,void *calldata );

  char *XAxisVariableName;
  char *YAxisVariableName;
  char *ZAxisVariableName;
  char *HaloIdVariableName;

  char *FileName;
  int GenericIOType;
  int BlockAssignment;

  int QueryRankNeighbors;
  int RankInQuery;

  bool BuildMetaData;
  bool AppendBlockCoordinates;


  vtkMultiProcessController* Controller;

  vtkStringArray* ArrayList;
  vtkIdList* HaloList;
  vtkDataArraySelection* PointDataArraySelection;
  vtkCallbackCommand* SelectionObserver;

  gio::GenericIOReader* Reader;
  vtkGenericIOMetaData* MetaData;

  int RequestInfoCounter;
  int RequestDataCounter;
private:
  vtkPGenericIOReader(const vtkPGenericIOReader&); // Not implemented.
  void operator=(const vtkPGenericIOReader&); // Not implemented.
};

#endif /* vtkPGenericIOReader_h */