VTK  9.4.20250413
vtkADIOS2CoreImageReader.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
21#ifndef vtkADIOS2CoreImageReader_h
22#define vtkADIOS2CoreImageReader_h
23
24#include <map> // For independently time stepped array indexing
25#include <memory> // For std::unique_ptr
26#include <string> // For variable name index mapping
27#include <vector> // For independently time stepped array indexing
28
30#include "vtkSetGet.h" // For property get/set macros
31#include "vtkSmartPointer.h" // For the object cache
32
33#include "vtkIOADIOS2Module.h" // For export macro
34
35VTK_ABI_NAMESPACE_BEGIN
36class vtkCellArray;
37class vtkDataArray;
38class vtkDataObject;
39class vtkDataSet;
41class vtkFieldData;
42class vtkImageData;
45class vtkStringArray;
46
47//----------------------------------------------------------------------------
48
49class VTKIOADIOS2_EXPORT vtkADIOS2CoreImageReader : public vtkDataObjectAlgorithm
50{
51public:
52 enum class VarType
53 {
54 PointData,
55 CellData
56 };
57 using Params = std::map<std::string, std::string>;
58 using StringToParams = std::map<std::string, Params>;
59 using InquireVariablesType = std::map<std::string, VarType>;
62 void PrintSelf(ostream& os, vtkIndent indent) override;
63
68 int CanReadFile(VTK_FILEPATH const std::string& name);
69
70 virtual int CanReadFile(VTK_FILEPATH const char* filename);
71
73
76 vtkSetMacro(FileName, std::string);
77 vtkGetMacro(FileName, std::string);
79
80 void SetFileName(VTK_FILEPATH const char* filename);
81
83
87 vtkSetVector3Macro(Origin, double);
88 vtkGetVector3Macro(Origin, double);
90
92
96 vtkSetVector3Macro(Spacing, double);
97 vtkGetVector3Macro(Spacing, double);
99
101
107 vtkSetMacro(DimensionArray, std::string);
108 vtkGetMacro(DimensionArray, std::string);
110
112
116 vtkSetMacro(DimensionArrayAsCell, bool);
117 vtkGetMacro(DimensionArrayAsCell, bool);
118 vtkBooleanMacro(DimensionArrayAsCell, bool);
120
123
127 vtkSetMacro(TimeStepArray, std::string);
128 vtkGetMacro(TimeStepArray, std::string);
130
132
142 const char* GetArrayName(int index);
143
145
149 void SetArrayStatus(const char* name, int status);
150 int GetArrayStatus(const char* name);
152
157
159
166 vtkSetMacro(IsColumnMajor, bool);
167 vtkGetMacro(IsColumnMajor, bool);
168 vtkBooleanMacro(IsColumnMajor, bool);
170
172
175 void SetActiveScalar(const std::pair<std::string, VarType>& inqVars);
176 std::pair<std::string, VarType>& GetActiveScalar();
177 const std::pair<std::string, VarType>& GetActiveScalar() const;
178
180
185
187
192
194
199
204
205protected:
208
210
212 vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
214 vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
215
216 std::string FetchTypeStringFromVarName(const std::string& name);
217
219
220 // Read available variables and attributes in the file
222
223 // Convert the array selection into inquire variables.
225
226 // Init the workDistribution based on the first inquired variable
228
230
231 // Gather time steps info from the time step array
233
234 // Helper function for InitWorkDistribution to calculate how many blocks each process shall read
235 template <typename T>
236 void CalculateWorkDistribution(const std::string& varName);
237
238 // Helper function for ReadImageBlocks to populate vtk data array from adios variable
239 template <typename T, template <typename...> class U>
241 const std::string& varName, size_t blockIndex);
242
243 // Helper function to gather time steps from adios time array
244 template <typename T>
246
247 std::string FileName;
248
251
252 std::string DimensionArray;
253 std::string TimeStepArray;
254
255 double Origin[3];
256 double Spacing[3];
257 int Dimension[3];
258
260
262
263 struct vtkADIOS2CoreImageReaderImpl;
264 std::unique_ptr<vtkADIOS2CoreImageReaderImpl> Impl;
265
266private:
268 void operator=(const vtkADIOS2CoreImageReader&) = delete;
269};
270VTK_ABI_NAMESPACE_END
271#endif
void CalculateWorkDistribution(const std::string &varName)
StringToParams & GetAvilableVariables()
Get the available variables.
std::unique_ptr< vtkADIOS2CoreImageReaderImpl > Impl
virtual int CanReadFile(VTK_FILEPATH const char *filename)
void ReadImageBlocks(vtkMultiBlockDataSet *mbds)
void GatherTimeStepsFromADIOSTimeArray()
const StringToParams & GetAvailableAttributes() const
Get/Set the active scalar on each image block.
static vtkADIOS2CoreImageReader * New()
int RequestDataObjectInternal(vtkInformationVector *)
~vtkADIOS2CoreImageReader() override
int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
The main interface which triggers the reader to start.
std::map< std::string, VarType > InquireVariablesType
const char * GetArrayName(int index)
Get information about arrays.
const std::pair< std::string, VarType > & GetActiveScalar() const
Get/Set the active scalar on each image block.
void UpdateDimensionFromDimensionArray()
void SetController(vtkMultiProcessController *)
Set the MPI controller.
void SetActiveScalar(const std::pair< std::string, VarType > &inqVars)
Get/Set the active scalar on each image block.
vtkSmartPointer< vtkMultiProcessController > Controller
int CanReadFile(VTK_FILEPATH const std::string &name)
Test whether or not a given file should even be attempted for use with this reader.
int RequestInformation(vtkInformation *request, vtkInformationVector **input, vtkInformationVector *output) override
std::map< std::string, std::string > Params
void SetArrayStatus(const char *name, int status)
Set the array that should be read in.
const StringToParams & GetAvilableVariables() const
Get/Set the active scalar on each image block.
vtkStringArray * GetAllTimeStepArrays()
StringToParams & GetAvailableAttributes()
Get the available attributes.
vtkMTimeType GetMTime() override
Overridden to take into account mtimes for vtkDataArraySelection instances.
void SetFileName(VTK_FILEPATH const char *filename)
std::pair< std::string, VarType > & GetActiveScalar()
Get/Set the active scalar on each image block.
vtkStringArray * GetAllDimensionArrays()
Get/Set the name of the array to deduce the dimension of vtkImageData.
int RequestData(vtkInformation *request, vtkInformationVector **input, vtkInformationVector *output) override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetNumberOfArrays()
Get information about arrays.
int GetArrayStatus(const char *name)
Get information about arrays.
std::string FetchTypeStringFromVarName(const std::string &name)
std::map< std::string, Params > StringToParams
vtkSmartPointer< vtkAbstractArray > PopulateDataArrayFromVar(const std::string &varName, size_t blockIndex)
object to represent cell connectivity
abstract superclass for arrays of numeric data
Superclass for algorithms that produce only data object as output.
general representation of visualization data
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
represent and manipulate fields of data
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.
Composite dataset that organizes datasets into blocks.
Multiprocessing communication superclass.
Hold a reference to a vtkObjectBase instance.
a vtkAbstractArray subclass for strings
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_FILEPATH