VTK  9.2.6
vtkADIOS2CoreImageReader.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkADIOS2CoreImageReader.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
30#ifndef vtkADIOS2CoreImageReader_h
31#define vtkADIOS2CoreImageReader_h
32
33#include <map> // For independently time stepped array indexing
34#include <memory> // For std::unique_ptr
35#include <string> // For variable name index mapping
36#include <vector> // For independently time stepped array indexing
37
39#include "vtkSetGet.h" // For property get/set macros
40#include "vtkSmartPointer.h" // For the object cache
41
42#include "vtkIOADIOS2Module.h" // For export macro
43
44class vtkCellArray;
45class vtkDataArray;
46class vtkDataObject;
47class vtkDataSet;
49class vtkFieldData;
50class vtkImageData;
53class vtkStringArray;
54
55//----------------------------------------------------------------------------
56
57class VTKIOADIOS2_EXPORT vtkADIOS2CoreImageReader : public vtkDataObjectAlgorithm
58{
59public:
60 enum class VarType
61 {
62 PointData,
63 CellData
64 };
65 using Params = std::map<std::string, std::string>;
66 using StringToParams = std::map<std::string, Params>;
67 using InquireVariablesType = std::vector<std::pair<std::string, VarType>>;
70 void PrintSelf(ostream& os, vtkIndent indent) override;
71
76 int CanReadFile(VTK_FILEPATH const std::string& name);
77
78 virtual int CanReadFile(VTK_FILEPATH const char* filename);
79
81
84 vtkSetMacro(FileName, std::string);
85 vtkGetMacro(FileName, std::string);
87
88 void SetFileName(VTK_FILEPATH const char* filename);
89
91
95 vtkSetVector3Macro(Origin, double);
96 vtkGetVector3Macro(Origin, double);
98
100
104 vtkSetVector3Macro(Spacing, double);
105 vtkGetVector3Macro(Spacing, double);
107
109
115 vtkSetMacro(DimensionArray, std::string);
116 vtkGetMacro(DimensionArray, std::string);
118
120
124 vtkSetMacro(DimensionArrayAsCell, bool);
125 vtkGetMacro(DimensionArrayAsCell, bool);
126 vtkBooleanMacro(DimensionArrayAsCell, bool);
128
131
135 vtkSetMacro(TimeStepArray, std::string);
136 vtkGetMacro(TimeStepArray, std::string);
138
140
150 const char* GetArrayName(int index);
151
153
157 void SetArrayStatus(const char* name, int status);
158 int GetArrayStatus(const char* name);
160
162
169 vtkSetMacro(IsColumnMajor, bool);
170 vtkGetMacro(IsColumnMajor, bool);
171 vtkBooleanMacro(IsColumnMajor, bool);
173
175
178 void SetActiveScalar(const std::pair<std::string, VarType>& inqVars);
179 std::pair<std::string, VarType>& GetActiveScalar();
180 const std::pair<std::string, VarType>& GetActiveScalar() const;
181
183
188
190
195
197
202
206 virtual int ProcessRequest(
208
209protected:
212
214
216 vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
217 virtual int RequestData(
218 vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
219
220 std::string FetchTypeStringFromVarName(const std::string& name);
221
223
224 // Read available variables and attributes in the file
226
227 // Convert the array selection into inquire variables.
229
230 // Init the workDistribution based on the first inquired variable
232
234
235 // Gather time steps info from the time step array
237
238 // Helper function for InitWorkDistribution to calculate how many blocks each process shall read
239 template <typename T>
240 void CalculateWorkDistribution(const std::string& varName);
241
242 // Helper function for ReadImageBlocks to populate vtk data array from adios variable
243 template <typename T, template <typename...> class U>
245 const std::string& varName, size_t blockIndex);
246
247 // Helper function to gather time steps from adios time array
248 template <typename T>
250
251 std::string FileName;
252
255
256 std::string DimensionArray;
257 std::string TimeStepArray;
258
259 double Origin[3];
260 double Spacing[3];
261 int Dimension[3];
262
264
266
267 struct vtkADIOS2CoreImageReaderImpl;
268 std::unique_ptr<vtkADIOS2CoreImageReaderImpl> Impl;
269
270private:
272 void operator=(const vtkADIOS2CoreImageReader&) = delete;
273};
274#endif
void CalculateWorkDistribution(const std::string &varName)
virtual int RequestData(vtkInformation *request, vtkInformationVector **input, vtkInformationVector *output) override
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.
int RequestDataObjectInternal(vtkInformationVector *)
~vtkADIOS2CoreImageReader() override
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.
std::vector< std::pair< std::string, VarType > > InquireVariablesType
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.
virtual int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
The main interface which triggers the reader to start.
static vtkADIOS2CoreImageReader * New(void)
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.
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.
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)
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **input, vtkInformationVector *output) override
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:57
represent and manipulate fields of data
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:34
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
#define VTK_FILEPATH