VTK  9.3.20240419
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
40 #ifndef vtkXMLCompositeDataReader_h
41 #define vtkXMLCompositeDataReader_h
42 
43 #include "vtkIOXMLModule.h" // For export macro
44 #include "vtkXMLReader.h"
45 
46 VTK_ABI_NAMESPACE_BEGIN
50 struct vtkXMLCompositeDataReaderInternals;
51 
52 VTK_ABI_NAMESPACE_END
53 #include <set> // for std::set
54 #include <string> // for std::string
55 
56 VTK_ABI_NAMESPACE_BEGIN
57 class VTKIOXML_EXPORT vtkXMLCompositeDataReader : public vtkXMLReader
58 {
59 public:
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
63  enum
64  {
66  Interleave
67  };
68 
81  vtkSetClampMacro(PieceDistribution, int, Block, Interleave);
82  vtkGetMacro(PieceDistribution, int);
86 
92 
93  void SetFileName(VTK_FILEPATH const char*) override;
94 
95 protected:
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.
119 
121 
124 
126 
128  vtkXMLReader* accum, vtkXMLDataElement* xmlElem, const std::string& filePath);
129 
130  // Adds a child data object to the composite parent. childXML is the XML for
131  // the child data object need to obtain certain meta-data about the child.
133 
134  // Read the XML element for the subtree of a the composite dataset.
135  // dataSetIndex is used to rank the leaf nodes in an inorder traversal.
136  virtual void ReadComposite(vtkXMLDataElement* element, vtkCompositeDataSet* composite,
137  const char* filePath, unsigned int& dataSetIndex) = 0;
138 
139  // Read the vtkDataSet (a leaf) in the composite dataset.
140  virtual vtkDataSet* ReadDataset(vtkXMLDataElement* xmlElem, const char* filePath);
141 
142  // Read the vtkDataObject (a leaf) in the composite dataset.
143  virtual vtkDataObject* ReadDataObject(vtkXMLDataElement* xmlElem, const char* filePath);
144 
157  unsigned int datasetIndex, unsigned int pieceIndex = 0, unsigned int numPieces = 0);
158 
159 #ifndef __VTK_WRAP__
164  static unsigned int CountNestedElements(vtkXMLDataElement* element, const std::string& tagName,
165  const std::set<std::string>& exclusions = std::set<std::string>());
166 #endif
167 private:
169  void operator=(const vtkXMLCompositeDataReader&) = delete;
170 
172 
177  static int GetPieceAssignmentForBlockStrategy(
178  unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
179  static int GetPieceAssignmentForInterleaveStrategy(
180  unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
182 
183  int PieceDistribution;
184 
185  vtkXMLCompositeDataReaderInternals* Internal;
186 };
187 
188 VTK_ABI_NAMESPACE_END
189 #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.
Definition: vtkExecutive.h:69
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.
Reader for multi-group datasets.
void AddChild(vtkCompositeDataSet *parent, vtkDataObject *child, vtkXMLDataElement *childXML)
int FillOutputPortInformation(int, vtkInformation *info) override
Fill the output port information objects for this algorithm.
vtkCompositeDataSet * GetOutput(int)
Get the output data object for a port on this algorithm.
void SetupEmptyOutput() override
Setup the output with no data available.
virtual void ReadComposite(vtkXMLDataElement *element, vtkCompositeDataSet *composite, const char *filePath, unsigned int &dataSetIndex)=0
vtkXMLReader * GetReaderForFile(const std::string &filename)
vtkXMLReader * GetReaderOfType(const char *type)
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...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
const char * GetDataSetName() override
Get the name of the data set being read.
vtkXMLDataElement * GetPrimaryElement()
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.
vtkExecutive * CreateDefaultExecutive() override
Create a default executive.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
virtual vtkDataSet * ReadDataset(vtkXMLDataElement *xmlElem, const char *filePath)
void ReadXMLData() override
Pipeline execution methods to be defined by subclass.
void SyncDataArraySelections(vtkXMLReader *accum, vtkXMLDataElement *xmlElem, const std::string &filePath)
int ReadPrimaryElement(vtkXMLDataElement *ePrimary) override
Read the primary element from the file.
std::string GetFileNameFromXML(vtkXMLDataElement *xmlElem, const std::string &filePath)
virtual vtkDataObject * ReadDataObject(vtkXMLDataElement *xmlElem, const char *filePath)
vtkCompositeDataSet * GetOutput()
Get the output data object for a port on this algorithm.
~vtkXMLCompositeDataReader() override
void SetFileName(VTK_FILEPATH const char *) override
Represents an XML element and those nested inside.
Superclass for VTK's XML format readers.
Definition: vtkXMLReader.h:59
@ info
Definition: vtkX3D.h:376
@ type
Definition: vtkX3D.h:516
@ string
Definition: vtkX3D.h:490
#define VTK_FILEPATH