VTK  9.1.0
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=========================================================================*/
33#ifndef vtkADIOS2CoreImageReader_h
34#define vtkADIOS2CoreImageReader_h
35
36#include <map> // For independently time stepped array indexing
37#include <memory> // For std::unique_ptr
38#include <string> // For variable name index mapping
39#include <vector> // For independently time stepped array indexing
40
42#include "vtkMultiProcessController.h" // For the process controller
43#include "vtkSetGet.h" // For property get/set macros
44#include "vtkSmartPointer.h" // For the object cache
45
46#include "vtkIOADIOS2Module.h" // For export macro
47
48class vtkCellArray;
49class vtkDataArray;
50class vtkDataObject;
51class vtkDataSet;
53class vtkFieldData;
54class vtkImageData;
56class vtkStringArray;
57
58//----------------------------------------------------------------------------
59
60class VTKIOADIOS2_EXPORT vtkADIOS2CoreImageReader : public vtkDataObjectAlgorithm
61{
62public:
63 enum class VarType
64 {
65 PointData,
66 CellData
67 };
68 using Params = std::map<std::string, std::string>;
69 using StringToParams = std::map<std::string, Params>;
70 using InquireVariablesType = std::vector<std::pair<std::string, VarType>>;
73 void PrintSelf(ostream& os, vtkIndent indent) override;
74
79 int CanReadFile(VTK_FILEPATH const std::string& name);
80
81 virtual int CanReadFile(VTK_FILEPATH const char* filename);
82
84
87 vtkSetMacro(FileName, std::string);
88 vtkGetMacro(FileName, std::string);
90
91 void SetFileName(VTK_FILEPATH const char* filename);
92
94
98 vtkSetVector3Macro(Origin, double);
99 vtkGetVector3Macro(Origin, double);
101
103
107 vtkSetVector3Macro(Spacing, double);
108 vtkGetVector3Macro(Spacing, double);
110
112
118 vtkSetMacro(DimensionArray, std::string);
119 vtkGetMacro(DimensionArray, std::string);
121
123
127 vtkSetMacro(DimensionArrayAsCell, bool);
128 vtkGetMacro(DimensionArrayAsCell, bool);
129 vtkBooleanMacro(DimensionArrayAsCell, bool);
131
134
138 vtkSetMacro(TimeStepArray, std::string);
139 vtkGetMacro(TimeStepArray, std::string);
141
143
153 const char* GetArrayName(int index);
154
156
160 void SetArrayStatus(const char* name, int status);
161 int GetArrayStatus(const char* name);
163
165
172 vtkSetMacro(IsColumnMajor, bool);
173 vtkGetMacro(IsColumnMajor, bool);
174 vtkBooleanMacro(IsColumnMajor, bool);
176
178
181 void SetActiveScalar(const std::pair<std::string, VarType>& inqVars);
182 std::pair<std::string, VarType>& GetActiveScalar();
183 const std::pair<std::string, VarType>& GetActiveScalar() const;
184
186
191
193
198
200
205
209 virtual int ProcessRequest(
211
212protected:
215
217
219 vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
220 virtual int RequestData(
221 vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
222
223 std::string FetchTypeStringFromVarName(const std::string& name);
224
226
227 // Read available variables and attributes in the file
229
230 // Convert the array selection into inquire variables.
232
233 // Init the workDistribution based on the first inquired variable
235
237
238 // Gather time steps info from the time step array
240
241 // Helper function for InitWorkDistribution to calculate how many blocks each process shall read
242 template <typename T>
243 void CalculateWorkDistribution(const std::string& varName);
244
245 // Helper function for ReadImageBlocks to populate vtk data array from adios variable
246 template <typename T, template <typename...> class U>
248 const std::string& varName, size_t blockIndex);
249
250 // Helper function to gather time steps from adios time array
251 template <typename T>
253
254 std::string FileName;
255
258
259 std::string DimensionArray;
260 std::string TimeStepArray;
261
262 double Origin[3];
263 double Spacing[3];
264 int Dimension[3];
265
267
269
270 struct vtkADIOS2CoreImageReaderImpl;
271 std::unique_ptr<vtkADIOS2CoreImageReaderImpl> Impl;
272
273private:
275 void operator=(const vtkADIOS2CoreImageReader&) = delete;
276};
277#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
Definition: vtkCellArray.h:290
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
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:166
represent and manipulate fields of data
Definition: vtkFieldData.h:164
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
a simple class to control print indentation
Definition: vtkIndent.h:113
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