1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkXdmfReader.h 5 Language: C++ 6 Date: $Date$ 7 Version: $Revision$ 8 9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 10 All rights reserved. 11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 12 13 This software is distributed WITHOUT ANY WARRANTY; without even 14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 PURPOSE. See the above copyright notice for more information. 16 17 =========================================================================*/ 18 // .NAME vtkXdmfReader - Reads <tt>eXtensible Data Model and Format</tt> files 19 // .SECTION Description 20 // vtkXdmfReader reads XDMF data files so that they can be visualized using 21 // VTK. The output data produced by this reader depends on the number of grids 22 // in the data file. If the data file has a single domain with a single grid, 23 // then the output type is a vtkDataSet subclass of the appropriate type, 24 // otherwise it's a vtkMultiBlockDataSet. 25 // 26 // Refer to vtkDataReader which provides many methods for controlling the 27 // reading of the data file. 28 // .SECTION Caveats 29 // Uses the XDMF API (http://www.xdmf.org) 30 // .SECTION See Also 31 // vtkDataReader 32 33 #ifndef vtkXdmfReader_h 34 #define vtkXdmfReader_h 35 36 #include "vtkIOXdmf2Module.h" // For export macro 37 #include "vtkDataReader.h" 38 39 class vtkXdmfArraySelection; 40 class vtkXdmfDocument; 41 class vtkGraph; 42 43 class VTKIOXDMF2_EXPORT vtkXdmfReader : public vtkDataReader 44 { 45 public: 46 static vtkXdmfReader* New(); 47 vtkTypeMacro(vtkXdmfReader, vtkDataReader); 48 void PrintSelf(ostream& os, vtkIndent indent); 49 50 // Until needed, multiple domains are not supported. 51 //// Description: 52 //// Returns the number of domains present in the data file. This in valid after 53 //// the filename has been set and UpdateInformation() has been called .i.e. the 54 //// RequestInformation pipeline pass has happened. 55 //unsigned int GetNumberOfDomains(); 56 57 // Description: 58 // Set the active domain. Only one domain can be selected at a time. By 59 // default the first domain in the datafile is chosen. Setting this to null 60 // results in the domain being automatically chosen. Note that if the domain 61 // name is changed, you should explicitly call UpdateInformation() before 62 // accessing information about grids, data arrays etc. 63 vtkSetStringMacro(DomainName); 64 vtkGetStringMacro(DomainName); 65 66 //// Description: 67 //// Returns the name for the active domain. Note that this may be different 68 //// from what GetDomainName() returns if DomainName is NULL or invalid. 69 // vtkGetStringMacro(ActiveDomainName); 70 71 // Description: 72 // Get information about point-based arrays. As is typical with readers this 73 // in only valid after the filename is set and UpdateInformation() has been 74 // called. 75 int GetNumberOfPointArrays(); 76 77 // Description: 78 // Returns the name of point array at the give index. Returns NULL if index is 79 // invalid. 80 const char* GetPointArrayName(int index); 81 82 // Description: 83 // Get/Set the point array status. 84 int GetPointArrayStatus(const char* name); 85 void SetPointArrayStatus(const char* name, int status); 86 87 // Description: 88 // Get information about cell-based arrays. As is typical with readers this 89 // in only valid after the filename is set and UpdateInformation() has been 90 // called. 91 int GetNumberOfCellArrays(); 92 const char* GetCellArrayName(int index); 93 void SetCellArrayStatus(const char* name, int status); 94 int GetCellArrayStatus(const char* name); 95 96 // Description: 97 // Get/Set information about grids. As is typical with readers this is valid 98 // only after the filename as been set and UpdateInformation() has been 99 // called. 100 int GetNumberOfGrids(); 101 const char* GetGridName(int index); 102 void SetGridStatus(const char* gridname, int status); 103 int GetGridStatus(const char* gridname); 104 105 // Description: 106 // Get/Set information about sets. As is typical with readers this is valid 107 // only after the filename as been set and UpdateInformation() has been 108 // called. Note that sets with non-zero Ghost value are not treated as sets 109 // that the user can select using this API. 110 int GetNumberOfSets(); 111 const char* GetSetName(int index); 112 void SetSetStatus(const char* gridname, int status); 113 int GetSetStatus(const char* gridname); 114 115 // Description: 116 // These methods are provided to make it easier to use the Sets in ParaView. GetNumberOfSetArrays()117 int GetNumberOfSetArrays() { return this->GetNumberOfSets(); } GetSetArrayName(int index)118 const char* GetSetArrayName(int index) 119 { return this->GetSetName(index); } GetSetArrayStatus(const char * name)120 int GetSetArrayStatus(const char* name) 121 { return this->GetSetStatus(name); } 122 123 // Description: 124 // Get/Set the stride used to skip points when reading structured datasets. 125 // This affects all grids being read. 126 vtkSetVector3Macro(Stride, int); 127 vtkGetVector3Macro(Stride, int); 128 129 // Description: 130 // Determine if the file can be read with this reader. 131 virtual int CanReadFile(const char* filename); 132 133 // Description: 134 // Every time the SIL is updated a this will return a different value. 135 vtkGetMacro(SILUpdateStamp, int); 136 137 // Description: 138 // SIL describes organization of/relationships between classifications 139 // eg. blocks/materials/hierarchies. 140 virtual vtkGraph* GetSIL(); 141 142 //BTX 143 protected: 144 vtkXdmfReader(); 145 ~vtkXdmfReader(); 146 147 virtual int ProcessRequest(vtkInformation *request, 148 vtkInformationVector **inputVector, 149 vtkInformationVector *outputVector); 150 virtual int RequestDataObject(vtkInformationVector *outputVector); 151 virtual int RequestData(vtkInformation *, vtkInformationVector **, 152 vtkInformationVector *); 153 virtual int RequestInformation(vtkInformation *, vtkInformationVector **, 154 vtkInformationVector *); 155 virtual int FillOutputPortInformation(int port, vtkInformation *info); 156 157 vtkXdmfArraySelection* GetPointArraySelection(); 158 vtkXdmfArraySelection* GetCellArraySelection(); 159 vtkXdmfArraySelection* GetGridSelection(); 160 vtkXdmfArraySelection* GetSetsSelection(); 161 void PassCachedSelections(); 162 163 char* DomainName; 164 // char* ActiveDomainName; 165 int Stride[3]; 166 unsigned int LastTimeIndex; 167 168 vtkXdmfDocument* XdmfDocument; 169 170 // Until RequestInformation() is called, the active domain is not set 171 // correctly. If SetGridStatus() etc. are called before that happens, then we 172 // have no place to save the user choices. So we cache them in these temporary 173 // caches. These are passed on to the actual vtkXdmfArraySelection instances 174 // used by the active vtkXdmfDomain in RequestInformation(). 175 // Note that these are only used until the first domain is setup, once that 176 // happens, the information set in these is passed to the domain and these 177 // are cleared an no longer used, until the active domain becomes invalid 178 // again. 179 vtkXdmfArraySelection* PointArraysCache; 180 vtkXdmfArraySelection* CellArraysCache; 181 vtkXdmfArraySelection* GridsCache; 182 vtkXdmfArraySelection* SetsCache; 183 184 int SILUpdateStamp; 185 private: 186 // Description: 187 // Prepares the XdmfDocument. 188 bool PrepareDocument(); 189 190 // Description: 191 // Returns the time-step index requested using the UPDATE_TIME_STEPS from the 192 // information. 193 int ChooseTimeStep(vtkInformation* outInfo); 194 195 private: 196 vtkXdmfReader(const vtkXdmfReader&); // Not implemented 197 void operator=(const vtkXdmfReader&); // Not implemented 198 //ETX 199 }; 200 201 #endif 202