vtkSpyPlotUniReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
3 // SPDX-License-Identifier: BSD-3-Clause
23 #ifndef vtkSpyPlotUniReader_h
24 #define vtkSpyPlotUniReader_h
25 
26 #include "vtkObject.h"
27 #include "vtkPVVTKExtensionsIOSPCTHModule.h" //needed for exports
28 class vtkSpyPlotBlock;
30 class vtkDataArray;
31 class vtkFloatArray;
32 class vtkIntArray;
34 class vtkSpyPlotIStream;
35 
37 {
38 public:
40  static vtkSpyPlotUniReader* New();
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
44 
47  vtkSetStringMacro(FileName);
48  vtkGetStringMacro(FileName);
49  virtual void SetCellArraySelection(vtkDataArraySelection* da);
51 
56  virtual int ReadInformation();
57 
62  int MakeCurrent();
63 
64  void PrintInformation();
65  void PrintMemoryUsage();
66 
68 
71  // FIXME: This collides with `windows.h` symbols. It should be renamed.
72  // https://gitlab.kitware.com/paraview/paraview/-/issues/20916
73  int SetCurrentTime(double time);
74  vtkGetMacro(CurrentTime, double);
75 
76  int SetCurrentTimeStep(int timeStep);
77  vtkGetMacro(CurrentTimeStep, int);
79 
81 
84  vtkGetVector2Macro(TimeStepRange, int);
85  vtkGetVector2Macro(TimeRange, double);
87 
89  vtkSetMacro(NeedToCheck, int);
91 
93 
96  int GetTimeStepFromTime(double time);
97  double GetTimeFromTimeStep(int timeStep);
99 
100  vtkGetMacro(NumberOfCellFields, int);
101 
102  double* GetTimeArray();
103 
108  int IsAMR();
109 
113  int GetNumberOfDataBlocks();
114 
118  const char* GetCellFieldName(int field);
119 
125  vtkDataArray* GetCellFieldData(int block, int field, int* fixed);
126 
131  vtkDataArray* GetMaterialMassField(const int& block, const int& materialIndex);
132 
137  vtkDataArray* GetMaterialVolumeFractionField(const int& block, const int& materialIndex);
138 
142  int MarkCellFieldDataFixed(int block, int field);
143 
147  vtkFloatArray* GetTracers();
148 
149  // Return the ith block (i.e. grid) in the reader
150  vtkSpyPlotBlock* GetBlock(int i);
151 
152  // Returns the number of materials
153  int GetNumberOfMaterials() const { return NumberOfMaterials; }
154 
155  // Returns the number of dimensions
156  int GetNumberOfDimensions() const { return NumberOfDimensions; }
157 
158  // Returns the coordinate system of the file
159  int GetCoordinateSystem() const { return IGM; }
160 
162  {
163  char Id[30];
164  char Comment[80];
165  int Index;
166  };
167  struct Variable
168  {
169  char* Name;
170  int Material;
171  int Index;
175  };
176  struct DataDump
177  {
178  int NumVars;
180  vtkTypeInt64* SavedVariableOffsets;
183  vtkTypeInt64 BlocksOffset;
190  };
192  {
193  char Name[30];
194  char Label[256];
195  };
197  {
198  int NumMarks;
200  int NumVars;
202  };
203  struct MarkerDump
204  {
213  };
216  vtkSetMacro(GenerateMarkers, int);
217  vtkGetMacro(GenerateMarkers, int);
218 
219  vtkGetMacro(MarkersOn, int);
220 
221  vtkSpyPlotBlock* GetDataBlock(int block);
222 
223  vtkSetMacro(DataTypeChanged, int);
224  void SetDownConvertVolumeFraction(int vf);
225 
226 protected:
228  ~vtkSpyPlotUniReader() override;
230 
231 private:
232  int RunLengthDataDecode(const unsigned char* in, int inSize, float* out, int outSize);
233  int RunLengthDataDecode(const unsigned char* in, int inSize, int* out, int outSize);
234  int RunLengthDataDecode(const unsigned char* in, int inSize, unsigned char* out, int outSize);
235 
236  int ReadHeader(vtkSpyPlotIStream* spis);
237  int ReadMarkerHeader(vtkSpyPlotIStream* spis);
238  int ReadCellVariableInfo(vtkSpyPlotIStream* spis);
239  int ReadMaterialInfo(vtkSpyPlotIStream* spis);
240  int ReadGroupHeaderInformation(vtkSpyPlotIStream* spis);
241  int ReadDataDumps(vtkSpyPlotIStream* spis);
242  int ReadMarkerDumps(vtkSpyPlotIStream* spis);
243 
244  vtkDataArray* GetMaterialField(const int& block, const int& materialIndex, const char* Id);
245 
246  // Header information
247  char FileDescription[128];
248  int FileVersion;
249  int SizeOfFilePointer;
250  int FileCompressionFlag;
251  int FileProcessorId;
252  int NumberOfProcessors;
253  int IGM;
254  int NumberOfDimensions;
255  int NumberOfMaterials;
256  int MaximumNumberOfMaterials;
257  double GlobalMin[3];
258  double GlobalMax[3];
259  int NumberOfBlocks;
260  int MaximumNumberOfLevels;
261  int MarkersOn;
262  int GenerateMarkers;
263 
264  // For storing possible cell/material fields meta data
265  int NumberOfPossibleCellFields;
266  CellMaterialField* CellFields;
267  int NumberOfPossibleMaterialFields;
268  CellMaterialField* MaterialFields;
269 
270  // Individual dump information
271  int NumberOfDataDumps;
272  int* DumpCycle;
273  double* DumpTime;
274  double* DumpDT; // SPCTH 102 (What is this anyway?)
275  vtkTypeInt64* DumpOffset;
276 
277  DataDump* DataDumps;
278 
279  // File name
280  char* FileName;
281 
282  // Was information read
283  int HaveInformation;
284 
285  // Current time and time range information
286  int CurrentTimeStep;
287  // Time step that the geometry represents
288  int GeomTimeStep;
289  double CurrentTime;
290  int TimeStepRange[2];
291  double TimeRange[2];
292 
293  // Indicates that the reader needs to check its data
294  // (Not its geometry) - the reason is that ReadData
295  // will be called a lot and there needs to be a way to
296  // optimize this
297  int NeedToCheck;
298 
299  int DataTypeChanged;
300  int DownConvertVolumeFraction;
301 
302  int NumberOfCellFields;
303 
304  vtkDataArraySelection* CellArraySelection;
305 
306  Variable* GetCellField(int field);
307  int IsVolumeFraction(Variable* var);
308 
309  vtkSpyPlotUniReader(const vtkSpyPlotUniReader&) = delete;
310  void operator=(const vtkSpyPlotUniReader&) = delete;
311 };
312 
314 {
315  return this->DumpTime;
316 }
317 
319 {
320  return (this->NumberOfBlocks > 1);
321 }
322 
323 #endif
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.