X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvImageContour.cxx;h=68dc72059a32d5cf02ac3424720149e6ffd9fc7f;hb=140bf134a2e40ba737bdb85f040d2a052c9a8e2a;hp=e89f84be3a1a2779e42963e2ef6781cf7d40c2a4;hpb=f6ec1c5f4f1c2105b428fe2d87e794417897a4e8;p=clitk.git diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index e89f84b..68dc720 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -18,6 +18,7 @@ #include "vvImageContour.h" #include "vvImage.h" +#include #include #include #include @@ -26,16 +27,18 @@ #include #include #include +#include //------------------------------------------------------------------------------ vvImageContour::vvImageContour() -{ +{ mTSlice = -1; mSlice = 0; mHiddenImageIsUsed = false; mDisplayModeIsPreserveMemory = true; SetPreserveMemoryModeEnabled(true); mPreviousOrientation = -1; + mPreviousValue=0; mDepth = 1.0; mSlice = 0; } @@ -44,7 +47,7 @@ vvImageContour::vvImageContour() //------------------------------------------------------------------------------ vvImageContour::~vvImageContour() -{ +{ mSquaresActorList.clear(); } //------------------------------------------------------------------------------ @@ -52,7 +55,7 @@ vvImageContour::~vvImageContour() //------------------------------------------------------------------------------ void vvImageContour::RemoveActors() -{ +{ for (unsigned int i = 0; i < mSquaresActorList.size(); i++) { if (mSlicer != 0) { if (mSlicer!= NULL) { @@ -69,7 +72,8 @@ void vvImageContour::RemoveActors() //------------------------------------------------------------------------------ -void vvImageContour::SetSlicer(vvSlicer * slicer) { +void vvImageContour::SetSlicer(vvSlicer * slicer) +{ mSlicer = slicer; // Create an actor for each time slice for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) { @@ -80,9 +84,14 @@ void vvImageContour::SetSlicer(vvSlicer * slicer) { //------------------------------------------------------------------------------ -void vvImageContour::SetImage(vvImage::Pointer image) { +void vvImageContour::SetImage(vvImage::Pointer image) +{ for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) { +#if VTK_MAJOR_VERSION <= 5 mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]); +#else + mClipperList[numImage]->SetInputData(image->GetVTKImages()[numImage]); +#endif } mHiddenImageIsUsed = true; mHiddenImage = image; @@ -91,7 +100,8 @@ void vvImageContour::SetImage(vvImage::Pointer image) { //------------------------------------------------------------------------------ -void vvImageContour::SetPreserveMemoryModeEnabled(bool b) { +void vvImageContour::SetPreserveMemoryModeEnabled(bool b) +{ // FastCache mode work only if threshold is always the same if (mDisplayModeIsPreserveMemory == b) return; mDisplayModeIsPreserveMemory = b; @@ -111,9 +121,11 @@ void vvImageContour::SetPreserveMemoryModeEnabled(bool b) { //------------------------------------------------------------------------------ -void vvImageContour::SetColor(double r, double g, double b) { +void vvImageContour::SetColor(double r, double g, double b) +{ for(unsigned int i=0; iGetProperty()->SetColor(r,g,b); + mSquaresActorList[i]->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL } } //------------------------------------------------------------------------------ @@ -121,7 +133,7 @@ void vvImageContour::SetColor(double r, double g, double b) { //------------------------------------------------------------------------------ void vvImageContour::SetLineWidth(double w) -{ +{ for(unsigned int i=0; iGetProperty()->SetLineWidth(w); } @@ -130,7 +142,8 @@ void vvImageContour::SetLineWidth(double w) //------------------------------------------------------------------------------ -void vvImageContour::HideActors() { +void vvImageContour::HideActors() +{ if (!mSlicer) return; mSlice = mSlicer->GetSlice(); for(unsigned int i=0; iGetSlice(); mTSlice = mSlicer->GetTSlice(); @@ -154,19 +168,20 @@ void vvImageContour::ShowActors() { //------------------------------------------------------------------------------ void vvImageContour::SetDepth(double d) { - mDepth = d+0.5; // FIXME to not be equal to overlay + mDepth = d; // Move the actor to be visible double position[3] = {0, 0, 0}; - int orientation = ComputeCurrentOrientation(); + int orientation = ComputeCurrentOrientation(); position[orientation] = -mDepth; - for(uint i=0; iSetPosition(position); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::Update(double value) { +void vvImageContour::Update(double value) +{ if (!mSlicer) return; if (mPreviousValue == value) { if (mPreviousSlice == mSlicer->GetSlice()) { @@ -202,7 +217,8 @@ void vvImageContour::Update(double value) { //------------------------------------------------------------------------------ -void vvImageContour::UpdateWithPreserveMemoryMode() { +void vvImageContour::UpdateWithPreserveMemoryMode() +{ // Only change actor visibility if tslice change mPreviousTslice = mTSlice; mTSlice = mSlicer->GetTSlice(); @@ -218,14 +234,15 @@ void vvImageContour::UpdateWithPreserveMemoryMode() { if (mPreviousTslice != mTSlice) { if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff(); } - - mSlicer->Render(); + + //mSlicer->Render(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::InitializeCacheMode() { +void vvImageContour::InitializeCacheMode() +{ clitkExceptionMacro("TODO : not implemented yet"); mPreviousSlice = mPreviousOrientation = 0; int dim = mSlicer->GetImage()->GetNumberOfDimensions(); @@ -243,7 +260,8 @@ clitkExceptionMacro("TODO : not implemented yet"); //------------------------------------------------------------------------------ -int vvImageContour::ComputeCurrentOrientation() { +int vvImageContour::ComputeCurrentOrientation() +{ // Get extent of image in the slicer int* extent = mSlicer->GetImageActor()->GetDisplayExtent(); @@ -261,7 +279,8 @@ int vvImageContour::ComputeCurrentOrientation() { //------------------------------------------------------------------------------ -void vvImageContour::UpdateWithFastCacheMode() { +void vvImageContour::UpdateWithFastCacheMode() +{ clitkExceptionMacro("TODO : not implemented yet"); // Compute orientation @@ -289,22 +308,37 @@ clitkExceptionMacro("TODO : not implemented yet"); //------------------------------------------------------------------------------ -void vvImageContour::CreateNewActor(int numImage) { +void vvImageContour::CreateNewActor(int numImage) +{ vtkSmartPointer squaresActor = vtkSmartPointer::New(); vtkSmartPointer clipper = vtkSmartPointer::New(); vtkSmartPointer squares = vtkSmartPointer::New(); vtkSmartPointer squaresMapper = vtkSmartPointer::New(); - if (mHiddenImageIsUsed) + if (mHiddenImageIsUsed) { +#if VTK_MAJOR_VERSION <= 5 clipper->SetInput(mHiddenImage->GetVTKImages()[0]); - else +#else + clipper->SetInputData(mHiddenImage->GetVTKImages()[0]); +#endif + } else { +#if VTK_MAJOR_VERSION <= 5 clipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]); - +#else + clipper->SetInputData(mSlicer->GetImage()->GetVTKImages()[numImage]); +#endif + } +#if VTK_MAJOR_VERSION <= 5 squares->SetInput(clipper->GetOutput()); squaresMapper->SetInput(squares->GetOutput()); +#else + squares->SetInputConnection(clipper->GetOutputPort(0)); + squaresMapper->SetInputConnection(squares->GetOutputPort(0)); +#endif squaresMapper->ScalarVisibilityOff(); squaresActor->SetMapper(squaresMapper); squaresActor->GetProperty()->SetColor(1.0,0,0); + squaresActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL squaresActor->SetPickable(0); squaresActor->VisibilityOff(); mSlicer->GetRenderer()->AddActor(squaresActor); @@ -322,10 +356,11 @@ void vvImageContour::UpdateActor(vtkActor * actor, vtkPolyDataMapper * mapper, vtkMarchingSquares * squares, vtkImageClip * clipper, - double threshold, int orientation, int slice) { + double threshold, int orientation, int slice) +{ // Set parameter for the MarchigSquare squares->SetValue(0, threshold); - + squares->Update(); // Get image extent int* extent = mSlicer->GetImageActor()->GetDisplayExtent(); @@ -362,10 +397,10 @@ void vvImageContour::UpdateActor(vtkActor * actor, extent2 = extent; actor->VisibilityOn(); } - + clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2], extent2[3],extent2[4],extent2[5]); - + if (mHiddenImageIsUsed) delete extent2; // Move the actor to be visible @@ -374,7 +409,6 @@ void vvImageContour::UpdateActor(vtkActor * actor, // DD(mDepth); // position[orientation] = -mDepth; // actor->SetPosition(position); - mapper->Update(); } //------------------------------------------------------------------------------