forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkXMLCompositeDataReader.h
174 lines (139 loc) · 6.09 KB
/
vtkXMLCompositeDataReader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*=========================================================================
Program: ParaView
Module: vtkXMLCompositeDataReader.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkXMLCompositeDataReader
* @brief Reader for multi-group datasets
*
* vtkXMLCompositeDataReader reads the VTK XML multi-group data file
* format. XML multi-group data files are meta-files that point to a list
* of serial VTK XML files. When reading in parallel, it will distribute
* sub-blocks among processor. If the number of sub-blocks is less than
* the number of processors, some processors will not have any sub-blocks
* for that group. If the number of sub-blocks is larger than the
* number of processors, each processor will possibly have more than
* 1 sub-block.
*/
#ifndef vtkXMLCompositeDataReader_h
#define vtkXMLCompositeDataReader_h
#include "vtkIOXMLModule.h" // For export macro
#include "vtkXMLReader.h"
class vtkCompositeDataSet;
class vtkInformationIntegerKey;
class vtkInformationIntegerVectorKey;
struct vtkXMLCompositeDataReaderInternals;
#include <set> // for std::set
#include <string> // for std::string
class VTKIOXML_EXPORT vtkXMLCompositeDataReader : public vtkXMLReader
{
public:
vtkTypeMacro(vtkXMLCompositeDataReader, vtkXMLReader);
void PrintSelf(ostream& os, vtkIndent indent) override;
enum
{
Block,
Interleave
};
/**
* Set the strategy for assigning files to parallel readers. The default is
* @a Block.
*
* Let @a X be the rank of a specific reader, and @a N be the number of
* reader, then:
* @arg @c Block Each processor is assigned a contiguous block of files,
* [@a X * @a N, ( @a X + 1) * @a N ).
* @arg @c Interleave The files are interleaved across readers,
* @a i * @a N + @a X.
* @{
*/
vtkSetClampMacro(PieceDistribution, int, Block, Interleave);
vtkGetMacro(PieceDistribution, int);
/**@}*/
///@{
/**
* Get the output data object for a port on this algorithm.
*/
vtkCompositeDataSet* GetOutput();
vtkCompositeDataSet* GetOutput(int);
///@}
void SetFileName(VTK_FILEPATH const char*) override;
protected:
vtkXMLCompositeDataReader();
~vtkXMLCompositeDataReader() override;
// Get the name of the data set being read.
const char* GetDataSetName() override;
// Returns the primary element pass to ReadPrimaryElement().
vtkXMLDataElement* GetPrimaryElement();
void ReadXMLData() override;
int ReadPrimaryElement(vtkXMLDataElement* ePrimary) override;
// Setup the output with no data available. Used in error cases.
void SetupEmptyOutput() override;
int FillOutputPortInformation(int, vtkInformation* info) override;
// Create a default executive.
vtkExecutive* CreateDefaultExecutive() override;
// Find the path to this file in case the internal files are
// specified as relative paths.
std::string GetFilePath();
std::string GetFileNameFromXML(vtkXMLDataElement* xmlElem, const std::string& filePath);
vtkXMLReader* GetReaderOfType(const char* type);
vtkXMLReader* GetReaderForFile(const std::string& filename);
int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
void SyncDataArraySelections(
vtkXMLReader* accum, vtkXMLDataElement* xmlElem, const std::string& filePath);
// Adds a child data object to the composite parent. childXML is the XML for
// the child data object need to obtain certain meta-data about the child.
void AddChild(vtkCompositeDataSet* parent, vtkDataObject* child, vtkXMLDataElement* childXML);
// Read the XML element for the subtree of a the composite dataset.
// dataSetIndex is used to rank the leaf nodes in an inorder traversal.
virtual void ReadComposite(vtkXMLDataElement* element, vtkCompositeDataSet* composite,
const char* filePath, unsigned int& dataSetIndex) = 0;
// Read the vtkDataSet (a leaf) in the composite dataset.
virtual vtkDataSet* ReadDataset(vtkXMLDataElement* xmlElem, const char* filePath);
// Read the vtkDataObject (a leaf) in the composite dataset.
virtual vtkDataObject* ReadDataObject(vtkXMLDataElement* xmlElem, const char* filePath);
/**
* Given the inorder index for a leaf node, this method tells if the current
* process should read the dataset.
*
* For a dataset that is part of a vtkParititionedDataSet or a
* vtkMultiPieceDataset, valid `pieceIndex` and `numPieces` should be specified such that
* `pieceIndex < numPieces`. When provided, this method can use the
* `PieceDistribution` selection to distribute each vtkMultiPieceDataset and
* vtkParititionedDataSet across ranks.
*
*/
int ShouldReadDataSet(
unsigned int datasetIndex, unsigned int pieceIndex = 0, unsigned int numPieces = 0);
#ifndef __VTK_WRAP__
/**
* Convenience method to count all nested elements with the given tag name.
* In addition, one can specify a list of tags to skip traversing into.
*/
static unsigned int CountNestedElements(vtkXMLDataElement* element, const std::string& tagName,
const std::set<std::string>& exclusions = std::set<std::string>());
#endif
private:
vtkXMLCompositeDataReader(const vtkXMLCompositeDataReader&) = delete;
void operator=(const vtkXMLCompositeDataReader&) = delete;
///@{
/**
* Given the number of datasets (@a numDatasets) and number of pieces (@a numPieces),
* return the piece number of a dataset at the chosen index (@a datasetIndex)
* based on the assignment strategy.
*/
static int GetPieceAssignmentForBlockStrategy(
unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
static int GetPieceAssignmentForInterleaveStrategy(
unsigned int datasetIndex, unsigned int numDatasets, int numPieces);
///@}
int PieceDistribution;
vtkXMLCompositeDataReaderInternals* Internal;
};
#endif