VTK  9.7.1
vtkHDFWriter.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
36 #ifndef vtkHDFWriter_h
37 #define vtkHDFWriter_h
38 
39 #include "vtkIOHDFModule.h" // For export macro
40 #include "vtkWriter.h"
41 
42 #include <map>
43 #include <memory>
44 
45 VTK_ABI_NAMESPACE_BEGIN
46 
47 class vtkCellArray;
48 class vtkDataObjectTree;
49 class vtkDataSet;
50 class vtkHyperTreeGrid;
51 class vtkImageData;
52 class vtkPoints;
53 class vtkPointSet;
54 class vtkPolyData;
55 class vtkRectilinearGrid;
56 class vtkStructuredGrid;
57 class vtkTable;
64 
65 typedef int64_t hid_t;
66 
67 class VTKIOHDF_EXPORT vtkHDFWriter : public vtkWriter
68 {
69 
70 private:
71  vtkHDFWriter(const vtkHDFWriter&) = delete;
72  void operator=(const vtkHDFWriter&) = delete;
73 
74 public:
75  static vtkHDFWriter* New();
76  vtkTypeMacro(vtkHDFWriter, vtkWriter);
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
80 
83  virtual void SetController(vtkMultiProcessController*);
84  vtkGetObjectMacro(Controller, vtkMultiProcessController);
86 
88 
91  vtkSetFilePathMacro(FileName);
92  vtkGetFilePathMacro(FileName);
94 
96 
100  vtkSetMacro(Overwrite, bool);
101  vtkGetMacro(Overwrite, bool);
103 
105 
110  vtkSetMacro(WriteAllTimeSteps, bool);
111  vtkGetMacro(WriteAllTimeSteps, bool);
113 
115 
127  vtkSetMacro(ChunkSize, int);
128  vtkGetMacro(ChunkSize, int);
130 
132 
144  vtkSetClampMacro(CompressionLevel, int, 0, 9);
145  vtkGetMacro(CompressionLevel, int);
147 
149 
156  vtkSetMacro(UseExternalComposite, bool);
157  vtkGetMacro(UseExternalComposite, bool);
159 
161 
175  vtkSetMacro(UseExternalTimeSteps, bool);
176  vtkGetMacro(UseExternalTimeSteps, bool);
178 
180 
189  vtkSetMacro(UseExternalPartitions, bool);
190  vtkGetMacro(UseExternalPartitions, bool);
192 
193 protected:
200  vtkInformationVector* outputVector) override;
201 
202  int FillInputPortInformation(int port, vtkInformation* info) override;
203 
204  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
205  vtkInformationVector* outputVector);
206 
207  virtual int RequestUpdateExtent(vtkInformation* request, vtkInformationVector** inputVector,
208  vtkInformationVector* outputVector);
209 
210  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
211  vtkInformationVector* outputVector) override;
212 
213  vtkHDFWriter();
214  ~vtkHDFWriter() override;
215 
216 private:
221  bool WriteDataAndReturn() override;
222 
228  bool DispatchDataObject(hid_t group, vtkDataObject* input, unsigned int partId = 0);
229 
234  bool WriteDistributedMetafile(vtkDataObject* input);
235 
237 
241  bool WriteDatasetToFile(hid_t group, vtkImageData* input, unsigned int partId = 0);
242  bool WriteDatasetToFile(hid_t group, vtkRectilinearGrid* input, unsigned int partId = 0);
243  bool WriteDatasetToFile(hid_t group, vtkStructuredGrid* input, unsigned int partId = 0);
244  bool WriteDatasetToFile(hid_t group, vtkPolyData* input, unsigned int partId = 0);
245  bool WriteDatasetToFile(hid_t group, vtkUnstructuredGrid* input, unsigned int partId = 0);
246  bool WriteDatasetToFile(hid_t group, vtkTable* input, unsigned int partId = 0);
247  bool WriteDatasetToFile(hid_t group, vtkHyperTreeGrid* input, unsigned int partId = 0);
248  bool WriteDatasetToFile(hid_t group, vtkPartitionedDataSet* input);
249  bool WriteDatasetToFile(hid_t group, vtkDataObjectTree* input);
251 
253 
257  bool UpdateStepsGroup(hid_t group, vtkRectilinearGrid* input);
258  bool UpdateStepsGroup(hid_t group, vtkStructuredGrid* input);
259  bool UpdateStepsGroup(hid_t group, vtkUnstructuredGrid* input, unsigned int partId);
260  bool UpdateStepsGroup(hid_t group, vtkPolyData* input, unsigned int partId);
261  bool UpdateStepsGroup(hid_t group, vtkHyperTreeGrid* input, unsigned int partId,
262  vtkIdType numberOfCellsPerDepthSize, vtkIdType descriptorsSize, vtkIdType maskSize);
264 
266 
270  bool InitializeTemporalRectilinearGrid(hid_t group);
271  bool InitializeTemporalStructuredGrid(hid_t group);
272  bool InitializeTemporalPolyData(hid_t group);
273  bool InitializeTemporalUnstructuredGrid(hid_t group);
274  bool InitializeTemporalPolyhedra(hid_t group);
275  bool InitializeTemporalHTG(hid_t group);
277 
279 
283  bool InitializeChunkedDatasets(hid_t group, vtkUnstructuredGrid* input);
284  bool InitializeChunkedDatasets(hid_t group, vtkPolyData* input);
285  bool InitializeChunkedDatasets(hid_t group, vtkHyperTreeGrid* input);
286  bool InitializePointDatasets(hid_t group, vtkPoints* input);
287  bool InitializePrimitiveDataset(hid_t group);
288  bool InitializePolyhedraDatasets(hid_t group);
290 
295  bool AppendRectilinearCoordinates(hid_t group, vtkRectilinearGrid* input);
296 
301  bool AppendNumberOfPoints(hid_t group, vtkPointSet* input);
302 
309  bool AppendPoints(hid_t group, vtkPointSet* input, const int* dims = nullptr);
310 
315  bool AppendNumberOfCells(hid_t group, vtkCellArray* input);
316 
321  bool AppendNumberOfFaceConnectivityIds(hid_t group, vtkCellArray* input);
322 
327  bool AppendNumberOfFaces(hid_t group, vtkCellArray* input);
328 
333  bool AppendNumberOfConnectivityIds(hid_t group, vtkCellArray* input);
334 
339  bool AppendCellTypes(hid_t group, vtkUnstructuredGrid* input);
340 
345  bool AppendOffsets(hid_t group, vtkCellArray* input);
346 
351  bool AppendConnectivity(hid_t group, vtkCellArray* input);
352 
357  bool AppendFaceConnectivity(hid_t group, vtkCellArray* input);
358 
363  bool AppendFaceOffsets(hid_t group, vtkCellArray* input);
364 
369  bool AppendPolyhedronToFaces(hid_t group, vtkCellArray* input);
370 
375  bool AppendPolyhedronOffsets(hid_t group, vtkCellArray* input);
376 
381  bool AppendNumberOfPolyhedronToFaceIds(hid_t group, vtkCellArray* input);
382 
387  bool AppendPrimitiveCells(hid_t baseGroup, vtkPolyData* input);
388 
390 
398  bool AppendDataArrays(hid_t group, vtkDataObject* input, unsigned int partId = 0);
399  bool AppendDataSetAttributes(hid_t group, vtkDataObject* input, unsigned int partId = 0,
400  vtkIdList* cellIdMap = nullptr, const int* dims = nullptr);
401  bool AppendFieldDataArrays(hid_t group, vtkDataObject* input, unsigned int partId = 0);
403 
405 
409  bool AppendBlocks(hid_t group, vtkPartitionedDataSetCollection* pdc);
411 
413 
418  bool AppendExternalBlock(vtkDataObject* block, const std::string& blockName);
420 
425  bool AppendAssembly(hid_t group, vtkPartitionedDataSetCollection* pdc);
426 
432  bool AppendMultiblock(hid_t group, vtkMultiBlockDataSet* mb, int& leafIndex);
433 
438  bool AppendIterDataObject(vtkDataObjectTreeIterator* treeIter, const int& leafIndex,
439  const std::string& uniqueSubTreeName);
440 
447  bool AppendCompositeSubfilesDataObject(const std::string& uniqueSubTreeName);
448 
450 
453  bool AppendDataArrayOffset(hid_t baseGroup, vtkAbstractArray* array, const std::string& arrayName,
454  const std::string& offsetsGroupName, unsigned int partId, bool isStructured = false);
455  bool AppendDataArraySizeOffset(hid_t baseGroup, vtkAbstractArray* array,
456  const std::string& arrayName, const std::string& offsetsGroupName, unsigned int partId);
458 
462  bool AppendTimeValues(hid_t group);
463 
467  bool HasGeometryChangedFromPreviousStep(vtkDataSet* input);
468 
472  void UpdatePreviousStepMeshMTime(vtkDataObject* input);
473 
474  class Implementation;
475  std::unique_ptr<Implementation> Impl;
476 
477  // Configurable properties
478  char* FileName = nullptr;
479  bool Overwrite = true;
480  bool WriteAllTimeSteps = true;
481  bool UseExternalComposite = false;
482  bool UseExternalTimeSteps = false;
483  bool UseExternalPartitions = false;
484  int ChunkSize = 25000;
485  int CompressionLevel = 0;
486 
487  // Temporal-related private variables
488  std::vector<double> timeSteps;
489  bool IsTemporal = false;
490  int CurrentTimeIndex = 0;
491  int NumberOfTimeSteps = 1;
492  vtkMTimeType PreviousStepMeshMTime = 0;
493  std::map<vtkIdType, vtkMTimeType> CompositeMeshMTime;
494 
495  // Distributed-related variables
496  vtkMultiProcessController* Controller = nullptr;
497  int NbPieces = 1;
498  int CurrentPiece = 0;
499  bool UsesDummyController = false;
500  std::vector<vtkIdType> PointOffsets;
501  std::vector<vtkIdType> CellOffsets;
502  std::vector<vtkIdType> ConnectivityIdOffsets;
503 };
504 VTK_ABI_NAMESPACE_END
505 #endif
composite dataset to encapsulates a dataset consisting of partitions.
a dataset that is topologically regular with variable spacing in the three coordinate directions ...
provides implementation for most abstract methods in the superclass vtkCompositeDataSet ...
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
Abstract superclass for all arrays.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
concrete class for storing a set of points
Definition: vtkPointSet.h:58
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
abstract class to write data to file(s)
Definition: vtkWriter.h:35
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int64_t hid_t
Definition: vtkHDFWriter.h:63
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
list of point or cell ids
Definition: vtkIdList.h:25
dataset represents arbitrary combinations of all possible cell types
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
object to represent cell connectivity
Definition: vtkCellArray.h:177
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.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
Write a data object to a VTKHDF file.
Definition: vtkHDFWriter.h:67
superclass for composite data iterators
virtual bool WriteDataAndReturn()
general representation of visualization data
Definition: vtkDataObject.h:55
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
represent and manipulate 3D points
Definition: vtkPoints.h:30
Composite dataset that groups datasets as a collection.
Multiprocessing communication superclass.