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

Method GetWebGLBinaryData

Web/Core/vtkWebApplication.cxx:393–443  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

391
392//------------------------------------------------------------------------------
393const char* vtkWebApplication::GetWebGLBinaryData(vtkRenderWindow* view, const char* id, int part)
394{
395 if (!view)
396 {
397 vtkErrorMacro("No view specified.");
398 return nullptr;
399 }
400 if (this->Internals->ViewWebGLMap.find(view) == this->Internals->ViewWebGLMap.end())
401 {
402 if (this->GetWebGLSceneMetaData(view) == nullptr)
403 {
404 vtkErrorMacro("Failed to generate WebGL MetaData for: " << view);
405 return nullptr;
406 }
407 }
408
409 vtkWebGLExporter* webglExporter = this->Internals->ViewWebGLMap[view];
410 if (webglExporter == nullptr)
411 {
412 vtkErrorMacro("There is no cached WebGL Exporter for: " << view);
413 return nullptr;
414 }
415
416 if (!this->Internals->WebGLExporterObjIdMap[webglExporter].empty() &&
417 this->Internals->WebGLExporterObjIdMap[webglExporter].find(id) !=
418 this->Internals->WebGLExporterObjIdMap[webglExporter].end())
419 {
420 vtkInternals::WebGLObjCacheValue* cachedVal =
421 &(this->Internals->WebGLExporterObjIdMap[webglExporter][id]);
422 if (cachedVal->BinaryParts.find(part) != cachedVal->BinaryParts.end())
423 {
424 if (cachedVal->BinaryParts[part].empty())
425 {
426 vtkWebGLObject* obj = webglExporter->GetWebGLObject(cachedVal->ObjIndex);
427 if (obj && obj->isVisible())
428 {
429 // Manage Base64
430 vtkNew<vtkBase64Utilities> base64;
431 unsigned char* output = new unsigned char[obj->GetBinarySize(part) * 2];
432 int size =
433 base64->Encode(obj->GetBinaryData(part), obj->GetBinarySize(part), output, false);
434 cachedVal->BinaryParts[part] = std::string((const char*)output, size);
435 delete[] output;
436 }
437 }
438 return cachedVal->BinaryParts[part].c_str();
439 }
440 }
441
442 return nullptr;
443}
444
445//------------------------------------------------------------------------------
446void vtkWebApplication::PrintSelf(ostream& os, vtkIndent indent)

Callers 1

getWebGLDataMethod · 0.80

Calls 11

GetWebGLSceneMetaDataMethod · 0.95
GetWebGLObjectMethod · 0.80
isVisibleMethod · 0.80
EncodeMethod · 0.80
stringClass · 0.50
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
GetBinarySizeMethod · 0.45
GetBinaryDataMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected