Medical Imaging Interaction Toolkit  2018.4.99-08619e4f
Medical Imaging Interaction Toolkit
mitkGPUVolumeMapper3D.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #define GPU_INFO MITK_INFO("mapper.vr")
14 #define GPU_WARN MITK_WARN("mapper.vr")
15 #define GPU_ERROR MITK_ERROR("mapper.vr")
16 
17 #include "mitkGPUVolumeMapper3D.h"
18 
19 #include "mitkDataNode.h"
20 
21 #include "mitkColorProperty.h"
22 #include "mitkColorProperty.h"
23 #include "mitkLevelWindow.h"
26 #include "mitkProperties.h"
27 #include "mitkRenderingManager.h"
30 #include "mitkVtkPropRenderer.h"
31 
32 #include <vtkActor.h>
33 #include <vtkProperty.h>
34 
35 #include <vtkAssembly.h>
36 #include <vtkColorTransferFunction.h>
37 #include <vtkFiniteDifferenceGradientEstimator.h>
38 #include <vtkImageData.h>
39 #include <vtkImageResample.h>
40 #include <vtkImageWriter.h>
41 #include <vtkImplicitPlaneWidget.h>
42 #include <vtkLODProp3D.h>
43 #include <vtkPiecewiseFunction.h>
44 #include <vtkPlane.h>
45 #include <vtkRenderWindow.h>
46 #include <vtkRenderWindowInteractor.h>
47 #include <vtkVolume.h>
48 #include <vtkVolumeProperty.h>
49 
50 #include <vtkCubeSource.h>
51 #include <vtkPolyDataMapper.h>
52 
54 
55 #include "vtkOpenGLGPUVolumeRayCastMapper.h"
56 
58 {
59  return static_cast<const mitk::Image *>(GetDataNode()->GetData());
60 }
61 
63 {
65 
66  // if(ls->m_gpuInitialized)
67  // ls->m_MapperGPU->UpdateMTime();
68 }
69 
71 {
72  return false;
73 }
74 
76 {
77  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
78 
79  if (ls->m_cpuInitialized)
80  return;
81 
82  ls->m_VtkRenderWindow = renderer->GetVtkRenderer()->GetRenderWindow();
83 
84  ls->m_MapperCPU = vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();
85  int numThreads = ls->m_MapperCPU->GetNumberOfThreads();
86 
87  GPU_INFO << "initializing cpu-raycast-vr (vtkFixedPointVolumeRayCastMapper) (" << numThreads << " threads)";
88 
89  ls->m_MapperCPU->SetSampleDistance(1.0);
90  // ls->m_MapperCPU->LockSampleDistanceToInputSpacingOn();
91  ls->m_MapperCPU->SetImageSampleDistance(1.0);
92  ls->m_MapperCPU->IntermixIntersectingGeometryOn();
93  ls->m_MapperCPU->SetAutoAdjustSampleDistances(0);
94 
95  ls->m_VolumePropertyCPU = vtkSmartPointer<vtkVolumeProperty>::New();
96  ls->m_VolumePropertyCPU->ShadeOn();
97  ls->m_VolumePropertyCPU->SetAmbient(0.10f); // 0.05f
98  ls->m_VolumePropertyCPU->SetDiffuse(0.50f); // 0.45f
99  ls->m_VolumePropertyCPU->SetSpecular(0.40f); // 0.50f
100  ls->m_VolumePropertyCPU->SetSpecularPower(16.0f);
101  ls->m_VolumePropertyCPU->SetInterpolationTypeToLinear();
102 
103  ls->m_VolumeCPU = vtkSmartPointer<vtkVolume>::New();
104  ls->m_VolumeCPU->SetMapper(ls->m_MapperCPU);
105  ls->m_VolumeCPU->SetProperty(ls->m_VolumePropertyCPU);
106  ls->m_VolumeCPU->VisibilityOn();
107 
108  ls->m_MapperCPU->SetInputConnection(m_UnitSpacingImageFilter->GetOutputPort()); // m_Resampler->GetOutput());
109 
110  ls->m_cpuInitialized = true;
111 }
112 
114 {
115  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
116 
117  if (!ls->m_cpuInitialized)
118  return;
119 
120  GPU_INFO << "deinitializing cpu-raycast-vr";
121 
122  ls->m_VolumePropertyCPU = nullptr;
123  ls->m_MapperCPU = nullptr;
124  ls->m_VolumeCPU = nullptr;
125  ls->m_cpuInitialized = false;
126 }
127 
129 {
130  m_Volumenullptr = nullptr;
131  m_commonInitialized = false;
132 }
133 
135 {
136  DeinitCommon();
137 }
138 
140 {
142  return;
143 
144  m_UnitSpacingImageFilter = vtkSmartPointer<vtkImageChangeInformation>::New();
145  m_UnitSpacingImageFilter->SetOutputSpacing(1.0, 1.0, 1.0);
146 
148 
149  m_commonInitialized = true;
150 }
151 
153 {
154  if (!m_commonInitialized)
155  return;
156 
157  m_commonInitialized = false;
158 }
159 
161 {
162  if (!GetDataNode())
163  return false;
164 
165  DataNode *node = GetDataNode();
166 
167  bool visible = true;
168  node->GetVisibility(visible, renderer, "visible");
169 
170  if (!visible)
171  return false;
172 
173  bool value = false;
174  if (!node->GetBoolProperty("volumerendering", value, renderer))
175  return false;
176 
177  if (!value)
178  return false;
179 
180  auto *input = const_cast<mitk::Image *>(this->GetInput());
181 
182  if (!input || !input->IsInitialized())
183  return false;
184 
185  vtkImageData *inputData = input->GetVtkImageData(this->GetTimestep());
186 
187  if (inputData == nullptr)
188  return false;
189 
190  return true;
191 }
192 
194 {
195  if (IsRAYEnabled(renderer))
196  {
197  DeinitCPU(renderer);
198  if (!InitRAY(renderer))
199  {
200  GPU_WARN << "hardware renderer can't initialize ... falling back to software renderer";
201  goto fallback;
202  }
203  }
204  else if (IsGPUEnabled(renderer))
205  {
206  DeinitCPU(renderer);
207  DeinitRAY(renderer);
208  if (!InitGPU(renderer))
209  {
210  GPU_WARN << "hardware renderer can't initialize ... falling back to software renderer";
211  goto fallback;
212  }
213  }
214  else
215  {
216  fallback:
217  DeinitRAY(renderer);
218  InitCPU(renderer);
219  }
220 }
221 
223 {
224  if (!IsRenderable(renderer))
225  {
226  if (!m_Volumenullptr)
227  {
228  m_Volumenullptr = vtkSmartPointer<vtkVolume>::New();
229  m_Volumenullptr->VisibilityOff();
230  }
231  return m_Volumenullptr;
232  }
233 
234  InitCommon();
235  InitVtkMapper(renderer);
236 
237  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
238 
239  if (ls->m_rayInitialized)
240  return ls->m_VolumeRAY;
241 
242  if (ls->m_gpuInitialized)
243  return ls->m_VolumeGPU;
244 
245  return ls->m_VolumeCPU;
246 }
247 
249 {
250  if (!IsRenderable(renderer))
251  return;
252 
253  InitCommon();
254  InitVtkMapper(renderer);
255 
256  auto *input = const_cast<mitk::Image *>(this->GetInput());
257  vtkImageData *inputData = input->GetVtkImageData(this->GetTimestep());
258  m_UnitSpacingImageFilter->SetInputData(inputData);
259 
260  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
261 
262  if (ls->m_rayInitialized)
263  {
264  GenerateDataRAY(renderer);
265  }
266  else
267 
268  if (ls->m_gpuInitialized)
269  {
270  GenerateDataGPU(renderer);
271  }
272  else
273  {
274  GenerateDataCPU(renderer);
275  }
276 
277  // UpdateTransferFunctions
278  UpdateTransferFunctions(renderer);
279 }
280 
282 {
283 }
284 
286 {
287  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
288 
289  int nextLod = mitk::RenderingManager::GetInstance()->GetNextLOD(renderer);
290 
291  if (IsLODEnabled(renderer) && nextLod == 0)
292  {
293  ls->m_MapperCPU->SetImageSampleDistance(3.5);
294  ls->m_MapperCPU->SetSampleDistance(1.25);
295  ls->m_VolumePropertyCPU->SetInterpolationTypeToNearest();
296  }
297  else
298  {
299  ls->m_MapperCPU->SetImageSampleDistance(1.0);
300  ls->m_MapperCPU->SetSampleDistance(1.0);
301  ls->m_VolumePropertyCPU->SetInterpolationTypeToLinear();
302  }
303 
304  // Check raycasting mode
305  if (IsMIPEnabled(renderer))
306  ls->m_MapperCPU->SetBlendModeToMaximumIntensity();
307  else
308  ls->m_MapperCPU->SetBlendModeToComposite();
309 
310  // Updating shadings
311  {
312  float value = 0;
313  if (GetDataNode()->GetFloatProperty("volumerendering.cpu.ambient", value, renderer))
314  ls->m_VolumePropertyCPU->SetAmbient(value);
315  if (GetDataNode()->GetFloatProperty("volumerendering.cpu.diffuse", value, renderer))
316  ls->m_VolumePropertyCPU->SetDiffuse(value);
317  if (GetDataNode()->GetFloatProperty("volumerendering.cpu.specular", value, renderer))
318  ls->m_VolumePropertyCPU->SetSpecular(value);
319  if (GetDataNode()->GetFloatProperty("volumerendering.cpu.specular.power", value, renderer))
320  ls->m_VolumePropertyCPU->SetSpecularPower(value);
321  }
322 }
323 
325 {
326  m_DefaultOpacityTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();
327  m_DefaultOpacityTransferFunction->AddPoint(0.0, 0.0);
328  m_DefaultOpacityTransferFunction->AddPoint(255.0, 0.8);
329  m_DefaultOpacityTransferFunction->ClampingOn();
330 
331  m_DefaultGradientTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();
332  m_DefaultGradientTransferFunction->AddPoint(0.0, 0.0);
333  m_DefaultGradientTransferFunction->AddPoint(255.0, 0.8);
334  m_DefaultGradientTransferFunction->ClampingOn();
335 
336  m_DefaultColorTransferFunction = vtkSmartPointer<vtkColorTransferFunction>::New();
337  m_DefaultColorTransferFunction->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
338  m_DefaultColorTransferFunction->AddRGBPoint(127.5, 1, 1, 0.0);
339  m_DefaultColorTransferFunction->AddRGBPoint(255.0, 0.8, 0.2, 0);
340  m_DefaultColorTransferFunction->ClampingOn();
341 
342  m_BinaryOpacityTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();
343  m_BinaryOpacityTransferFunction->AddPoint(0, 0.0);
344  m_BinaryOpacityTransferFunction->AddPoint(1, 1.0);
345 
346  m_BinaryGradientTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();
347  m_BinaryGradientTransferFunction->AddPoint(0.0, 1.0);
348 
349  m_BinaryColorTransferFunction = vtkSmartPointer<vtkColorTransferFunction>::New();
350 }
351 
353 {
354  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
355 
356  vtkPiecewiseFunction *opacityTransferFunction = m_DefaultOpacityTransferFunction;
357  vtkPiecewiseFunction *gradientTransferFunction = m_DefaultGradientTransferFunction;
358  vtkColorTransferFunction *colorTransferFunction = m_DefaultColorTransferFunction;
359 
360  bool isBinary = false;
361 
362  GetDataNode()->GetBoolProperty("binary", isBinary, renderer);
363 
364  if (isBinary)
365  {
366  opacityTransferFunction = m_BinaryOpacityTransferFunction;
367  gradientTransferFunction = m_BinaryGradientTransferFunction;
368  colorTransferFunction = m_BinaryColorTransferFunction;
369 
370  colorTransferFunction->RemoveAllPoints();
371  float rgb[3];
372  if (!GetDataNode()->GetColor(rgb, renderer))
373  rgb[0] = rgb[1] = rgb[2] = 1;
374  colorTransferFunction->AddRGBPoint(0, rgb[0], rgb[1], rgb[2]);
375  colorTransferFunction->Modified();
376  }
377  else
378  {
379  auto *transferFunctionProp =
380  dynamic_cast<mitk::TransferFunctionProperty *>(this->GetDataNode()->GetProperty("TransferFunction", renderer));
381 
382  if (transferFunctionProp)
383  {
384  opacityTransferFunction = transferFunctionProp->GetValue()->GetScalarOpacityFunction();
385  gradientTransferFunction = transferFunctionProp->GetValue()->GetGradientOpacityFunction();
386  colorTransferFunction = transferFunctionProp->GetValue()->GetColorTransferFunction();
387  }
388  }
389 
390  if (ls->m_gpuInitialized)
391  {
392  ls->m_VolumePropertyGPU->SetColor(colorTransferFunction);
393  ls->m_VolumePropertyGPU->SetScalarOpacity(opacityTransferFunction);
394  ls->m_VolumePropertyGPU->SetGradientOpacity(gradientTransferFunction);
395  }
396 
397  if (ls->m_rayInitialized)
398  {
399  ls->m_VolumePropertyRAY->SetColor(colorTransferFunction);
400  ls->m_VolumePropertyRAY->SetScalarOpacity(opacityTransferFunction);
401  ls->m_VolumePropertyRAY->SetGradientOpacity(gradientTransferFunction);
402  }
403 
404  if (ls->m_cpuInitialized)
405  {
406  ls->m_VolumePropertyCPU->SetColor(colorTransferFunction);
407  ls->m_VolumePropertyCPU->SetScalarOpacity(opacityTransferFunction);
408  ls->m_VolumePropertyCPU->SetGradientOpacity(gradientTransferFunction);
409  }
410 }
411 
412 void mitk::GPUVolumeMapper3D::ApplyProperties(vtkActor * /*actor*/, mitk::BaseRenderer * /*renderer*/)
413 {
414  // GPU_INFO << "ApplyProperties";
415 }
416 
418 {
419  // GPU_INFO << "SetDefaultProperties";
420 
421  node->AddProperty("volumerendering", mitk::BoolProperty::New(false), renderer, overwrite);
422  node->AddProperty("volumerendering.usemip", mitk::BoolProperty::New(false), renderer, overwrite);
423  node->AddProperty("volumerendering.uselod", mitk::BoolProperty::New(false), renderer, overwrite);
424 
425  node->AddProperty("volumerendering.cpu.ambient", mitk::FloatProperty::New(0.10f), renderer, overwrite);
426  node->AddProperty("volumerendering.cpu.diffuse", mitk::FloatProperty::New(0.50f), renderer, overwrite);
427  node->AddProperty("volumerendering.cpu.specular", mitk::FloatProperty::New(0.40f), renderer, overwrite);
428  node->AddProperty("volumerendering.cpu.specular.power", mitk::FloatProperty::New(16.0f), renderer, overwrite);
429  bool usegpu = true;
430 #ifdef __APPLE__
431  usegpu = false;
432  node->AddProperty("volumerendering.uselod", mitk::BoolProperty::New(true), renderer, overwrite);
433 #endif
434  node->AddProperty("volumerendering.usegpu", mitk::BoolProperty::New(usegpu), renderer, overwrite);
435 
436  node->AddProperty("volumerendering.useray", mitk::BoolProperty::New(false), renderer, overwrite);
437 
438  node->AddProperty("volumerendering.ray.ambient", mitk::FloatProperty::New(0.25f), renderer, overwrite);
439  node->AddProperty("volumerendering.ray.diffuse", mitk::FloatProperty::New(0.50f), renderer, overwrite);
440  node->AddProperty("volumerendering.ray.specular", mitk::FloatProperty::New(0.40f), renderer, overwrite);
441  node->AddProperty("volumerendering.ray.specular.power", mitk::FloatProperty::New(16.0f), renderer, overwrite);
442 
443  node->AddProperty("volumerendering.gpu.ambient", mitk::FloatProperty::New(0.25f), renderer, overwrite);
444  node->AddProperty("volumerendering.gpu.diffuse", mitk::FloatProperty::New(0.50f), renderer, overwrite);
445  node->AddProperty("volumerendering.gpu.specular", mitk::FloatProperty::New(0.40f), renderer, overwrite);
446  node->AddProperty("volumerendering.gpu.specular.power", mitk::FloatProperty::New(16.0f), renderer, overwrite);
447  node->AddProperty("volumerendering.gpu.usetexturecompression", mitk::BoolProperty::New(false), renderer, overwrite);
448  node->AddProperty("volumerendering.gpu.reducesliceartifacts", mitk::BoolProperty::New(false), renderer, overwrite);
449 
450  node->AddProperty("binary", mitk::BoolProperty::New(false), renderer, overwrite);
451 
452  mitk::Image::Pointer image = dynamic_cast<mitk::Image *>(node->GetData());
453  if (image.IsNotNull() && image->IsInitialized())
454  {
455  if ((overwrite) || (node->GetProperty("levelwindow", renderer) == nullptr))
456  {
458  mitk::LevelWindow levelwindow;
459  levelwindow.SetAuto(image);
460  levWinProp->SetLevelWindow(levelwindow);
461  node->SetProperty("levelwindow", levWinProp, renderer);
462  }
463 
464  if ((overwrite) || (node->GetProperty("TransferFunction", renderer) == nullptr))
465  {
466  // add a default transfer function
469  tfInit->SetTransferFunctionMode(0);
470  node->SetProperty("TransferFunction", mitk::TransferFunctionProperty::New(tf.GetPointer()));
471  }
472  }
473 
474  Superclass::SetDefaultProperties(node, renderer, overwrite);
475 }
476 
478 {
479  bool value = false;
480  return GetDataNode()->GetBoolProperty("volumerendering.uselod", value, renderer) && value;
481 }
482 
484 {
485  bool value = false;
486  return GetDataNode()->GetBoolProperty("volumerendering.usemip", value, renderer) && value;
487 }
488 
490 {
491  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
492  bool value = false;
493  return ls->m_gpuSupported && GetDataNode()->GetBoolProperty("volumerendering.usegpu", value, renderer) && value;
494 }
495 
497 {
498  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
499 
500  if (ls->m_rayInitialized)
501  return ls->m_raySupported;
502 
503  ls->m_VtkRenderWindow = renderer->GetVtkRenderer()->GetRenderWindow();
504 
505  GPU_INFO << "initializing gpu-raycast-vr (vtkOpenGLGPUVolumeRayCastMapper)";
506 
507  ls->m_MapperRAY = vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper>::New();
508  ls->m_MapperRAY->SetAutoAdjustSampleDistances(0);
509  ls->m_MapperRAY->SetSampleDistance(1.0);
510 
511  ls->m_VolumePropertyRAY = vtkSmartPointer<vtkVolumeProperty>::New();
512  ls->m_VolumePropertyRAY->ShadeOn();
513  ls->m_VolumePropertyRAY->SetAmbient(0.25f); // 0.05f
514  ls->m_VolumePropertyRAY->SetDiffuse(0.50f); // 0.45f
515  ls->m_VolumePropertyRAY->SetSpecular(0.40f); // 0.50f
516  ls->m_VolumePropertyRAY->SetSpecularPower(16.0f);
517  ls->m_VolumePropertyRAY->SetInterpolationTypeToLinear();
518 
519  ls->m_VolumeRAY = vtkSmartPointer<vtkVolume>::New();
520  ls->m_VolumeRAY->SetMapper(ls->m_MapperRAY);
521  ls->m_VolumeRAY->SetProperty(ls->m_VolumePropertyRAY);
522  ls->m_VolumeRAY->VisibilityOn();
523 
524  ls->m_MapperRAY->SetInputConnection(this->m_UnitSpacingImageFilter->GetOutputPort());
525 
526  ls->m_raySupported = ls->m_MapperRAY->IsRenderSupported(renderer->GetRenderWindow(), ls->m_VolumePropertyRAY);
527 
528  ls->m_rayInitialized = true;
529  return ls->m_raySupported;
530 }
531 
533 {
534  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
535 
536  if (ls->m_rayInitialized)
537  {
538  GPU_INFO << "deinitializing gpu-raycast-vr";
539 
540  ls->m_MapperRAY = nullptr;
541  ls->m_VolumePropertyRAY = nullptr;
542  // Here ReleaseGraphicsResources has to be called to avoid VTK error messages.
543  // This seems like a VTK bug, because ReleaseGraphicsResources() is ment for internal use,
544  // but you cannot just delete the object (last smartpointer reference) without getting the
545  // VTK error.
546  ls->m_VolumeRAY->ReleaseGraphicsResources(renderer->GetVtkRenderer()->GetRenderWindow());
547  ls->m_VolumeRAY = nullptr;
548  ls->m_rayInitialized = false;
549  }
550 }
551 
553 {
554  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
555 
556  if (IsLODEnabled(renderer) && mitk::RenderingManager::GetInstance()->GetNextLOD(renderer) == 0)
557  ls->m_MapperRAY->SetImageSampleDistance(4.0);
558  else
559  ls->m_MapperRAY->SetImageSampleDistance(1.0);
560 
561  // Check raycasting mode
562  if (IsMIPEnabled(renderer))
563  ls->m_MapperRAY->SetBlendModeToMaximumIntensity();
564  else
565  ls->m_MapperRAY->SetBlendModeToComposite();
566 
567  // Updating shadings
568  {
569  float value = 0;
570  if (GetDataNode()->GetFloatProperty("volumerendering.ray.ambient", value, renderer))
571  ls->m_VolumePropertyRAY->SetAmbient(value);
572  if (GetDataNode()->GetFloatProperty("volumerendering.ray.diffuse", value, renderer))
573  ls->m_VolumePropertyRAY->SetDiffuse(value);
574  if (GetDataNode()->GetFloatProperty("volumerendering.ray.specular", value, renderer))
575  ls->m_VolumePropertyRAY->SetSpecular(value);
576  if (GetDataNode()->GetFloatProperty("volumerendering.ray.specular.power", value, renderer))
577  ls->m_VolumePropertyRAY->SetSpecularPower(value);
578  }
579 }
580 
582 {
583  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
584  bool value = false;
585  return ls->m_raySupported && GetDataNode()->GetBoolProperty("volumerendering.useray", value, renderer) && value;
586 }
#define ls
Definition: MitkMCxyz.cpp:57
bool IsGPUEnabled(BaseRenderer *renderer=nullptr)
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr, bool fallBackOnDataProperties=true) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
bool IsRAYEnabled(BaseRenderer *renderer=nullptr)
vtkSmartPointer< vtkImageChangeInformation > m_UnitSpacingImageFilter
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
The TransferFunctionProperty class Property class for the mitk::TransferFunction. ...
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
void ApplyProperties(vtkActor *actor, mitk::BaseRenderer *renderer) override
Apply color and opacity properties read from the PropertyList.
static Pointer New()
void DeinitRAY(mitk::BaseRenderer *renderer)
vtkRenderer * GetVtkRenderer() const
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
Definition: mitkMapper.cpp:31
vtkSmartPointer< vtkPiecewiseFunction > m_DefaultOpacityTransferFunction
vtkSmartPointer< vtkGPUVolumeRayCastMapper > m_MapperRAY
bool IsMIPEnabled(BaseRenderer *renderer=nullptr)
vtkSmartPointer< vtkVolumeProperty > m_VolumePropertyGPU
Organizes the rendering process.
virtual vtkImageData * GetVtkImageData(int t=0, int n=0)
Get a volume at a specific time t of channel n as a vtkImageData.
Definition: mitkImage.cpp:217
vtkSmartPointer< vtkVolume > m_VolumeGPU
void InitVtkMapper(mitk::BaseRenderer *renderer)
virtual mitk::TransferFunction::Pointer GetValue() const
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
vtkSmartPointer< vtkVolumeProperty > m_VolumePropertyRAY
vtkSmartPointer< vtkPiecewiseFunction > m_DefaultGradientTransferFunction
vtkSmartPointer< vtkVolume > m_VolumeRAY
void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
The LevelWindow class Class to store level/window values.
static Pointer New()
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
void InitCPU(mitk::BaseRenderer *renderer)
virtual void MitkRenderVolumetricGeometry(BaseRenderer *renderer)
Checks visibility and renders volumes.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
virtual const mitk::Image * GetInput()
vtkSmartPointer< vtkVolumeProperty > m_VolumePropertyCPU
vtkSmartPointer< vtkPiecewiseFunction > m_BinaryOpacityTransferFunction
static RenderingManager * GetInstance()
virtual bool GetColor(float rgb[3], BaseRenderer *renderer, const char *name="color") const
Convenience access method for color properties (instances of ColorProperty)
Definition: mitkMapper.cpp:36
bool IsRenderable(mitk::BaseRenderer *renderer)
Image class for storing images.
Definition: mitkImage.h:72
bool InitGPU(mitk::BaseRenderer *renderer)
bool GetVisibility(bool &visible, const mitk::BaseRenderer *renderer, const char *propertyKey="visible") const
Convenience access method for visibility properties (instances of BoolProperty with property-key "vis...
Definition: mitkDataNode.h:421
#define GPU_WARN
void SetAuto(const Image *image, bool tryPicTags=true, bool guessByCentralSlice=true, unsigned selectedComponent=0)
sets level/window to optimize the contrast of the given Image
void GenerateDataGPU(mitk::BaseRenderer *)
static Pointer New()
void GenerateDataCPU(mitk::BaseRenderer *renderer)
void UpdateTransferFunctions(mitk::BaseRenderer *renderer)
int GetNextLOD(BaseRenderer *renderer)
mitk::Image::Pointer image
void DeinitCPU(mitk::BaseRenderer *renderer)
static Pointer New()
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
vtkSmartPointer< vtkVolume > m_Volumenullptr
int GetTimestep() const
Returns the current time step as calculated from the renderer.
Definition: mitkMapper.h:147
mitk::LocalStorageHandler< LocalStorage > m_LSH
void MitkRenderVolumetricGeometry(mitk::BaseRenderer *renderer) override
Checks visibility and renders volumes.
bool IsLODEnabled(BaseRenderer *renderer=nullptr) const override
#define GPU_INFO
vtkSmartPointer< vtkColorTransferFunction > m_DefaultColorTransferFunction
vtkSmartPointer< vtkVolume > m_VolumeCPU
vtkSmartPointer< vtkColorTransferFunction > m_BinaryColorTransferFunction
void GenerateDataRAY(mitk::BaseRenderer *renderer)
bool InitRAY(mitk::BaseRenderer *renderer)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
vtkSmartPointer< vtkPiecewiseFunction > m_BinaryGradientTransferFunction
vtkSmartPointer< vtkFixedPointVolumeRayCastMapper > m_MapperCPU