vtkXdmfReader.h 7.22 KB
Newer Older
1
2
3
4
5
6
7
8
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkXdmfReader.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

Nikhil Shetty's avatar
Nikhil Shetty committed
9
  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
10
11
12
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

Nikhil Shetty's avatar
Nikhil Shetty committed
13
14
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
16
17
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
18
// .NAME vtkXdmfReader - Reads <tt>eXtensible Data Model and Format</tt> files
19
// .SECTION Description
20
21
22
23
24
25
26
27
// vtkXdmfReader reads XDMF data files so that they can be visualized using
// VTK. The output data produced by this reader depends on the number of grids
// in the data file. If the data file has a single domain with a single grid,
// then the output type is a vtkDataSet subclass of the appropriate type,
// otherwise it's a vtkMultiBlockDataSet.
//
// Refer to vtkDataReader which provides many methods for controlling the
// reading of the data file.
28
// .SECTION Caveats
29
// Uses the XDMF API (http://www.xdmf.org)
30
31
32
// .SECTION See Also
// vtkDataReader

Andy Cedilnik's avatar
Andy Cedilnik committed
33
34
#ifndef __vtkXdmfReader_h
#define __vtkXdmfReader_h
35

Jerry Clarke's avatar
Jerry Clarke committed
36
37
#include "vtkDataReader.h"

38
class vtkXdmfArraySelection;
39
class vtkXdmfDocument;
40
class vtkGraph;
Jerry Clarke's avatar
Jerry Clarke committed
41

Andy Cedilnik's avatar
Andy Cedilnik committed
42
class VTK_EXPORT vtkXdmfReader : public vtkDataReader
Jerry Clarke's avatar
Jerry Clarke committed
43
{
44
public:
Andy Cedilnik's avatar
Andy Cedilnik committed
45
  static vtkXdmfReader* New();
46
  vtkTypeMacro(vtkXdmfReader, vtkDataReader);
Jerry Clarke's avatar
Jerry Clarke committed
47
48
  void PrintSelf(ostream& os, vtkIndent indent);

49
50
51
52
53
54
  // Until needed, multiple domains are not supported.
  //// Description:
  //// Returns the number of domains present in the data file. This in valid after
  //// the filename has been set and UpdateInformation() has been called .i.e. the
  //// RequestInformation pipeline pass has happened.
  //unsigned int GetNumberOfDomains();
55

56
  // Description:
57
58
59
60
61
62
  // Set the active domain. Only one domain can be selected at a time. By
  // default the first domain in the datafile is chosen. Setting this to null
  // results in the domain being automatically chosen. Note that if the domain
  // name is changed, you should explicitly call UpdateInformation() before
  // accessing information about grids, data arrays etc.
  vtkSetStringMacro(DomainName);
63
64
  vtkGetStringMacro(DomainName);

65
66
67
68
  //// Description:
  //// Returns the name for the active domain. Note that this may be different
  //// from what GetDomainName() returns if DomainName is NULL or invalid.
  // vtkGetStringMacro(ActiveDomainName);
69

70
  // Description:
71
72
73
  // Get information about point-based arrays. As is typical with readers this
  // in only valid after the filename is set and UpdateInformation() has been
  // called.
74
  int GetNumberOfPointArrays();
Nikhil Shetty's avatar
Nikhil Shetty committed
75

76
  // Description:
77
78
  // Returns the name of point array at the give index. Returns NULL if index is
  // invalid.
79
  const char* GetPointArrayName(int index);
80
81

  // Description:
82
  // Get/Set the point array status.
83
  int GetPointArrayStatus(const char* name);
Nikhil Shetty's avatar
Nikhil Shetty committed
84
  void SetPointArrayStatus(const char* name, int status);
85

86
  // Description:
87
88
89
90
91
92
93
  // Get information about cell-based arrays.  As is typical with readers this
  // in only valid after the filename is set and UpdateInformation() has been
  // called.
  int GetNumberOfCellArrays();
  const char* GetCellArrayName(int index);
  void SetCellArrayStatus(const char* name, int status);
  int GetCellArrayStatus(const char* name);
94

95
  // Description:
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  // Get/Set information about grids. As is typical with readers this is valid
  // only after the filename as been set and UpdateInformation() has been
  // called.
  int GetNumberOfGrids();
  const char* GetGridName(int index);
  void SetGridStatus(const char* gridname, int status);
  int GetGridStatus(const char* gridname);

  // Description:
  // Get/Set information about sets. As is typical with readers this is valid
  // only after the filename as been set and UpdateInformation() has been
  // called. Note that sets with non-zero Ghost value are not treated as sets
  // that the user can select using this API.
  int GetNumberOfSets();
  const char* GetSetName(int index);
  void SetSetStatus(const char* gridname, int status);
  int GetSetStatus(const char* gridname);

  // Description:
  // These methods are provided to make it easier to use the Sets in ParaView.
  int GetNumberOfSetArrays() { return this->GetNumberOfSets(); }
  const char* GetSetArrayName(int index)
    { return this->GetSetName(index); }
  int GetSetArrayStatus(const char* name)
    { return this->GetSetStatus(name); }
 
  // Description:
  // Get/Set the stride used to skip points when reading structured datasets.
  // This affects all grids being read.
  vtkSetVector3Macro(Stride, int);
126
127
128
  vtkGetVector3Macro(Stride, int);

  // Description:
129
130
  // Determine if the file can be read with this reader.
  virtual int CanReadFile(const char* filename);
131
132

  // Description:
133
134
  // Every time the SIL is updated a this will return a different value.
  vtkGetMacro(SILUpdateStamp, int);
135

136
137
138
139
140
  // Description:
  // SIL describes organization of/relationships between classifications
  // eg. blocks/materials/hierarchies.
  virtual vtkGraph* GetSIL();

Nikhil Shetty's avatar
Nikhil Shetty committed
141
//BTX
Jerry Clarke's avatar
Jerry Clarke committed
142
protected:
Andy Cedilnik's avatar
Andy Cedilnik committed
143
  vtkXdmfReader();
144
145
  ~vtkXdmfReader();

146
  virtual int ProcessRequest(vtkInformation *request,
147
148
    vtkInformationVector **inputVector,
    vtkInformationVector *outputVector);
149
  virtual int RequestDataObject(vtkInformationVector *outputVector);
150
  virtual int RequestData(vtkInformation *, vtkInformationVector **,
151
    vtkInformationVector *);
152
  virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
153
    vtkInformationVector *);
