VTK  9.0.1
vtkXdmfReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkXdmfReader.h
5  Language: C++
6 
7  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
8  All rights reserved.
9  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notice for more information.
14 
15 =========================================================================*/
34 #ifndef vtkXdmfReader_h
35 #define vtkXdmfReader_h
36 
37 #include "vtkDataObjectAlgorithm.h"
38 #include "vtkIOXdmf2Module.h" // For export macro
39 #include <map> // for caching
40 #include <string> // needed for string API
41 
43 class vtkXdmfDocument;
44 class vtkGraph;
45 class vtkCharArray;
46 
47 class VTKIOXDMF2_EXPORT vtkXdmfReader : public vtkDataObjectAlgorithm
48 {
49 public:
50  static vtkXdmfReader* New();
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
54  // Until needed, multiple domains are not supported.
59  // unsigned int GetNumberOfDomains();
60 
62 
69  vtkSetStringMacro(DomainName);
70  vtkGetStringMacro(DomainName);
72 
76  // vtkGetStringMacro(ActiveDomainName);
77 
79 
82  vtkSetStringMacro(FileName);
83  vtkGetStringMacro(FileName);
85 
91  int GetNumberOfPointArrays();
92 
97  const char* GetPointArrayName(int index);
98 
100 
103  int GetPointArrayStatus(const char* name);
104  void SetPointArrayStatus(const char* name, int status);
106 
108 
113  int GetNumberOfCellArrays();
114  const char* GetCellArrayName(int index);
115  void SetCellArrayStatus(const char* name, int status);
116  int GetCellArrayStatus(const char* name);
118 
120 
125  int GetNumberOfGrids();
126  const char* GetGridName(int index);
127  void SetGridStatus(const char* gridname, int status);
128  int GetGridStatus(const char* gridname);
130 
132 
138  int GetNumberOfSets();
139  const char* GetSetName(int index);
140  void SetSetStatus(const char* gridname, int status);
141  int GetSetStatus(const char* gridname);
143 
147  int GetNumberOfSetArrays() { return this->GetNumberOfSets(); }
148  const char* GetSetArrayName(int index) { return this->GetSetName(index); }
149  int GetSetArrayStatus(const char* name) { return this->GetSetStatus(name); }
150 
152 
156  vtkSetVector3Macro(Stride, int);
157  vtkGetVector3Macro(Stride, int);
159 
163  virtual int CanReadFile(const char* filename);
164 
166 
169  vtkGetMacro(SILUpdateStamp, int);
171 
176  virtual vtkGraph* GetSIL();
177 
179  {
180  public:
182  : dataset(0)
183  , topologyPath()
184  , geometryPath()
185  {
186  }
190  };
191 
192  typedef std::map<int, XdmfDataSetTopoGeoPath> XdmfReaderCachedData;
193 
197  XdmfReaderCachedData& GetDataSetCache();
198 
200 
204  vtkSetMacro(ReadFromInputString, bool);
205  vtkGetMacro(ReadFromInputString, bool);
206  vtkBooleanMacro(ReadFromInputString, bool);
208 
210 
218  virtual void SetInputArray(vtkCharArray*);
219  vtkGetObjectMacro(InputArray, vtkCharArray);
221 
223 
229  void SetInputString(const char* in);
230  vtkGetStringMacro(InputString);
231  void SetInputString(const char* in, int len);
232  vtkGetMacro(InputStringLength, int);
233  void SetBinaryInputString(const char*, int len);
234  void SetInputString(const std::string& input)
235  {
236  this->SetBinaryInputString(input.c_str(), static_cast<int>(input.length()));
237  }
239 
240 protected:
241  vtkXdmfReader();
242  ~vtkXdmfReader() override;
243 
244  char* FileName;
245 
247 
249 
250  char* InputString;
253 
254  vtkTypeBool ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector,
255  vtkInformationVector* outputVector) override;
256  virtual int RequestDataObjectInternal(vtkInformationVector* outputVector);
257  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
258  int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
259  int FillOutputPortInformation(int port, vtkInformation* info) override;
260 
261  vtkXdmfArraySelection* GetPointArraySelection();
262  vtkXdmfArraySelection* GetCellArraySelection();
263  vtkXdmfArraySelection* GetGridSelection();
264  vtkXdmfArraySelection* GetSetsSelection();
265  void PassCachedSelections();
266 
267  char* DomainName;
268  // char* ActiveDomainName;
269  int Stride[3];
270  unsigned int LastTimeIndex;
271 
273 
274  // Until RequestInformation() is called, the active domain is not set
275  // correctly. If SetGridStatus() etc. are called before that happens, then we
276  // have no place to save the user choices. So we cache them in these temporary
277  // caches. These are passed on to the actual vtkXdmfArraySelection instances
278  // used by the active vtkXdmfDomain in RequestInformation().
279  // Note that these are only used until the first domain is setup, once that
280  // happens, the information set in these is passed to the domain and these
281  // are cleared an no longer used, until the active domain becomes invalid
282  // again.
287 
289 
290  XdmfReaderCachedData DataSetCache;
291 
292 private:
296  bool PrepareDocument();
297 
298  void ClearDataSetCache();
299 
304  int ChooseTimeStep(vtkInformation* outInfo);
305 
306 private:
307  vtkXdmfReader(const vtkXdmfReader&) = delete;
308  void operator=(const vtkXdmfReader&) = delete;
309 };
310 
311 #endif
void SetInputString(const std::string &input)
Specify the InputString for use when reading from a character array.
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
static vtkDataObjectAlgorithm * New()
vtkXdmfArraySelection * CellArraysCache
Reads eXtensible Data Model and Format files.
Definition: vtkXdmfReader.h:47
std::map< int, XdmfDataSetTopoGeoPath > XdmfReaderCachedData
int vtkTypeBool
Definition: vtkABI.h:69
Base class for graph data types.
Definition: vtkGraph.h:289
vtkXdmfArraySelection * PointArraysCache
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:35
bool ReadFromInputString
a simple class to control print indentation
Definition: vtkIndent.h:33
const char * GetSetArrayName(int index)
vtkCharArray * InputArray
char * InputString
vtkXdmfDocument * XdmfDocument
vtkXdmfArraySelection * GridsCache
Superclass for algorithms that produce only data object as output.
int GetNumberOfSetArrays()
These methods are provided to make it easier to use the Sets in ParaView.
Store zero or more vtkInformation instances.
XdmfReaderCachedData DataSetCache
unsigned int LastTimeIndex
vtkXdmfArraySelection * SetsCache
int GetSetArrayStatus(const char *name)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.