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

Method ComputeRenderMode

Rendering/VolumeOpenGL2/vtkSmartVolumeMapper.cxx:324–546  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Compute the render mode based on what hardware is available, what the user requested as a render mode, and the desired update rate of the render window ------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

322// requested as a render mode, and the desired update rate of the render window
323//------------------------------------------------------------------------------
324void vtkSmartVolumeMapper::ComputeRenderMode(vtkRenderer* ren, vtkVolume* vol)
325{
326 // If we are already initialized, and the volume,
327 // volume's input, and volume's property have not
328 // changed since last time we computed the render mode,
329 // then we don't need to initialize again
330 if (!(this->Initialized && this->SupportStatusCheckTime.GetMTime() > this->GetMTime() &&
331 this->SupportStatusCheckTime.GetMTime() > vol->GetProperty()->GetMTime() &&
332 this->SupportStatusCheckTime.GetMTime() > this->GetInput()->GetMTime() &&
333 this->InitializedBlendMode == this->GetBlendMode()))
334 {
335 this->Initialize(ren, vol);
336 }
337
338 // Use this as the initial state to simplify the code below
339 this->CurrentRenderMode = vtkSmartVolumeMapper::InvalidRenderMode;
340
341 if (!this->GetInput())
342 {
343 return;
344 }
345
346 double scale[3];
347 double spacing[3];
348 if (auto imData = vtkImageData::SafeDownCast(this->GetInput()))
349 {
350 imData->GetSpacing(spacing);
351 }
352 else if (auto rectGrid = vtkRectilinearGrid::SafeDownCast(this->GetInput()))
353 {
354 // compute average spacing along each dimension
355 double bounds[6];
356 rectGrid->GetBounds(bounds);
357 int dims[3];
358 rectGrid->GetDimensions(dims);
359 for (int i = 0; i < 3; ++i)
360 {
361 spacing[i] = (bounds[2 * i + 1] - bounds[2 * i]) / dims[i];
362 }
363 }
364
365 // Compute the sample distance based on dataset spacing.
366 // It is assumed that a negative SampleDistance means the user would like to
367 // compute volume mapper sample distance based on data spacing.
368 if (this->SampleDistance < 0)
369 {
370 this->SampleDistance = static_cast<float>((spacing[0] + spacing[1] + spacing[2]) / 6.0);
371 }
372
373 vtkRenderWindow* win = ren->GetRenderWindow();
374
375 switch (this->RequestedRenderMode)
376 {
377 // Requested ray casting - OK as long as it is supported
378 // This ray caster is a software mapper so it is supported as
379 // we aren't attempting to render cell scalars
380 case vtkSmartVolumeMapper::RayCastRenderMode:
381 if (this->RayCastSupported)

Callers 2

RenderMethod · 0.95
CreateCanonicalViewMethod · 0.95

Calls 15

InitializeMethod · 0.95
ConnectMapperInputMethod · 0.95
SetupVectorModeMethod · 0.95
ConnectFilterInputMethod · 0.95
GetBlendModeMethod · 0.80
GetCroppingMethod · 0.80

Tested by

no test coverage detected