#include <vtkVolumeRayCastMapper.h>
-#if VTK_MAJOR_VERSION >= 5
- #if VTK_MINOR_VERSION >= 6
- #include "vtkGPUVolumeRayCastMapper.h"
- #endif
+// EED This is code for Juan Carlos Prieto TESTES
+//#if VTK_MAJOR_VERSION >= 5
+// #if VTK_MINOR_VERSION >= 6
+// #include "vtkGPUVolumeRayCastMapper.h"
+// #endif
+//#endif
+
+#if VTK_MAJOR_VERSION >= 6
+ #include "vtkSmartVolumeMapper.h"
#endif
+
+
using namespace std;
VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, bool usegpu){
_volumeProperty = vtkVolumeProperty::New();
_volumeProperty->SetInterpolationTypeToLinear();
- _volumeProperty->ShadeOn();
+ _volumeProperty->ShadeOff();
_volumeProperty->SetAmbient(3);
_volumeProperty->SetDiffuse(0.2);
_volumeProperty->SetSpecular(0.5);
- //_volumeProperty->DisableGradientOpacityOn();
+ _volumeProperty->DisableGradientOpacityOn();
_tfun = vtkPiecewiseFunction::New();
_volumeProperty->SetScalarOpacity(_tfun );
_ctfun = vtkColorTransferFunction::New();
}
*/
- VolumeMapper = 0;
-#if VTK_MAJOR_VERSION >= 5
- #if VTK_MINOR_VERSION >= 6
- cout<<"using volume render GPU"<<endl;
- vtkGPUVolumeRayCastMapper * volumeMappergpu = vtkGPUVolumeRayCastMapper::New();
- volumeMappergpu->AutoAdjustSampleDistancesOn();
- VolumeMapper = volumeMappergpu;
- #endif
+ VolumeMapper = NULL;
+
+// EED This is code for Juan Carlos Prieto TESTES
+//#if VTK_MAJOR_VERSION >= 5
+// #if VTK_MINOR_VERSION >= 6
+// cout<<"using volume render GPU"<<endl;
+// vtkGPUVolumeRayCastMapper * volumeMappergpu = vtkGPUVolumeRayCastMapper::New();
+// volumeMappergpu->AutoAdjustSampleDistancesOn();
+// VolumeMapper = volumeMappergpu;
+// #endif
+//#else
+// _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
+// _MIPFunction = vtkVolumeRayCastMIPFunction::New();
+// vtkVolumeRayCastMapper* volumeMapper = vtkVolumeRayCastMapper::New();
+// volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
+// volumeMapper->AutoAdjustSampleDistancesOn();
+// VolumeMapper = volumeMapper;
+//#endif
+
+#if VTK_MAJOR_VERSION >= 6
+ cout<<"using SmartVolumeRenderingMapper render GPU"<<endl;
+ vtkSmartVolumeMapper * smartvolumemapper = vtkSmartVolumeMapper::New();
+ VolumeMapper = smartvolumemapper;
+ smartvolumemapper->AutoAdjustSampleDistancesOn();
#else
-
-
- _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
- _MIPFunction = vtkVolumeRayCastMIPFunction::New();
- vtkVolumeRayCastMapper* volumeMapper = vtkVolumeRayCastMapper::New();
+ _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
+ _MIPFunction = vtkVolumeRayCastMIPFunction::New();
+ vtkVolumeRayCastMapper* volumeMapper = vtkVolumeRayCastMapper::New();
+ VolumeMapper = volumeMapper;
volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
- volumeMapper->AutoAdjustSampleDistancesOn();
- VolumeMapper = volumeMapper;
+ volumeMapper->AutoAdjustSampleDistancesOn();
#endif
-
-
- VolumeMapper->SetClippingPlanes( _volumePlanes );
- _newvol->SetMapper(VolumeMapper );
- VolumeMapper->SetInput( _vol );
- VolumeMapper->Update();
- _newvol->Update();
+ VolumeMapper->SetClippingPlanes( _volumePlanes );
+ _newvol->SetMapper(VolumeMapper );
+ VolumeMapper->SetInput( _vol );
+ VolumeMapper->Update();
+ _newvol->Update();
}
VolumeRendererManagerData::~VolumeRendererManagerData()
{
-
_tfun->Delete();
_ctfun->Delete();
_volumePlanes->Delete();
if(BoxWidget){
DisableBoundingBox();
}
-
}
-void VolumeRendererManagerData::SetIndependentComponents(bool independent){
- if(independent){
+
+void VolumeRendererManagerData::SetIndependentComponents(bool independent)
+{
+ if(independent)
+ {
_volumeProperty->IndependentComponentsOn();
}else{
_volumeProperty->IndependentComponentsOff();
}
}
+
void VolumeRendererManagerData::EnableBoundingBox(vtkRenderWindowInteractor* interactor)
{
//EED9Juin2011 if(_volumeMappergpu){
- if(!BoxWidget){
+ if(!BoxWidget)
+ {
BoxWidget = vtkBoxWidget::New();
BoxWidget->SetInteractor( interactor );
BoxWidget->SetPlaceFactor(1.01);
//EED9Juin2011 }
}
-void VolumeRendererManagerData::DisableBoundingBox(){
-
- if(BoxWidget){
+void VolumeRendererManagerData::DisableBoundingBox()
+{
+ if(BoxWidget)
+ {
BoxWidget->EnabledOff();
//BoxWidget->Delete();
//BoxWidget = 0;
-
cout<<"JPRG::VolumeRendererManagerData::DisableBoundingBox"<<endl;
-
-
}
}
_newvol->Update();
}
+
+
/**
** Volume Opacity
**/
-void VolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value){
-
+void VolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value)
+{
_tfun->RemoveAllPoints();
- for(unsigned int i = 0; i < greylevel.size();i++){
+ for(unsigned int i = 0; i < greylevel.size();i++)
+ {
_tfun->AddPoint(greylevel[i], value[i]);
//std::cout<<"VolumeRendererManagerData::setVolumeOpacity "<<greylevel[i]<<" "<< value[i]<<std::endl;
- }
+ } // for i
_newvol->Update();
}
+
/**
** Volume Opacity
**/
setVolumeOpacity(greylevel, valuevector);
}
+
/**
** Check if the variables are setted correctly
**/
}
}
+
/**
** Check if the variables are setted correctly
**/
-void VolumeRendererManagerData::Update(){
+void VolumeRendererManagerData::Update()
+{
_newvol->Update();
}
+
+
/**
** get the prop3D
**/
-vtkProp3D* VolumeRendererManagerData::getProp3D(){
+vtkProp3D* VolumeRendererManagerData::getProp3D()
+{
return this->_newvol;
}
+
/**
** return the id from the daat
**/
-int VolumeRendererManagerData::getId(){
+int VolumeRendererManagerData::getId()
+{
return _id;
}
+
+
/**
** set data id
**/
-void VolumeRendererManagerData::setId(int propid){
+void VolumeRendererManagerData::setId(int propid)
+{
_id = propid;
}
+
/**
** Get the filanme
**/
-std::string VolumeRendererManagerData::getDataname(){
+std::string VolumeRendererManagerData::getDataname()
+{
return _dataname;
}
+
+
/**
** Set the filanme
**/
-void VolumeRendererManagerData::setDataname(std::string dataname){
+void VolumeRendererManagerData::setDataname(std::string dataname)
+{
_dataname = dataname;
}
-void VolumeRendererManagerData::changeCompositeMIPFunction(int function){
+
+void VolumeRendererManagerData::changeCompositeMIPFunction(int function)
+{
//checkInvariant();
- if(VolumeMapper){
-#if VTK_MAJOR_VERSION >= 5
- #if VTK_MINOR_VERSION >= 6
- if(dynamic_cast<vtkVolumeRayCastMapper*>(VolumeMapper)){
+ if(VolumeMapper!=NULL){
+#if VTK_MAJOR_VERSION >= 6
+ if(dynamic_cast<vtkVolumeRayCastMapper*>(VolumeMapper))
+ {
vtkVolumeRayCastMapper* volumemapper = dynamic_cast<vtkVolumeRayCastMapper*>(VolumeMapper);
if(function == 0){
volumemapper->SetVolumeRayCastFunction(_compositeFunction);
volumemapper->SetBlendModeToMinimumIntensity();
}
}
- #endif
#else
- vtkGPUVolumeRayCastMapper* volumemapper = dynamic_cast<vtkGPUVolumeRayCastMapper*>(VolumeMapper);
+ vtkVolumeRayCastMapper* volumemapper = dynamic_cast<vtkVolumeRayCastMapper*>(VolumeMapper);
if(function == 0){
volumemapper->SetBlendModeToComposite();
}else if(function == 1){
}
-void VolumeRendererManagerData::SetLookupTable(vtkLookupTable* lookuptable){
+void VolumeRendererManagerData::SetLookupTable(vtkLookupTable* lookuptable)
+{
if(lookuptable){
_ctfun->RemoveAllPoints();
vtkColorTransferFunction* colort = (vtkColorTransferFunction*)lookuptable;
}
-void VolumeRendererManagerData::changeInterpolationType(int type){
+void VolumeRendererManagerData::changeInterpolationType(int type)
+{
//checkInvariant();
if(type == 0){
_volumeProperty->SetInterpolationTypeToLinear();