VTK  9.6.20260416
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 "vtkXMLReader.h"
45
46VTK_ABI_NAMESPACE_BEGIN
50struct vtkXMLCompositeDataReaderInternals;
51
52VTK_ABI_NAMESPACE_END
53#include <set> // for std::set
54#include <string> // for std::string
55
56VTK_ABI_NAMESPACE_BEGIN
57class VTKIOXML_EXPORT vtkXMLCompositeDataReader : public vtkXMLReader
58{
59public:
61 void PrintSelf(ostream& os, vtkIndent indent) override;
62
63 enum
64 {
67 };
68
81 vtkSetClampMacro(PieceDistribution, int, Block, Interleave);
82 vtkGetMacro(PieceDistribution, int);
84
86
92
93 void SetFileName(VTK_FILEPATH const char*) override;
94
95protected:
98
99 // Get the name of the data set being read.
100 const char* GetDataSetName() override;
101
102 // Returns the primary element pass to ReadPrimaryElement().
104
105 void ReadXMLData() override;
106 int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
107
108 // Setup the output with no data available. Used in error cases.
109 void SetupEmptyOutput() override;
110
112
113 // Create a default executive.
115
116 // Find the path to this file in case the internal files are
117 // specified as relative paths.
118 std::string GetFilePath();
119
120 std::string GetFileNameFromXML(vtkXMLDataElement* xmlElem, const std::string& filePath);
121
122 vtkXMLReader* GetReaderOfType(const char* type);
123 vtkXMLReader* GetReaderForFile(const std::string& filename);
124
126
128 vtkXMLReader* accum, vtkXMLDataElement* xmlElem, const std::string& filePath);
129
130 // Read the XML element for the subtree of a composite dataset.
131 // dataSetIndex is used to rank the leaf nodes in an inorder traversal.
132 virtual void ReadComposite(vtkXMLDataElement* element, vtkCompositeDataSet* composite,
133 const char* filePath, unsigned int& dataSetIndex) = 0;
134
135 // Read the vtkDataSet (a leaf) in the composite dataset.
136 virtual vtkDataSet* ReadDataset(vtkXMLDataElement* xmlElem, const char* filePath);
137
138 // Read the vtkDataObject (a leaf) in the composite dataset.
139 virtual vtkDataObject* ReadDataObject(vtkXMLDataElement* xmlElem, const char* filePath);
140
151 unsigned int datasetIndex, unsigned int pieceIndex = 0, unsigned int numPieces = 0);
152
153#ifndef __VTK_WRAP__
158 static unsigned int CountNestedElements(vtkXMLDataElement* element, const std::string& tagName,
159 const std::set<std::string>& exclusions = std::set<std::string>());
160
161#endif
162
167 virtual void PrepareToCreateMetaData(vtkXMLDataElement* vtkNotUsed(ePrimary)) {}
168
172 virtual void CreateMetaData(vtkXMLDataElement* ePrimary) = 0;
173
179 vtkCompositeDataSet* composite, vtkXMLDataElement* element, const std::string& filePath) = 0;
180
182
183private:
185 void operator=(const vtkXMLCompositeDataReader&) = delete;
186
188
193 static int GetPieceAssignmentForBlockStrategy(
194 unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
195 static int GetPieceAssignmentForInterleaveStrategy(
196 unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
198
199 int PieceDistribution;
200
201 vtkXMLCompositeDataReaderInternals* Internal;
202};
203
204VTK_ABI_NAMESPACE_END
205#endif
abstract superclass for composite (multi-block or AMR) datasets
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
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.
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