VTK  9.7.1
vtkHDFReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
32 #ifndef vtkHDFReader_h
33 #define vtkHDFReader_h
34 
35 #include "vtkDataAssembly.h" // For vtkDataAssembly
36 #include "vtkDataObjectAlgorithm.h"
37 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0 VTK_DEPRECATED_IN_9_6_0
38 #include "vtkIOHDFModule.h" // For export macro
39 #include "vtkSmartPointer.h" // For vtkSmartPointer
40 
41 #include <array> // For storing the time range
42 #include <memory> // For std::unique_ptr
43 #include <vector> // For storing list of values
44 
45 VTK_ABI_NAMESPACE_BEGIN
46 class vtkAbstractArray;
47 class vtkCallbackCommand;
48 class vtkCellData;
49 class vtkCommand;
51 class vtkDataSet;
53 class vtkHyperTreeGrid;
54 class vtkImageData;
55 class vtkInformation;
58 class vtkOverlappingAMR;
61 class vtkPointData;
62 class vtkPolyData;
63 class vtkRectilinearGrid;
64 class vtkResourceStream;
65 class vtkStructuredGrid;
66 class vtkTable;
68 
69 namespace vtkHDFUtilities
70 {
73 }
74 
75 class VTKIOHDF_EXPORT vtkHDFReader : public vtkDataObjectAlgorithm
76 {
77 public:
78  static vtkHDFReader* New();
80  void PrintSelf(ostream& os, vtkIndent indent) override;
81 
83 
86  vtkSetFilePathMacro(FileName);
87  vtkGetFilePathMacro(FileName);
89 
91 
97  void SetStream(vtkResourceStream* stream);
98  vtkResourceStream* GetStream();
100 
101  enum
102  {
104  Interleave
105  };
106 
108 
120  vtkSetClampMacro(PieceDistribution, int, Block, Interleave);
121  vtkGetMacro(PieceDistribution, int);
123 
133  virtual vtkTypeBool CanReadFile(VTK_FILEPATH const char* name);
134  static bool CanReadFile(vtkResourceStream* stream);
136 
138 
141  vtkDataSet* GetOutputAsDataSet();
142  vtkDataSet* GetOutputAsDataSet(int index);
144 
146 
150  virtual vtkDataArraySelection* GetPointDataArraySelection();
151  virtual vtkDataArraySelection* GetCellDataArraySelection();
152  virtual vtkDataArraySelection* GetFieldDataArraySelection();
153  virtual vtkDataArraySelection* GetRowDataArraySelection();
155 
157 
160  int GetNumberOfPointArrays();
161  int GetNumberOfCellArrays();
163 
165 
169  const char* GetPointArrayName(int index);
170  const char* GetCellArrayName(int index);
172 
174 
182  bool GetHasTemporalData();
183  vtkGetMacro(NumberOfSteps, vtkIdType);
184  vtkGetMacro(Step, vtkIdType);
185  vtkSetMacro(Step, vtkIdType);
186  vtkGetMacro(TimeValue, double);
187  const std::array<double, 2>& GetTimeRange() const { return this->TimeRange; }
189 
191 
194  VTK_DEPRECATED_IN_9_7_0("Do not use, cache is on by default and should not be disabled.")
195  virtual bool GetUseCache();
196  VTK_DEPRECATED_IN_9_7_0("Do not use, cache is on by default and should not be disabled.")
197  virtual void SetUseCache(bool use);
198  VTK_DEPRECATED_IN_9_7_0("Do not use, cache is on by default and should not be disabled.")
199  virtual void UseCacheOn();
200  VTK_DEPRECATED_IN_9_7_0("Do not use, cache is on by default and should not be disabled.")
201  virtual void UseCacheOff();
203 
205 
211  vtkSetMacro(MaximumLevelsToReadByDefaultForAMR, unsigned int);
212  vtkGetMacro(MaximumLevelsToReadByDefaultForAMR, unsigned int);
214 
216 
219  VTK_DEPRECATED_IN_9_7_0("Do not use, will be removed.")
220  std::string GetAttributeOriginalIdName(vtkIdType attribute);
221  VTK_DEPRECATED_IN_9_7_0("Do not use, will be removed.")
222  void SetAttributeOriginalIdName(vtkIdType attribute, const std::string& name);
224 
228  vtkMTimeType GetMTime() override;
229 
230 protected:
231  vtkHDFReader();
232  ~vtkHDFReader() override;
233 
237  int CanReadFileVersion(int major, int minor);
238 
240 
245  int Read(vtkInformation* outInfo, vtkImageData* data);
246  int Read(vtkInformation* outInfo, vtkRectilinearGrid* data);
247  int Read(vtkInformation* outInfo, vtkStructuredGrid* data);
248  int Read(vtkInformation* outInfo, vtkTable* data);
249  int Read(vtkInformation* outInfo, vtkUnstructuredGrid* data, vtkPartitionedDataSet* pData);
250  int Read(vtkInformation* outInfo, vtkPolyData* data, vtkPartitionedDataSet* pData);
251  int Read(vtkInformation* outInfo, vtkHyperTreeGrid* data, vtkPartitionedDataSet* pData);
252  int Read(vtkInformation* outInfo, vtkOverlappingAMR* data);
253  int Read(vtkInformation* outInfo, vtkPartitionedDataSetCollection* data);
254  int Read(vtkInformation* outInfo, vtkMultiBlockDataSet* data);
255  int ReadRecursively(vtkInformation* outInfo, vtkMultiBlockDataSet* data, const std::string& path);
257 
258  VTK_DEPRECATED_IN_9_6_0("This method is deprecated, do not use")
259  int Read(const std::vector<vtkIdType>& numberOfPoints,
260  const std::vector<vtkIdType>& numberOfCells,
261  const std::vector<vtkIdType>& numberOfConnectivityIds, vtkIdType partOffset,
262  vtkIdType startingPointOffset, vtkIdType startingCellOffset,
263  vtkIdType startingConnectctivityIdOffset, int filePiece, vtkUnstructuredGrid* pieceData);
264 
268  VTK_DEPRECATED_IN_9_7_0("This method is deprecated, do not use")
269  int AddFieldArrays(vtkDataObject* data);
270 
274  static void SelectionModifiedCallback(
275  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
276 
278 
282  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
283  vtkInformationVector* outputVector) override;
284  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
285  vtkInformationVector* outputVector) override;
286  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
287  vtkInformationVector* outputVector) override;
289 
293  void PrintPieceInformation(vtkInformation* outInfo);
294 
298  int SetupInformation(vtkInformation* outInfo);
299 
303  char* FileName;
304 
309 
314  std::map<int, vtkDataArraySelection*> DataArraySelection;
315 
320  vtkCallbackCommand* SelectionObserver;
322 
327 
329 
332  vtkIdType Step = 0;
333  vtkIdType NumberOfSteps = 1;
334  double TimeValue = 0.0;
335  std::array<double, 2> TimeRange;
337 
338  unsigned int MaximumLevelsToReadByDefaultForAMR = 0;
339 
340  bool UseCache = true;
341  struct DataCache;
342  std::shared_ptr<DataCache> Cache;
343 
344 private:
345  vtkHDFReader(const vtkHDFReader&) = delete;
346  void operator=(const vtkHDFReader&) = delete;
347 
348  class Implementation;
349  Implementation* Impl;
350 
355  bool ReadData(vtkInformation* outInfo, vtkDataObject* data);
356 
362  bool ReadStructuredData(
363  vtkDataSet* data, const int* WholeExtent, const std::vector<int>& updateExtent);
364 
369  bool ReadAMRData(vtkOverlappingAMR* data, unsigned int maxLevel,
370  const std::map<int, vtkDataArraySelection*>& dataArraySelection, bool isTemporalData);
371 
377  int Read(const std::vector<vtkIdType>& numberOfPoints,
378  const std::vector<vtkIdType>& numberOfCells,
379  const std::vector<vtkIdType>& numberOfConnectivityIds,
380  const std::vector<vtkIdType>& numberOfFaces,
381  const std::vector<vtkIdType>& numberOfPolyhedronToFaceIds,
382  const std::vector<vtkIdType>& numberOfFaceConnectivityIds,
383  vtkHDFUtilities::TemporalGeometryOffsets& geoOffsets, int filePiece,
384  vtkUnstructuredGrid* pieceData);
385 
391  int Read(const std::vector<vtkIdType>& numberOfTrees, const std::vector<vtkIdType>& numberOfCells,
392  const std::vector<vtkIdType>& numberOfDepths, const std::vector<vtkIdType>& descriptorSizes,
393  const vtkHDFUtilities::TemporalHyperTreeGridOffsets& htgTemporalOffsets, int filePiece,
394  vtkHyperTreeGrid* pieceData);
395 
399  void SetHasTemporalData(bool useTemporalData);
400 
407  std::vector<int> GetPieceAssignmentForDistribution(
408  int pieceIdx, int numDatasets, int numPieces) const;
409 
414  void GenerateAssembly();
415 
420  bool RetrieveStepsFromAssembly();
421 
426  bool RetrieveDataArraysFromAssembly();
427 
431  bool ReadFieldArrays(vtkDataObject* data);
432 
433  vtkSmartPointer<vtkDataObject> OutputCache;
434 
435  std::map<vtkIdType, std::string> AttributesOriginalIdName{
436  { vtkDataObject::POINT, "__pointsOriginalIds__" },
437  { vtkDataObject::CELL, "__cellOriginalIds__" }, { vtkDataObject::FIELD, "__fieldOriginalIds__" }
438  };
439 
440  bool HasTemporalData = false;
441  std::string CompositeCachePath; // Identifier for the current composite piece
442  int PieceDistribution = Interleave;
443 };
444 
445 VTK_ABI_NAMESPACE_END
446 #endif
composite dataset to encapsulates a dataset consisting of partitions.
a dataset that is topologically regular with variable spacing in the three coordinate directions ...
abstract base class for most VTK objects
Definition: vtkObject.h:52
represent and manipulate point attribute data
Definition: vtkPointData.h:30
Abstract class used for custom streams.
Store vtkAlgorithm input/output information.
Read VTK HDF files.
Definition: vtkHDFReader.h:75
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
Abstract superclass for all arrays.
static vtkDataObjectAlgorithm * New()
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
Implementation for the vtkHDFReader.
represent and manipulate cell attribute data
Definition: vtkCellData.h:31
const std::array< double, 2 > & GetTimeRange() const
Getters and setters for temporal data.
Definition: vtkHDFReader.h:187
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
int vtkTypeBool
Definition: vtkABI.h:64
superclass for callback/observer methods
Definition: vtkCommand.h:384
#define VTK_DEPRECATED_IN_9_6_0(reason)
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
Store on/off settings for data arrays, etc.
Common utility variables and functions for reader and writer of vtkHDF.
Definition: vtkHDFReader.h:69
dataset represents arbitrary combinations of all possible cell types
represent and manipulate attribute data in a dataset
#define VTK_FILEPATH
Superclass for algorithms that produce only data object as output.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:59
topologically regular array of data
Composite dataset that organizes datasets into blocks.
a multi-resolution dataset based on vtkCartesianGrid allowing overlaps
Store zero or more vtkInformation instances.
hierarchical representation to use with vtkPartitionedDataSetCollection
general representation of visualization data
Definition: vtkDataObject.h:55
#define VTK_DEPRECATED_IN_9_7_0(reason)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Composite dataset that groups datasets as a collection.