vtkSpyPlotUniReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkSpyPlotUniReader.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
34 #ifndef vtkSpyPlotUniReader_h
35 #define vtkSpyPlotUniReader_h
36 
37 #include "vtkObject.h"
38 #include "vtkPVVTKExtensionsIOSPCTHModule.h" //needed for exports
39 class vtkSpyPlotBlock;
41 class vtkDataArray;
42 class vtkFloatArray;
43 class vtkIntArray;
45 class vtkSpyPlotIStream;
46 
48 {
49 public:
51  static vtkSpyPlotUniReader* New();
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
55 
58  vtkSetStringMacro(FileName);
59  vtkGetStringMacro(FileName);
60  virtual void SetCellArraySelection(vtkDataArraySelection* da);
62 
67  virtual int ReadInformation();
68 
73  int MakeCurrent();
74 
75  void PrintInformation();
76  void PrintMemoryUsage();
77 
79 
82  int SetCurrentTime(double time);
83  int SetCurrentTimeStep(int timeStep);
84  vtkGetMacro(CurrentTime, double);
85  vtkGetMacro(CurrentTimeStep, int);
87 
89 
92  vtkGetVector2Macro(TimeStepRange, int);
93  vtkGetVector2Macro(TimeRange, double);
95 
97  vtkSetMacro(NeedToCheck, int);
99 
101 
104  int GetTimeStepFromTime(double time);
105  double GetTimeFromTimeStep(int timeStep);
107 
108  vtkGetMacro(NumberOfCellFields, int);
109 
110  double* GetTimeArray();
111 
116  int IsAMR();
117 
121  int GetNumberOfDataBlocks();
122 
126  const char* GetCellFieldName(int field);
127 
133  vtkDataArray* GetCellFieldData(int block, int field, int* fixed);
134 
139  vtkDataArray* GetMaterialMassField(const int& block, const int& materialIndex);
140 
145  vtkDataArray* GetMaterialVolumeFractionField(const int& block, const int& materialIndex);
146 
150  int MarkCellFieldDataFixed(int block, int field);
151 
155  vtkFloatArray* GetTracers();
156 
157  // Return the ith block (i.e. grid) in the reader
158  vtkSpyPlotBlock* GetBlock(int i);
159 
160  // Returns the number of materials
161  int GetNumberOfMaterials() const { return NumberOfMaterials; }
162 
163  // Returns the number of dimensions
164  int GetNumberOfDimensions() const { return NumberOfDimensions; }
165 
166  // Returns the coordinate system of the file
167  int GetCoordinateSystem() const { return IGM; }
168 
170  {
171  char Id[30];
172  char Comment[80];
173  int Index;
174  };
175  struct Variable
176  {
177  char* Name;
178  int Material;
179  int Index;
183  };
184  struct DataDump
185  {
186  int NumVars;
188  vtkTypeInt64* SavedVariableOffsets;
191  vtkTypeInt64 BlocksOffset;
198  };
200  {
201  char Name[30];
202  char Label[256];
203  };
205  {
206  int NumMarks;
208  int NumVars;
210  };
211  struct MarkerDump
212  {
221  };
224  vtkSetMacro(GenerateMarkers, int);
225  vtkGetMacro(GenerateMarkers, int);
226 
227  vtkGetMacro(MarkersOn, int);
228 
229  vtkSpyPlotBlock* GetDataBlock(int block);
230 
231  vtkSetMacro(DataTypeChanged, int);
232  void SetDownConvertVolumeFraction(int vf);
233 
234 protected:
236  ~vtkSpyPlotUniReader() override;
238 
239 private:
240  int RunLengthDataDecode(const unsigned char* in, int inSize, float* out, int outSize);
241  int RunLengthDataDecode(const unsigned char* in, int inSize, int* out, int outSize);
242  int RunLengthDataDecode(const unsigned char* in, int inSize, unsigned char* out, int outSize);
243 
244  int ReadHeader(vtkSpyPlotIStream* spis);
245  int ReadMarkerHeader(vtkSpyPlotIStream* spis);
246  int ReadCellVariableInfo(vtkSpyPlotIStream* spis);
247  int ReadMaterialInfo(vtkSpyPlotIStream* spis);
248  int ReadGroupHeaderInformation(vtkSpyPlotIStream* spis);
249  int ReadDataDumps(vtkSpyPlotIStream* spis);
250  int ReadMarkerDumps(vtkSpyPlotIStream* spis);
251 
252  vtkDataArray* GetMaterialField(const int& block, const int& materialIndex, const char* Id);
253 
254  // Header information
255  char FileDescription[128];
256  int FileVersion;
257  int SizeOfFilePointer;
258  int FileCompressionFlag;
259  int FileProcessorId;
260  int NumberOfProcessors;
261  int IGM;
262  int NumberOfDimensions;
263  int NumberOfMaterials;
264  int MaximumNumberOfMaterials;
265  double GlobalMin[3];
266  double GlobalMax[3];
267  int NumberOfBlocks;
268  int MaximumNumberOfLevels;
269  int MarkersOn;
270  int GenerateMarkers;
271 
272  // For storing possible cell/material fields meta data
273  int NumberOfPossibleCellFields;
274  CellMaterialField* CellFields;
275  int NumberOfPossibleMaterialFields;
276  CellMaterialField* MaterialFields;
277 
278  // Individual dump information
279  int NumberOfDataDumps;
280  int* DumpCycle;
281  double* DumpTime;
282  double* DumpDT; // SPCTH 102 (What is this anyway?)
283  vtkTypeInt64* DumpOffset;
284 
285  DataDump* DataDumps;
286 
287  // File name
288  char* FileName;
289 
290  // Was information read
291  int HaveInformation;
292 
293  // Current time and time range information
294  int CurrentTimeStep;
295  // Time step that the geometry represents
296  int GeomTimeStep;
297  double CurrentTime;
298  int TimeStepRange[2];
299  double TimeRange[2];
300 
301  // Indicates that the reader needs to check its data
302  // (Not its geometry) - the reason is that ReadData
303  // will be called a lot and there needs to be a way to
304  // optimize this
305  int NeedToCheck;
306 
307  int DataTypeChanged;
308  int DownConvertVolumeFraction;
309 
310  int NumberOfCellFields;
311 
312  vtkDataArraySelection* CellArraySelection;
313 
314  Variable* GetCellField(int field);
315  int IsVolumeFraction(Variable* var);
316 
317 private:
318  vtkSpyPlotUniReader(const vtkSpyPlotUniReader&) = delete;
319  void operator=(const vtkSpyPlotUniReader&) = delete;
320 };
321 
323 {
324  return this->DumpTime;
325 }
326 
328 {
329  return (this->NumberOfBlocks > 1);
330 }
331 
332 #endif
333 
334 // VTK-HeaderTest-Exclude: vtkSpyPlotUniReader.h
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
MaterialMarker * Markers
int GetNumberOfMaterials() const
int GetNumberOfDimensions() const
int IsAMR()
Returns 1 if the grid information contained in the file has Adaptive Mesh Refinement (AMR) else it re...
vtkSpyPlotIStream represents input functionality required by the vtkSpyPlotReader and vtkSpyPlotUniRe...
vtkSpyPlotBlock * Blocks
#define VTKPVVTKEXTENSIONSIOSPCTH_EXPORT
static vtkObject * New()
Represents a SpyPlot Block Grid.
Read SPCTH Spy Plot file format.