Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkVtkMapper.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 #include "mitkVtkMapper.h"
14 
16 {
17 }
18 
20 {
21 }
22 
24 {
25  switch (type)
26  {
28  this->MitkRenderOpaqueGeometry(renderer);
29  break;
31  this->MitkRenderTranslucentGeometry(renderer);
32  break;
34  this->MitkRenderOverlay(renderer);
35  break;
37  this->MitkRenderVolumetricGeometry(renderer);
38  break;
39  }
40 }
41 
43 {
44  return true;
45 }
46 
48 {
49  bool visible = true;
50  GetDataNode()->GetVisibility(visible, renderer, "visible");
51  if (!visible)
52  return;
53 
54  if (this->GetVtkProp(renderer)->GetVisibility())
55  {
56  GetVtkProp(renderer)->RenderOverlay(renderer->GetVtkRenderer());
57  }
58 }
59 
61 {
62  bool visible = true;
63 
64  GetDataNode()->GetVisibility(visible, renderer, "visible");
65  if (!visible)
66  return;
67 
68  if (this->GetVtkProp(renderer)->GetVisibility())
69  {
70  GetVtkProp(renderer)->RenderOpaqueGeometry(renderer->GetVtkRenderer());
71  }
72 }
73 
75 {
76  bool visible = true;
77  GetDataNode()->GetVisibility(visible, renderer, "visible");
78  if (!visible)
79  return;
80 
81  if (this->GetVtkProp(renderer)->GetVisibility())
82  {
83  GetVtkProp(renderer)->RenderTranslucentPolygonalGeometry(renderer->GetVtkRenderer());
84  }
85 }
86 
88 {
89  bool visible = true;
90  GetDataNode()->GetVisibility(visible, renderer, "visible");
91  if (!visible)
92  return;
93 
94  if (GetVtkProp(renderer)->GetVisibility())
95  {
96  GetVtkProp(renderer)->RenderVolumetricGeometry(renderer->GetVtkRenderer());
97  }
98 }
99 
100 bool mitk::VtkMapper::HasVtkProp(const vtkProp *prop, BaseRenderer *renderer)
101 {
102  vtkProp *myProp = this->GetVtkProp(renderer);
103 
104  // TODO: check if myProp is a vtkAssembly and if so, check if prop is contained in its leafs
105  return (prop == myProp);
106 }
107 
109 {
110  vtkLinearTransform *vtktransform = GetDataNode()->GetVtkTransform(this->GetTimestep());
111 
112  auto *prop = dynamic_cast<vtkProp3D *>(GetVtkProp(renderer));
113  if (prop)
114  prop->SetUserTransform(vtktransform);
115 }
116 
118 {
119  float rgba[4] = {1.0f, 1.0f, 1.0f, 1.0f};
120  DataNode *node = GetDataNode();
121 
122  // check for color prop and use it for rendering if it exists
123  node->GetColor(rgba, renderer, "color");
124  // check for opacity prop and use it for rendering if it exists
125  node->GetOpacity(rgba[3], renderer, "opacity");
126 
127  double drgba[4] = {rgba[0], rgba[1], rgba[2], rgba[3]};
128  actor->GetProperty()->SetColor(drgba);
129  actor->GetProperty()->SetOpacity(drgba[3]);
130 }
virtual void MitkRenderTranslucentGeometry(BaseRenderer *renderer)
Checks visiblity and renders transparent geometry.
virtual bool HasVtkProp(const vtkProp *prop, BaseRenderer *renderer)
Returns true if this mapper owns the specified vtkProp for the given BaseRenderer.
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
Organizes the rendering process.
void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor) override
Apply color and opacity properties read from the PropertyList. Called by mapper subclasses.
void MitkRender(mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type) override
Determines which geometry should be rendered (opaque, translucent, volumetric, overlay) and calls the...
bool GetOpacity(float &opacity, const mitk::BaseRenderer *renderer, const char *propertyKey="opacity") const
Convenience access method for opacity properties (instances of FloatProperty)
virtual bool IsVtkBased() const override
Returns whether this is an vtk-based mapper.
virtual void MitkRenderVolumetricGeometry(BaseRenderer *renderer)
Checks visibility and renders volumes.
bool GetColor(float rgb[3], const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="color") const
Convenience access method for color properties (instances of ColorProperty)
virtual bool GetVisibility(bool &visible, BaseRenderer *renderer, const char *name="visible") const
Convenience access method for visibility properties (instances of BoolProperty)
Definition: mitkMapper.cpp:45
virtual void MitkRenderOverlay(BaseRenderer *renderer)
Checks visibility and renders the overlay.
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer)=0
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:422
vtkLinearTransform * GetVtkTransform(int t=0) const
Get the transformation applied prior to displaying the data as a vtkTransform.
virtual void UpdateVtkTransform(mitk::BaseRenderer *renderer)
Set the vtkTransform of the m_Prop3D for the current time step of renderer.
~VtkMapper() override
int GetTimestep() const
Returns the current time step as calculated from the renderer.
Definition: mitkMapper.h:147
virtual void MitkRenderOpaqueGeometry(BaseRenderer *renderer)
Checks visibility and renders untransparent geometry.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57