VTK  9.3.20240419
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 
29 #include "vtkDataObjectAlgorithm.h"
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 
35 VTK_ABI_NAMESPACE_BEGIN
36 class vtkCellArray;
37 class vtkDataArray;
38 class vtkDataObject;
39 class vtkDataSet;
41 class vtkFieldData;
42 class vtkImageData;
45 class vtkStringArray;
46 
47 //----------------------------------------------------------------------------
48 
49 class VTKIOADIOS2_EXPORT vtkADIOS2CoreImageReader : public vtkDataObjectAlgorithm
50 {
51 public:
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 
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 
156  vtkMTimeType GetMTime() override;
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 
205 protected:
208 
210 
212  vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
214  vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
215 
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>
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 
248 
251 
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 
266 private:
268  void operator=(const vtkADIOS2CoreImageReader&) = delete;
269 };
270 VTK_ABI_NAMESPACE_END
271 #endif
void CalculateWorkDistribution(const std::string &varName)
std::unique_ptr< vtkADIOS2CoreImageReaderImpl > Impl
virtual int CanReadFile(VTK_FILEPATH const char *filename)
void ReadImageBlocks(vtkMultiBlockDataSet *mbds)
void GatherTimeStepsFromADIOSTimeArray()
vtkStringArray * GetAllDimensionArrays()
Get/Set the name of the array to deduce the dimension of vtkImageData.
int RequestDataObjectInternal(vtkInformationVector *)
~vtkADIOS2CoreImageReader() override
int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
The main interface which triggers the reader to start.
const char * GetArrayName(int index)
Get information about arrays.
std::map< std::string, VarType > InquireVariablesType
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.
static vtkADIOS2CoreImageReader * New()
vtkSmartPointer< vtkMultiProcessController > Controller
StringToParams & GetAvilableVariables()
Get the available variables.
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 std::pair< std::string, VarType > & GetActiveScalar() const
Get/Set the active scalar on each image block.
vtkMTimeType GetMTime() override
Overridden to take into account mtimes for vtkDataArraySelection instances.
void SetFileName(VTK_FILEPATH const char *filename)
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.
StringToParams & GetAvailableAttributes()
Get the available attributes.
int GetNumberOfArrays()
Get information about arrays.
int GetArrayStatus(const char *name)
Get information about arrays.
const StringToParams & GetAvilableVariables() const
Get/Set the active scalar on each image block.
vtkSmartPointer< vtkAbstractArray > PopulateDataArrayFromVar(const std::string &varName, size_t blockIndex)
std::string FetchTypeStringFromVarName(const std::string &name)
std::map< std::string, Params > StringToParams
vtkStringArray * GetAllTimeStepArrays()
std::pair< std::string, VarType > & GetActiveScalar()
Get/Set the active scalar on each image block.
const StringToParams & GetAvailableAttributes() const
Get/Set the active scalar on each image block.
object to represent cell connectivity
Definition: vtkCellArray.h:286
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:155
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:162
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
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.
a vtkAbstractArray subclass for strings
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
@ string
Definition: vtkX3D.h:490
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_FILEPATH