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

Method RequestData

IO/Infovis/vtkXMLTreeReader.cxx:160–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160int vtkXMLTreeReader::RequestData(
161 vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
162{
163 if (!this->FileName && !this->XMLString)
164 {
165 vtkErrorMacro("A FileName or XMLString must be specified");
166 return 0;
167 }
168
169 xmlDoc* doc = nullptr;
170 if (this->FileName)
171 {
172 // Parse the file and get the DOM
173 doc = xmlReadFile(this->FileName, nullptr, 0);
174 }
175 else if (this->XMLString)
176 {
177 // Parse from memory and get the DOM
178 doc = xmlReadMemory(
179 this->XMLString, static_cast<int>(strlen(this->XMLString)), "noname.xml", nullptr, 0);
180 }
181
182 // Store the XML hierarchy into a vtkMutableDirectedGraph,
183 // later to be placed in a vtkTree.
184 vtkSmartPointer<vtkMutableDirectedGraph> builder =
185 vtkSmartPointer<vtkMutableDirectedGraph>::New();
186
187 vtkDataSetAttributes* data = builder->GetVertexData();
188
189 if (this->ReadTagName)
190 {
191 vtkStringArray* nameArr = vtkStringArray::New();
192 nameArr->SetName(vtkXMLTreeReader::TagNameField);
193 data->AddArray(nameArr);
194 nameArr->Delete();
195 }
196
197 if (this->ReadCharData)
198 {
199 vtkStringArray* charArr = vtkStringArray::New();
200 charArr->SetName(vtkXMLTreeReader::CharDataField);
201 data->AddArray(charArr);
202 charArr->Delete();
203 }
204
205 // Get the root element node
206 xmlNode* rootElement = xmlDocGetRootElement(doc);
207 if (!rootElement)
208 {
209 vtkErrorMacro(<< "Could not get root element of document.");
210 return 0;
211 }
212
213 vtkXMLTreeReaderProcessElement(builder, -1, rootElement, this->ReadCharData, this->MaskArrays);
214
215 xmlFreeDoc(doc);
216
217 // Make all the arrays the same size

Callers

nothing calls this directly

Calls 15

xmlReadFileFunction · 0.85
xmlReadMemoryFunction · 0.85
xmlDocGetRootElementFunction · 0.85
xmlFreeDocFunction · 0.85
GetVertexDataMethod · 0.80
GetAbstractArrayMethod · 0.80
GetNumberOfVerticesMethod · 0.80
SetPedigreeIdsMethod · 0.80
GetEdgeDataMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50

Tested by

no test coverage detected