00001 00002 #include "wxMaracasMultipleVolumeRendererManagerData.h" 00003 00004 /******************************************************************************************** 00005 ** Start of data viewmanagerData 00006 *********************************************************************************************/ 00007 00008 wxMaracasMultipleVolumeRendererManagerData::wxMaracasMultipleVolumeRendererManagerData(vtkImageData* vol, std::string dataname){ 00009 00010 _vol = vol; 00011 _dataname = dataname; 00012 00013 _tfun = vtkPiecewiseFunction::New(); 00014 _ctfun = vtkColorTransferFunction::New(); 00015 00016 _volumePlanes = vtkPlanes::New(); 00017 _compositeFunction = vtkVolumeRayCastCompositeFunction::New(); 00018 _MIPFunction = vtkVolumeRayCastMIPFunction::New(); 00019 00020 _volumeMapper = vtkVolumeRayCastMapper::New(); 00021 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction); 00022 _volumeMapper->SetClippingPlanes( _volumePlanes ); 00023 _volumeMapper->AutoAdjustSampleDistancesOn(); 00024 _volumeProperty = vtkVolumeProperty::New(); 00025 _volumeProperty->SetInterpolationTypeToLinear(); 00026 //_volumeProperty->ShadeOn(); 00027 _volumeProperty->DisableGradientOpacityOn(); 00028 _volumeProperty->SetColor(_ctfun); 00029 _volumeProperty->SetScalarOpacity(_tfun ); 00030 00031 _newvol = vtkVolume::New(); 00032 _newvol->SetMapper(_volumeMapper ); 00033 _newvol->SetProperty(_volumeProperty ); 00034 _volumeMapper->SetInput( _vol ); 00035 _volumeMapper->Update(); 00036 _newvol->Update(); 00037 } 00038 00039 00040 wxMaracasMultipleVolumeRendererManagerData::~wxMaracasMultipleVolumeRendererManagerData(){ 00041 00042 _tfun->Delete(); 00043 _ctfun->Delete(); 00044 _volumePlanes->Delete(); 00045 _compositeFunction->Delete(); 00046 _volumeMapper->Delete(); 00047 _volumeProperty->Delete(); 00048 _newvol->Delete(); 00049 00050 } 00054 void wxMaracasMultipleVolumeRendererManagerData::setVolumeColor(std::vector<double>& greylevelcolors, 00055 std::vector<double>& red, 00056 std::vector<double>& green, 00057 std::vector<double>& blue) 00058 { 00059 00060 _ctfun->RemoveAllPoints(); 00061 for(int i = 0; i < greylevelcolors.size();i++){ 00062 _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]); 00063 //std::cout<<"wxMaracasMultipleVolumeRendererManagerData::setVolumeColor "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl; 00064 } 00065 _newvol->Update(); 00066 } 00067 00071 void wxMaracasMultipleVolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value){ 00072 00073 _tfun->RemoveAllPoints(); 00074 for(int i = 0; i < greylevel.size();i++){ 00075 _tfun->AddPoint(greylevel[i], value[i]); 00076 //std::cout<<"wxMaracasMultipleVolumeRendererManagerData::setVolumeOpacity "<<greylevel[i]<<" "<< value[i]<<std::endl; 00077 } 00078 _newvol->Update(); 00079 } 00080 00084 void wxMaracasMultipleVolumeRendererManagerData::checkInvariant()throw (char *){ 00085 if(!_compositeFunction){ 00086 throw "No composite function initialized"; 00087 } 00088 if(!_MIPFunction){ 00089 throw "No MIP function initialized"; 00090 } 00091 if(!_volumeMapper){ 00092 throw "No volume mapper initialized"; 00093 } 00094 } 00095 00099 void wxMaracasMultipleVolumeRendererManagerData::Update(){ 00100 _newvol->Update(); 00101 } 00105 vtkProp3D* wxMaracasMultipleVolumeRendererManagerData::getProp3D(){ 00106 return this->_newvol; 00107 } 00111 int wxMaracasMultipleVolumeRendererManagerData::getId(){ 00112 return _id; 00113 } 00117 void wxMaracasMultipleVolumeRendererManagerData::setId(int propid){ 00118 _id = propid; 00119 } 00120 00124 std::string wxMaracasMultipleVolumeRendererManagerData::getDataname(){ 00125 return _dataname; 00126 } 00130 void wxMaracasMultipleVolumeRendererManagerData::setDataname(std::string dataname){ 00131 _dataname = dataname; 00132 } 00133 00134 void wxMaracasMultipleVolumeRendererManagerData::changeCompositeMIPFunction(int function) throw (char *){ 00135 checkInvariant(); 00136 if(function == 0){ 00137 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction); 00138 }else{ 00139 _volumeMapper->SetVolumeRayCastFunction(_MIPFunction); 00140 } 00141 00142 }