VTK  9.7.1
vtkXMLCompositeDataReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
3 // SPDX-License-Identifier: BSD-3-Clause
21 #ifndef vtkXMLCompositeDataReader_h
22 #define vtkXMLCompositeDataReader_h
23 
24 #include "vtkIOXMLModule.h" // For export macro
25 #include "vtkXMLReader.h"
26 
27 VTK_ABI_NAMESPACE_BEGIN
31 struct vtkXMLCompositeDataReaderInternals;
32 
33 VTK_ABI_NAMESPACE_END
34 #include <set> // for std::set
35 #include <string> // for std::string
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class VTKIOXML_EXPORT vtkXMLCompositeDataReader : public vtkXMLReader
39 {
40 public:
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
44  enum
45  {
47  Interleave
48  };
49 
62  vtkSetClampMacro(PieceDistribution, int, Block, Interleave);
63  vtkGetMacro(PieceDistribution, int);
66 
70  vtkCompositeDataSet* GetOutput();
71  vtkCompositeDataSet* GetOutput(int);
73 
74  void SetFileName(VTK_FILEPATH const char*) override;
75 
76 protected:
78  ~vtkXMLCompositeDataReader() override;
79 
80  // Get the name of the data set being read.
81  const char* GetDataSetName() override;
82 
83  // Returns the primary element pass to ReadPrimaryElement().
84  vtkXMLDataElement* GetPrimaryElement();
85 
86  void ReadXMLData() override;
87  int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
88 
89  // Setup the output with no data available. Used in error cases.
90  void SetupEmptyOutput() override;
91 
92  int FillOutputPortInformation(int, vtkInformation* info) override;
93 
94  // Create a default executive.
96 
97  // Find the path to this file in case the internal files are
98  // specified as relative paths.
99  std::string GetFilePath();
100 
101  std::string GetFileNameFromXML(vtkXMLDataElement* xmlElem, const std::string& filePath);
102 
103  vtkXMLReader* GetReaderOfType(const char* type);
104  vtkXMLReader* GetReaderForFile(const std::string& filename);
105 
107 
108  void SyncDataArraySelections(
109  vtkXMLReader* accum, vtkXMLDataElement* xmlElem, const std::string& filePath);
110 
111  // Read the XML element for the subtree of a composite dataset.
112  // dataSetIndex is used to rank the leaf nodes in an inorder traversal.
113  virtual void ReadComposite(vtkXMLDataElement* element, vtkCompositeDataSet* composite,
114  const char* filePath, unsigned int& dataSetIndex) = 0;
115 
116  // Read the vtkDataSet (a leaf) in the composite dataset.
117  virtual vtkDataSet* ReadDataset(vtkXMLDataElement* xmlElem, const char* filePath);
118 
119  // Read the vtkDataObject (a leaf) in the composite dataset.
120  virtual vtkDataObject* ReadDataObject(vtkXMLDataElement* xmlElem, const char* filePath);
121  // Sets the file name or the input data for the reader
122  // The default function simply calls SetFileName on the reader. In this case
123  // the reader opens the file and reads the data from it.
124  // An override, could specify that data is read from an input string using
125  // ReadFromInputStringOn and SetInputString. In this case the data is read
126  // by the function and then set to the reader.
127  virtual bool ReaderSetFileNameOrData(vtkXMLReader* reader, const char* fileName);
128 
138  int ShouldReadDataSet(
139  unsigned int datasetIndex, unsigned int pieceIndex = 0, unsigned int numPieces = 0);
140 
141 #ifndef __VTK_WRAP__
142 
146  static unsigned int CountNestedElements(vtkXMLDataElement* element, const std::string& tagName,
147  const std::set<std::string>& exclusions = std::set<std::string>());
148 
149 #endif
150 
155  virtual void PrepareToCreateMetaData(vtkXMLDataElement* vtkNotUsed(ePrimary)) {}
156 
160  virtual void CreateMetaData(vtkXMLDataElement* ePrimary) = 0;
161 
166  virtual void SyncCompositeDataArraySelections(
167  vtkCompositeDataSet* composite, vtkXMLDataElement* element, const std::string& filePath) = 0;
168 
170 
171 private:
173  void operator=(const vtkXMLCompositeDataReader&) = delete;
174 
176 
181  static int GetPieceAssignmentForBlockStrategy(
182  unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
183  static int GetPieceAssignmentForInterleaveStrategy(
184  unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
186 
187  int PieceDistribution;
188 
189  vtkXMLCompositeDataReaderInternals* Internal;
190 };
191 
192 VTK_ABI_NAMESPACE_END
193 #endif
virtual const char * GetDataSetName()=0
Get the name of the data set being read.
virtual void SetupEmptyOutput()=0
Setup the output with no data available.
Represents an XML element and those nested inside.
virtual vtkExecutive * CreateDefaultExecutive()
Create a default executive.
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
Reader for multi-group datasets.
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
virtual void PrepareToCreateMetaData(vtkXMLDataElement *ePrimary)
Prepare to create the meta-data from the composite dataset from the file.
virtual void ReadXMLData()
Pipeline execution methods to be defined by subclass.
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:39
abstract superclass for composite (multi-block or AMR) datasets
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Fill the output port information objects for this algorithm.
a simple class to control print indentation
Definition: vtkIndent.h:28
Key for integer values in vtkInformation.
virtual int ReadPrimaryElement(vtkXMLDataElement *ePrimary)
Read the primary element from the file.
#define VTK_FILEPATH
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:55
Superclass for VTK's XML format readers.
Definition: vtkXMLReader.h:44
vtkSmartPointer< vtkCompositeDataSet > Metadata