13 #define GPU_INFO MITK_INFO("mapper.vr") 14 #define GPU_WARN MITK_WARN("mapper.vr") 15 #define GPU_ERROR MITK_ERROR("mapper.vr") 33 #include <vtkProperty.h> 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> 45 #include <vtkRenderWindow.h> 46 #include <vtkRenderWindowInteractor.h> 47 #include <vtkVolume.h> 48 #include <vtkVolumeProperty.h> 50 #include <vtkCubeSource.h> 51 #include <vtkPolyDataMapper.h> 55 #include "vtkOpenGLGPUVolumeRayCastMapper.h" 84 ls->
m_MapperCPU = vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();
85 int numThreads = ls->
m_MapperCPU->GetNumberOfThreads();
87 GPU_INFO <<
"initializing cpu-raycast-vr (vtkFixedPointVolumeRayCastMapper) (" << numThreads <<
" threads)";
103 ls->
m_VolumeCPU = vtkSmartPointer<vtkVolume>::New();
120 GPU_INFO <<
"deinitializing cpu-raycast-vr";
182 if (!input || !input->IsInitialized())
187 if (inputData ==
nullptr)
200 GPU_WARN <<
"hardware renderer can't initialize ... falling back to software renderer";
210 GPU_WARN <<
"hardware renderer can't initialize ... falling back to software renderer";
313 if (
GetDataNode()->GetFloatProperty(
"volumerendering.cpu.ambient", value, renderer))
315 if (
GetDataNode()->GetFloatProperty(
"volumerendering.cpu.diffuse", value, renderer))
317 if (
GetDataNode()->GetFloatProperty(
"volumerendering.cpu.specular", value, renderer))
319 if (
GetDataNode()->GetFloatProperty(
"volumerendering.cpu.specular.power", value, renderer))
360 bool isBinary =
false;
370 colorTransferFunction->RemoveAllPoints();
373 rgb[0] = rgb[1] = rgb[2] = 1;
374 colorTransferFunction->AddRGBPoint(0, rgb[0], rgb[1], rgb[2]);
375 colorTransferFunction->Modified();
379 auto *transferFunctionProp =
382 if (transferFunctionProp)
384 opacityTransferFunction = transferFunctionProp->
GetValue()->GetScalarOpacityFunction();
385 gradientTransferFunction = transferFunctionProp->GetValue()->GetGradientOpacityFunction();
386 colorTransferFunction = transferFunctionProp->GetValue()->GetColorTransferFunction();
453 if (image.IsNotNull() && image->IsInitialized())
455 if ((overwrite) || (node->
GetProperty(
"levelwindow", renderer) ==
nullptr))
460 levWinProp->SetLevelWindow(levelwindow);
461 node->
SetProperty(
"levelwindow", levWinProp, renderer);
464 if ((overwrite) || (node->
GetProperty(
"TransferFunction", renderer) ==
nullptr))
469 tfInit->SetTransferFunctionMode(0);
474 Superclass::SetDefaultProperties(node, renderer, overwrite);
505 GPU_INFO <<
"initializing gpu-raycast-vr (vtkOpenGLGPUVolumeRayCastMapper)";
507 ls->
m_MapperRAY = vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper>::New();
519 ls->
m_VolumeRAY = vtkSmartPointer<vtkVolume>::New();
538 GPU_INFO <<
"deinitializing gpu-raycast-vr";
570 if (
GetDataNode()->GetFloatProperty(
"volumerendering.ray.ambient", value, renderer))
572 if (
GetDataNode()->GetFloatProperty(
"volumerendering.ray.diffuse", value, renderer))
574 if (
GetDataNode()->GetFloatProperty(
"volumerendering.ray.specular", value, renderer))
576 if (
GetDataNode()->GetFloatProperty(
"volumerendering.ray.specular.power", value, renderer))
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. ...
vtkRenderWindow * m_VtkRenderWindow
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.
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...
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.
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.
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)
bool IsRenderable(mitk::BaseRenderer *renderer)
Image class for storing images.
~GPUVolumeMapper3D() override
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...
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 *)
void GenerateDataCPU(mitk::BaseRenderer *renderer)
void UpdateTransferFunctions(mitk::BaseRenderer *renderer)
int GetNextLOD(BaseRenderer *renderer)
mitk::Image::Pointer image
void DeinitCPU(mitk::BaseRenderer *renderer)
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.
void CreateDefaultTransferFunctions()
mitk::LocalStorageHandler< LocalStorage > m_LSH
void MitkRenderVolumetricGeometry(mitk::BaseRenderer *renderer) override
Checks visibility and renders volumes.
bool IsLODEnabled(BaseRenderer *renderer=nullptr) const override
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.
vtkSmartPointer< vtkPiecewiseFunction > m_BinaryGradientTransferFunction
vtkSmartPointer< vtkFixedPointVolumeRayCastMapper > m_MapperCPU