VTK
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 =========================================================================*/
37 #ifndef vtkXdmfReader_h
38 #define vtkXdmfReader_h
39 
40 #include "vtkIOXdmf2Module.h" // For export macro
41 #include "vtkDataObjectAlgorithm.h"
42 #include <map> // for caching
43 #include <string> // needed for string API
44 
46 class vtkXdmfDocument;
47 class vtkGraph;
48 class vtkCharArray;
49 
50 class VTKIOXDMF2_EXPORT vtkXdmfReader : public vtkDataObjectAlgorithm
51 {
52 public:
53  static vtkXdmfReader* New();
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
57  // Until needed, multiple domains are not supported.
62  //unsigned int GetNumberOfDomains();
63 
65 
72  vtkSetStringMacro(DomainName);
73  vtkGetStringMacro(DomainName);
75 
79  // vtkGetStringMacro(ActiveDomainName);
80 
82 
85  vtkSetStringMacro(FileName);
86  vtkGetStringMacro(FileName);
88 
94  int GetNumberOfPointArrays();
95 
100  const char* GetPointArrayName(int index);
101 
103 
106  int GetPointArrayStatus(const char* name);
107  void SetPointArrayStatus(const char* name, int status);
109 
111 
116  int GetNumberOfCellArrays();
117  const char* GetCellArrayName(int index);
118  void SetCellArrayStatus(const char* name, int status);
119  int GetCellArrayStatus(const char* name);
121 
123 
128  int GetNumberOfGrids();
129  const char* GetGridName(int index);
130  void SetGridStatus(const char* gridname, int status);
131  int GetGridStatus(const char* gridname);
133 
135 
141  int GetNumberOfSets();
142  const char* GetSetName(int index);
143  void SetSetStatus(const char* gridname, int status);
144  int GetSetStatus(const char* gridname);
146 
150  int GetNumberOfSetArrays() { return this->GetNumberOfSets(); }
151  const char* GetSetArrayName(int index)
152  { return this->GetSetName(index); }
153  int GetSetArrayStatus(const char* name)
154  { return this->GetSetStatus(name); }
155 
157 
161  vtkSetVector3Macro(Stride, int);
162  vtkGetVector3Macro(Stride, int);
164 
168  virtual int CanReadFile(const char* filename);
169 
171 
174  vtkGetMacro(SILUpdateStamp, int);
176 
181  virtual vtkGraph* GetSIL();
182 
184  {
185  public:
186  XdmfDataSetTopoGeoPath() : dataset(0), topologyPath(), geometryPath() {}
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  { this->SetBinaryInputString(input.c_str(), static_cast<int>(input.length())); }
237 
238 protected:
239  vtkXdmfReader();
240  ~vtkXdmfReader() override;
241 
242  char* FileName;
243 
245 
247 
248  char *InputString;
251 
252  int ProcessRequest(vtkInformation *request,
253  vtkInformationVector **inputVector,
254  vtkInformationVector *outputVector) override;
255  virtual int RequestDataObjectInternal(vtkInformationVector *outputVector);
256  int RequestData(vtkInformation *, vtkInformationVector **,
257  vtkInformationVector *) override;
258  int RequestInformation(vtkInformation *, vtkInformationVector **,
259  vtkInformationVector *) override;
260  int FillOutputPortInformation(int port, vtkInformation *info) override;
261 
262  vtkXdmfArraySelection* GetPointArraySelection();
263  vtkXdmfArraySelection* GetCellArraySelection();
264  vtkXdmfArraySelection* GetGridSelection();
265  vtkXdmfArraySelection* GetSetsSelection();
266  void PassCachedSelections();
267 
268  char* DomainName;
269  // char* ActiveDomainName;
270  int Stride[3];
271  unsigned int LastTimeIndex;
272 
274 
275  // Until RequestInformation() is called, the active domain is not set
276  // correctly. If SetGridStatus() etc. are called before that happens, then we
277  // have no place to save the user choices. So we cache them in these temporary
278  // caches. These are passed on to the actual vtkXdmfArraySelection instances
279  // used by the active vtkXdmfDomain in RequestInformation().
280  // Note that these are only used until the first domain is setup, once that
281  // happens, the information set in these is passed to the domain and these
282  // are cleared an no longer used, until the active domain becomes invalid
283  // again.
288 
290 
291  XdmfReaderCachedData DataSetCache;
292 
293 private:
297  bool PrepareDocument();
298 
299  void ClearDataSetCache();
300 
305  int ChooseTimeStep(vtkInformation* outInfo);
306 
307 private:
308  vtkXdmfReader(const vtkXdmfReader&) = delete;
309  void operator=(const vtkXdmfReader&) = delete;
310 
311 };
312 
313 #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:62
static vtkDataObjectAlgorithm * New()
vtkXdmfArraySelection * CellArraysCache
Reads eXtensible Data Model and Format files.
Definition: vtkXdmfReader.h:50
std::map< int, XdmfDataSetTopoGeoPath > XdmfReaderCachedData
Base class for graph data types.
Definition: vtkGraph.h:287
vtkXdmfArraySelection * PointArraysCache
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:38
bool ReadFromInputString
a simple class to control print indentation
Definition: vtkIndent.h:39
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.