vtkSpyPlotReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkSpyPlotReader.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 =========================================================================*/
52 #ifndef vtkSpyPlotReader_h
53 #define vtkSpyPlotReader_h
54 
56 #include "vtkPVVTKExtensionsIOSPCTHModule.h" //needed for exports
57 
58 class vtkBoundingBox;
59 class vtkCallbackCommand;
60 class vtkCellData;
61 class vtkDataArray;
64 // class vtkHierarchicalBoxDataSet;
68 class vtkRectilinearGrid;
69 class vtkSpyPlotBlock;
73 
75 {
76 public:
77  static vtkSpyPlotReader* New();
79  void PrintSelf(ostream& os, vtkIndent indent) override;
80  void PrintBlockList(vtkNonOverlappingAMR* hbds, int myProcId);
81 
83 
87  virtual void SetFileName(const char* filename);
88  vtkGetStringMacro(FileName);
90 
92 
96  vtkSetMacro(TimeStep, int);
97  vtkGetMacro(TimeStep, int);
99 
101 
108  vtkSetMacro(DistributeFiles, int);
109  vtkGetMacro(DistributeFiles, int);
110  vtkBooleanMacro(DistributeFiles, int);
112 
114 
119  vtkSetMacro(GenerateLevelArray, int);
120  vtkGetMacro(GenerateLevelArray, int);
121  vtkBooleanMacro(GenerateLevelArray, int);
123 
125 
130  vtkSetMacro(GenerateBlockIdArray, int);
131  vtkGetMacro(GenerateBlockIdArray, int);
132  vtkBooleanMacro(GenerateBlockIdArray, int);
134 
136 
141  vtkSetMacro(GenerateActiveBlockArray, int);
142  vtkGetMacro(GenerateActiveBlockArray, int);
143  vtkBooleanMacro(GenerateActiveBlockArray, int);
145 
147 
152  vtkSetMacro(GenerateTracerArray, int);
153  vtkGetMacro(GenerateTracerArray, int);
154  vtkBooleanMacro(GenerateTracerArray, int);
156 
158 
163  void SetGenerateMarkers(int gm);
164  vtkGetMacro(GenerateMarkers, int);
165  vtkBooleanMacro(GenerateMarkers, int);
167 
169 
173  void SetDownConvertVolumeFraction(int vf);
174  vtkGetMacro(DownConvertVolumeFraction, int);
175  vtkBooleanMacro(DownConvertVolumeFraction, int);
177 
179 
184  vtkSetMacro(ComputeDerivedVariables, int);
185  vtkGetMacro(ComputeDerivedVariables, int);
186  vtkBooleanMacro(ComputeDerivedVariables, int);
188 
190 
197  void SetMergeXYZComponents(int merge);
198  vtkGetMacro(MergeXYZComponents, int);
199  vtkBooleanMacro(MergeXYZComponents, int);
201 
203 
206  vtkGetVector2Macro(TimeStepRange, int);
208 
210 
213  int GetNumberOfCellArrays();
214  const char* GetCellArrayName(int idx);
215  int GetCellArrayStatus(const char* name);
216  void SetCellArrayStatus(const char* name, int status);
218 
224  void SetGlobalController(vtkMultiProcessController* controller);
225 
229  virtual int CanReadFile(const char* fname);
230 
231 protected:
233  ~vtkSpyPlotReader() override;
234 
235  // Determine the bounds of just this reader
236  void GetLocalBounds(vtkSpyPlotBlockIterator* biter, int nBlocks, int progressInterval);
237 
238  // Set the global bounds of all readers
239  void SetGlobalBounds(vtkSpyPlotBlockIterator* biter, int total_num_of_block, int progressInterval,
240  int* rightHasBounds, int* leftHasBounds);
241 
242  // Determine the box size on just this reader
243  // returns true if box size is a constant on this reader
244  // false if not.
245  bool GetLocalBoxSize(vtkSpyPlotBlockIterator* biter, int* localBoxSize) const;
246 
247  // Determine box size if it is a constant across the data set
248  // If not then this is set to -1,-1,-1.
249  void SetGlobalBoxSize(vtkSpyPlotBlockIterator* biter);
250 
251  // Determine the minimum level that is used on just this level
252  // and get the spacing there
253  void GetLocalMinLevelAndSpacing(
254  vtkSpyPlotBlockIterator* biter, int* localMinLevel, double spacing[3]) const;
255 
256  // Set the minimum level that is used
257  // and get the spacing there
258  void SetGlobalMinLevelAndSpacing(vtkSpyPlotBlockIterator* biter);
259 
260  // Set things up to process an AMR Block
261  int PrepareAMRData(vtkNonOverlappingAMR* hb, vtkSpyPlotBlock* block, int* level, int* blockId,
262  int extents[6], int realExtents[6], int realDims[3], vtkCellData** cd);
263 
264  // Set things up to process a non-AMR Block
265  int PrepareData(vtkMultiBlockDataSet* hb, vtkSpyPlotBlock* block, vtkRectilinearGrid** rg,
266  int extents[6], int realExtents[6], int realDims[3], vtkCellData** cd);
267 
268  // Update the field data (interms of ghost cells) that
269  // contain whose block did not contain any bad ghost cells
270  void UpdateFieldData(int numFields, int dims[3], int level, int blockID,
271  vtkSpyPlotUniReader* uniReader, vtkCellData* cd);
272 
273  // Update the field data (interms of ghost cells) that
274  // contain whose block did contain bad ghost cells
275  void UpdateBadGhostFieldData(int numFields, int dims[3], int realDims[3], int realExtents[6],
276  int level, int blockID, vtkSpyPlotUniReader* uniReader, vtkCellData* cd);
277 
278  // Sets up the blocks for the markers data
279  void PrepareBlocks(vtkMultiBlockDataSet* poly, int numMat);
280 
281  // Sets up the markers data on the second output port
282  int PrepareMarkers(vtkMultiBlockDataSet* poly, vtkSpyPlotUniReader* reader);
283 
284  // The array selections.
286 
287  int FillOutputPortInformation(int port, vtkInformation* info) override;
288 
289  // Create either vtkNonOverlappingAMR or vtkMultiBlockDataSet based on
290  // whether the dataset is AMR.
291  int RequestDataObject(
292  vtkInformation* req, vtkInformationVector** inV, vtkInformationVector* outV) override;
293 
294  // Read the case file and the first binary file do get meta
295  // information (number of files, number of fields, number of timestep).
296  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
297  vtkInformationVector* outputVector) override;
298 
299  // Read the data: get the number of pieces (=processors) and get
300  // my piece id (=my processor id).
301  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
302  vtkInformationVector* outputVector) override;
303 
311  int UpdateMetaData(vtkInformation* request, vtkInformationVector* outputVector);
312 
313  int UpdateFile(vtkInformation* request, vtkInformationVector* outputVector);
314 
315  void AddGhostLevelArray(int numLevels);
316  int AddBlockIdArray(vtkCompositeDataSet* cds);
317  int AddAttributes(vtkNonOverlappingAMR* hbds);
318  int AddActiveBlockArray(vtkCellData* cd, vtkIdType nCells, unsigned char status);
319 
320  // Have all the readers have the same global level structure
321  void SetGlobalLevels(vtkCompositeDataSet* cds);
322 
323  // The observer to modify this object when the array selections are
324  // modified.
325  char* FileName;
326 
327  int TimeStep; // set by the user
328  int TimeStepRange[2];
329  int CurrentTimeStep; // computed
330 
331  int IsAMR; // AMR (hierarchy of uniform grids)
332  // or flat mesh (set of rectilinear grids)?
333 
334  // access to all processes
336 
340  int UpdateTimeStep(
341  vtkInformation* requestInfo, vtkInformationVector* outputInfo, vtkCompositeDataSet* hb);
342 
346  int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
347  const int extents[6] = 0) override
348  {
349  return this->Superclass::UpdateTimeStep(time, piece, numPieces, ghostLevels, extents);
350  }
351 
352  // The file format stores a vector field as separated scalar component
353  // fields. This method rebuilds the vector field from those scalar
354  // component fields.
355  void MergeVectors(vtkDataSetAttributes* da);
356  int MergeVectors(vtkDataSetAttributes* da, vtkDataArray* a1, vtkDataArray* a2);
357  int MergeVectors(vtkDataSetAttributes* da, vtkDataArray* a1, vtkDataArray* a2, vtkDataArray* a3);
358 
360  int ComputeDerivedVars(
361  vtkCellData* data, vtkSpyPlotBlock* block, vtkSpyPlotUniReader* reader, const int& blockID);
362 
364 
368  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
370 
371  // vtkSpyPlotReaderMap needs access to GetCellDataArraySelection().
372  friend class vtkSpyPlotReaderMap;
374 
376 
377  vtkBoundingBox* Bounds; // bounds of the hierarchy without the bad ghostcells.
378  int BoxSize[3]; // size of boxes if they are all the same, else -1,-1,-1
379  int MinLevel; // first used level
380  double MinLevelSpacing[3]; // grid spacing on first used level
381 
382  int GenerateLevelArray; // user flag
383  int GenerateBlockIdArray; // user flag
384  int GenerateActiveBlockArray; // user flag
385  int GenerateTracerArray; // user flag
386  int GenerateMarkers; // user flag
387 
389 
391 
393 
394  // This flag is used to determine if core meta-data needs to be re-read.
396 
397 private:
398  vtkSpyPlotReader(const vtkSpyPlotReader&) = delete;
399  void operator=(const vtkSpyPlotReader&) = delete;
400 
401  class VectorOfDoubles;
402 
403  VectorOfDoubles* TimeSteps;
404  void SetTimeStepsInternal(const VectorOfDoubles&);
405 };
406 
407 #endif
virtual int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Maps strings to vtkSpyPlotUniReaders.
vtkDataArraySelection * CellDataArraySelection
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual int FillOutputPortInformation(int port, vtkInformation *info)
vtkBoundingBox * Bounds
int vtkIdType
vtkSpyPlotReaderMap * Map
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0)
Read SPCTH Spy Plot file format.
static vtkCompositeDataSetAlgorithm * New()
#define VTKPVVTKEXTENSIONSIOSPCTH_EXPORT
Represents a SpyPlot Block Grid.
vtkMultiProcessController * GlobalController
int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0) override
Overwritten to avoid hiding.
void operator=(const vtkObjectBase &)
Read SPCTH Spy Plot file format.