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 vtkCallbackCommand;
00029 class vtkDataArray;
00030 class vtkDataArraySelection;
00031 class vtkDataSet;
00032 class vtkDataSetAttributes;
00033 class vtkXMLDataElement;
00034 class vtkXMLDataParser;
00035 class vtkInformationVector;
00036
00037 class VTK_IO_EXPORT vtkXMLReader : public vtkAlgorithm
00038 {
00039 public:
00040 vtkTypeRevisionMacro(vtkXMLReader,vtkAlgorithm);
00041 void PrintSelf(ostream& os, vtkIndent indent);
00042
00044
00045 vtkSetStringMacro(FileName);
00046 vtkGetStringMacro(FileName);
00048
00050 virtual int CanReadFile(const char* name);
00051
00053
00054 vtkDataSet* GetOutputAsDataSet();
00055 vtkDataSet* GetOutputAsDataSet(int index);
00057
00059
00061 vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
00062 vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
00064
00066
00067 int GetNumberOfPointArrays();
00068 int GetNumberOfCellArrays();
00070
00072
00074 const char* GetPointArrayName(int index);
00075 const char* GetCellArrayName(int index);
00077
00079
00081 int GetPointArrayStatus(const char* name);
00082 int GetCellArrayStatus(const char* name);
00083 void SetPointArrayStatus(const char* name, int status);
00084 void SetCellArrayStatus(const char* name, int status);
00086
00087
00088
00089 virtual void CopyOutputInformation(vtkInformation *vtkNotUsed(outInfo),
00090 int vtkNotUsed(port)) {}
00091
00093
00094 vtkSetMacro(TimeStep, int);
00095 vtkGetMacro(TimeStep, int);
00097
00098 vtkGetMacro(NumberOfTimeSteps, int);
00100
00101 vtkGetVector2Macro(TimeStepRange, int);
00102 vtkSetVector2Macro(TimeStepRange, int);
00104
00105 protected:
00106 vtkXMLReader();
00107 ~vtkXMLReader();
00108
00109
00110
00111
00112 virtual int ReadXMLInformation();
00113 virtual void ReadXMLData();
00114
00115
00116 virtual const char* GetDataSetName()=0;
00117
00118
00119 virtual int CanReadFileVersion(int major, int minor);
00120
00121
00122 virtual void SetupEmptyOutput()=0;
00123
00124
00125 virtual void SetupOutputInformation(vtkInformation *vtkNotUsed(outInfo)) {}
00126
00127
00128 virtual void SetupOutputData();
00129
00130
00131
00132 virtual int ReadPrimaryElement(vtkXMLDataElement* ePrimary);
00133
00134
00135
00136 int ReadVTKFile(vtkXMLDataElement* eVTKFile);
00137
00138
00139
00140 vtkDataArray* CreateDataArray(vtkXMLDataElement* da);
00141
00142
00143 int OpenVTKFile();
00144 void CloseVTKFile();
00145 virtual void CreateXMLParser();
00146 virtual void DestroyXMLParser();
00147 void SetupCompressor(const char* type);
00148 int CanReadFileVersionString(const char* version);
00149
00150
00151 int IntersectExtents(int* extent1, int* extent2, int* result);
00152 int Min(int a, int b);
00153 int Max(int a, int b);
00154 void ComputePointDimensions(int* extent, int* dimensions);
00155 void ComputePointIncrements(int* extent, vtkIdType* increments);
00156 void ComputeCellDimensions(int* extent, int* dimensions);
00157 void ComputeCellIncrements(int* extent, vtkIdType* increments);
00158 vtkIdType GetStartTuple(int* extent, vtkIdType* increments,
00159 int i, int j, int k);
00160 void ReadAttributeIndices(vtkXMLDataElement* eDSA,
00161 vtkDataSetAttributes* dsa);
00162 char** CreateStringArray(int numStrings);
00163 void DestroyStringArray(int numStrings, char** strings);
00164
00165
00166 void SetDataArraySelections(vtkXMLDataElement* eDSA,
00167 vtkDataArraySelection* sel);
00168
00169
00170 int SetFieldDataInfo(vtkXMLDataElement *eDSA, int association,
00171 int numTuples, vtkInformationVector *(&infoVector));
00172
00173
00174
00175 int PointDataArrayIsEnabled(vtkXMLDataElement* ePDA);
00176 int CellDataArrayIsEnabled(vtkXMLDataElement* eCDA);
00177
00178
00179 static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
00180 void* clientdata, void* calldata);
00181
00182
00183 vtkXMLDataParser* XMLParser;
00184
00185
00186 vtkXMLDataElement* FieldDataElement;
00187
00188
00189 char* FileName;
00190
00191
00192 istream* Stream;
00193
00194
00195 vtkDataArraySelection* PointDataArraySelection;
00196 vtkDataArraySelection* CellDataArraySelection;
00197
00198
00199
00200 vtkCallbackCommand* SelectionObserver;
00201
00202
00203 int InformationError;
00204
00205
00206 int DataError;
00207
00208
00209
00210 int CurrentOutput;
00211
00212
00213
00214 virtual void GetProgressRange(float* range);
00215 virtual void SetProgressRange(float* range, int curStep, int numSteps);
00216 virtual void SetProgressRange(float* range, int curStep, float* fractions);
00217 virtual void UpdateProgressDiscrete(float progress);
00218 float ProgressRange[2];
00219
00220 virtual int ProcessRequest(vtkInformation *request,
00221 vtkInformationVector **inputVector,
00222 vtkInformationVector *outputVector);
00223 virtual int RequestData(vtkInformation *request,
00224 vtkInformationVector **inputVector,
00225 vtkInformationVector *outputVector);
00226 virtual int RequestDataObject(vtkInformation *vtkNotUsed(request),
00227 vtkInformationVector **vtkNotUsed(inputVector),
00228 vtkInformationVector *vtkNotUsed(outputVector))
00229 { return 1; }
00230 virtual int RequestInformation(vtkInformation *request,
00231 vtkInformationVector **inputVector,
00232 vtkInformationVector *outputVector);
00233
00234 vtkTimeStamp ReadMTime;
00235
00236
00237 int ReadError;
00238
00239
00240
00241
00242 int AxesEmpty[3];
00243
00244
00245 int TimeStep;
00246 int CurrentTimeStep;
00247 int NumberOfTimeSteps;
00248 void SetNumberOfTimeSteps(int num);
00249
00250
00251 int *TimeSteps;
00252
00253 int TimeStepRange[2];
00254
00255
00256
00257
00258
00259
00260
00261 static int IsTimeStepInArray(int timestep, int* timesteps, int length);
00262
00263 private:
00264
00265 ifstream* FileStream;
00266 int TimeStepWasReadOnce;
00267
00268 private:
00269 vtkXMLReader(const vtkXMLReader&);
00270 void operator=(const vtkXMLReader&);
00271 };
00272
00273 #endif