VTK  9.7.20261008
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
39
40#ifndef vtkXMLCompositeDataReader_h
41#define vtkXMLCompositeDataReader_h
42
43#include "vtkIOXMLModule.h" // For export macro
44#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
45#include "vtkXMLReader.h"
46
47VTK_ABI_NAMESPACE_BEGIN
51struct vtkXMLCompositeDataReaderInternals;
52
53VTK_ABI_NAMESPACE_END
54#include <set> // for std::set
55#include <string> // for std::string
56
57VTK_ABI_NAMESPACE_BEGIN
59{
60public:
62 void PrintSelf(ostream& os, vtkIndent indent) override;
63
64 enum
65 {
68 };
69
82 vtkSetClampMacro(PieceDistribution, int, Block, Interleave);
83 vtkGetMacro(PieceDistribution, int);
85
87
93
94 void SetFileName(VTK_FILEPATH const char*) override;
95
96protected:
99
100 // Get the name of the data set being read.
101 const char* GetDataSetName() override;
102
103 // Returns the primary element pass to ReadPrimaryElement().
105
106 void ReadXMLData() override;
107 int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
108
109 // Setup the output with no data available. Used in error cases.
110 void SetupEmptyOutput() override;
111
113
114 // Create a default executive.
116
117 // Find the path to this file in case the internal files are
118 // specified as relative paths.
119 std::string GetFilePath();
120
121 std::string GetFileNameFromXML(vtkXMLDataElement* xmlElem, const std::string& filePath);
122
123 vtkXMLReader* GetReaderOfType(const char* type);
124 vtkXMLReader* GetReaderForFile(const std::string& filename);
125
127
129 vtkXMLReader* accum, vtkXMLDataElement* xmlElem, const std::string& filePath);
130
131 // Read the XML element for the subtree of a composite dataset.
132 // dataSetIndex is used to rank the leaf nodes in an inorder traversal.
133 virtual void ReadComposite(vtkXMLDataElement* element, vtkCompositeDataSet* composite,
134 const char* filePath, unsigned int& dataSetIndex) = 0;
135
136 // Read the vtkDataSet (a leaf) in the composite dataset.
137 virtual vtkDataSet* ReadDataset(vtkXMLDataElement* xmlElem, const char* filePath);
138
139 // Read the vtkDataObject (a leaf) in the composite dataset.
140 virtual vtkDataObject* ReadDataObject(vtkXMLDataElement* xmlElem, const char* filePath);
141 // Sets the file name or the input data for the reader
142 // The default function simply calls SetFileName on the reader. In this case
143 // the reader opens the file and reads the data from it.
144 // An override, could specify that data is read from an input string using
145 // ReadFromInputStringOn and SetInputString. In this case the data is read
146 // by the function and then set to the reader.
147 virtual bool ReaderSetFileNameOrData(vtkXMLReader* reader, const char* fileName);
148
159 unsigned int datasetIndex, unsigned int pieceIndex = 0, unsigned int numPieces = 0);
160
161#ifndef __VTK_WRAP__
166 static unsigned int CountNestedElements(vtkXMLDataElement* element, const std::string& tagName,
167 const std::set<std::string>& exclusions = std::set<std::string>());
168
169#endif
170
175 virtual void PrepareToCreateMetaData(vtkXMLDataElement* vtkNotUsed(ePrimary)) {}
176
180 virtual void CreateMetaData(vtkXMLDataElement* ePrimary) = 0;
181
187 vtkCompositeDataSet* composite, vtkXMLDataElement* element, const std::string& filePath) = 0;
188
190
191private:
193 void operator=(const vtkXMLCompositeDataReader&) = delete;
194
196
201 static int GetPieceAssignmentForBlockStrategy(
202 unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
203 static int GetPieceAssignmentForInterleaveStrategy(
204 unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
206
207 int PieceDistribution;
208
209 vtkXMLCompositeDataReaderInternals* Internal;
210};
211
212VTK_ABI_NAMESPACE_END
213#endif
abstract superclass for composite (multi-block or AMR) datasets
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
Superclass for all pipeline executives in VTK.
a simple class to control print indentation
Definition vtkIndent.h:108
Key for integer values in vtkInformation.
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Hold a reference to a vtkObjectBase instance.
virtual void SyncCompositeDataArraySelections(vtkCompositeDataSet *composite, vtkXMLDataElement *element, const std::string &filePath)=0
Recursively synchronize the data array selection of the reader for the file specified in the XML elem...
vtkXMLDataElement * GetPrimaryElement()
vtkCompositeDataSet * GetOutput(int)
Get the output data object for a port on this algorithm.
int FillOutputPortInformation(int, vtkInformation *info) override
Fill the output port information objects for this algorithm.
vtkCompositeDataSet * GetOutput()
Get the output data object for a port on this algorithm.
virtual void PrepareToCreateMetaData(vtkXMLDataElement *ePrimary)
Prepare to create the meta-data from the composite dataset from the file.
void SetupEmptyOutput() override
Setup the output with no data available.
virtual void ReadComposite(vtkXMLDataElement *element, vtkCompositeDataSet *composite, const char *filePath, unsigned int &dataSetIndex)=0
virtual vtkDataObject * ReadDataObject(vtkXMLDataElement *xmlElem, const char *filePath)
int ShouldReadDataSet(unsigned int datasetIndex, unsigned int pieceIndex=0, unsigned int numPieces=0)
Given the inorder index for a leaf node, this method tells if the current process should read the dat...
vtkSmartPointer< vtkCompositeDataSet > Metadata
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool ReaderSetFileNameOrData(vtkXMLReader *reader, const char *fileName)
static unsigned int CountNestedElements(vtkXMLDataElement *element, const std::string &tagName, const std::set< std::string > &exclusions=std::set< std::string >())
Convenience method to count all nested elements with the given tag name.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
virtual void CreateMetaData(vtkXMLDataElement *ePrimary)=0
Create the meta-data from the composite dataset from the file.
virtual vtkDataSet * ReadDataset(vtkXMLDataElement *xmlElem, const char *filePath)
const char * GetDataSetName() override
Get the name of the data set being read.
void ReadXMLData() override
Pipeline execution methods to be defined by subclass.
void SyncDataArraySelections(vtkXMLReader *accum, vtkXMLDataElement *xmlElem, const std::string &filePath)
void SetFileName(const char *) override
int ReadPrimaryElement(vtkXMLDataElement *ePrimary) override
Read the primary element from the file.
std::string GetFileNameFromXML(vtkXMLDataElement *xmlElem, const std::string &filePath)
vtkXMLReader * GetReaderOfType(const char *type)
vtkExecutive * CreateDefaultExecutive() override
Create a default executive.
vtkXMLReader * GetReaderForFile(const std::string &filename)
~vtkXMLCompositeDataReader() override
Represents an XML element and those nested inside.
#define VTK_FILEPATH
#define VTK_MARSHALAUTO