VTK  9.3.1
vtkXMLDataReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
15 #ifndef vtkXMLDataReader_h
16 #define vtkXMLDataReader_h
17 
18 #include "vtkIOXMLModule.h" // For export macro
19 #include "vtkXMLReader.h"
20 
21 #include <memory> // for std::unique_ptr
22 
23 VTK_ABI_NAMESPACE_BEGIN
24 class VTKIOXML_EXPORT vtkXMLDataReader : public vtkXMLReader
25 {
26 public:
28  void PrintSelf(ostream& os, vtkIndent indent) override;
29 
33  virtual vtkIdType GetNumberOfPoints() = 0;
34 
38  virtual vtkIdType GetNumberOfCells() = 0;
39 
40  // For the specified port, copy the information this reader sets up in
41  // SetupOutputInformation to outInfo
42  void CopyOutputInformation(vtkInformation* outInfo, int port) override;
43 
44 protected:
46  ~vtkXMLDataReader() override;
47 
48  // Add functionality to methods from superclass.
49  void CreateXMLParser() override;
50  void DestroyXMLParser() override;
51  void SetupOutputInformation(vtkInformation* outInfo) override;
52 
53  int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
54  void SetupOutputData() override;
55 
56  // Setup the reader for a given number of pieces.
57  virtual void SetupPieces(int numPieces);
58  virtual void DestroyPieces();
59 
60  // Read information from the file for the given piece.
61  int ReadPiece(vtkXMLDataElement* ePiece, int piece);
62  virtual int ReadPiece(vtkXMLDataElement* ePiece);
63 
64  // Read data from the file for the given piece.
65  int ReadPieceData(int piece);
66  virtual int ReadPieceData();
67 
68  void ReadXMLData() override;
69 
70  // Read a data array whose tuples coorrespond to points or cells.
71  virtual int ReadArrayForPoints(vtkXMLDataElement* da, vtkAbstractArray* outArray);
72  virtual int ReadArrayForCells(vtkXMLDataElement* da, vtkAbstractArray* outArray);
73 
74  // Callback registered with the DataProgressObserver.
75  static void DataProgressCallbackFunction(vtkObject*, unsigned long, void*, void*);
76  // Progress callback from XMLParser.
77  virtual void DataProgressCallback();
78 
79  // The number of Pieces of data found in the file.
81 
82  // The PointData and CellData element representations for each piece.
86 
87  // The piece currently being read.
88  int Piece;
89 
90  // The number of point/cell data arrays in the output. Valid after
91  // SetupOutputData has been called.
94 
95  // The observer to report progress from reading data from XMLParser.
97 
98 private:
99  class MapStringToInt;
100  class MapStringToInt64;
101 
102  // Specify the last time step read, useful to know if we need to rearead data
103  // //PointData
104  std::unique_ptr<MapStringToInt> PointDataTimeStep;
105  std::unique_ptr<MapStringToInt64> PointDataOffset;
106  int PointDataNeedToReadTimeStep(vtkXMLDataElement* eNested);
107 
108  // CellData
109  std::unique_ptr<MapStringToInt> CellDataTimeStep;
110  std::unique_ptr<MapStringToInt64> CellDataOffset;
111  int CellDataNeedToReadTimeStep(vtkXMLDataElement* eNested);
112 
113  vtkXMLDataReader(const vtkXMLDataReader&) = delete;
114  void operator=(const vtkXMLDataReader&) = delete;
115 
117  FieldType type, vtkAbstractArray* data, vtkIdType startIndex, vtkIdType numValues) override;
118 };
119 
120 VTK_ABI_NAMESPACE_END
121 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:51
Represents an XML element and those nested inside.
Store vtkAlgorithm input/output information.
Abstract superclass for all arrays.
vtkXMLDataElement ** CellDataElements
virtual void ReadXMLData()
Pipeline execution methods to be defined by subclass.
int vtkIdType
Definition: vtkType.h:315
virtual void DestroyXMLParser()
Internal utility methods.
supports function callbacks
vtkXMLDataElement ** PointDataElements
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void SetupOutputInformation(vtkInformation *vtkNotUsed(outInfo))
Setup the output's information.
Definition: vtkXMLReader.h:228
vtkCallbackCommand * DataProgressObserver
vtkXMLDataElement ** TimeDataElements
virtual void ConvertGhostLevelsToGhostType(FieldType, vtkAbstractArray *, vtkIdType, vtkIdType)
Definition: vtkXMLReader.h:481
virtual int ReadPrimaryElement(vtkXMLDataElement *ePrimary)
Read the primary element from the file.
Superclass for VTK XML file readers.
virtual void CopyOutputInformation(vtkInformation *vtkNotUsed(outInfo), int vtkNotUsed(port))
Definition: vtkXMLReader.h:150
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void CreateXMLParser()
Internal utility methods.
Superclass for VTK's XML format readers.
Definition: vtkXMLReader.h:38
virtual void SetupOutputData()
Setup the output's data with allocation.