Commit 81891b82 authored by finetjul's avatar finetjul
Browse files

ENH: Use vtkGPURayCastMapper as a volume rendering.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@12239 3bd1e089-480b-0410-8dfb-8563597acbee
parent 8db6f272
......@@ -238,6 +238,12 @@ ELSE(Slicer3_USE_KWWIDGETS)
INCLUDE(${VTK_USE_FILE})
ENDIF (Slicer3_USE_KWWIDGETS)
#-----------------------------------------------------------------------------
# Slicer3 is built with cvs head
#
option(Slicer3_USE_CVS_HEAD "Slicer3 is configurated with cvs head." OFF)
mark_as_advanced(Slicer3_USE_CVS_HEAD)
#-----------------------------------------------------------------------------
#
# Call macro defined in ${PROJECT_SOURCE_DIR}/CMake/Slicer3FindQT.cmake
......
......@@ -85,6 +85,8 @@ vtkMRMLVolumeRenderingParametersNode::vtkMRMLVolumeRenderingParametersNode()
this->GPURaycastTechniqueII = 0;
this->GPURaycastTechniqueIIFg = 0;
this->GPURaycastTechnique3 = 0;
this->CroppingEnabled = 0;//by default cropping is not enabled
......@@ -264,6 +266,13 @@ void vtkMRMLVolumeRenderingParametersNode::ReadXMLAttributes(const char** atts)
ss >> this->GPURaycastIIFusion;
continue;
}
if (!strcmp(attName,"gpuRaycastTechnique3"))
{
std::stringstream ss;
ss << attValue;
ss >> this->GPURaycastTechnique3;
continue;
}
if (!strcmp(attName,"threshold"))
{
std::stringstream ss;
......@@ -320,6 +329,7 @@ void vtkMRMLVolumeRenderingParametersNode::WriteXML(ostream& of, int nIndent)
of << indent << " gpuRaycastTechniqueII=\"" << this->GPURaycastTechniqueII << "\"";
of << indent << " gpuRaycastTechniqueIIFg=\"" << this->GPURaycastTechniqueIIFg << "\"";
of << indent << " gpuRaycastIIFusion=\"" << this->GPURaycastIIFusion << "\"";
of << indent << " gpuRaycastTechnique3=\"" << this->GPURaycastTechnique3 << "\"";
of << indent << " threshold=\"" << this->Threshold[0] << " " << this->Threshold[1] << "\"";
of << indent << " useThreshold=\"" << this->UseThreshold << "\"";
of << indent << " thresholdFg=\"" << this->ThresholdFg[0] << " " << this->ThresholdFg[1] << "\"";
......@@ -406,6 +416,7 @@ void vtkMRMLVolumeRenderingParametersNode::Copy(vtkMRMLNode *anode)
this->SetGPURaycastTechnique(node->GetGPURaycastTechnique());
this->SetGPURaycastTechniqueII(node->GetGPURaycastTechniqueII());
this->SetGPURaycastTechniqueIIFg(node->GetGPURaycastTechniqueIIFg());
this->SetGPURaycastTechnique3(node->GetGPURaycastTechnique3());
this->SetThreshold(node->GetThreshold());
this->SetUseThreshold(node->GetUseThreshold());
this->SetThresholdFg(node->GetThresholdFg());
......
......@@ -170,6 +170,9 @@ class VTK_SLICERVOLUMERENDERING_EXPORT vtkMRMLVolumeRenderingParametersNode : pu
vtkGetMacro (GPURaycastIIFusion, int);
vtkSetMacro (GPURaycastIIFusion, int);
vtkGetMacro (GPURaycastTechnique3, int);
vtkSetMacro (GPURaycastTechnique3, int);
vtkSetVector2Macro(Threshold, double);
vtkGetVectorMacro(Threshold, double, 2);
......@@ -224,7 +227,7 @@ protected:
* 1: GPU ray cast
* 2: GPU ray cast II
* 3: GPU texture mapping
* 4: CUDA ray cast
* 4: VTK GPU ray cast
*/
int CurrentVolumeMapper;
......@@ -289,6 +292,13 @@ protected:
* */
int GPURaycastIIFusion;
/* techniques in GPU ray cast 3
* 0: composite (default)
* 2: MIP
* 3: MINIP
* */
int GPURaycastTechnique3;
double Threshold[2];
double ThresholdFg[2];
......
......@@ -79,6 +79,8 @@ vtkSlicerVolumeRenderingHelper::vtkSlicerVolumeRenderingHelper(void)
this->MB_GPURayCastTechniqueII = NULL;
this->MB_GPURayCastTechniqueIIFg = NULL;
this->MB_GPURayCastTechnique3 = NULL;
this->SC_GPURayCastDepthPeelingThreshold = NULL;
this->SC_GPURayCastICPEkt = NULL;
this->SC_GPURayCastICPEks = NULL;
......@@ -430,7 +432,31 @@ void vtkSlicerVolumeRenderingHelper::CreateTechniquesTab()
this->SC_GPURayCastIIFgBgRatio->AddObserver(vtkKWScale::ScaleValueChangedEvent, (vtkCommand *) this->GUICallbackCommand);
this->Script ( "pack %s -side top -anchor nw -fill x -padx 2 -pady 2", this->SC_GPURayCastIIFgBgRatio->GetWidgetName() );
}
//GPU ray casting 3
{
this->FrameGPURayCasting3 = vtkKWFrameWithLabel::New();
this->FrameGPURayCasting3->SetParent(this->FrameTechniques->GetFrame());
this->FrameGPURayCasting3->Create();
this->FrameGPURayCasting3->AllowFrameToCollapseOff();
this->FrameGPURayCasting3->SetLabelText("VTK GPU Ray Casting");
this->Script( "pack %s -side top -anchor nw -fill x -padx 2 -pady 2", this->FrameGPURayCasting3->GetWidgetName() );
//set technique
this->MB_GPURayCastTechnique3 = vtkKWMenuButtonWithLabel::New();
this->MB_GPURayCastTechnique3->SetParent(this->FrameGPURayCasting3->GetFrame());
this->MB_GPURayCastTechnique3->SetLabelText("Technique (bg):");
this->MB_GPURayCastTechnique3->Create();
this->MB_GPURayCastTechnique3->SetLabelWidth(labelWidth);
this->MB_GPURayCastTechnique3->SetBalloonHelpString("Select GPU ray casting technique for bg volume");
this->MB_GPURayCastTechnique3->GetWidget()->GetMenu()->AddRadioButton("Composite");
this->MB_GPURayCastTechnique3->GetWidget()->GetMenu()->SetItemCommand(0, this,"ProcessGPURayCastTechnique3 0");
this->MB_GPURayCastTechnique3->GetWidget()->GetMenu()->AddRadioButton("Maximum Intensity Projection");
this->MB_GPURayCastTechnique3->GetWidget()->GetMenu()->SetItemCommand(1, this,"ProcessGPURayCastTechnique3 1");
this->MB_GPURayCastTechnique3->GetWidget()->GetMenu()->AddRadioButton("Minimum Intensity Projection");
this->MB_GPURayCastTechnique3->GetWidget()->GetMenu()->SetItemCommand(2, this,"ProcessGPURayCastTechnique3 2");
this->Script ( "pack %s -side top -anchor nw -fill x -padx 2 -pady 2", this->MB_GPURayCastTechnique3->GetWidgetName() );
}
//opengl 2D Polygon Texture 3D
{
this->FramePolygonBlending = vtkKWFrameWithLabel::New();
......@@ -483,6 +509,13 @@ void vtkSlicerVolumeRenderingHelper::DestroyTechniquesTab()
this->MB_GPURayCastTechniqueIIFg = NULL;
}
if(this->MB_GPURayCastTechnique3 != NULL)
{
this->MB_GPURayCastTechnique3->SetParent(NULL);
this->MB_GPURayCastTechnique3->Delete();
this->MB_GPURayCastTechnique3 = NULL;
}
if(this->SC_ExpectedFPS != NULL)
{
this->SC_ExpectedFPS->RemoveObservers(vtkKWScale::ScaleValueChangingEvent,(vtkCommand *) this->GUICallbackCommand);
......@@ -1299,6 +1332,28 @@ void vtkSlicerVolumeRenderingHelper::SetupGUIFromParametersNode(vtkMRMLVolumeRen
break;
}
switch(vspNode->GetGPURaycastTechnique3())
{
case 0:
this->MB_GPURayCastTechnique3->GetWidget()->SetValue("Composite With Shading");
break;
case 1:
this->MB_GPURayCastTechnique3->GetWidget()->SetValue("Composite With Fast Psuedo Shading");
break;
case 2:
this->MB_GPURayCastTechnique3->GetWidget()->SetValue("Maximum Intensity Projection");
break;
case 3:
this->MB_GPURayCastTechnique3->GetWidget()->SetValue("Minimum Intensity Projection");
break;
case 4:
this->MB_GPURayCastTechnique3->GetWidget()->SetValue("Gradient Magnitude Opacity Modulation");
break;
case 5:
this->MB_GPURayCastTechnique3->GetWidget()->SetValue("Illustrative Context Preserving Exploration");
break;
}
this->SC_GPURayCastICPEkt->GetWidget()->SetRange(0, 10);
this->SC_GPURayCastICPEkt->GetWidget()->SetResolution(0.01);
this->SC_GPURayCastICPEkt->SetValue(vspNode->GetICPEScale());
......@@ -1427,6 +1482,16 @@ void vtkSlicerVolumeRenderingHelper::ProcessGPURayCastTechniqueIIFg(int id)
this->Gui->RequestRender();
}
void vtkSlicerVolumeRenderingHelper::ProcessGPURayCastTechnique3(int id)
{
vtkMRMLVolumeRenderingParametersNode* vspNode = this->Gui->GetCurrentParametersNode();
vspNode->SetGPURaycastTechnique3(id);
this->Gui->GetLogic()->SetGPURaycast3Parameters(vspNode);
this->Gui->RequestRender();
}
void vtkSlicerVolumeRenderingHelper::ProcessGPURayCastColorOpacityFusion(int id)
{
vtkMRMLVolumeRenderingParametersNode* vspNode = this->Gui->GetCurrentParametersNode();
......@@ -1469,6 +1534,7 @@ void vtkSlicerVolumeRenderingHelper::ProcessRenderingMethodEvents(int id)
this->FrameGPURayCasting->CollapseFrame();
this->FrameGPURayCastingII->CollapseFrame();
this->FrameGPURayCasting3->CollapseFrame();
this->FramePolygonBlending->CollapseFrame();
this->FrameCPURayCasting->CollapseFrame();
......@@ -1506,7 +1572,13 @@ void vtkSlicerVolumeRenderingHelper::ProcessRenderingMethodEvents(int id)
this->Gui->GetApplicationGUI()->GetMainSlicerWindow()->SetStatusText("OpenGL Polygon Texture 3D is not supported by your computer.");
break;
case 4://vtk edge gpu ray casting
this->Gui->GetApplicationGUI()->GetMainSlicerWindow()->SetStatusText("VTK GPU Ray Casting is being integrated into Slicer.");
if (success)
{
this->FrameGPURayCasting3->ExpandFrame();
this->Gui->GetApplicationGUI()->GetMainSlicerWindow()->SetStatusText("Using GPU Raycasting 3");
}
else
this->Gui->GetApplicationGUI()->GetMainSlicerWindow()->SetStatusText("GPU ray casting 3 is not supported by your computer.");
break;
}
......@@ -1605,6 +1677,17 @@ void vtkSlicerVolumeRenderingHelper::ProcessExpectedFPS(void)
this->Gui->GetLogic()->SetExpectedFPS(vspNode);
int numViewer = this->Gui->GetApplicationGUI()->GetNumberOfViewerWidgets();
for (int i = 0; i < numViewer; i++)
{
vtkSlicerViewerWidget *slicer_viewer_widget = this->Gui->GetApplicationGUI()->GetNthViewerWidget(i);
if (slicer_viewer_widget)
{
slicer_viewer_widget->GetMainViewer()->GetRenderWindow()->SetDesiredUpdateRate (this->SC_ExpectedFPS->GetValue());
slicer_viewer_widget->GetMainViewer()->GetRenderWindow()->GetInteractor()->SetDesiredUpdateRate(this->SC_ExpectedFPS->GetValue());
}
}
this->Gui->RequestRender();
}
......
......@@ -87,6 +87,7 @@ public:
void ProcessGPURayCastTechnique(int id);
void ProcessGPURayCastTechniqueII(int id);
void ProcessGPURayCastTechniqueIIFg(int id);
void ProcessGPURayCastTechnique3(int id);
// Description:
// Callback, that is processed when the multi-volume rendering fusion method is changed
......@@ -165,6 +166,7 @@ protected:
vtkKWFrameWithLabel *FrameTechniques;
vtkKWFrameWithLabel *FrameGPURayCasting;
vtkKWFrameWithLabel *FrameGPURayCastingII;
vtkKWFrameWithLabel *FrameGPURayCasting3;
vtkKWFrameWithLabel *FramePolygonBlending;
vtkKWFrameWithLabel *FrameCPURayCasting;
vtkKWFrameWithLabel *FrameFPS;
......@@ -187,6 +189,7 @@ protected:
vtkKWMenuButtonWithLabel *MB_GPURayCastTechniqueII;
vtkKWMenuButtonWithLabel *MB_GPURayCastTechniqueIIFg;
vtkKWMenuButtonWithLabel *MB_GPURayCastTechnique3;
// Description:
// Menu button to select color/opacity fusion method in multi-volume rendering
......
......@@ -7,6 +7,9 @@
#include "vtkMatrix4x4.h"
#include "vtkPlanes.h"
#include "vtkPlane.h"
#ifdef Slicer3_USE_CVS_HEAD
#include "vtkGPUVolumeRayCastMapper.h"
#endif
#include <itksys/SystemTools.hxx>
#include <itksys/Directory.hxx>
......@@ -39,7 +42,10 @@ vtkVolumeRenderingLogic::vtkVolumeRenderingLogic(void)
this->MapperGPURaycastII = vtkSlicerGPURayCastVolumeMapper::New();
this->MapperRaycast=vtkSlicerFixedPointVolumeRayCastMapper::New();
this->MapperRaycast = vtkSlicerFixedPointVolumeRayCastMapper::New();
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3 = vtkGPUVolumeRayCastMapper::New();
#endif
//create instance of the actor
this->Volume = vtkVolume::New();
......@@ -50,6 +56,7 @@ vtkVolumeRenderingLogic::vtkVolumeRenderingLogic(void)
this->GUICallback = NULL;
this->VolumePropertyGPURaycastII = NULL;
//this->VolumePropertyGPURaycast3 = NULL;
}
vtkVolumeRenderingLogic::~vtkVolumeRenderingLogic(void)
......@@ -80,6 +87,15 @@ vtkVolumeRenderingLogic::~vtkVolumeRenderingLogic(void)
this->MapperRaycast->Delete();
this->MapperRaycast = NULL;
}
#ifdef Slicer3_USE_CVS_HEAD
if (this->MapperGPURaycast3)
{
this->MapperGPURaycast3->RemoveObservers(vtkCommand::VolumeMapperComputeGradientsProgressEvent, this->GUICallback);
this->MapperGPURaycast3->Delete();
this->MapperGPURaycast3 = NULL;
}
#endif
if (this->Volume)
{
this->Volume->Delete();
......@@ -102,6 +118,11 @@ vtkVolumeRenderingLogic::~vtkVolumeRenderingLogic(void)
this->VolumePropertyGPURaycastII->Delete();
this->VolumePropertyGPURaycastII = NULL;
}
//if (this->VolumePropertyGPURaycast3 != NULL)
//{
// this->VolumePropertyGPURaycast3->Delete();
// this->VolumePropertyGPURaycast3 = NULL;
//}
}
vtkVolumeRenderingLogic* vtkVolumeRenderingLogic::New()
......@@ -156,6 +177,9 @@ void vtkVolumeRenderingLogic::SetGUICallbackCommand(vtkCommand* callback)
this->MapperGPURaycast->AddObserver(vtkCommand::VolumeMapperComputeGradientsProgressEvent, callback);
this->MapperGPURaycastII->AddObserver(vtkCommand::VolumeMapperComputeGradientsProgressEvent, callback);
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->AddObserver(vtkCommand::VolumeMapperComputeGradientsProgressEvent, callback);
#endif
this->GUICallback = callback;
}
......@@ -188,6 +212,14 @@ void vtkVolumeRenderingLogic::Reset()
this->MapperRaycast->Delete();
this->MapperRaycast = NULL;
}
#ifdef Slicer3_USE_CVS_HEAD
if (this->MapperGPURaycast3)
{
this->MapperGPURaycast3->RemoveObservers(vtkCommand::VolumeMapperComputeGradientsProgressEvent, this->GUICallback);
this->MapperGPURaycast3->Delete();
this->MapperGPURaycast3 = NULL;
}
#endif
if (this->Volume)
{
this->Volume->Delete();
......@@ -210,7 +242,12 @@ void vtkVolumeRenderingLogic::Reset()
this->VolumePropertyGPURaycastII->Delete();
this->VolumePropertyGPURaycastII = NULL;
}
//if (this->VolumePropertyGPURaycast3 != NULL)
//{
// this->VolumePropertyGPURaycast3->Delete();
// this->VolumePropertyGPURaycast3 = NULL;
//}
//create instances of mappers
this->MapperTexture = vtkSlicerVolumeTextureMapper3D::New();
......@@ -218,7 +255,11 @@ void vtkVolumeRenderingLogic::Reset()
this->MapperGPURaycastII = vtkSlicerGPURayCastVolumeMapper::New();
this->MapperRaycast=vtkSlicerFixedPointVolumeRayCastMapper::New();
this->MapperRaycast = vtkSlicerFixedPointVolumeRayCastMapper::New();
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3 = vtkGPUVolumeRayCastMapper::New();
#endif
//create instance of the actor
this->Volume = vtkVolume::New();
......@@ -236,6 +277,9 @@ void vtkVolumeRenderingLogic::Reset()
this->MapperGPURaycast->AddObserver(vtkCommand::VolumeMapperComputeGradientsProgressEvent, this->GUICallback);
this->MapperGPURaycastII->AddObserver(vtkCommand::VolumeMapperComputeGradientsProgressEvent, this->GUICallback);
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->AddObserver(vtkCommand::VolumeMapperComputeGradientsProgressEvent, this->GUICallback);
#endif
}
vtkMRMLVolumeRenderingParametersNode* vtkVolumeRenderingLogic::CreateParametersNode()
......@@ -633,31 +677,49 @@ void vtkVolumeRenderingLogic::ComputeInternalVolumeSize(int index)
case 0://128M
this->MapperGPURaycast->SetInternalVolumeSize(200);
this->MapperGPURaycastII->SetInternalVolumeSize(200);
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->SetMaxMemoryInBytes(128*1024*1024);
#endif
this->MapperTexture->SetInternalVolumeSize(128);//has to be power-of-two in this mapper
break;
case 1://256M
this->MapperGPURaycast->SetInternalVolumeSize(256);//256^3
this->MapperGPURaycastII->SetInternalVolumeSize(256);
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->SetMaxMemoryInBytes(256*1024*1024);
#endif
this->MapperTexture->SetInternalVolumeSize(256);
break;
case 2://512M
this->MapperGPURaycast->SetInternalVolumeSize(320);
this->MapperGPURaycastII->SetInternalVolumeSize(320);
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->SetMaxMemoryInBytes(512*1024*1024);
#endif
this->MapperTexture->SetInternalVolumeSize(256);
break;
case 3://1024M
this->MapperGPURaycast->SetInternalVolumeSize(400);
this->MapperGPURaycastII->SetInternalVolumeSize(400);
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->SetMaxMemoryInBytes(1024*1024*1024);
#endif
this->MapperTexture->SetInternalVolumeSize(256);
break;
case 4://1.5G
this->MapperGPURaycast->SetInternalVolumeSize(460);
this->MapperGPURaycastII->SetInternalVolumeSize(460);
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->SetMaxMemoryInBytes(1536*1024*1024);
#endif
this->MapperTexture->SetInternalVolumeSize(256);
break;
case 5://2.0G
this->MapperGPURaycast->SetInternalVolumeSize(512);
this->MapperGPURaycastII->SetInternalVolumeSize(512);
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->SetMaxMemoryInBytes(2047*1024*1024);
#endif
this->MapperTexture->SetInternalVolumeSize(512);
break;
}
......@@ -698,6 +760,7 @@ void vtkVolumeRenderingLogic::SetExpectedFPS(vtkMRMLVolumeRenderingParametersNod
this->MapperTexture->SetFramerate(fps);
this->MapperGPURaycast->SetFramerate(fps);
this->MapperGPURaycastII->SetFramerate(fps);
//this->MapperGPURaycast3->SetFramerate(fps);
}
void vtkVolumeRenderingLogic::SetGPUMemorySize(vtkMRMLVolumeRenderingParametersNode* vspNode)
......@@ -728,6 +791,25 @@ void vtkVolumeRenderingLogic::SetGPURaycastIIParameters(vtkMRMLVolumeRenderingPa
this->MapperGPURaycastII->SetColorOpacityFusion(vspNode->GetGPURaycastIIFusion());
}
void vtkVolumeRenderingLogic::SetGPURaycast3Parameters(vtkMRMLVolumeRenderingParametersNode* vspNode)
{
#ifdef Slicer3_USE_CVS_HEAD
switch(vspNode->GetGPURaycastTechnique3())
{
default:
case 0:
this->MapperGPURaycast3->SetBlendMode(vtkVolumeMapper::COMPOSITE_BLEND);
break;
case 1:
this->MapperGPURaycast3->SetBlendMode(vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND);
break;
case 2:
this->MapperGPURaycast3->SetBlendMode(vtkVolumeMapper::MINIMUM_INTENSITY_BLEND);
break;
}
#endif
}
void vtkVolumeRenderingLogic::EstimateSampleDistance(vtkMRMLVolumeRenderingParametersNode* vspNode)
{
double *spacing = vtkMRMLScalarVolumeNode::SafeDownCast(vspNode->GetVolumeNode())->GetSpacing();
......@@ -811,6 +893,20 @@ int vtkVolumeRenderingLogic::SetupMapperFromParametersNode(vtkMRMLVolumeRenderin
return -1;
break;
case 4:
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->SetInput(vtkMRMLScalarVolumeNode::SafeDownCast(vspNode->GetVolumeNode())->GetImageData());
//this->MapperGPURaycast3->SetFramerate(vspNode->GetExpectedFPS());
//if (this->MapperGPURaycast3->IsRenderSupported(vspNode->GetVolumePropertyNode()->GetVolumeProperty()))
{
this->Volume->SetMapper(this->MapperGPURaycast3);
//this->CreateVolumePropertyGPURaycast3(vspNode);
//this->Volume->SetProperty(this->VolumePropertyGPURaycast3);
this->Volume->SetProperty(vspNode->GetVolumePropertyNode()->GetVolumeProperty());
}
#endif
//else
// return -1;
break;
}
......@@ -896,10 +992,15 @@ void vtkVolumeRenderingLogic::SetROI(vtkMRMLVolumeRenderingParametersNode* vspNo
this->MapperGPURaycast->ClippingOff();
this->MapperGPURaycastII->RemoveAllClippingPlanes();
this->MapperGPURaycastII->ClippingOff();
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->RemoveAllClippingPlanes();
//this->MapperGPURaycast3->ClippingOff();
#endif
if (vspNode->GetCroppingEnabled())
{
vtkPlanes *planes = vtkPlanes::New();
//vspNode->GetROINode()->SetInsideOut(0);
vspNode->GetROINode()->GetTransformedPlanes(planes);
this->MapperTexture->SetClippingPlanes(planes);
......@@ -911,6 +1012,11 @@ void vtkVolumeRenderingLogic::SetROI(vtkMRMLVolumeRenderingParametersNode* vspNo
this->MapperGPURaycastII->SetClippingPlanes(planes);
this->MapperGPURaycastII->ClippingOn();
#ifdef Slicer3_USE_CVS_HEAD
this->MapperGPURaycast3->SetClippingPlanes(planes);
//this->MapperGPURaycast3->ClippingOn();
#endif
planes->Delete();
}
}
......@@ -997,6 +1103,60 @@ void vtkVolumeRenderingLogic::CreateVolumePropertyGPURaycastII(vtkMRMLVolumeRend
this->Volume->SetProperty(this->VolumePropertyGPURaycastII);
}
/*
void vtkVolumeRenderingLogic::UpdateVolumePropertyGPURaycast3(vtkMRMLVolumeRenderingParametersNode* vspNode)
{
if (vspNode->GetCurrentVolumeMapper() == 5)
{
this->CreateVolumePropertyGPURaycast3(vspNode);
this->Volume->SetProperty(this->VolumePropertyGPURaycast3);
}
}
void vtkVolumeRenderingLogic::CreateVolumePropertyGPURaycast3(vtkMRMLVolumeRenderingParametersNode* vspNode)
{
if (vspNode->GetCurrentVolumeMapper() != 5)
return;
if (this->VolumePropertyGPURaycast3 != NULL)
this->VolumePropertyGPURaycast3->Delete();
this->VolumePropertyGPURaycast3 = vtkVolumeProperty::New();
//copy bg property into 1st compoent property
vtkVolumeProperty* prop = vspNode->GetVolumePropertyNode()->GetVolumeProperty();
{
int colorChannels = prop->GetColorChannels(0);
switch(colorChannels)
{
case 1:
this->VolumePropertyGPURaycast3->SetColor(0, prop->GetGrayTransferFunction(0));
break;
case 3:
this->VolumePropertyGPURaycast3->SetColor(0, prop->GetRGBTransferFunction(0));
break;
}
this->VolumePropertyGPURaycast3->SetScalarOpacity(0, prop->GetScalarOpacity(0));
this->VolumePropertyGPURaycast3->SetGradientOpacity(0, prop->GetGradientOpacity(0));
this->VolumePropertyGPURaycast3->SetScalarOpacityUnitDistance(0, prop->GetScalarOpacityUnitDistance(0));
this->VolumePropertyGPURaycast3->SetDisableGradientOpacity(0, prop->GetDisableGradientOpacity(0));
this->VolumePropertyGPURaycast3->SetShade(0, prop->GetShade(0));
this->VolumePropertyGPURaycast3->SetAmbient(0, prop->GetAmbient(0));
this->VolumePropertyGPURaycast3->SetDiffuse(0, prop->GetDiffuse(0));
this->VolumePropertyGPURaycast3->SetSpecular(0, prop->GetSpecular(0));
this->VolumePropertyGPURaycast3->SetSpecularPower(0, prop->GetSpecularPower(0));
this->VolumePropertyGPURaycast3->SetIndependentComponents(prop->GetIndependentComponents());
this->VolumePropertyGPURaycast3->SetInterpolationType(prop->GetInterpolationType());
}
this->Volume->SetProperty(this->VolumePropertyGPURaycast3);
}
*/
//----------------------------------------------------------------------------
void vtkVolumeRenderingLogic::ProcessMRMLEvents(vtkObject *vtkNotUsed(caller),
......
......@@ -13,6 +13,7 @@ class vtkSlicerVolumeTextureMapper3D;
class vtkSlicerFixedPointVolumeRayCastMapper;
class vtkSlicerGPURayCastVolumeTextureMapper3D;
class vtkSlicerGPURayCastVolumeMapper;
class vtkGPUVolumeRayCastMapper;
class vtkKWHistogramSet;
......@@ -79,6 +80,7 @@ public:
void SetCPURaycastParameters(vtkMRMLVolumeRenderingParametersNode* vspNode);
void SetGPURaycastParameters(vtkMRMLVolumeRenderingParametersNode* vspNode);
void SetGPURaycastIIParameters(vtkMRMLVolumeRenderingParametersNode* vspNode);
void SetGPURaycast3Parameters(vtkMRMLVolumeRenderingParametersNode* vspNode);
void SetROI(vtkMRMLVolumeRenderingParametersNode* vspNode);
void UpdateVolumePropertyScalarRange(vtkMRMLVolumeRenderingParametersNode* vspNode);
......@@ -90,6 +92,9 @@ public:
void UpdateVolumePropertyByDisplayNode(vtkMRMLVolumeRenderingParametersNode* vspNode);
//void CreateVolumePropertyGPURaycast3(vtkMRMLVolumeRenderingParametersNode* vspNode);
//void UpdateVolumePropertyGPURaycast3(vtkMRMLVolumeRenderingParametersNode* vspNode);
void TransformModified(vtkMRMLVolumeRenderingParametersNode* vspNode);
void SetVolumeVisibility(int isVisible);
......@@ -126,6 +131,10 @@ protected:
// The software accelerated software mapper
vtkSlicerFixedPointVolumeRayCastMapper *MapperRaycast;
// Description:
// The gpu ray cast mapper.
vtkGPUVolumeRayCastMapper *MapperGPURaycast3;
// Description:
// Actor used for Volume Rendering
vtkVolume *Volume;
......@@ -142,6 +151,9 @@ protected:
vtkVolumeProperty *VolumePropertyGPURaycastII;
//vtkVolumeProperty *VolumePropertyGPURaycast3;
protected:
void ComputeInternalVolumeSize(int index);
void CalculateMatrix(vtkMRMLVolumeRenderingParametersNode *vspNode, vtkMatrix4x4 *output);
......