154
  virtual int FillOutputPortInformation(int port, vtkInformation *info);
Jerry Clarke's avatar
Jerry Clarke committed
155

156
157
158
159
160
161
  vtkXdmfArraySelection* GetPointArraySelection();
  vtkXdmfArraySelection* GetCellArraySelection();
  vtkXdmfArraySelection* GetGridSelection();
  vtkXdmfArraySelection* GetSetsSelection();
  void PassCachedSelections();
  
162
  char* DomainName;
163
164
165
  // char* ActiveDomainName;
  int Stride[3];
  unsigned int LastTimeIndex;
166

167
  vtkXdmfDocument* XdmfDocument;
168

169
170
171
172
173
174
175
176
177
178
179
180
181
182
  // Until RequestInformation() is called, the active domain is not set
  // correctly. If SetGridStatus() etc. are called before that happens, then we
  // have no place to save the user choices. So we cache them in these temporary
  // caches. These are passed on to the actual vtkXdmfArraySelection instances
  // used by the active vtkXdmfDomain in RequestInformation().
  // Note that these are only used until the first domain is setup, once that
  // happens, the information set in these is passed to the domain and  these
  // are cleared an no longer used, until the active domain becomes invalid
  // again.
  vtkXdmfArraySelection* PointArraysCache;
  vtkXdmfArraySelection* CellArraysCache;
  vtkXdmfArraySelection* GridsCache;
  vtkXdmfArraySelection* SetsCache;

183
184
185
186
187
188
189
190
191
192
  int SILUpdateStamp;
private:
  // Description:
  // Prepares the XdmfDocument.
  bool PrepareDocument();

  // Description:
  // Returns the time-step index requested using the UPDATE_TIME_STEPS from the
  // information.
  int ChooseTimeStep(vtkInformation* outInfo);
193

194
private:
Andy Cedilnik's avatar
Andy Cedilnik committed
195
  vtkXdmfReader(const vtkXdmfReader&); // Not implemented
Nikhil Shetty's avatar
Nikhil Shetty committed
196
  void operator=(const vtkXdmfReader&); // Not implemented
197
//ETX
Jerry Clarke's avatar
Jerry Clarke committed
198
199
};

200
201
#endif