X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvImageContour.cxx;h=68dc72059a32d5cf02ac3424720149e6ffd9fc7f;hb=5e0e24a8a2a21ba08afbb80bdaf9175d615f98f4;hp=8fb22ae4d000428bd0fb50317b2843fa22372c80;hpb=3a823a03d4a2217e41e4dd3b05a8ea825bb762a5;p=clitk.git diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 8fb22ae..68dc720 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -27,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; } @@ -45,7 +47,7 @@ vvImageContour::vvImageContour() //------------------------------------------------------------------------------ vvImageContour::~vvImageContour() -{ +{ mSquaresActorList.clear(); } //------------------------------------------------------------------------------ @@ -53,7 +55,7 @@ vvImageContour::~vvImageContour() //------------------------------------------------------------------------------ void vvImageContour::RemoveActors() -{ +{ for (unsigned int i = 0; i < mSquaresActorList.size(); i++) { if (mSlicer != 0) { if (mSlicer!= NULL) { @@ -70,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++) { @@ -81,7 +84,8 @@ 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]); @@ -96,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; @@ -116,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 } } //------------------------------------------------------------------------------ @@ -126,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); } @@ -135,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(); @@ -171,7 +180,8 @@ void vvImageContour::SetDepth(double d) //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::Update(double value) { +void vvImageContour::Update(double value) +{ if (!mSlicer) return; if (mPreviousValue == value) { if (mPreviousSlice == mSlicer->GetSlice()) { @@ -207,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(); @@ -223,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(); @@ -248,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(); @@ -266,7 +279,8 @@ int vvImageContour::ComputeCurrentOrientation() { //------------------------------------------------------------------------------ -void vvImageContour::UpdateWithFastCacheMode() { +void vvImageContour::UpdateWithFastCacheMode() +{ clitkExceptionMacro("TODO : not implemented yet"); // Compute orientation @@ -294,7 +308,8 @@ 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(); @@ -313,17 +328,17 @@ void vvImageContour::CreateNewActor(int numImage) { clipper->SetInputData(mSlicer->GetImage()->GetVTKImages()[numImage]); #endif } - #if VTK_MAJOR_VERSION <= 5 squares->SetInput(clipper->GetOutput()); squaresMapper->SetInput(squares->GetOutput()); #else - squares->SetInputData(clipper->GetOutput()); - squaresMapper->SetInputData(squares->GetOutput()); + 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); @@ -341,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(); @@ -381,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 @@ -393,7 +409,6 @@ void vvImageContour::UpdateActor(vtkActor * actor, // DD(mDepth); // position[orientation] = -mDepth; // actor->SetPosition(position); - mapper->Update(); } //------------------------------------------------------------------------------