]> Creatis software - clitk.git/blobdiff - vv/vvImageContour.cxx
New ComputeOptimalThreshold
[clitk.git] / vv / vvImageContour.cxx
index ab6d8202647e24485c156f51251e4dbbf4be6fc0..94129031759648c7808a40f6216b12b95ef74d1d 100644 (file)
@@ -135,13 +135,11 @@ void vvImageContour::ShowActors() {
 
 //------------------------------------------------------------------------------
 void vvImageContour::Update(double value) {
-  std::cout << "vvImageContour::Update " << value << std::endl;
   if (!mSlicer) return;
   if (mPreviousValue == value) {
     if (mPreviousSlice == mSlicer->GetSlice()) {
       if (mPreviousTSlice == mSlicer->GetTSlice()) {
         if (mPreviousOrientation == ComputeCurrentOrientation()) {
-          std::cout << "Nothing to do" << std::endl;
           return; // Nothing to do
         }
       }
@@ -161,7 +159,7 @@ void vvImageContour::Update(double value) {
     UpdateWithFastCacheMode();
   }
 
-  //  mSlicer->Render(); //DS ---> REMOVE ??
+  //mSlicer->Render(); //DS ---> REMOVE ??
 
   mPreviousTSlice = mSlicer->GetTSlice();
   mPreviousSlice  = mSlicer->GetSlice();
@@ -174,7 +172,7 @@ void vvImageContour::Update(double value) {
 //------------------------------------------------------------------------------
 void vvImageContour::UpdateWithPreserveMemoryMode() {
   // Only change actor visibility if tslice change
-  int mPreviousTslice = mTSlice;
+  mPreviousTslice = mTSlice;
   mTSlice = mSlicer->GetTSlice();
 
   vtkMarchingSquares * mSquares = mSquaresList[mTSlice];
@@ -184,11 +182,12 @@ void vvImageContour::UpdateWithPreserveMemoryMode() {
   int orientation = ComputeCurrentOrientation();
 
   UpdateActor(mSquaresActor, mapper, mSquares, mClipper, mValue, orientation, mSlice);
-  //mSquaresActorList[mTSlice]->VisibilityOn();
 
   if (mPreviousTslice != mTSlice) {
     if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff();
   }
+  
+  mSlicer->Render();
 }
 //------------------------------------------------------------------------------
 
@@ -268,6 +267,7 @@ void vvImageContour::CreateNewActor(int numImage) {
     clipper->SetInput(mHiddenImage->GetVTKImages()[0]);
   else
     clipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]);
+  
   squares->SetInput(clipper->GetOutput());
   squaresMapper->SetInput(squares->GetOutput());
   squaresMapper->ScalarVisibilityOff();
@@ -291,7 +291,6 @@ void vvImageContour::UpdateActor(vtkActor * actor,
                                  vtkMarchingSquares * squares, 
                                  vtkImageClip * clipper, 
                                  double threshold, int orientation, int slice) {
-  std::cout << "vvImageContour::UpdateActor" << std::endl;
   
    // Set parameter for the MarchigSquare
   squares->SetValue(0, threshold);
@@ -329,6 +328,7 @@ void vvImageContour::UpdateActor(vtkActor * actor,
 
   } else {
     extent2 = extent;
+    actor->VisibilityOn();
   }
  
   clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2],
@@ -341,45 +341,7 @@ void vvImageContour::UpdateActor(vtkActor * actor,
   position[orientation] = -1;
   actor->SetPosition(position);
   
-//   switch (orientation)  {
-//   case 0:
-//     actor->SetPosition(-1,0,0);
-//     /*
-//     // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0]);
-//     if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) {
-//     actor->SetPosition(1,0,0);
-//     } else {
-//       actor->SetPosition(-1,0,0);
-//       }*/
-//     break;
-//   case 1:
-//     actor->SetPosition(0,-1,0);
-//     /*
-//     // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1]);
-//     if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) {
-//       actor->SetPosition(0,1,0);
-//     } else {
-//       actor->SetPosition(0,-1,0);
-//     }
-//     */
-//     break;
-//   case 2:
-//     actor->SetPosition(0,0,-1);
-//     /*
-//     DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]);
-//     if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) {
-//       DD("1");
-//       actor->SetPosition(0,0,1);
-//     } else {
-//      DD("-1");
-//       actor->SetPosition(0,0,-1);
-//     }
-//     */
-//     break;
-//   }
-
   mapper->Update();
-  actor->VisibilityOn();
 }
 //------------------------------------------------------------------------------