VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkXMLDataReader.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00026 #ifndef vtkXMLDataReader_h 00027 #define vtkXMLDataReader_h 00028 00029 #include "vtkIOXMLModule.h" // For export macro 00030 #include "vtkXMLReader.h" 00031 00032 class VTKIOXML_EXPORT vtkXMLDataReader : public vtkXMLReader 00033 { 00034 public: 00035 vtkTypeMacro(vtkXMLDataReader,vtkXMLReader); 00036 void PrintSelf(ostream& os, vtkIndent indent); 00037 00039 virtual vtkIdType GetNumberOfPoints()=0; 00040 00042 virtual vtkIdType GetNumberOfCells()=0; 00043 00044 // For the specified port, copy the information this reader sets up in 00045 // SetupOutputInformation to outInfo 00046 virtual void CopyOutputInformation(vtkInformation *outInfo, int port); 00047 00048 protected: 00049 vtkXMLDataReader(); 00050 ~vtkXMLDataReader(); 00051 00052 // Add functionality to methods from superclass. 00053 virtual void CreateXMLParser(); 00054 virtual void DestroyXMLParser(); 00055 virtual void SetupOutputInformation(vtkInformation *outInfo); 00056 00057 int ReadPrimaryElement(vtkXMLDataElement* ePrimary); 00058 void SetupOutputData(); 00059 00060 // Setup the reader for a given number of pieces. 00061 virtual void SetupPieces(int numPieces); 00062 virtual void DestroyPieces(); 00063 00064 // Read information from the file for the given piece. 00065 int ReadPiece(vtkXMLDataElement* ePiece, int piece); 00066 virtual int ReadPiece(vtkXMLDataElement* ePiece); 00067 00068 // Read data from the file for the given piece. 00069 int ReadPieceData(int piece); 00070 virtual int ReadPieceData(); 00071 00072 virtual void ReadXMLData(); 00073 00074 // Read a data array whose tuples coorrespond to points or cells. 00075 virtual int ReadArrayForPoints(vtkXMLDataElement* da, 00076 vtkAbstractArray* outArray); 00077 virtual int ReadArrayForCells(vtkXMLDataElement* da, 00078 vtkAbstractArray* outArray); 00079 00080 // Read an Array values starting at the given index and up to numValues. 00081 // This method assumes that the array is of correct size to 00082 // accommodate all numValues values. arrayIndex is the value index at which the read 00083 // values will be put in the array. 00084 int ReadArrayValues(vtkXMLDataElement* da, vtkIdType arrayIndex, vtkAbstractArray* array, 00085 vtkIdType startIndex, vtkIdType numValues); 00086 00087 00088 00089 // Callback registered with the DataProgressObserver. 00090 static void DataProgressCallbackFunction(vtkObject*, unsigned long, void*, 00091 void*); 00092 // Progress callback from XMLParser. 00093 virtual void DataProgressCallback(); 00094 00095 // The number of Pieces of data found in the file. 00096 int NumberOfPieces; 00097 00098 // The PointData and CellData element representations for each piece. 00099 vtkXMLDataElement** PointDataElements; 00100 vtkXMLDataElement** CellDataElements; 00101 00102 // The piece currently being read. 00103 int Piece; 00104 00105 // The number of point/cell data arrays in the output. Valid after 00106 // SetupOutputData has been called. 00107 int NumberOfPointArrays; 00108 int NumberOfCellArrays; 00109 00110 // Flag for whether DataProgressCallback should actually update 00111 // progress. 00112 int InReadData; 00113 00114 // The observer to report progress from reading data from XMLParser. 00115 vtkCallbackCommand* DataProgressObserver; 00116 00117 // Specify the last time step read, useful to know if we need to rearead data 00118 // //PointData 00119 int *PointDataTimeStep; 00120 vtkTypeInt64 *PointDataOffset; 00121 int PointDataNeedToReadTimeStep(vtkXMLDataElement *eNested); 00122 00123 //CellData 00124 int *CellDataTimeStep; 00125 vtkTypeInt64 *CellDataOffset; 00126 int CellDataNeedToReadTimeStep(vtkXMLDataElement *eNested); 00127 00128 private: 00129 vtkXMLDataReader(const vtkXMLDataReader&); // Not implemented. 00130 void operator=(const vtkXMLDataReader&); // Not implemented. 00131 }; 00132 00133 #endif