------------------------------------------------------------------------------
| 391 | |
| 392 | //------------------------------------------------------------------------------ |
| 393 | const 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 | //------------------------------------------------------------------------------ |
| 446 | void vtkWebApplication::PrintSelf(ostream& os, vtkIndent indent) |
no test coverage detected