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

Method ReadComposite

IO/XML/vtkXMLPartitionedDataSetCollectionReader.cxx:84–160  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

82
83//------------------------------------------------------------------------------
84void vtkXMLPartitionedDataSetCollectionReader::ReadComposite(vtkXMLDataElement* element,
85 vtkCompositeDataSet* composite, const char* filePath, unsigned int& dataSetIndex)
86{
87 vtkPartitionedDataSetCollection* col = vtkPartitionedDataSetCollection::SafeDownCast(composite);
88 vtkPartitionedDataSet* ds = vtkPartitionedDataSet::SafeDownCast(composite);
89 if (!col && !ds)
90 {
91 vtkErrorMacro("Unsupported composite dataset.");
92 return;
93 }
94
95 // count partitions to guide partition allocation when reading in parallel.
96 const unsigned int numberOfParitions =
97 ds ? vtkXMLCompositeDataReader::CountNestedElements(element, "DataSet") : 0;
98
99 unsigned int maxElems = element->GetNumberOfNestedElements();
100 for (unsigned int cc = 0; cc < maxElems; ++cc)
101 {
102 vtkXMLDataElement* childXML = element->GetNestedElement(cc);
103 if (!childXML || !childXML->GetName())
104 {
105 continue;
106 }
107
108 int index = 0;
109 if (!childXML->GetScalarAttribute("index", index))
110 // if index not in the structure file, then
111 // set up to add at the end
112 {
113 if (col)
114 {
115 index = col->GetNumberOfPartitionedDataSets();
116 }
117 else if (ds)
118 {
119 index = ds->GetNumberOfPartitions();
120 }
121 }
122 // child is a leaf node, read and insert.
123 const char* tagName = childXML->GetName();
124 if (strcmp(tagName, "DataSet") == 0)
125 {
126 vtkSmartPointer<vtkDataObject> childDS;
127 if (this->ShouldReadDataSet(dataSetIndex, index, numberOfParitions))
128 {
129 // Read
130 childDS.TakeReference(this->ReadDataObject(childXML, filePath));
131 }
132 // insert
133 ds->SetPartition(index, childDS);
134 dataSetIndex++;
135 }
136 else if (col != nullptr && strcmp(tagName, "Partitions") == 0)
137 {
138 vtkPartitionedDataSet* childDS = vtkPartitionedDataSet::New();
139 this->ReadComposite(childXML, childDS, filePath, dataSetIndex);
140 col->SetPartitionedDataSet(index, childDS);
141 childDS->Delete();

Callers

nothing calls this directly

Calls 15

ReadDataAssemblyFunction · 0.85
GetNestedElementMethod · 0.80
GetScalarAttributeMethod · 0.80
ShouldReadDataSetMethod · 0.80
ReadDataObjectMethod · 0.80
SetPartitionedDataSetMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetNameMethod · 0.45
GetNumberOfPartitionsMethod · 0.45

Tested by

no test coverage detected