X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxMPRBaseData.cxx;h=e1b7c370dec6bffd60f649ef9622cb86dc43fd17;hb=24937478048aca664712bb708240bff79879e0d9;hp=9358a924ab69a01bc3a9ae2e6a2d3e7a70c12f8b;hpb=3fdde2fc9525d85df4fcdd49dab89ab19266cf84;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx index 9358a92..e1b7c37 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx @@ -18,90 +18,6 @@ //------------------------------------------------------------------- //------------------------------------------------------------------- -vtkBaseData::vtkBaseData() -{ - - _z = 0; - _t = 0; - _marImageData = NULL; -} - -//------------------------------------------------------------------- -vtkBaseData::~vtkBaseData() -{ -} - -//------------------------------------------------------------------- -void vtkBaseData::SetMarImageData(marImageData *marimagedata) -{ - _marImageData = marimagedata; - Configure(); -} - -//------------------------------------------------------------------- -vtkImageData* vtkBaseData::GetImageData() -{ - return _marImageData->GetImageDataT(_t); -} -//------------------------------------------------------------------- -marImageData* vtkBaseData::GetMarImageData() -{ - return _marImageData; -} - -//------------------------------------------------------------------- - -void vtkBaseData::Configure() // virtual -{ -} - -//------------------------------------------------------------------- -void vtkBaseData::SetZ(double z){ - int maxZ; - -// int dim[3]; -// _marImageData->GetDimensions(dim); -// maxZ=dim[2]; - - int ext[6]; - _marImageData->GetImageData()->GetWholeExtent(ext); - maxZ=ext[5]-ext[4]+1; - - if (z>=maxZ) - { - z=maxZ-1; - } - if (z<=0) - { - z=0; - } - - _z=z; -} -//------------------------------------------------------------------- -double vtkBaseData::GetZ() -{ - return _z; -} -//------------------------------------------------------------------- -int vtkBaseData::GetT() -{ - return _t; -} -//------------------------------------------------------------------- -void vtkBaseData::SetT(double t) -{ - int maxT = _marImageData->GetMaxT(); - if (t>=maxT) - { - t=maxT-1; - } - if (t<=0) - { - t=0; - } - _t=t; -} //------------------------------------------------------------------- //------------------------------------------------------------------- @@ -111,7 +27,14 @@ vtkMPRBaseData::vtkMPRBaseData() _x=0; _y=0; _z=0; + _x1 = 0; + _x2 = 0; + _y1 = 0; + _y2 = 0; + _z1 = 0; + _z2 = 0; _transformOrientation = NULL; + _marImageData = NULL; } //------------------------------------------------------------------- vtkMPRBaseData::~vtkMPRBaseData() @@ -122,8 +45,15 @@ vtkMPRBaseData::~vtkMPRBaseData() //------------------------------------------------------------------- void vtkMPRBaseData::Configure() { - _marImageData->GetImageData()->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2); - _transformOrientation=vtkTransform::New(); + vtkImageData* img = _marImageData->GetImageData(); + if(img !=NULL){ + img->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2); + //std::cout<<"vtkMPRBaseData::Configure() _x1= "<<_x1<<" _x2= "<<_x2<<" _y1= "<<_y1<<" _y2= "<<_y2<<" _z1= "<<_z1<<" _z2= "<<_z2<Identity(); } //------------------------------------------------------------------- @@ -156,6 +86,7 @@ int vtkMPRBaseData::GetMaxPositionZ( ) //------------------------------------------------------------------- double vtkMPRBaseData::GetX() { + return _x; } //------------------------------------------------------------------- @@ -164,38 +95,77 @@ double vtkMPRBaseData::GetY() return _y; } //------------------------------------------------------------------- +/** +** Calculates the value of the slider and the layer in the image that is spouse to show +**/ void vtkMPRBaseData::SetX(double x) { - int dim[3]; - _marImageData->GetImageData()->GetDimensions(dim); - if (x<0) - { - x=0; + //int dim[3]; + int ext[6]; + double* origin; + vtkImageData* img = _marImageData->GetImageData(); + if(img!=NULL){ + /*img->GetDimensions(dim); + if (x<0) + { + x=0; + } + if (x>=dim[0]) + { + x=dim[0]-1; + } + _x=x;*/ + img->GetExtent(ext); + origin = img->GetOrigin(); + if (x < ext[0]) + { + x=ext[0] + origin[0]; + } + if (x > ext[1]) + { + x=ext[1] + origin[0]; + } + + _x=x; } - if (x>=dim[0]) - { - x=dim[0]-1; - }; - _x=x; } //------------------------------------------------------------------- +/** +** Calculates the value of the slider and the layer in the image that is spouse to show +**/ void vtkMPRBaseData::SetY(double y) { - int dim[3]; - _marImageData->GetImageData()->GetDimensions(dim); - if (y<0) - { - y=0; + //int dim[3]; + int ext[6]; + double* origin; + vtkImageData* img = _marImageData->GetImageData(); + if(img!=NULL){ + /*img->GetDimensions(dim); + if (y<0) + { + y=0; + } + if (y>=dim[1]) + { + y=dim[1]-1; + } + _y=y;*/ + img->GetExtent(ext); + origin = img->GetOrigin(); + if (y ext[3]) + { + y=ext[3] + origin[1]; + } + _y=y; } - if (y>=dim[1]) - { - y=dim[1]-1; - }; - _y=y; } //------------------------------------------------------------------- vtkTransform *vtkMPRBaseData::GetTransformOrientation() -{ +{ return _transformOrientation; } //------------------------------------------------------------------- @@ -219,894 +189,3 @@ void vtkMPRBaseData::InitTransformOrientation(vtkTransform *trans) //------------------------------------------------------------------- //------------------------------------------------------------------- - -vtkMPR3DDataViewer::vtkMPR3DDataViewer() -{ - _visiblePosition[0]=false; - _visiblePosition[1]=false; - _visiblePosition[2]=false; - _ctfun = NULL; -} -//------------------------------------------------------------------- -vtkMPR3DDataViewer::~vtkMPR3DDataViewer() -{ - _outlineData -> Delete(); - _mapOutline -> Delete(); - _outline -> Delete(); - -// if (_bwLut) _bwLut -> Delete(); -// if (_hueLut) _hueLut -> Delete(); -// if (_satLut) _satLut -> Delete(); - if (_ctfun) _ctfun -> Delete(); - if (_saggitalColors) _saggitalColors -> Delete(); - if (_saggital) _saggital -> Delete(); - if (_axialColors) _axialColors -> Delete(); - if (_axial) _axial -> Delete(); - if (_coronalColors) _coronalColors -> Delete(); - if (_coronal) _coronal -> Delete(); - -} -//------------------------------------------------------------------- -vtkActor* vtkMPR3DDataViewer::GetOutlineActor() -{ - return _outline; -} -//------------------------------------------------------------------- -vtkImageActor* vtkMPR3DDataViewer::GetImageActor(int id) -{ - vtkImageActor *tmpVtkActor=NULL; - if (id==0){ - tmpVtkActor = GetvtkActor_saggital(); - } - if (id==1){ - tmpVtkActor = GetvtkActor_coronal(); - } - if (id==2){ - tmpVtkActor = GetvtkActor_axial(); - } - return tmpVtkActor; -} -//------------------------------------------------------------------- -void vtkMPR3DDataViewer::Refresh() -{ - int x = (int)(_vtkmprbasedata->GetX()); - int y = (int)(_vtkmprbasedata->GetY()); - int z = (int)(_vtkmprbasedata->GetZ()); - - SetPositionX( x ); - SetPositionY( y ); - SetPositionZ( z ); -} -//------------------------------------------------------------------- -void vtkMPR3DDataViewer::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata) -{ - _vtkmprbasedata=vtkmprbasedata; -} -//------------------------------------------------------------------- -vtkMPRBaseData* vtkMPR3DDataViewer::GetVtkMPRBaseData() -{ - return _vtkmprbasedata; -} -//------------------------------------------------------------------- - -vtkColorTransferFunction *vtkMPR3DDataViewer::GetvtkColorTransferFunction() -{ - return _ctfun; -} -//------------------------------------------------------------------- - -std::vector* vtkMPR3DDataViewer::GetctFunVectorPoint() -{ - return &_ctFunVectorPoint; -} -//------------------------------------------------------------------- -std::vector* vtkMPR3DDataViewer::GetctFunVectorRed() -{ - return &_ctFunVectorRed; -} - -//------------------------------------------------------------------- -std::vector* vtkMPR3DDataViewer::GetctFunVectorGreen() -{ - return &_ctFunVectorGreen; -} - -//------------------------------------------------------------------- -std::vector* vtkMPR3DDataViewer::GetctFunVectorBlue() -{ - return &_ctFunVectorBlue; -} - -//------------------------------------------------------------------- -void vtkMPR3DDataViewer::Configure() -{ -/* - // Start by creatin a black/white lookup table. - _bwLut = vtkLookupTable::New(); - _bwLut->SetTableRange (0, 2000); - _bwLut->SetSaturationRange (0, 0); - _bwLut->SetHueRange (0, 0); - _bwLut->SetValueRange (0, 1); - - // Now create a lookup table that consists of the full hue circle - // (from HSV). - _hueLut = vtkLookupTable::New(); - _hueLut->SetTableRange (0, 2000); - _hueLut->SetHueRange (0, 1); - _hueLut->SetSaturationRange (1, 1); - _hueLut->SetValueRange (1, 1); - - // Finally, create a lookup table with a single hue but having a range - // in the saturation of the hue. - _satLut = vtkLookupTable::New(); - _satLut->SetTableRange (0, 2000); - _satLut->SetHueRange (.6, .6); - _satLut->SetSaturationRange (0, 1); - _satLut->SetValueRange (1, 1); -*/ - - - double range[2]; - _vtkmprbasedata->GetImageData()->GetScalarRange(range); - double max = range[1]; - - - _ctFunVectorPoint.push_back(max*0/4); - _ctFunVectorPoint.push_back(max*1/4); - _ctFunVectorPoint.push_back(max*2/4); - _ctFunVectorPoint.push_back(max*3/4); - _ctFunVectorPoint.push_back(max*4/4); - - _ctFunVectorRed.push_back(0.0); - _ctFunVectorRed.push_back(1.0); - _ctFunVectorRed.push_back(0.0); - _ctFunVectorRed.push_back(0.0); - _ctFunVectorRed.push_back(0.0); - - _ctFunVectorGreen.push_back(0.0); - _ctFunVectorGreen.push_back(0.0); - _ctFunVectorGreen.push_back(0.0); - _ctFunVectorGreen.push_back(1.0); - _ctFunVectorGreen.push_back(0.2); - - _ctFunVectorBlue.push_back(0.0); - _ctFunVectorBlue.push_back(0.0); - _ctFunVectorBlue.push_back(1.0); - _ctFunVectorBlue.push_back(0.0); - _ctFunVectorBlue.push_back(0.0); - - - _ctfun = vtkColorTransferFunction::New(); - - int i,size=_ctFunVectorPoint.size(); - for (i=0;iAddRGBPoint( _ctFunVectorPoint[i] , _ctFunVectorRed[i],_ctFunVectorGreen[i],_ctFunVectorBlue[i]); - - } -/* - _ctfun->AddRGBPoint( 100 ,0 ,0,0); - _ctfun->AddRGBPoint( 200 ,1 ,0,0); - _ctfun->AddRGBPoint( 300 ,0 ,1,0); - _ctfun->AddRGBPoint( 400 ,0 ,0,1); -*/ -// void *p=this; - - // Create the first of the three planes. The filter vtkImageMapToColors - // maps the data through the corresponding lookup table created above. The - // vtkImageActor is a type of vtkProp and conveniently displays an image on - // a single quadrilateral plane. It does this using texture mapping and as - // a result is quite fast. (Note: the input image has to be unsigned char - // values, which the vtkImageMapToColors produces.) Note also that by - // specifying the DisplayExtent, the pipeline requests data of this extent - // and the vtkImageMapToColors only processes a slice of data. - _saggitalColors = vtkImageMapToColors::New(); - _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() ); -// _saggitalColors->SetLookupTable(_bwLut); - _saggitalColors->SetLookupTable(_ctfun); - _saggital = vtkImageActor::New(); - _saggital->SetInput(_saggitalColors->GetOutput()); - - - // Create the second (axial) plane of the three planes. We use the - // same approach as before except that the extent differs. - _axialColors = vtkImageMapToColors::New(); - _axialColors->SetInput( _vtkmprbasedata->GetImageData() ); -// _axialColors->SetLookupTable(_hueLut); - _axialColors->SetLookupTable(_ctfun); - _axial = vtkImageActor::New(); - _axial->SetInput(_axialColors->GetOutput()); - - // Create the third (coronal) plane of the three planes. We use - // the same approach as before except that the extent differs. - _coronalColors = vtkImageMapToColors::New(); - _coronalColors->SetInput( _vtkmprbasedata->GetImageData() ); -// _coronalColors->SetLookupTable(_satLut); - _coronalColors->SetLookupTable(_ctfun); - _coronal = vtkImageActor::New(); - _coronal->SetInput(_coronalColors->GetOutput()); - - // An outline provides context around the data. - // - _outlineData = vtkOutlineFilter::New(); - _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() ); - _mapOutline = vtkPolyDataMapper::New(); - _mapOutline->SetInput(_outlineData->GetOutput()); - _outline = vtkActor::New(); - _outline->SetMapper(_mapOutline); - _outline->GetProperty()->SetColor(0,0,0); - - int ext[6]; - _vtkmprbasedata->GetImageData()->GetExtent(ext); - - - -} - -//------------------------------------------------------------------- -vtkImageActor * vtkMPR3DDataViewer::GetvtkActor_saggital() -{ - return _saggital; -} -//------------------------------------------------------------------- -vtkImageActor * vtkMPR3DDataViewer::GetvtkActor_coronal() -{ - return _coronal; -} -//------------------------------------------------------------------- -vtkImageActor * vtkMPR3DDataViewer::GetvtkActor_axial() -{ - return _axial; -} - -//------------------------------------------------------------------------ -void vtkMPR3DDataViewer::SetPositionX(int pos){ - int x1,x2,y1,y2,z1,z2; - _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2); - _saggital->SetDisplayExtent( pos , pos , y1 ,y2 , z1 , z2 ); -} -//------------------------------------------------------------------------ -void vtkMPR3DDataViewer::SetPositionY(int pos){ - int x1,x2,y1,y2,z1,z2; - _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2); - _coronal->SetDisplayExtent(x1,x2, pos,pos, z1,z2); -} -//------------------------------------------------------------------------ -void vtkMPR3DDataViewer::SetPositionZ(int pos){ - int x1,x2,y1,y2,z1,z2; - _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2); - _axial->SetDisplayExtent(x1,x2, y1,y2, pos,pos); -} -//------------------------------------------------------------------- -void vtkMPR3DDataViewer::SetVisiblePosition(int idPosition, bool visible) -{ - _visiblePosition[idPosition]=visible; -} -//------------------------------------------------------------------- -bool vtkMPR3DDataViewer::GetVisiblePosition(int idPosition) -{ - return _visiblePosition[idPosition]; -} -//------------------------------------------------------------------- -//------------------------------------------------------------------- -//------------------------------------------------------------------- - - -vtkClipping3DDataViewer::vtkClipping3DDataViewer() -{ - int i; - for (i=0; iDelete(); - _tissueStripper[i] ->Delete(); - _tissueMapper[i] ->Delete(); - _tissuePlanes[i] ->Delete(); - _tissueClipper[i] ->Delete(); - } - _outlineData ->Delete(); - _mapOutline ->Delete(); - _outline ->Delete(); - // Volume - _tfun ->Delete(); - _ctfun ->Delete(); - _compositeFunction ->Delete(); - _volumeMapper ->Delete(); - _volumeProperty ->Delete(); - _newvol ->Delete(); - _volumePlanes ->Delete(); - - for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){ - _tissue[i] -> Delete(); - _observerS[i] -> Delete(); - } - _observerV -> Delete(); -} -//------------------------------------------------------------------- -vtkActor* vtkClipping3DDataViewer::GetOutlineActor() -{ - return _outline; -} -//------------------------------------------------------------------- -vtkClipPolyData* vtkClipping3DDataViewer::GetTissueClipper(int id) -{ - return this->_tissueClipper[id]; -} -//------------------------------------------------------------------- -vtkPolyDataMapper* vtkClipping3DDataViewer::GetTissueMapper(int id) -{ - return _tissueMapper[id]; -} -//------------------------------------------------------------------- -vtkPlanes* vtkClipping3DDataViewer::GetTissuePlanes(int id) -{ - return _tissuePlanes[id]; -} -//------------------------------------------------------------------- -vtkStripper* vtkClipping3DDataViewer::GetTissueStripper(int id) -{ - return _tissueStripper[id]; -} -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::Refresh() -{ -// _volumeMapper->SetClippingPlanes(_volumePlanes); - -// this->_volumeMapper->Update(); -// this->_newvol->Update(); - -// _newvol->VisibilityOn(); - - -// _volumeMapper = vtkVolumeRayCastMapper::New(); -// _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() ); -// _volumeMapper->SetVolumeRayCastFunction(_compositeFunction); -// _volumeMapper->SetClippingPlanes( _volumePlanes ); -// _newvol->SetMapper(_volumeMapper ); - - -} -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::RefreshSurface() -{ - int i; - for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++) - { - SetIsovalue(i, (int) (GetIsovalue(i)+1) ); -// this->GetMCubes(i)->Update(); - } -} -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata) -{ - _vtkmprbasedata=vtkmprbasedata; -} -//------------------------------------------------------------------- -vtkMPRBaseData* vtkClipping3DDataViewer::GetVtkMPRBaseData() -{ - return _vtkmprbasedata; -} - - -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::SetVisibleTissue(int idTissue, bool visible) -{ - _visibleTissue[idTissue]=visible; -} -//------------------------------------------------------------------- -bool vtkClipping3DDataViewer::GetVisibleTissue(int idTissue){ - return _visibleTissue[idTissue]; -} -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::SetRepresentationType(int idTissue, bool representationType) -{ - _representationType[idTissue]=representationType; -} -//------------------------------------------------------------------- -bool vtkClipping3DDataViewer::GetRepresentationType(int idTissue) -{ - return _representationType[idTissue]; -} - -//------------------------------------------------------------------- -vtkActor* vtkClipping3DDataViewer::GetTissueActor(int id){ - return _tissue[id]; -} - -//------------------------------------------------------------------- -boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverS(int idObserverS) -{ - return _observerS[idObserverS]; -} -//------------------------------------------------------------------- -boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverV() -{ - return _observerV; -} - -//------------------------------------------------------------------- -bool vtkClipping3DDataViewer::GetVisibleVolume() -{ - return _visibleVolume; -} -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::SetVisibleVolume(bool visiblevolume) -{ - _visibleVolume = visiblevolume; -} - - -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::Configure_Tissue() -{ - - double range[2]; - int i; - for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){ - // Visualisation - original volume - vtkImageData *imagedata=_vtkmprbasedata->GetImageData(); - imagedata->GetScalarRange( range ); - _mCubes[i] = vtkMarchingCubes::New( ); - _mCubes[i]->SetInput( imagedata ); - - _mCubes[i]->SetValue( 0, range[1]*(4+i) / 8 ); -// _mCubes[i]->SetValue( 0, 1500 ); - - _tissueStripper[i] = vtkStripper::New(); - _tissueStripper[i]->SetInput( _mCubes[i]->GetOutput( ) ); - - - - _tissuePlanes[i] = vtkPlanes::New(); - - int x1,x2,y1,y2,z1,z2; - imagedata->GetExtent(x1,x2,y1,y2,z1,z2); - _tissuePlanes[i]->SetBounds (x1,x2,y1,y2,z1,z2); - - _tissueClipper[i] = vtkClipPolyData::New(); - _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() ); - _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] ); - _tissueClipper[i]->InsideOutOn( ); - - _tissueMapper[i] = vtkPolyDataMapper::New( ); - _tissueMapper[i]->SetInput( _tissueClipper[i]->GetOutput() ); - _tissueMapper[i]->ScalarVisibilityOff( ); -// _tissueMapper[i]->Update(); - - } - - - - // vtkActor tissue - for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){ - // tissue - _tissue[i] = vtkActor::New(); - _tissue[i]->SetMapper( GetTissueMapper(i) ); - float cr=1,cg=0.5,cb=0.5; - _tissue[i]->GetProperty()->SetDiffuseColor(cr/255, cg/255 , cb/255 ); - _tissue[i]->GetProperty()->SetSpecular(.3); - _tissue[i]->GetProperty()->SetSpecularPower(20); - _tissue[i]->GetProperty()->SetOpacity(0.5); - if (i==0) _tissue[i]->GetProperty()->SetColor(0.85, 0.85 , 0.85 ); - if (i==1) _tissue[i]->GetProperty()->SetColor(0, 0 , 1 ); - if (i==2) _tissue[i]->GetProperty()->SetColor(0.85, 0.20 , 0.20 ); - if (i==3) _tissue[i]->GetProperty()->SetColor(0, 1 , 0 ); - } - - for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++) - { - _observerS[i] = boxSurfaceObserver::New(); - _observerS[i]->SetPlanes( GetTissuePlanes(i) ); - _observerS[i]->SetActor( _tissue[i] ); - } - -} - -//----------------------------------------------------------------------------- - -void vtkClipping3DDataViewer::Configure_Volume() -{ - // Volume - - _tfun = vtkPiecewiseFunction::New(); - _ctfun = vtkColorTransferFunction::New(); - - double range[2]; - this->_vtkmprbasedata->GetImageData()->GetScalarRange(range); - double max = range[1]; - - /* - adding the poinst of the transference function - */ - //X - greyValuesTransferenceFVector.push_back(max * 0/2); - greyValuesTransferenceFVector.push_back(max * 1/2); - greyValuesTransferenceFVector.push_back(max * 2/2); - //Y - intensityValuesTransferenceFVector.push_back(0.0); - intensityValuesTransferenceFVector.push_back(1.0); - intensityValuesTransferenceFVector.push_back(1.0); - - _tfun->AddPoint(max * 0/2 , 0.0); - _tfun->AddPoint(max * 1/2 , 1.0); - _tfun->AddPoint(max * 2/2 , 1.0); - - /* - Adding the colors to the vectors - */ - //RED - redColorsOfColorTransferenceFVector.push_back(0.0); - redColorsOfColorTransferenceFVector.push_back(1.0); - redColorsOfColorTransferenceFVector.push_back(0.0); - redColorsOfColorTransferenceFVector.push_back(0.0); - redColorsOfColorTransferenceFVector.push_back(0.0); - - //GREEN - greenColorsOfColorTransferenceFVector.push_back(0.0); - greenColorsOfColorTransferenceFVector.push_back(0.0); - greenColorsOfColorTransferenceFVector.push_back(0.0); - greenColorsOfColorTransferenceFVector.push_back(1.0); - greenColorsOfColorTransferenceFVector.push_back(0.2); - - //BLUE - blueColorsOfColorTransferenceFVector.push_back(0.0); - blueColorsOfColorTransferenceFVector.push_back(0.0); - blueColorsOfColorTransferenceFVector.push_back(1.0); - blueColorsOfColorTransferenceFVector.push_back(0.0); - blueColorsOfColorTransferenceFVector.push_back(0.0); - //GREY VALUE - greyValueColorsOfColorTransferenceFVector.push_back(max*0/4); - greyValueColorsOfColorTransferenceFVector.push_back(max*1/4); - greyValueColorsOfColorTransferenceFVector.push_back(max*2/4); - greyValueColorsOfColorTransferenceFVector.push_back(max*3/4); - greyValueColorsOfColorTransferenceFVector.push_back(max*4/4); - - _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0); - _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0); - _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0); - _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0); - _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0); - - _volumePlanes = vtkPlanes::New(); -// int x1,x2,y1,y2,z1,z2; -// vtkImageData *imagedata=_vtkmprbasedata->GetImageData(); -// imagedata->GetExtent(x1,x2,y1,y2,z1,z2); -// _volumePlanes->SetBounds(x1,x2,y1,y2,z1,z2); - - _compositeFunction = vtkVolumeRayCastCompositeFunction::New(); - - _volumeMapper = vtkVolumeRayCastMapper::New(); - _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() ); - _volumeMapper->SetVolumeRayCastFunction(_compositeFunction); - _volumeMapper->SetClippingPlanes( _volumePlanes ); - _volumeMapper->AutoAdjustSampleDistancesOn(); - - _volumeProperty = vtkVolumeProperty::New(); - _volumeProperty->SetColor(_ctfun); - _volumeProperty->SetScalarOpacity( _tfun ); -// EED 31/03/2008 - _volumeProperty->SetInterpolationTypeToLinear(); - _volumeProperty->ShadeOn(); - _volumeProperty->DisableGradientOpacityOn(); - -// _volumeProperty->SetInterpolationTypeToNearest(); -// _volumeProperty->ShadeOff(); -// _volumeProperty->SetAmbient(0.3); -// _volumeProperty->SetDiffuse(0.1); -// _volumeProperty->SetSpecular(0.8); -// _volumeProperty->DisableGradientOpacityOn(); - - _newvol = vtkVolume::New(); - _newvol->SetMapper(_volumeMapper ); - _newvol->SetProperty(_volumeProperty ); - - _observerV = boxSurfaceObserver::New(); - _observerV->SetPlanes( _volumePlanes ); - _observerV->SetActor( _newvol ); - _observerV->SetvtkVolumeRayCastMapper( _volumeMapper ); -} - - -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::Configure() -{ - Configure_Tissue(); - Configure_Volume(); - - // An outline provides context around the data. - // - _outlineData = vtkOutlineFilter::New(); - _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() ); - _mapOutline = vtkPolyDataMapper::New(); - _mapOutline->SetInput(_outlineData->GetOutput()); - _outline = vtkActor::New(); - _outline->SetMapper(_mapOutline); - _outline->GetProperty()->SetColor(0,0,0); -} - - -//------------------------------------------------------------------- -void vtkClipping3DDataViewer::SetIsovalue(int idTissue, int isoValue) -{ - _mCubes[idTissue]->SetValue(0, isoValue); -} -//------------------------------------------------------------------- -double vtkClipping3DDataViewer::GetIsovalue(int idTissue) -{ - return _mCubes[idTissue]->GetValue(0); -} -//------------------------------------------------------------------- -vtkVolume* vtkClipping3DDataViewer::GetVolumeActor() -{ - return _newvol; -} -//------------------------------------------------------------------- -vtkVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper(){ - return _volumeMapper; -} -//------------------------------------------------------------------- -vtkPlanes* vtkClipping3DDataViewer::GetVolumePlanes() -{ - return _volumePlanes; -} - -//------------------------------------------------------------------- -vtkMarchingCubes *vtkClipping3DDataViewer::GetMCubes(int idTissue) -{ - return _mCubes[idTissue]; -} -//-------------------------------------------------------------------- -//------------------- -//Getters Vectors -//------------------- - -std::vector* vtkClipping3DDataViewer::GetGreyValuesTransferenceFVector() -{ - return &greyValuesTransferenceFVector; -} -//-------------------------------------------------------------------- -std::vector* vtkClipping3DDataViewer::GetIntensityValuesTransferenceFVector() -{ - return &intensityValuesTransferenceFVector; -} -//-------------------------------------------------------------------- -std::vector* vtkClipping3DDataViewer::GetRedColorsOfColorTransferenceFVector() -{ - return &redColorsOfColorTransferenceFVector; -} -//-------------------------------------------------------------------- -std::vector* vtkClipping3DDataViewer::GetGreenColorsOfColorTransferenceFVector() -{ - return &greenColorsOfColorTransferenceFVector; -} -//-------------------------------------------------------------------- -std::vector* vtkClipping3DDataViewer::GetBlueColorsOfColorTransferenceFVector() -{ - return &blueColorsOfColorTransferenceFVector; -} -//-------------------------------------------------------------------- -std::vector* vtkClipping3DDataViewer::GetGreyValueColorsOfColorTransferenceFVector() -{ - return &greyValueColorsOfColorTransferenceFVector; -} -//-------------------------------------------------------------------- -//-------------------------------------- -//Getters transference function -//and color of the transference function -//--------------------------------------- -vtkPiecewiseFunction* vtkClipping3DDataViewer::GetTransferencefunction() -{ - return this->_tfun; -} -//-------------------------------------------------------------------- -vtkColorTransferFunction* vtkClipping3DDataViewer::GetColorTransferenceFunction() -{ - return this->_ctfun; -} - -//------------------------------------------------------------------- - -void vtkClipping3DDataViewer::ReadVolumeFunctions() -{ -/* - int i=0,xi,yi,r,g,b,gValue; - vtkImageData *imagedata = this->_vtkmprbasedata->GetImageData(); - - HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata); - // - // put in a method - // - int tfSize=this->greyValuesTransferenceFVector.size(); - if(tfSize>0) - { - int i=0,y; - hDlg->erasePointsTransferenceFunction(); - while(iaddPointToTransferenceFunction(g,in*100); - i++; - } - - } - - int ctfSize=this->redColorsOfColorTransferenceFVector.size(); - if(ctfSize>0) - { - int i=0,y; - while(iaddColorPoint(gr,r*255,g*255,b*255); - i++; - } - } - //If it is smooth activate next line - //hDlg->updatePlotter(); - //setting variables if the user wants to do refresh - hDlg->setCTF(_ctfun); - hDlg->setTF(_tfun); - - // - // when the user had changed the transference Function - // - if(hDlg->ShowModal()== wxID_OK ) - { - // -- vtkPiecewiseFunction -- - this->_tfun->RemoveAllPoints(); - greyValuesTransferenceFVector.clear(); - intensityValuesTransferenceFVector.clear(); - - int nTFPoints=hDlg->getSizeTransferenceFunction(); - i=0; - while(igetTransferenceFunctionPoint(i,xi,yi); - this->_tfun->AddPoint( xi , yi/100.0 ); - greyValuesTransferenceFVector.push_back(xi); - intensityValuesTransferenceFVector.push_back(yi/100.0); - i++; - } - // -- vtkColorTransferFunction -- - this->_ctfun->RemoveAllPoints (); - //clean colors - redColorsOfColorTransferenceFVector.clear(); - greenColorsOfColorTransferenceFVector.clear(); - blueColorsOfColorTransferenceFVector.clear(); - greyValueColorsOfColorTransferenceFVector.clear(); - - int nCTFpoints=hDlg->getSizeBarColor(); - i=0; - while(igetDataBarColorPoint(i,xi,r,g,b); - this->_ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 ); - redColorsOfColorTransferenceFVector.push_back(r/255.0); - greenColorsOfColorTransferenceFVector.push_back(g/255.0); - blueColorsOfColorTransferenceFVector.push_back(b/255.0); - greyValueColorsOfColorTransferenceFVector.push_back(xi); - i++; - } - - this->_volumeMapper->Update(); - this->_newvol->Update(); - } - - else - { - - if(hDlg->getRefreshed()) - { - int i=0,size; - //--Transference Function---- - this->_tfun->RemoveAllPoints(); - i=0; - size=greyValuesTransferenceFVector.size(); - for(i=0;i_tfun->AddPoint( grey1 , in2 ); - } - - // -- vtkColorTransferFunction -- - _ctfun->RemoveAllPoints (); - - i=0; - size=greyValueColorsOfColorTransferenceFVector.size(); - for(i=0;iAddRGBPoint(grey2,red,green,blue); - } - this->_volumeMapper->Update(); - this->_newvol->Update(); - } - - } - hDlg->Destroy(); -*/ -} -/* -void vtkClipping3DDataViewer::ReadVolumeFunctions(char *namefile) -{ - char tmp[256]; - short int max; - double range[2]; - double x,val,r,g,b; - - FILE *ff = fopen ( namefile ,"r"); - - // -- MAX -- - fscanf(ff,"%s",tmp); - if (strcmp(tmp,"MAX")==0) - { - vtkImageData *vtkimagedata = this->_vtkmprbasedata->GetImageData(); - vtkimagedata->GetScalarRange(range); - max = (int) (range[1]); - } else { - max = atoi(tmp); - } - - fscanf(ff,"%s",tmp); // -- - - // -- vtkPiecewiseFunction -- - this->_tfun->RemoveAllPoints(); - fscanf(ff,"%s",tmp); - while ( strcmp(tmp,"--")!=0 ) - { - x=atof(tmp); - fscanf(ff,"%s",tmp); - val=atof(tmp); - this->_tfun->AddPoint( x*max , val ); - fscanf(ff,"%s",tmp); - } - - this->_ctfun->RemoveAllPoints (); - // -- vtkColorTransferFunction -- - while ( !feof(ff)) - { - fscanf(ff,"%s",tmp); - x=atof(tmp); - fscanf(ff,"%s",tmp); - r=atof(tmp); - fscanf(ff,"%s",tmp); - g=atof(tmp); - fscanf(ff,"%s",tmp); - b=atof(tmp); - this->_ctfun->AddRGBPoint( x*max , r,g,b ); - } - - - this->_volumeMapper->Update(); - this->_newvol->Update(); - - - fclose(ff); -} -*/ - -//------------------------------------------------------------------- -// EED 23 Mai 2007 -void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile) -{ - vtkDataSetReader *reader = vtkDataSetReader::New(); - reader->SetFileName(namefile); - reader->Update(); - _tissueStripper[3]->SetInput( reader->GetPolyDataOutput() ); -}