Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/IO/vtkXMLReader.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkXMLReader.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00027 #ifndef __vtkXMLReader_h 00028 #define __vtkXMLReader_h 00029 00030 #include "vtkSource.h" 00031 00032 class vtkCallbackCommand; 00033 class vtkDataArray; 00034 class vtkDataArraySelection; 00035 class vtkDataSet; 00036 class vtkDataSetAttributes; 00037 class vtkXMLDataElement; 00038 class vtkXMLDataParser; 00039 00040 class VTK_IO_EXPORT vtkXMLReader : public vtkSource 00041 { 00042 public: 00043 vtkTypeRevisionMacro(vtkXMLReader,vtkSource); 00044 void PrintSelf(ostream& os, vtkIndent indent); 00045 00047 00048 vtkSetStringMacro(FileName); 00049 vtkGetStringMacro(FileName); 00051 00053 virtual int CanReadFile(const char* name); 00054 00056 vtkDataSet* GetOutputAsDataSet(); 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 protected: 00088 vtkXMLReader(); 00089 ~vtkXMLReader(); 00090 00091 // Standard pipeline exectution methods. 00092 void ExecuteInformation(); 00093 void ExecuteData(vtkDataObject* output); 00094 00095 // Pipeline execution methods to be defined by subclass. Called by 00096 // corresponding Execute methods after appropriate setup has been 00097 // done. 00098 virtual void ReadXMLInformation(); 00099 virtual void ReadXMLData(); 00100 00101 // Get the name of the data set being read. 00102 virtual const char* GetDataSetName()=0; 00103 00104 // Test if the reader can read a file with the given version number. 00105 virtual int CanReadFileVersion(int major, int minor); 00106 00107 // Setup the output with no data available. Used in error cases. 00108 virtual void SetupEmptyOutput()=0; 00109 00110 // Setup the output's information and data without allocation. 00111 virtual void SetupOutputInformation(); 00112 00113 // Setup the output's information and data with allocation. 00114 virtual void SetupOutputData(); 00115 00116 // Read the primary element from the file. This is the element 00117 // whose name is the value returned by GetDataSetName(). 00118 virtual int ReadPrimaryElement(vtkXMLDataElement* ePrimary); 00119 00120 // Read the top-level element from the file. This is always the 00121 // VTKFile element. 00122 int ReadVTKFile(vtkXMLDataElement* eVTKFile); 00123 00124 // Create a vtkDataArray from its cooresponding XML representation. 00125 // Does not allocate. 00126 vtkDataArray* CreateDataArray(vtkXMLDataElement* da); 00127 00128 // Internal utility methods. 00129 int OpenVTKFile(); 00130 void CloseVTKFile(); 00131 void CreateXMLParser(); 00132 void DestroyXMLParser(); 00133 void SetupCompressor(const char* type); 00134 int CanReadFileVersionString(const char* version); 00135 00136 // Utility methods for subclasses. 00137 int IntersectExtents(int* extent1, int* extent2, int* result); 00138 int Min(int a, int b); 00139 int Max(int a, int b); 00140 void ComputeDimensions(int* extent, int* dimensions, int isPoint); 00141 void ComputeIncrements(int* extent, int* increments, int isPoint); 00142 unsigned int GetStartTuple(int* extent, int* increments, 00143 int i, int j, int k); 00144 void ReadAttributeIndices(vtkXMLDataElement* eDSA, 00145 vtkDataSetAttributes* dsa); 00146 char** CreateStringArray(int numStrings); 00147 void DestroyStringArray(int numStrings, char** strings); 00148 00149 // Setup the data array selections for the input's set of arrays. 00150 void SetDataArraySelections(vtkXMLDataElement* eDSA, 00151 vtkDataArraySelection* sel); 00152 00153 // Check whether the given array element is an enabled array. 00154 int PointDataArrayIsEnabled(vtkXMLDataElement* ePDA); 00155 int CellDataArrayIsEnabled(vtkXMLDataElement* eCDA); 00156 00157 // Callback registered with the SelectionObserver. 00158 static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid, 00159 void* clientdata, void* calldata); 00160 00161 // The vtkXMLDataParser instance used to hide XML reading details. 00162 vtkXMLDataParser* XMLParser; 00163 00164 // The input file's name. 00165 char* FileName; 00166 00167 // The file stream used to read the input file. 00168 ifstream* FileStream; 00169 00170 // The array selections. 00171 vtkDataArraySelection* PointDataArraySelection; 00172 vtkDataArraySelection* CellDataArraySelection; 00173 00174 // The observer to modify this object when the array selections are 00175 // modified. 00176 vtkCallbackCommand* SelectionObserver; 00177 00178 // Whether there was an error reading the file in ExecuteInformation. 00179 int InformationError; 00180 00181 // Whether there was an error reading the file in ExecuteData. 00182 int DataError; 00183 00184 private: 00185 vtkXMLReader(const vtkXMLReader&); // Not implemented. 00186 void operator=(const vtkXMLReader&); // Not implemented. 00187 }; 00188 00189 #endif