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