VTK  9.7.0
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
31
32#ifndef vtkHDFReader_h
33#define vtkHDFReader_h
34
35#include "vtkDataAssembly.h" // For vtkDataAssembly
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
45VTK_ABI_NAMESPACE_BEGIN
48class vtkCellData;
49class vtkCommand;
51class vtkDataSet;
54class vtkImageData;
55class vtkInformation;
61class vtkPointData;
62class vtkPolyData;
66class vtkTable;
68
70{
73}
74
75class VTKIOHDF_EXPORT vtkHDFReader : public vtkDataObjectAlgorithm
76{
77public:
78 static vtkHDFReader* New();
80 void PrintSelf(ostream& os, vtkIndent indent) override;
81
83
89
91
100
101 enum
102 {
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
144
146
155
157
163
165
169 const char* GetPointArrayName(int index);
170 const char* GetCellArrayName(int index);
172
174
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.")
221 VTK_DEPRECATED_IN_9_7_0("Do not use, will be removed.")
222 void SetAttributeOriginalIdName(vtkIdType attribute, const std::string& name);
224
229
230protected:
232 ~vtkHDFReader() override;
233
237 int CanReadFileVersion(int major, int minor);
238
240
245 int Read(vtkInformation* outInfo, vtkImageData* data);
248 int Read(vtkInformation* outInfo, vtkTable* 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")
270
275 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
276
278
283 vtkInformationVector* outputVector) override;
285 vtkInformationVector* outputVector) override;
287 vtkInformationVector* outputVector) override;
289
294
299
303 char* FileName;
304
309
315
322
327
329
334 double TimeValue = 0.0;
335 std::array<double, 2> TimeRange;
337
339
340 bool UseCache = true;
341 struct DataCache;
342 std::shared_ptr<DataCache> Cache;
343
344private:
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
445VTK_ABI_NAMESPACE_END
446#endif
Abstract superclass for all arrays.
supports function callbacks
represent and manipulate cell attribute data
Definition vtkCellData.h:32
superclass for callback/observer methods
Definition vtkCommand.h:385
Store on/off settings for data arrays, etc.
hierarchical representation to use with vtkPartitionedDataSetCollection
general representation of visualization data
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition vtkDataSet.h:57
Implementation for the vtkHDFReader.
int GetNumberOfPointArrays()
Get the number of point or cell arrays available in the input.
int GetNumberOfCellArrays()
Get the number of point or cell arrays available in the input.
static bool CanReadFile(vtkResourceStream *stream)
const char * GetCellArrayName(int index)
Get the name of the point or cell array with the given index in the input.
vtkIdType Step
Temporal data properties.
vtkSmartPointer< vtkResourceStream > Stream
The input stream.
virtual vtkDataArraySelection * GetFieldDataArraySelection()
Get the data array selection tables used to configure which data arrays are loaded by the reader.
vtkDataSet * GetOutputAsDataSet(int index)
Get the output as a vtkDataSet pointer.
std::shared_ptr< DataCache > Cache
virtual vtkDataArraySelection * GetCellDataArraySelection()
Get the data array selection tables used to configure which data arrays are loaded by the reader.
virtual bool GetUseCache()
Boolean property determining whether to use the internal cache or not (default is true).
virtual vtkTypeBool CanReadFile(const char *name)
Return true if, after a quick check of file header, it looks like the provided file or stream can be ...
int CanReadFileVersion(int major, int minor)
Test if the reader can read a file with the given version number.
int Read(vtkInformation *outInfo, vtkImageData *data)
Reads the 'data' requested in 'outInfo' (through extents or pieces) for a specialized data type.
virtual void SetUseCache(bool use)
Boolean property determining whether to use the internal cache or not (default is true).
const std::array< double, 2 > & GetTimeRange() const
Getters and setters for temporal data.
vtkSetFilePathMacro(FileName)
Get/Set the name of the input file.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Standard functions to specify the type, information and read the data from the file.
int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Standard functions to specify the type, information and read the data from the file.
vtkMTimeType GetMTime() override
Overridden to take into account mtime from the internal vtkResourceStream.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Standard functions to specify the type, information and read the data from the file.
static vtkHDFReader * New()
virtual void UseCacheOff()
Boolean property determining whether to use the internal cache or not (default is true).
vtkGetFilePathMacro(FileName)
Get/Set the name of the input file.
static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Modify this object when an array selection is changed.
int AddFieldArrays(vtkDataObject *data)
Read the field arrays from the file and add them to the dataset.
std::array< double, 2 > TimeRange
Assembly used for PartitionedDataSetCollection.
vtkResourceStream * GetStream()
Specify stream to read from When both Stream and Filename are set, stream is used.
unsigned int MaximumLevelsToReadByDefaultForAMR
void SetAttributeOriginalIdName(vtkIdType attribute, const std::string &name)
Get or Set the Original id name of an attribute (POINT, CELL, FIELD...).
vtkIdType NumberOfSteps
Assembly used for PartitionedDataSetCollection.
double TimeValue
Assembly used for PartitionedDataSetCollection.
const char * GetPointArrayName(int index)
Get the name of the point or cell array with the given index in the input.
char * FileName
The input file's name.
int ReadRecursively(vtkInformation *outInfo, vtkMultiBlockDataSet *data, const std::string &path)
Reads the 'data' requested in 'outInfo' (through extents or pieces) for a specialized data type.
int SetupInformation(vtkInformation *outInfo)
Setup the information pass in parameter based on current vtkHDF file loaded.
virtual vtkDataArraySelection * GetPointDataArraySelection()
Get the data array selection tables used to configure which data arrays are loaded by the reader.
bool GetHasTemporalData()
Getters and setters for temporal data.
vtkCallbackCommand * SelectionObserver
The observer to modify this object when the array selections are modified.
virtual vtkDataArraySelection * GetRowDataArraySelection()
Get the data array selection tables used to configure which data arrays are loaded by the reader.
std::string GetAttributeOriginalIdName(vtkIdType attribute)
Get or Set the Original id name of an attribute (POINT, CELL, FIELD...).
void SetStream(vtkResourceStream *stream)
Specify stream to read from When both Stream and Filename are set, stream is used.
vtkSmartPointer< vtkDataAssembly > Assembly
Assembly used for PartitionedDataSetCollection.
void PrintPieceInformation(vtkInformation *outInfo)
Print update number of pieces, piece number and ghost levels.
vtkDataSet * GetOutputAsDataSet()
Get the output as a vtkDataSet pointer.
std::map< int, vtkDataArraySelection * > DataArraySelection
The array selections.
virtual void UseCacheOn()
Boolean property determining whether to use the internal cache or not (default is true).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Composite dataset that organizes datasets into blocks.
a multi-resolution dataset based on vtkCartesianGrid allowing overlaps
Composite dataset that groups datasets as a collection.
composite dataset to encapsulates a dataset consisting of partitions.
represent and manipulate point attribute data
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
a dataset that is topologically regular with variable spacing in the three coordinate directions
Abstract class used for custom streams.
Hold a reference to a vtkObjectBase instance.
topologically regular array of data
A table, which contains similar-typed columns of data.
Definition vtkTable.h:60
dataset represents arbitrary combinations of all possible cell types
Common utility variables and functions for reader and writer of vtkHDF.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_7_0(reason)
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:363
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_FILEPATH