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 "vtkXMLReader.h" 00030 00031 class VTK_IO_EXPORT vtkXMLDataReader : public vtkXMLReader 00032 { 00033 public: 00034 vtkTypeMacro(vtkXMLDataReader,vtkXMLReader); 00035 void PrintSelf(ostream& os, vtkIndent indent); 00036 00038 virtual vtkIdType GetNumberOfPoints()=0; 00039 00041 virtual vtkIdType GetNumberOfCells()=0; 00042 00043 // For the specified port, copy the information this reader sets up in 00044 // SetupOutputInformation to outInfo 00045 virtual void CopyOutputInformation(vtkInformation *outInfo, int port); 00046 00047 protected: 00048 vtkXMLDataReader(); 00049 ~vtkXMLDataReader(); 00050 00051 int SetUpdateExtentInfo(vtkXMLDataElement *eDSA, 00052 vtkInformationVector *infoVector, 00053 int piece, int numPieces); 00054 00055 // Add functionality to methods from superclass. 00056 virtual void CreateXMLParser(); 00057 virtual void DestroyXMLParser(); 00058 virtual void SetupOutputInformation(vtkInformation *outInfo); 00059 virtual void SetupUpdateExtentInformation(vtkInformation *outInfo); 00060 00061 int ReadPrimaryElement(vtkXMLDataElement* ePrimary); 00062 void SetupOutputData(); 00063 00064 // Setup the reader for a given number of pieces. 00065 virtual void SetupPieces(int numPieces); 00066 virtual void DestroyPieces(); 00067 00068 // Read information from the file for the given piece. 00069 int ReadPiece(vtkXMLDataElement* ePiece, int piece); 00070 virtual int ReadPiece(vtkXMLDataElement* ePiece); 00071 00072 // Read data from the file for the given piece. 00073 int ReadPieceData(int piece); 00074 virtual int ReadPieceData(); 00075 00076 virtual void ReadXMLData(); 00077 00078 // Read a data array whose tuples coorrespond to points or cells. 00079 virtual int ReadArrayForPoints(vtkXMLDataElement* da, 00080 vtkAbstractArray* outArray); 00081 virtual int ReadArrayForCells(vtkXMLDataElement* da, 00082 vtkAbstractArray* outArray); 00083 00084 // Read an Array values starting at the given index and up to numValues. 00085 // This method assumes that the array is of correct size to 00086 // accomodate all numValues values. arrayIndex is the value index at which the read 00087 // values will be put in the array. 00088 int ReadArrayValues(vtkXMLDataElement* da, vtkIdType arrayIndex, vtkAbstractArray* array, 00089 vtkIdType startIndex, vtkIdType numValues); 00090 00091 00092 00093 // Callback registered with the DataProgressObserver. 00094 static void DataProgressCallbackFunction(vtkObject*, unsigned long, void*, 00095 void*); 00096 // Progress callback from XMLParser. 00097 virtual void DataProgressCallback(); 00098 00099 // The number of Pieces of data found in the file. 00100 int NumberOfPieces; 00101 00102 // The PointData and CellData element representations for each piece. 00103 vtkXMLDataElement** PointDataElements; 00104 vtkXMLDataElement** CellDataElements; 00105 00106 // The piece currently being read. 00107 int Piece; 00108 00109 // The number of point/cell data arrays in the output. Valid after 00110 // SetupOutputData has been called. 00111 int NumberOfPointArrays; 00112 int NumberOfCellArrays; 00113 00114 // Flag for whether DataProgressCallback should actually update 00115 // progress. 00116 int InReadData; 00117 00118 // The observer to report progress from reading data from XMLParser. 00119 vtkCallbackCommand* DataProgressObserver; 00120 00121 // Specify the last time step read, useful to know if we need to rearead data 00122 // //PointData 00123 int *PointDataTimeStep; 00124 unsigned long *PointDataOffset; 00125 int PointDataNeedToReadTimeStep(vtkXMLDataElement *eNested); 00126 00127 //CellData 00128 int *CellDataTimeStep; 00129 unsigned long *CellDataOffset; 00130 int CellDataNeedToReadTimeStep(vtkXMLDataElement *eNested); 00131 00132 private: 00133 vtkXMLDataReader(const vtkXMLDataReader&); // Not implemented. 00134 void operator=(const vtkXMLDataReader&); // Not implemented. 00135 }; 00136 00137 #endif