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

Method ImportFromBytes

Serialization/Manager/vtkObjectManager.cxx:320–349  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

318
319//------------------------------------------------------------------------------
320std::vector<vtkSmartPointer<vtkObjectBase>> vtkObjectManager::ImportFromBytes(
321 vtkSmartPointer<vtkUnsignedCharArray> inputByteArray)
322{
323 this->Clear();
324 std::vector<vtkSmartPointer<vtkObjectBase>> strongObjects;
325 if (inputByteArray == nullptr || inputByteArray->GetNumberOfValues() == 0)
326 {
327 return strongObjects;
328 }
329 nlohmann::json importJson;
330 try
331 {
332 auto byteRange = vtk::DataArrayValueRange(inputByteArray);
333 importJson = nlohmann::json::from_cbor(byteRange.begin(), byteRange.end());
334 }
335 catch (nlohmann::json::exception& e)
336 {
337 vtkErrorMacro(<< "Failed to parse json from byte array. message=" << e.what());
338 }
339 const auto strongObjectIds = this->ImportFromJSON(importJson);
340 // Collect strong objects
341 for (const auto& id : strongObjectIds)
342 {
343 if (auto object = this->Context->GetObjectAtId(id))
344 {
345 strongObjects.emplace_back(object);
346 }
347 }
348 return strongObjects;
349}
350
351//------------------------------------------------------------------------------
352vtkTypeUInt32 vtkObjectManager::RegisterObject(vtkSmartPointer<vtkObjectBase> objectBase)

Callers 1

deserializeFunction · 0.80

Calls 10

ClearMethod · 0.95
ImportFromJSONMethod · 0.95
DataArrayValueRangeFunction · 0.85
from_cborFunction · 0.85
GetNumberOfValuesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
whatMethod · 0.45
GetObjectAtIdMethod · 0.45
emplace_backMethod · 0.45

Tested by 1

deserializeFunction · 0.64