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 vtkTypeRevisionMacro(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 protected:
00107 vtkXMLReader();
00108 ~vtkXMLReader();
00109
00110
00111
00112
00113 virtual int ReadXMLInformation();
00114 virtual void ReadXMLData();
00115
00116
00117 virtual const char* GetDataSetName()=0;
00118
00119
00120 virtual int CanReadFileVersion(int major, int minor);
00121
00122
00123 virtual void SetupEmptyOutput()=0;
00124
00125
00126 virtual void SetupOutputInformation(vtkInformation *vtkNotUsed(outInfo)) {}
00127
00128
00129 virtual void SetupUpdateExtentInformation
00130 (vtkInformation *vtkNotUsed(outInfo)) {}
00131
00132
00133 virtual void SetupOutputData();
00134
00135
00136
00137 virtual int ReadPrimaryElement(vtkXMLDataElement* ePrimary);
00138
00139
00140
00141 int ReadVTKFile(vtkXMLDataElement* eVTKFile);
00142
00143
00144
00145 vtkAbstractArray* CreateArray(vtkXMLDataElement* da);
00146
00147
00148
00149 int CreateInformationKey(vtkXMLDataElement *eInfoKey, vtkInformation *info);
00150
00151
00152 virtual int OpenVTKFile();
00153 virtual void CloseVTKFile();
00154 virtual void CreateXMLParser();
00155 virtual void DestroyXMLParser();
00156 void SetupCompressor(const char* type);
00157 int CanReadFileVersionString(const char* version);
00158
00159
00160 vtkGetMacro(FileMajorVersion, int);
00161
00162
00163 vtkGetMacro(FileMinorVersion, int);
00164
00165
00166 int IntersectExtents(int* extent1, int* extent2, int* result);
00167 int Min(int a, int b);
00168 int Max(int a, int b);
00169 void ComputePointDimensions(int* extent, int* dimensions);
00170 void ComputePointIncrements(int* extent, vtkIdType* increments);
00171 void ComputeCellDimensions(int* extent, int* dimensions);
00172 void ComputeCellIncrements(int* extent, vtkIdType* increments);
00173 vtkIdType GetStartTuple(int* extent, vtkIdType* increments,
00174 int i, int j, int k);
00175 void ReadAttributeIndices(vtkXMLDataElement* eDSA,
00176 vtkDataSetAttributes* dsa);
00177 char** CreateStringArray(int numStrings);
00178 void DestroyStringArray(int numStrings, char** strings);
00179
00180
00181 void SetDataArraySelections(vtkXMLDataElement* eDSA,
00182 vtkDataArraySelection* sel);
00183
00184
00185 int SetFieldDataInfo(vtkXMLDataElement *eDSA, int association,
00186 int numTuples, vtkInformationVector *(&infoVector));
00187
00188
00189
00190 int PointDataArrayIsEnabled(vtkXMLDataElement* ePDA);
00191 int CellDataArrayIsEnabled(vtkXMLDataElement* eCDA);
00192
00193
00194 static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
00195 void* clientdata, void* calldata);
00196
00197
00198 vtkXMLDataParser* XMLParser;
00199
00200
00201 vtkXMLDataElement* FieldDataElement;
00202
00203
00204 char* FileName;
00205
00206
00207 istream* Stream;
00208
00209
00210 vtkDataArraySelection* PointDataArraySelection;
00211 vtkDataArraySelection* CellDataArraySelection;
00212
00213
00214
00215 vtkCallbackCommand* SelectionObserver;
00216
00217
00218 int InformationError;
00219
00220
00221 int DataError;
00222
00223
00224 virtual void GetProgressRange(float* range);
00225 virtual void SetProgressRange(float* range, int curStep, int numSteps);
00226 virtual void SetProgressRange(float* range, int curStep, float* fractions);
00227 virtual void UpdateProgressDiscrete(float progress);
00228 float ProgressRange[2];
00229
00230 virtual int ProcessRequest(vtkInformation *request,
00231 vtkInformationVector **inputVector,
00232 vtkInformationVector *outputVector);
00233 virtual int RequestData(vtkInformation *request,
00234 vtkInformationVector **inputVector,
00235 vtkInformationVector *outputVector);
00236 virtual int RequestDataObject(vtkInformation *vtkNotUsed(request),
00237 vtkInformationVector **vtkNotUsed(inputVector),
00238 vtkInformationVector *vtkNotUsed(outputVector))
00239 { return 1; }
00240 virtual int RequestInformation(vtkInformation *request,
00241 vtkInformationVector **inputVector,
00242 vtkInformationVector *outputVector);
00243 virtual int RequestUpdateExtentInformation
00244 (vtkInformation *request,
00245 vtkInformationVector **inputVector,
00246 vtkInformationVector *outputVector);
00247
00248 vtkTimeStamp ReadMTime;
00249
00250
00251 int ReadError;
00252
00253
00254
00255
00256 int AxesEmpty[3];
00257
00258
00259 int TimeStep;
00260 int CurrentTimeStep;
00261 int NumberOfTimeSteps;
00262 void SetNumberOfTimeSteps(int num);
00263
00264
00265 int *TimeSteps;
00266
00267 int TimeStepRange[2];
00268
00269
00270
00271
00272
00273
00274
00275 static int IsTimeStepInArray(int timestep, int* timesteps, int length);
00276
00277 vtkDataObject* GetCurrentOutput();
00278 vtkInformation* GetCurrentOutputInformation();
00279
00280 private:
00281
00282 ifstream* FileStream;
00283 int TimeStepWasReadOnce;
00284
00285 int FileMajorVersion;
00286 int FileMinorVersion;
00287
00288 vtkDataObject* CurrentOutput;
00289 vtkInformation* CurrentOutputInformation;
00290
00291 private:
00292 vtkXMLReader(const vtkXMLReader&);
00293 void operator=(const vtkXMLReader&);
00294 };
00295
00296 #endif