00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00023 #ifndef __vtkXMLReader_h
00024 #define __vtkXMLReader_h
00025
00026 #include "vtkAlgorithm.h"
00027
00028 class vtkAbstractArray;
00029 class vtkCallbackCommand;
00030 class vtkDataArraySelection;
00031 class vtkDataSet;
00032 class vtkDataSetAttributes;
00033 class vtkXMLDataElement;
00034 class vtkXMLDataParser;
00035 class vtkInformationVector;
00036 class vtkInformation;
00037
00038 class VTK_IO_EXPORT vtkXMLReader : public vtkAlgorithm
00039 {
00040 public:
00041 vtkTypeMacro(vtkXMLReader,vtkAlgorithm);
00042 void PrintSelf(ostream& os, vtkIndent indent);
00043
00045
00046 vtkSetStringMacro(FileName);
00047 vtkGetStringMacro(FileName);
00049
00051 virtual int CanReadFile(const char* name);
00052
00054
00055 vtkDataSet* GetOutputAsDataSet();
00056 vtkDataSet* GetOutputAsDataSet(int index);
00058
00060
00062 vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
00063 vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
00065
00067
00068 int GetNumberOfPointArrays();
00069 int GetNumberOfCellArrays();
00071
00073
00075 const char* GetPointArrayName(int index);
00076 const char* GetCellArrayName(int index);
00078
00080
00082 int GetPointArrayStatus(const char* name);
00083 int GetCellArrayStatus(const char* name);
00084 void SetPointArrayStatus(const char* name, int status);
00085 void SetCellArrayStatus(const char* name, int status);
00087
00088
00089
00090 virtual void CopyOutputInformation(vtkInformation *vtkNotUsed(outInfo),
00091 int vtkNotUsed(port)) {}
00092
00094
00095 vtkSetMacro(TimeStep, int);
00096 vtkGetMacro(TimeStep, int);
00098
00099 vtkGetMacro(NumberOfTimeSteps, int);
00101
00102 vtkGetVector2Macro(TimeStepRange, int);
00103 vtkSetVector2Macro(TimeStepRange, int);
00105
00106 virtual int ProcessRequest(vtkInformation *request,
00107 vtkInformationVector **inputVector,
00108 vtkInformationVector *outputVector);
00109
00110 protected:
00111 vtkXMLReader();
00112 ~vtkXMLReader();
00113
00114
00115
00116
00117 virtual int ReadXMLInformation();
00118 virtual void ReadXMLData();
00119
00120
00121 virtual const char* GetDataSetName()=0;
00122
00123
00124 virtual int CanReadFileVersion(int major, int minor);
00125
00126
00127 virtual void SetupEmptyOutput()=0;
00128
00129
00130 virtual void SetupOutputInformation(vtkInformation *vtkNotUsed(outInfo)) {}
00131
00132
00133 virtual void SetupUpdateExtentInformation
00134 (vtkInformation *vtkNotUsed(outInfo)) {}
00135
00136
00137 virtual void SetupOutputData();
00138
00139
00140
00141 virtual int ReadPrimaryElement(vtkXMLDataElement* ePrimary);
00142
00143
00144
00145 int ReadVTKFile(vtkXMLDataElement* eVTKFile);
00146
00147
00148
00149 vtkAbstractArray* CreateArray(vtkXMLDataElement* da);
00150
00151
00152
00153 int CreateInformationKey(vtkXMLDataElement *eInfoKey, vtkInformation *info);
00154
00155
00156 virtual int OpenVTKFile();
00157 virtual void CloseVTKFile();
00158 virtual void CreateXMLParser();
00159 virtual void DestroyXMLParser();
00160 void SetupCompressor(const char* type);
00161 int CanReadFileVersionString(const char* version);
00162
00163
00164 vtkGetMacro(FileMajorVersion, int);
00165
00166
00167 vtkGetMacro(FileMinorVersion, int);
00168
00169
00170 int IntersectExtents(int* extent1, int* extent2, int* result);
00171 int Min(int a, int b);
00172 int Max(int a, int b);
00173 void ComputePointDimensions(int* extent, int* dimensions);
00174 void ComputePointIncrements(int* extent, vtkIdType* increments);
00175 void ComputeCellDimensions(int* extent, int* dimensions);
00176 void ComputeCellIncrements(int* extent, vtkIdType* increments);
00177 vtkIdType GetStartTuple(int* extent, vtkIdType* increments,
00178 int i, int j, int k);
00179 void ReadAttributeIndices(vtkXMLDataElement* eDSA,
00180 vtkDataSetAttributes* dsa);
00181 char** CreateStringArray(int numStrings);
00182 void DestroyStringArray(int numStrings, char** strings);
00183
00184
00185 void SetDataArraySelections(vtkXMLDataElement* eDSA,
00186 vtkDataArraySelection* sel);
00187
00188
00189 int SetFieldDataInfo(vtkXMLDataElement *eDSA, int association,
00190 int numTuples, vtkInformationVector *(&infoVector));
00191
00192
00193
00194 int PointDataArrayIsEnabled(vtkXMLDataElement* ePDA);
00195 int CellDataArrayIsEnabled(vtkXMLDataElement* eCDA);
00196
00197
00198 static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
00199 void* clientdata, void* calldata);
00200
00201
00202 vtkXMLDataParser* XMLParser;
00203
00204
00205 vtkXMLDataElement* FieldDataElement;
00206
00207
00208 char* FileName;
00209
00210
00211 istream* Stream;
00212
00213
00214 vtkDataArraySelection* PointDataArraySelection;
00215 vtkDataArraySelection* CellDataArraySelection;
00216
00217
00218
00219 vtkCallbackCommand* SelectionObserver;
00220
00221
00222 int InformationError;
00223
00224
00225 int DataError;
00226
00227
00228 virtual void GetProgressRange(float* range);
00229 virtual void SetProgressRange(float* range, int curStep, int numSteps);
00230 virtual void SetProgressRange(float* range, int curStep, float* fractions);
00231 virtual void UpdateProgressDiscrete(float progress);
00232 float ProgressRange[2];
00233
00234 virtual int RequestData(vtkInformation *request,
00235 vtkInformationVector **inputVector,
00236 vtkInformationVector *outputVector);
00237 virtual int RequestDataObject(vtkInformation *vtkNotUsed(request),
00238 vtkInformationVector **vtkNotUsed(inputVector),
00239 vtkInformationVector *vtkNotUsed(outputVector))
00240 { return 1; }
00241 virtual int RequestInformation(vtkInformation *request,
00242 vtkInformationVector **inputVector,
00243 vtkInformationVector *outputVector);
00244 virtual int RequestUpdateExtentInformation
00245 (vtkInformation *request,
00246 vtkInformationVector **inputVector,
00247 vtkInformationVector *outputVector);
00248
00249 vtkTimeStamp ReadMTime;
00250
00251
00252 int ReadError;
00253
00254
00255
00256
00257 int AxesEmpty[3];
00258
00259
00260 int TimeStep;
00261 int CurrentTimeStep;
00262 int NumberOfTimeSteps;
00263 void SetNumberOfTimeSteps(int num);
00264
00265
00266 int *TimeSteps;
00267
00268 int TimeStepRange[2];
00269
00270
00271
00272
00273
00274
00275
00276 static int IsTimeStepInArray(int timestep, int* timesteps, int length);
00277
00278 vtkDataObject* GetCurrentOutput();
00279 vtkInformation* GetCurrentOutputInformation();
00280
00281 private:
00282
00283 ifstream* FileStream;
00284 int TimeStepWasReadOnce;
00285
00286 int FileMajorVersion;
00287 int FileMinorVersion;
00288
00289 vtkDataObject* CurrentOutput;
00290 vtkInformation* CurrentOutputInformation;
00291
00292 private:
00293 vtkXMLReader(const vtkXMLReader&);
00294 void operator=(const vtkXMLReader&);
00295 };
00296
00297 #endif