MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadComposite

Method ReadComposite

IO/XML/vtkXMLMultiBlockDataReader.cxx:85–195  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

83
84//------------------------------------------------------------------------------
85void vtkXMLMultiBlockDataReader::ReadComposite(vtkXMLDataElement* element,
86 vtkCompositeDataSet* composite, const char* filePath, unsigned int& dataSetIndex)
87{
88 vtkMultiBlockDataSet* mblock = vtkMultiBlockDataSet::SafeDownCast(composite);
89 vtkMultiPieceDataSet* mpiece = vtkMultiPieceDataSet::SafeDownCast(composite);
90 if (!mblock && !mpiece)
91 {
92 vtkErrorMacro("Unsupported composite dataset.");
93 return;
94 }
95
96 if (this->GetFileMajorVersion() < 1)
97 {
98 // Read legacy file.
99 this->ReadVersion0(element, composite, filePath, dataSetIndex);
100 return;
101 }
102
103 // count how may piece in total are there when reading a multi-piece.
104 // This helps with distribution of the pieces.
105 const unsigned int numPieces = (mpiece && this->DistributePiecesInMultiPieces)
106 ? vtkXMLCompositeDataReader::CountNestedElements(element, "DataSet")
107 : 0;
108
109 const unsigned int maxElems = element->GetNumberOfNestedElements();
110 for (unsigned int cc = 0; cc < maxElems; ++cc)
111 {
112 vtkXMLDataElement* childXML = element->GetNestedElement(cc);
113 if (!childXML || !childXML->GetName())
114 {
115 continue;
116 }
117
118 int index = 0;
119 if (!childXML->GetScalarAttribute("index", index))
120 // if index not in the structure file, then
121 // set up to add at the end
122 {
123 if (mblock)
124 {
125 index = mblock->GetNumberOfBlocks();
126 }
127 else if (mpiece)
128 {
129 index = mpiece->GetNumberOfPieces();
130 }
131 }
132 // child is a leaf node, read and insert.
133 const char* tagName = childXML->GetName();
134 if (strcmp(tagName, "DataSet") == 0)
135 {
136 vtkSmartPointer<vtkDataObject> childDS;
137 const char* name = childXML->GetAttribute("name");
138 if (this->ShouldReadDataSet(dataSetIndex, index, numPieces))
139 {
140 // Read
141 childDS.TakeReference(this->ReadDataObject(childXML, filePath));
142 }

Callers 1

ReadXMLDataMethod · 0.45

Calls 15

ReadVersion0Method · 0.95
GetNestedElementMethod · 0.80
GetScalarAttributeMethod · 0.80
ShouldReadDataSetMethod · 0.80
ReadDataObjectMethod · 0.80
SetBlockMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetNameMethod · 0.45
GetNumberOfBlocksMethod · 0.45

Tested by

no test coverage detected