32 #include <vtkProperty.h>
33 #include <vtkUnstructuredGrid.h>
34 #include <vtkVolume.h>
35 #include <vtkVolumeProperty.h>
37 #include <vtkPlanes.h>
55 m_VtkDataSetMapper->SetResolveCoincidentTopologyToPolygonOffset();
56 m_VtkDataSetMapper->SetResolveCoincidentTopologyPolygonOffsetParameters(0, 1);
57 m_Actor->SetMapper(m_VtkDataSetMapper);
60 m_VtkDataSetMapper2->SetResolveCoincidentTopologyToPolygonOffset();
61 m_VtkDataSetMapper2->SetResolveCoincidentTopologyPolygonOffsetParameters(1, 1);
62 m_ActorWireframe->SetMapper(m_VtkDataSetMapper2);
63 m_ActorWireframe->GetProperty()->SetRepresentationToWireframe();
65 m_Assembly->AddPart(m_Actor);
66 m_Assembly->AddPart(m_ActorWireframe);
67 m_Assembly->AddPart(m_Volume);
69 m_VtkVolumeRayCastMapper = 0;
71 m_VtkVolumeZSweepMapper = 0;
78 if (m_VtkTriangleFilter != 0)
79 m_VtkTriangleFilter->Delete();
81 if (m_VtkVolumeRayCastMapper != 0)
82 m_VtkVolumeRayCastMapper->Delete();
84 if (m_VtkVolumeZSweepMapper != 0)
85 m_VtkVolumeZSweepMapper->Delete();
87 if (m_VtkPTMapper != 0)
88 m_VtkPTMapper->Delete();
90 if (m_VtkDataSetMapper != 0)
91 m_VtkDataSetMapper->Delete();
93 if (m_VtkDataSetMapper2 != 0)
94 m_VtkDataSetMapper2->Delete();
102 if (m_ActorWireframe != 0)
103 m_ActorWireframe->Delete();
121 if (needGenerateData)
125 m_Assembly->VisibilityOn();
127 m_ActorWireframe->GetProperty()->SetAmbient(1.0);
128 m_ActorWireframe->GetProperty()->SetDiffuse(0.0);
129 m_ActorWireframe->GetProperty()->SetSpecular(0.0);
132 if (node->GetProperty(transferFuncProp,
"TransferFunction"))
135 if (transferFunction->GetColorTransferFunction()->GetSize() < 2)
141 vtkUnstructuredGrid *grid = input->GetVtkUnstructuredGrid(this->GetTimestep());
145 double *scalarRange = grid->GetScalarRange();
146 vtkColorTransferFunction *colorFunc = transferFunction->GetColorTransferFunction();
147 colorFunc->RemoveAllPoints();
148 colorFunc->AddRGBPoint(scalarRange[0], 1, 0, 0);
149 colorFunc->AddRGBPoint((scalarRange[0] + scalarRange[1]) / 2.0, 0, 1, 0);
150 colorFunc->AddRGBPoint(scalarRange[1], 0, 0, 1);
156 GetDataNode()->GetVisibility(visible, renderer,
"visible");
160 m_Assembly->VisibilityOff();
172 vtkUnstructuredGrid *grid = input->GetVtkUnstructuredGrid(this->GetTimestep());
175 m_Assembly->VisibilityOff();
179 m_Assembly->VisibilityOn();
181 m_VtkTriangleFilter->SetInputData(grid);
182 m_VtkDataSetMapper->SetInput(grid);
183 m_VtkDataSetMapper2->SetInput(grid);
186 node->GetBoolProperty(
"enable clipping", clip);
188 if (clip && bbNode.IsNotNull())
190 m_VtkDataSetMapper->SetBoundingObject(dynamic_cast<mitk::BoundingObject *>(bbNode->GetData()));
191 m_VtkDataSetMapper2->SetBoundingObject(dynamic_cast<mitk::BoundingObject *>(bbNode->GetData()));
195 m_VtkDataSetMapper->SetBoundingObject(0);
196 m_VtkDataSetMapper2->SetBoundingObject(0);
202 ApplyProperties(0, renderer);
207 m_Assembly->VisibilityOff();
213 ApplyColorAndOpacityProperties(renderer, m_Actor);
214 ApplyColorAndOpacityProperties(renderer, m_ActorWireframe);
216 vtkVolumeProperty *volProp = m_Volume->GetProperty();
217 vtkProperty *
property = m_Actor->GetProperty();
218 vtkProperty *wireframeProp = m_ActorWireframe->GetProperty();
224 if (node->GetProperty(transferFuncProp,
"TransferFunction", renderer))
228 volProp->SetColor(transferFunction->GetColorTransferFunction());
229 volProp->SetScalarOpacity(transferFunction->GetScalarOpacityFunction());
230 volProp->SetGradientOpacity(transferFunction->GetGradientOpacityFunction());
232 m_VtkDataSetMapper->SetLookupTable(transferFunction->GetColorTransferFunction());
233 m_VtkDataSetMapper2->SetLookupTable(transferFunction->GetColorTransferFunction());
236 bool isVolumeRenderingOn =
false;
237 node->GetBoolProperty(
"volumerendering", isVolumeRenderingOn, renderer);
239 if (isVolumeRenderingOn)
241 m_Assembly->RemovePart(m_Actor);
242 m_Assembly->RemovePart(m_ActorWireframe);
243 m_Assembly->AddPart(m_Volume);
246 if (node->GetProperty(mapperProp,
"volumerendering.mapper", renderer))
252 if (m_VtkVolumeRayCastMapper == 0)
255 m_VtkVolumeRayCastMapper->SetInputConnection(m_VtkTriangleFilter->GetOutputPort());
257 m_Volume->SetMapper(m_VtkVolumeRayCastMapper);
260 if (m_VtkPTMapper == 0)
263 m_VtkPTMapper->SetInputConnection(m_VtkTriangleFilter->GetOutputPort());
265 m_Volume->SetMapper(m_VtkPTMapper);
268 if (m_VtkVolumeZSweepMapper == 0)
271 m_VtkVolumeZSweepMapper->SetInputConnection(m_VtkTriangleFilter->GetOutputPort());
273 m_Volume->SetMapper(m_VtkVolumeZSweepMapper);
280 m_Assembly->RemovePart(m_Volume);
281 m_Assembly->AddPart(m_Actor);
282 m_Assembly->RemovePart(m_ActorWireframe);
285 if (node->GetProperty(gridRepProp,
"grid representation", renderer))
291 property->SetRepresentationToPoints();
294 property->SetRepresentationToWireframe();
297 property->SetRepresentationToSurface();
331 if (node->GetProperty(scalarMode,
"scalar mode", renderer))
333 if (m_VtkVolumeRayCastMapper)
337 if (m_VtkVolumeZSweepMapper)
345 if (m_VtkVolumeRayCastMapper)
348 m_VtkPTMapper->SetScalarModeToDefault();
349 if (m_VtkVolumeZSweepMapper)
350 m_VtkVolumeZSweepMapper->SetScalarModeToDefault();
352 m_VtkDataSetMapper->SetScalarModeToDefault();
353 m_VtkDataSetMapper2->SetScalarModeToDefault();
356 bool scalarVisibility =
true;
357 node->GetBoolProperty(
"scalar visibility", scalarVisibility, renderer);
358 m_VtkDataSetMapper->SetScalarVisibility(scalarVisibility ? 1 : 0);
359 m_VtkDataSetMapper2->SetScalarVisibility(scalarVisibility ? 1 : 0);
408 if (overwrite || node->
GetProperty(
"TransferFunction", renderer) == 0)
416 Superclass::SetDefaultProperties(node, renderer, overwrite);
virtual ~UnstructuredGridVtkMapper3D()
Base class for mapper specific rendering ressources.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Organizes the rendering process.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
UnstructuredGridVtkMapper3D()
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
virtual DataStorage::Pointer GetDataStorage() const
virtual void SetScalarModeToDefault()
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 ...
bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Mapper *mapper, mitk::DataNode *dataNode) const
void ApplyProperties(vtkActor *, mitk::BaseRenderer *renderer) override
Apply color and opacity properties read from the PropertyList.
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
virtual int GetVtkScalarMode()
static void ApplyMitkPropertiesToVtkProperty(mitk::DataNode *node, vtkProperty *property, mitk::BaseRenderer *renderer)
virtual const mitk::UnstructuredGrid * GetInput()
static void SetDefaultPropertiesForVtkProperty(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite)
virtual void ResetMapper(BaseRenderer *) override
Reset the mapper (i.e., make sure that nothing is displayed) if no valid data is present. In most cases the reimplemented function disables the according actors (toggling visibility off)
static vtkUnstructuredGridMapper * New()
void UpdateGenerateDataTime()
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
Class for storing unstructured grids (vtkUnstructuredGrid)
void SetProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr)
Set the property (instance of BaseProperty) with key propertyKey in the PropertyList of the renderer ...
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
Class for nodes of the DataTree.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.