VTK
dox/IO/vtkXMLUnstructuredDataReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkXMLUnstructuredDataReader.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 =========================================================================*/
00025 #ifndef __vtkXMLUnstructuredDataReader_h
00026 #define __vtkXMLUnstructuredDataReader_h
00027 
00028 #include "vtkXMLDataReader.h"
00029 
00030 class vtkCellArray;
00031 class vtkIdTypeArray;
00032 class vtkPointSet;
00033 class vtkUnsignedCharArray;
00034 
00035 class VTK_IO_EXPORT vtkXMLUnstructuredDataReader : public vtkXMLDataReader
00036 {
00037 public:
00038   vtkTypeMacro(vtkXMLUnstructuredDataReader,vtkXMLDataReader);
00039   void PrintSelf(ostream& os, vtkIndent indent);  
00040   
00042   virtual vtkIdType GetNumberOfPoints();
00043   
00045   virtual vtkIdType GetNumberOfCells();
00046   
00051   void SetupUpdateExtent(int piece, int numberOfPieces, int ghostLevel);
00052   
00053   // For the specified port, copy the information this reader sets up in
00054   // SetupOutputInformation to outInfo
00055   virtual void CopyOutputInformation(vtkInformation *outInfo, int port);
00056 
00057 
00058 protected:
00059   vtkXMLUnstructuredDataReader();
00060   ~vtkXMLUnstructuredDataReader();
00061   
00062   vtkPointSet* GetOutputAsPointSet();
00063   vtkXMLDataElement* FindDataArrayWithName(vtkXMLDataElement* eParent,
00064                                            const char* name);
00065   vtkIdTypeArray* ConvertToIdTypeArray(vtkDataArray* a);
00066   vtkUnsignedCharArray* ConvertToUnsignedCharArray(vtkDataArray* a);
00067   
00068   // Pipeline execute data driver.  Called by vtkXMLReader.
00069   void ReadXMLData();
00070   
00071   virtual void SetupEmptyOutput();
00072   virtual void GetOutputUpdateExtent(int& piece, int& numberOfPieces,
00073                                      int& ghostLevel)=0;
00074   virtual void SetupOutputTotals();
00075   virtual void SetupNextPiece();
00076   void SetupPieces(int numPieces);
00077   void DestroyPieces();
00078   
00079   // Setup the output's information.
00080   void SetupOutputInformation(vtkInformation *outInfo);
00081 
00082   void SetupOutputData();
00083   int ReadPiece(vtkXMLDataElement* ePiece);
00084   int ReadPieceData();
00085   int ReadCellArray(vtkIdType numberOfCells, vtkIdType totalNumberOfCells,
00086                     vtkXMLDataElement* eCells, vtkCellArray* outCells);
00087 
00088   // Read faces and faceoffsets arrays for unstructured grid with polyhedon cells
00089   int ReadFaceArray(vtkIdType numberOfCells, vtkXMLDataElement* eCells,
00090                     vtkIdTypeArray* outFaces, vtkIdTypeArray* outFaceOffsets);
00091 
00092   // Read a data array whose tuples coorrespond to points.
00093   virtual int ReadArrayForPoints(vtkXMLDataElement* da, vtkAbstractArray* outArray);
00094   
00095   // Get the number of points/cells in the given piece.  Valid after
00096   // UpdateInformation.
00097   virtual vtkIdType GetNumberOfPointsInPiece(int piece);
00098   virtual vtkIdType GetNumberOfCellsInPiece(int piece)=0;
00099   
00100   // The update request.
00101   int UpdatePiece;
00102   int UpdateNumberOfPieces;
00103   int UpdateGhostLevel;
00104   
00105   // The range of pieces from the file that will form the UpdatePiece.
00106   int StartPiece;
00107   int EndPiece;
00108   vtkIdType TotalNumberOfPoints;
00109   vtkIdType TotalNumberOfCells;
00110   vtkIdType StartPoint;
00111   
00112   // The Points element for each piece.
00113   vtkXMLDataElement** PointElements;
00114   vtkIdType* NumberOfPoints;
00115   
00116   int PointsTimeStep;
00117   unsigned long PointsOffset;
00118   int PointsNeedToReadTimeStep(vtkXMLDataElement *eNested);
00119   int CellsNeedToReadTimeStep(vtkXMLDataElement *eNested, int &cellstimestep, 
00120     unsigned long &cellsoffset);
00121 
00122 
00123 private:
00124   vtkXMLUnstructuredDataReader(const vtkXMLUnstructuredDataReader&);  // Not implemented.
00125   void operator=(const vtkXMLUnstructuredDataReader&);  // Not implemented.
00126 };
00127 
00128 #endif