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

Function ReadDataAssembly

IO/XML/vtkXMLPartitionedDataSetCollectionReader.cxx:24–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace
23{
24vtkSmartPointer<vtkDataAssembly> ReadDataAssembly(
25 vtkXMLDataElement* elem, vtkXMLPartitionedDataSetCollectionReader* self)
26{
27 if (elem->GetAttribute("encoding") == nullptr ||
28 strcmp(elem->GetAttribute("encoding"), "base64") != 0 || elem->GetCharacterData() == nullptr)
29 {
30 vtkWarningWithObjectMacro(self, "Unsupported DataAssembly encoding. Ignoring.");
31 return nullptr;
32 }
33
34 vtkNew<vtkDataAssembly> assembly;
35 const char* encoded_buffer = elem->GetCharacterData();
36 size_t len_encoded_data = strlen(encoded_buffer);
37 char* decoded_buffer = new char[len_encoded_data];
38
39 // remove leading whitespace, if any.
40 while (std::isspace(static_cast<int>(*encoded_buffer)))
41 {
42 ++encoded_buffer;
43 --len_encoded_data;
44 }
45 auto decoded_buffer_len =
46 vtkBase64Utilities::DecodeSafely(reinterpret_cast<const unsigned char*>(encoded_buffer),
47 len_encoded_data, reinterpret_cast<unsigned char*>(decoded_buffer), len_encoded_data);
48 decoded_buffer[decoded_buffer_len] = '\0';
49 assembly->InitializeFromXML(decoded_buffer);
50 delete[] decoded_buffer;
51 return assembly;
52}
53}
54
55vtkStandardNewMacro(vtkXMLPartitionedDataSetCollectionReader);

Callers 1

ReadCompositeMethod · 0.85

Calls 2

InitializeFromXMLMethod · 0.80
GetAttributeMethod · 0.45

Tested by

no test coverage detected