vtkXMLDataReader.h 4.58 KB
Newer Older
1 2 3 4 5
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkXMLDataReader.h

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8 9
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 13 14 15 16 17 18 19 20 21 22 23
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkXMLDataReader - Superclass for VTK XML file readers.
// .SECTION Description
// vtkXMLDataReader provides functionality common to all VTK XML file
// readers.  Concrete subclasses call upon this functionality when
// needed.

// .SECTION See Also
// vtkXMLPDataReader

24 25
#ifndef vtkXMLDataReader_h
#define vtkXMLDataReader_h
26

27
#include "vtkIOXMLModule.h" // For export macro
28 29
#include "vtkXMLReader.h"

30
class VTKIOXML_EXPORT vtkXMLDataReader : public vtkXMLReader
31 32
{
public:
33 34 35 36 37 38 39 40
  enum FieldType
  {
    POINT_DATA,
    CELL_DATA,
    OTHER
  };


41
  vtkTypeMacro(vtkXMLDataReader,vtkXMLReader);
42
  void PrintSelf(ostream& os, vtkIndent indent);
43

44 45 46
  // Description:
  // Get the number of points in the output.
  virtual vtkIdType GetNumberOfPoints()=0;
47

48 49 50
  // Description:
  // Get the number of cells in the output.
  virtual vtkIdType GetNumberOfCells()=0;
51

52 53 54 55
  // For the specified port, copy the information this reader sets up in
  // SetupOutputInformation to outInfo
  virtual void CopyOutputInformation(vtkInformation *outInfo, int port);

56 57
protected:
  vtkXMLDataReader();
58 59
  ~vtkXMLDataReader();

60
  // Add functionality to methods from superclass.
61 62
  virtual void CreateXMLParser();
  virtual void DestroyXMLParser();
63
  virtual void SetupOutputInformation(vtkInformation *outInfo);
64

65 66
  int ReadPrimaryElement(vtkXMLDataElement* ePrimary);
  void SetupOutputData();
67

68 69 70
  // Setup the reader for a given number of pieces.
  virtual void SetupPieces(int numPieces);
  virtual void DestroyPieces();
71

72 73 74
  // Read information from the file for the given piece.
  int ReadPiece(vtkXMLDataElement* ePiece, int piece);
  virtual int ReadPiece(vtkXMLDataElement* ePiece);
75

76 77 78
  // Read data from the file for the given piece.
  int ReadPieceData(int piece);
  virtual int ReadPieceData();
79

80 81
  virtual void ReadXMLData();

82 83
  // Read a data array whose tuples coorrespond to points or cells.
  virtual int ReadArrayForPoints(vtkXMLDataElement* da,
Utkarsh Ayachit's avatar
ENH:  
Utkarsh Ayachit committed
84
                                 vtkAbstractArray* outArray);
85
  virtual int ReadArrayForCells(vtkXMLDataElement* da,
Utkarsh Ayachit's avatar
ENH:  
Utkarsh Ayachit committed
86 87 88
                                vtkAbstractArray* outArray);

  // Read an Array values starting at the given index and up to numValues.
89
  // This method assumes that the array is of correct size to
Kyle Lutz's avatar
Kyle Lutz committed
90
  // accommodate all numValues values. arrayIndex is the value index at which the read
Utkarsh Ayachit's avatar
ENH:  
Utkarsh Ayachit committed
91
  // values will be put in the array.
92 93 94
  int ReadArrayValues(
    vtkXMLDataElement* da, vtkIdType arrayIndex, vtkAbstractArray* array,
    vtkIdType startIndex, vtkIdType numValues, FieldType type = OTHER);
Utkarsh Ayachit's avatar
ENH:  
Utkarsh Ayachit committed
95

96 97


98 99 100
  // Callback registered with the DataProgressObserver.
  static void DataProgressCallbackFunction(vtkObject*, unsigned long, void*,
                                           void*);
101 102
  // Progress callback from XMLParser.
  virtual void DataProgressCallback();
103

104 105
  // The number of Pieces of data found in the file.
  int NumberOfPieces;
106

107 108
  // The PointData and CellData element representations for each piece.
  vtkXMLDataElement** PointDataElements;
109
  vtkXMLDataElement** CellDataElements;
110

111 112
  // The piece currently being read.
  int Piece;
113

114
  // The number of point/cell data arrays in the output.  Valid after
115
  // SetupOutputData has been called.
116
  int NumberOfPointArrays;
117 118
  int NumberOfCellArrays;

119 120 121
  // Flag for whether DataProgressCallback should actually update
  // progress.
  int InReadData;
122

123
  // The observer to report progress from reading data from XMLParser.
124
  vtkCallbackCommand* DataProgressObserver;
125

126
  // Specify the last time step read, useful to know if we need to rearead data
127 128
  // //PointData
  int *PointDataTimeStep;
129
  vtkTypeInt64 *PointDataOffset;
130 131 132 133
  int PointDataNeedToReadTimeStep(vtkXMLDataElement *eNested);

  //CellData
  int *CellDataTimeStep;
134
  vtkTypeInt64 *CellDataOffset;
135
  int CellDataNeedToReadTimeStep(vtkXMLDataElement *eNested);
136

137 138 139
private:
  vtkXMLDataReader(const vtkXMLDataReader&);  // Not implemented.
  void operator=(const vtkXMLDataReader&);  // Not implemented.
140 141 142 143 144

  void ConvertGhostLevelsToGhostType(
    FieldType type, vtkAbstractArray* data, vtkIdType startIndex,
    vtkIdType numValues);

145 146 147
};

#endif