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

Method FillMetaData

IO/XML/vtkXMLMultiBlockDataReader.cxx:219–342  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

217
218//------------------------------------------------------------------------------
219int vtkXMLMultiBlockDataReader::FillMetaData(vtkCompositeDataSet* metadata,
220 vtkXMLDataElement* element, const std::string& filePath, unsigned int& dataSetIndex)
221{
222 vtkMultiBlockDataSet* mblock = vtkMultiBlockDataSet::SafeDownCast(metadata);
223 vtkMultiPieceDataSet* mpiece = vtkMultiPieceDataSet::SafeDownCast(metadata);
224
225 // count how may piece in total are there when reading a multi-piece.
226 // This helps with distribution of the pieces.
227 const unsigned int numPieces = (mpiece && this->DistributePiecesInMultiPieces)
228 ? vtkXMLCompositeDataReader::CountNestedElements(element, "DataSet")
229 : 0;
230
231 const unsigned int maxElems = element->GetNumberOfNestedElements();
232 for (unsigned int cc = 0; cc < maxElems; ++cc)
233 {
234 vtkXMLDataElement* childXML = element->GetNestedElement(cc);
235 if (!childXML || !childXML->GetName())
236 {
237 continue;
238 }
239
240 int index = 0;
241 if (!childXML->GetScalarAttribute("index", index))
242 // if index not in the structure file, then
243 // set up to add at the end
244 {
245 if (mblock)
246 {
247 index = mblock->GetNumberOfBlocks();
248 }
249 else if (mpiece)
250 {
251 index = mpiece->GetNumberOfPieces();
252 }
253 }
254 // child is a leaf node, read and insert.
255 const char* tagName = childXML->GetName();
256 if (strcmp(tagName, "DataSet") == 0)
257 {
258 vtkInformation* piece_metadata = CreateMetaDataIfNecessary(mblock, mpiece, index);
259 double bounding_box[6];
260 if (childXML->GetVectorAttribute("bounding_box", 6, bounding_box) == 6)
261 {
262 if (piece_metadata)
263 {
264 piece_metadata->Set(vtkDataObject::BOUNDING_BOX(), bounding_box, 6);
265 }
266 }
267 int extent[6];
268 if (childXML->GetVectorAttribute("extent", 6, extent) == 6)
269 {
270 if (piece_metadata)
271 {
272 piece_metadata->Set(vtkDataObject::PIECE_EXTENT(), extent, 6);
273 }
274 }
275
276 if (this->ShouldReadDataSet(dataSetIndex, index, numPieces))

Callers 1

RequestInformationMethod · 0.95

Calls 15

GetNestedElementMethod · 0.80
GetScalarAttributeMethod · 0.80
GetVectorAttributeMethod · 0.80
ShouldReadDataSetMethod · 0.80
SetBlockMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetNameMethod · 0.45

Tested by

no test coverage detected