VTK
vtkXMLDataReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkXMLDataReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
27 #ifndef vtkXMLDataReader_h
28 #define vtkXMLDataReader_h
29 
30 #include "vtkIOXMLModule.h" // For export macro
31 #include "vtkXMLReader.h"
32 
33 #include <memory> // for std::unique_ptr
34 
35 class VTKIOXML_EXPORT vtkXMLDataReader : public vtkXMLReader
36 {
37 public:
38 
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
45  virtual vtkIdType GetNumberOfPoints()=0;
46 
50  virtual vtkIdType GetNumberOfCells()=0;
51 
52  // For the specified port, copy the information this reader sets up in
53  // SetupOutputInformation to outInfo
54  void CopyOutputInformation(vtkInformation *outInfo, int port) override;
55 
56 protected:
58  ~vtkXMLDataReader() override;
59 
60  // Add functionality to methods from superclass.
61  void CreateXMLParser() override;
62  void DestroyXMLParser() override;
63  void SetupOutputInformation(vtkInformation *outInfo) override;
64 
65  int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
66  void SetupOutputData() override;
67 
68  // Setup the reader for a given number of pieces.
69  virtual void SetupPieces(int numPieces);
70  virtual void DestroyPieces();
71 
72  // Read information from the file for the given piece.
73  int ReadPiece(vtkXMLDataElement* ePiece, int piece);
74  virtual int ReadPiece(vtkXMLDataElement* ePiece);
75 
76  // Read data from the file for the given piece.
77  int ReadPieceData(int piece);
78  virtual int ReadPieceData();
79 
80  void ReadXMLData() override;
81 
82  // Read a data array whose tuples coorrespond to points or cells.
83  virtual int ReadArrayForPoints(vtkXMLDataElement* da,
84  vtkAbstractArray* outArray);
85  virtual int ReadArrayForCells(vtkXMLDataElement* da,
86  vtkAbstractArray* outArray);
87 
88 
89  // Callback registered with the DataProgressObserver.
90  static void DataProgressCallbackFunction(vtkObject*, unsigned long, void*,
91  void*);
92  // Progress callback from XMLParser.
93  virtual void DataProgressCallback();
94 
95  // The number of Pieces of data found in the file.
97 
98  // The PointData and CellData element representations for each piece.
101 
102  // The piece currently being read.
103  int Piece;
104 
105  // The number of point/cell data arrays in the output. Valid after
106  // SetupOutputData has been called.
109 
110  // The observer to report progress from reading data from XMLParser.
112 
113 private:
114  class MapStringToInt;
115  class MapStringToInt64;
116 
117  // Specify the last time step read, useful to know if we need to rearead data
118  // //PointData
119  std::unique_ptr<MapStringToInt> PointDataTimeStep;
120  std::unique_ptr<MapStringToInt64> PointDataOffset;
121  int PointDataNeedToReadTimeStep(vtkXMLDataElement *eNested);
122 
123  //CellData
124  std::unique_ptr<MapStringToInt> CellDataTimeStep;
125  std::unique_ptr<MapStringToInt64> CellDataOffset;
126  int CellDataNeedToReadTimeStep(vtkXMLDataElement *eNested);
127 
128  vtkXMLDataReader(const vtkXMLDataReader&) = delete;
129  void operator=(const vtkXMLDataReader&) = delete;
130 
133  vtkIdType numValues) override;
134 };
135 
136 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:59
Represents an XML element and those nested inside.
Store vtkAlgorithm input/output information.
Abstract superclass for all arrays.
vtkXMLDataElement ** CellDataElements
virtual void ReadXMLData()
int vtkIdType
Definition: vtkType.h:347
virtual void DestroyXMLParser()
supports function callbacks
vtkXMLDataElement ** PointDataElements
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void SetupOutputInformation(vtkInformation *vtkNotUsed(outInfo))
Definition: vtkXMLReader.h:207
vtkCallbackCommand * DataProgressObserver
virtual void ConvertGhostLevelsToGhostType(FieldType, vtkAbstractArray *, vtkIdType, vtkIdType)
Definition: vtkXMLReader.h:386
virtual int ReadPrimaryElement(vtkXMLDataElement *ePrimary)
Superclass for VTK XML file readers.
virtual void CopyOutputInformation(vtkInformation *vtkNotUsed(outInfo), int vtkNotUsed(port))
Definition: vtkXMLReader.h:136
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void CreateXMLParser()
Superclass for VTK&#39;s XML format readers.
Definition: vtkXMLReader.h:43
virtual void SetupOutputData()