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

Method GetWebGLSceneMetaData

Web/Core/vtkWebApplication.cxx:347–390  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

345
346//------------------------------------------------------------------------------
347const char* vtkWebApplication::GetWebGLSceneMetaData(vtkRenderWindow* view)
348{
349 if (!view)
350 {
351 vtkErrorMacro("No view specified.");
352 return nullptr;
353 }
354
355 // We use the camera focal point to be the center of rotation
356 double centerOfRotation[3];
357 vtkCamera* cam = view->GetRenderers()->GetFirstRenderer()->GetActiveCamera();
358 cam->GetFocalPoint(centerOfRotation);
359
360 if (this->Internals->ViewWebGLMap.find(view) == this->Internals->ViewWebGLMap.end())
361 {
362 this->Internals->ViewWebGLMap[view] = vtkSmartPointer<vtkWebGLExporter>::New();
363 }
364
365 std::stringstream globalIdAsString;
366 globalIdAsString << this->Internals->ObjectIdMap->GetGlobalId(view);
367
368 vtkWebGLExporter* webglExporter = this->Internals->ViewWebGLMap[view];
369 webglExporter->parseScene(view->GetRenderers(), globalIdAsString.str().c_str(), VTK_PARSEALL);
370
371 vtkInternals::WebGLObjId2IndexMap webglMap;
372 for (int i = 0; i < webglExporter->GetNumberOfObjects(); ++i)
373 {
374 vtkWebGLObject* wObj = webglExporter->GetWebGLObject(i);
375 if (wObj && wObj->isVisible())
376 {
377 vtkInternals::WebGLObjCacheValue val;
378 val.ObjIndex = i;
379 for (int j = 0; j < wObj->GetNumberOfParts(); ++j)
380 {
381 val.BinaryParts[j] = "";
382 }
383 webglMap[wObj->GetId()] = val;
384 }
385 }
386 this->Internals->WebGLExporterObjIdMap[webglExporter] = webglMap;
387 webglExporter->SetCenterOfRotation(static_cast<float>(centerOfRotation[0]),
388 static_cast<float>(centerOfRotation[1]), static_cast<float>(centerOfRotation[2]));
389 return webglExporter->GenerateMetadata();
390}
391
392//------------------------------------------------------------------------------
393const char* vtkWebApplication::GetWebGLBinaryData(vtkRenderWindow* view, const char* id, int part)

Callers 2

GetWebGLBinaryDataMethod · 0.95
getSceneMetaDataMethod · 0.80

Calls 15

GetActiveCameraMethod · 0.80
GetFirstRendererMethod · 0.80
GetRenderersMethod · 0.80
GetGlobalIdMethod · 0.80
parseSceneMethod · 0.80
GetWebGLObjectMethod · 0.80
isVisibleMethod · 0.80
SetCenterOfRotationMethod · 0.80
GenerateMetadataMethod · 0.80
NewFunction · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected