2 #include "wxMaracasMultipleVolumeRendererManagerData.h"
4 /********************************************************************************************
5 ** Start of data viewmanagerData
6 *********************************************************************************************/
8 wxMaracasMultipleVolumeRendererManagerData::wxMaracasMultipleVolumeRendererManagerData(vtkImageData* vol, std::string dataname){
13 _tfun = vtkPiecewiseFunction::New();
14 _ctfun = vtkColorTransferFunction::New();
16 _volumePlanes = vtkPlanes::New();
17 _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
18 _MIPFunction = vtkVolumeRayCastMIPFunction::New();
20 _volumeMapper = vtkVolumeRayCastMapper::New();
21 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
22 _volumeMapper->SetClippingPlanes( _volumePlanes );
23 _volumeMapper->AutoAdjustSampleDistancesOn();
24 _volumeProperty = vtkVolumeProperty::New();
25 _volumeProperty->SetInterpolationTypeToLinear();
26 _volumeProperty->ShadeOn();
27 _volumeProperty->DisableGradientOpacityOn();
28 _volumeProperty->SetColor(_ctfun);
29 _volumeProperty->SetScalarOpacity(_tfun );
31 _newvol = vtkVolume::New();
32 _newvol->SetMapper(_volumeMapper );
33 _newvol->SetProperty(_volumeProperty );
34 _volumeMapper->SetInput( _vol );
35 _volumeMapper->Update();
40 wxMaracasMultipleVolumeRendererManagerData::~wxMaracasMultipleVolumeRendererManagerData(){
44 _volumePlanes->Delete();
45 _compositeFunction->Delete();
46 _volumeMapper->Delete();
47 _volumeProperty->Delete();
54 void wxMaracasMultipleVolumeRendererManagerData::setVolumeColor(std::vector<double>& greylevelcolors,
55 std::vector<double>& red,
56 std::vector<double>& green,
57 std::vector<double>& blue)
60 _ctfun->RemoveAllPoints();
61 for(int i = 0; i < greylevelcolors.size();i++){
62 _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
63 //std::cout<<"wxMaracasMultipleVolumeRendererManagerData::setVolumeColor "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
71 void wxMaracasMultipleVolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value){
73 _tfun->RemoveAllPoints();
74 for(int i = 0; i < greylevel.size();i++){
75 _tfun->AddPoint(greylevel[i], value[i]);
76 //std::cout<<"wxMaracasMultipleVolumeRendererManagerData::setVolumeOpacity "<<greylevel[i]<<" "<< value[i]<<std::endl;
82 ** Check if the variables are setted correctly
84 void wxMaracasMultipleVolumeRendererManagerData::checkInvariant()throw (char *){
85 if(!_compositeFunction){
86 throw "No composite function initialized";
89 throw "No MIP function initialized";
92 throw "No volume mapper initialized";
97 ** Check if the variables are setted correctly
99 void wxMaracasMultipleVolumeRendererManagerData::Update(){
105 vtkProp3D* wxMaracasMultipleVolumeRendererManagerData::getProp3D(){
106 return this->_newvol;
109 ** return the id from the daat
111 int wxMaracasMultipleVolumeRendererManagerData::getId(){
117 void wxMaracasMultipleVolumeRendererManagerData::setId(int propid){
124 std::string wxMaracasMultipleVolumeRendererManagerData::getDataname(){
130 void wxMaracasMultipleVolumeRendererManagerData::setDataname(std::string dataname){
131 _dataname = dataname;
134 void wxMaracasMultipleVolumeRendererManagerData::changeCompositeMIPFunction(int function) throw (char *){
137 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
139 _volumeMapper->SetVolumeRayCastFunction(_MIPFunction);