VTK  9.5.20250805
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
50#ifndef vtkHDFReader_h
51#define vtkHDFReader_h
52
53#include "vtkDataAssembly.h" // For vtkDataAssembly
55#include "vtkIOHDFModule.h" // For export macro
56#include "vtkSmartPointer.h" // For vtkSmartPointer
57
58#include <array> // For storing the time range
59#include <memory> // For std::unique_ptr
60#include <vector> // For storing list of values
61
62VTK_ABI_NAMESPACE_BEGIN
65class vtkCellData;
66class vtkCommand;
69class vtkDataSet;
72class vtkImageData;
74class vtkInformation;
79class vtkPointData;
80class vtkPolyData;
82
84{
86}
87
88class VTKIOHDF_EXPORT vtkHDFReader : public vtkDataObjectAlgorithm
89{
90public:
91 static vtkHDFReader* New();
93 void PrintSelf(ostream& os, vtkIndent indent) override;
94
96
102
110 virtual int CanReadFile(VTK_FILEPATH const char* name);
111
113
119
121
129
131
137
139
143 const char* GetPointArrayName(int index);
144 const char* GetCellArrayName(int index);
146
148
157 vtkGetMacro(NumberOfSteps, vtkIdType);
158 vtkGetMacro(Step, vtkIdType);
159 vtkSetMacro(Step, vtkIdType);
160 vtkGetMacro(TimeValue, double);
161 const std::array<double, 2>& GetTimeRange() const { return this->TimeRange; }
163
165
174 vtkGetMacro(UseCache, bool);
175 vtkSetMacro(UseCache, bool);
176 vtkBooleanMacro(UseCache, bool);
178
180
198 VTK_DEPRECATED_IN_9_5_0("Use vtkMergeBlocks or vtkAppendDataSets instead.")
199 vtkGetMacro(MergeParts, bool);
201 vtkSetMacro(MergeParts, bool);
203 virtual void MergePartsOn();
205 virtual void MergePartsOff();
207
209
215 vtkSetMacro(MaximumLevelsToReadByDefaultForAMR, unsigned int);
216 vtkGetMacro(MaximumLevelsToReadByDefaultForAMR, unsigned int);
218
220
223 std::string GetAttributeOriginalIdName(vtkIdType attribute);
224 void SetAttributeOriginalIdName(vtkIdType attribute, const std::string& name);
226
227protected:
229 ~vtkHDFReader() override;
230
234 int CanReadFileVersion(int major, int minor);
235
237
242 int Read(vtkInformation* outInfo, vtkImageData* data);
244 int Read(vtkInformation* outInfo, vtkPolyData* data, vtkPartitionedDataSet* pData);
245 int Read(vtkInformation* outInfo, vtkHyperTreeGrid* data, vtkPartitionedDataSet* pData);
246 int Read(vtkInformation* outInfo, vtkOverlappingAMR* data);
248 int Read(vtkInformation* outInfo, vtkMultiBlockDataSet* data);
249 int ReadRecursively(vtkInformation* outInfo, vtkMultiBlockDataSet* data, const std::string& path);
251
257 int Read(const std::vector<vtkIdType>& numberOfPoints,
258 const std::vector<vtkIdType>& numberOfCells,
259 const std::vector<vtkIdType>& numberOfConnectivityIds, vtkIdType partOffset,
260 vtkIdType startingPointOffset, vtkIdType startingCellOffset,
261 vtkIdType startingConnectctivityIdOffset, int filePiece, vtkUnstructuredGrid* pieceData);
262
266 int AddFieldArrays(vtkDataObject* data);
267
271 static void SelectionModifiedCallback(
272 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
273
275
279 int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
280 vtkInformationVector* outputVector) override;
281 int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
282 vtkInformationVector* outputVector) override;
283 int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
284 vtkInformationVector* outputVector) override;
286
290 void PrintPieceInformation(vtkInformation* outInfo);
291
295 int SetupInformation(vtkInformation* outInfo);
296
300 char* FileName;
301
306 vtkDataArraySelection* DataArraySelection[3];
307
312 vtkCallbackCommand* SelectionObserver;
314
319
321
324 vtkIdType Step = 0;
325 vtkIdType NumberOfSteps = 1;
326 double TimeValue = 0.0;
327 std::array<double, 2> TimeRange;
329
334 // VTK_DEPRECATED_IN_9_5_0( )
335 bool MergeParts = false;
336
337 unsigned int MaximumLevelsToReadByDefaultForAMR = 0;
338
339 bool UseCache = false;
340 struct DataCache;
341 std::shared_ptr<DataCache> Cache;
342
343private:
344 vtkHDFReader(const vtkHDFReader&) = delete;
345 void operator=(const vtkHDFReader&) = delete;
346
347 class Implementation;
348 Implementation* Impl;
349
354 bool ReadData(vtkInformation* outInfo, vtkDataObject* data);
355
361 int Read(const std::vector<vtkIdType>& numberOfTrees, const std::vector<vtkIdType>& numberOfCells,
362 const std::vector<vtkIdType>& numberOfDepths, const std::vector<vtkIdType>& descriptorSizes,
363 const vtkHDFUtilities::TemporalHyperTreeGridOffsets& htgTemporalOffsets, int filePiece,
364 vtkHyperTreeGrid* pieceData);
365
369 void SetHasTemporalData(bool useTemporalData);
370
374 void GenerateAssembly();
375
380 bool RetrieveStepsFromAssembly();
381
386 bool RetrieveDataArraysFromAssembly();
387
395 bool AddOriginalIds(vtkDataSetAttributes* attributes, vtkIdType size, const std::string& name);
396
403 void CleanOriginalIds(vtkPartitionedDataSet* output);
404
405 bool MeshGeometryChangedFromPreviousTimeStep = true;
406
408
409 std::map<vtkIdType, std::string> AttributesOriginalIdName{
410 { vtkDataObject::POINT, "__pointsOriginalIds__" },
411 { vtkDataObject::CELL, "__cellOriginalIds__" }, { vtkDataObject::FIELD, "__fieldOriginalIds__" }
412 };
413
414 bool HasTemporalData = false;
415 std::string CompositeCachePath; // Identifier for the current composite piece
416};
417
418VTK_ABI_NAMESPACE_END
419#endif
Abstract superclass for all arrays.
Appends one or more datasets together into a single output vtkPointSet.
supports function callbacks
represent and manipulate cell attribute data
superclass for callback/observer methods
Definition vtkCommand.h:384
Store on/off settings for data arrays, etc.
hierarchical representation to use with vtkPartitionedDataSetCollection
Superclass for algorithms that produce only data object as output.
vtkDataObjectMeshCache is a class to store and reuse the mesh of a vtkDataSet, while forwarding data ...
general representation of visualization data
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
Implementation for the vtkHDFReader.
Read VTK HDF files.
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.
const char * GetCellArrayName(int index)
Get the name of the point or cell array with the given index in the input.
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.
virtual int CanReadFile(const char *name)
Test whether the file (type) with the given name can be read by this reader.
virtual vtkDataArraySelection * GetCellDataArraySelection()
Get the data array selection tables used to configure which data arrays are loaded by the reader.
const std::array< double, 2 > & GetTimeRange() const
Getters and setters for temporal data.
vtkSetFilePathMacro(FileName)
Get/Set the name of the input file.
static vtkHDFReader * New()
vtkGetFilePathMacro(FileName)
Get/Set the name of the input file.
const char * GetPointArrayName(int index)
Get the name of the point or cell array with the given index in the input.
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.
vtkDataSet * GetOutputAsDataSet()
Get the output as a vtkDataSet pointer.
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:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
merges blocks in a composite dataset to a dataset.
Composite dataset that organizes datasets into blocks.
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract base class for most VTK objects
Definition vtkObject.h:162
a multi-resolution dataset based on vtkUniformGrid 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
Hold a reference to a vtkObjectBase instance.
dataset represents arbitrary combinations of all possible cell types
Common utility variables and functions for reader and writer of vtkHDF.
#define VTK_DEPRECATED_IN_9_5_0(reason)
int vtkIdType
Definition vtkType.h:332
#define VTK_FILEPATH