2 #include "volumerenderermanagerdata.h"
4 /********************************************************************************************
5 ** Start of data viewmanagerData
6 *********************************************************************************************/
8 VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, std::string dataname){
10 Initialize(vol, dataname);
15 VolumeRendererManagerData::VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname){
17 Initialize(vol, dataname);
18 render->AddActor(this->getProp3D());
21 void VolumeRendererManagerData::Initialize(vtkImageData* vol, std::string dataname){
25 _tfun = vtkPiecewiseFunction::New();
26 _ctfun = vtkColorTransferFunction::New();
28 _volumePlanes = vtkPlanes::New();
29 _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
30 _MIPFunction = vtkVolumeRayCastMIPFunction::New();
32 _volumeMapper = vtkVolumeRayCastMapper::New();
33 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
34 _volumeMapper->SetClippingPlanes( _volumePlanes );
35 _volumeMapper->AutoAdjustSampleDistancesOn();
36 _volumeProperty = vtkVolumeProperty::New();
37 _volumeProperty->SetInterpolationTypeToLinear();
38 //_volumeProperty->ShadeOn();
39 _volumeProperty->DisableGradientOpacityOn();
40 _volumeProperty->SetColor(_ctfun);
41 _volumeProperty->SetScalarOpacity(_tfun );
43 _newvol = vtkVolume::New();
44 _newvol->SetMapper(_volumeMapper );
45 _newvol->SetProperty(_volumeProperty );
46 _volumeMapper->SetInput( _vol );
47 _volumeMapper->Update();
52 VolumeRendererManagerData::~VolumeRendererManagerData(){
56 _volumePlanes->Delete();
57 _compositeFunction->Delete();
58 _volumeMapper->Delete();
59 _volumeProperty->Delete();
66 void VolumeRendererManagerData::setVolumeColor(std::vector<double>& greylevelcolors,
67 std::vector<double>& red,
68 std::vector<double>& green,
69 std::vector<double>& blue)
72 _ctfun->RemoveAllPoints();
73 for(int i = 0; i < greylevelcolors.size();i++){
74 _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
75 //std::cout<<"VolumeRendererManagerData::setVolumeColor "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
83 void VolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value){
85 _tfun->RemoveAllPoints();
86 for(int i = 0; i < greylevel.size();i++){
87 _tfun->AddPoint(greylevel[i], value[i]);
88 //std::cout<<"VolumeRendererManagerData::setVolumeOpacity "<<greylevel[i]<<" "<< value[i]<<std::endl;
94 ** Check if the variables are setted correctly
96 void VolumeRendererManagerData::checkInvariant()throw (char *){
97 if(!_compositeFunction){
98 throw "No composite function initialized";
101 throw "No MIP function initialized";
104 throw "No volume mapper initialized";
109 ** Check if the variables are setted correctly
111 void VolumeRendererManagerData::Update(){
117 vtkProp3D* VolumeRendererManagerData::getProp3D(){
118 return this->_newvol;
121 ** return the id from the daat
123 int VolumeRendererManagerData::getId(){
129 void VolumeRendererManagerData::setId(int propid){
136 std::string VolumeRendererManagerData::getDataname(){
142 void VolumeRendererManagerData::setDataname(std::string dataname){
143 _dataname = dataname;
146 void VolumeRendererManagerData::changeCompositeMIPFunction(int function) throw (char *){
149 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
151 _volumeMapper->SetVolumeRayCastFunction(_MIPFunction);
156 void VolumeRendererManagerData::SetLookupTable(vtkLookupTable* lookuptable){
157 _ctfun->RemoveAllPoints();
158 _ctfun->DeepCopy((vtkColorTransferFunction*)lookuptable);