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