X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvImageContour.cxx;h=4fecf93e9371f52703dfc9634899547f74965f11;hb=9c5f0e4d3d6b33e09d0413439ed7a867e3d85faa;hp=27703963c345be05e09715957a59423295319d38;hpb=f4fc4c25f08ee080852aa6e75526bfa8116cc59a;p=clitk.git diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 2770396..4fecf93 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -36,6 +36,8 @@ vvImageContour::vvImageContour() mDisplayModeIsPreserveMemory = true; SetPreserveMemoryModeEnabled(true); mPreviousOrientation = -1; + mDepth = 1.0; + mSlice = 0; } //------------------------------------------------------------------------------ @@ -43,8 +45,24 @@ vvImageContour::vvImageContour() //------------------------------------------------------------------------------ vvImageContour::~vvImageContour() { - for (unsigned int i = 0; i < mSlicer->GetImage()->GetVTKImages().size(); i++) { - mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]); + mSquaresActorList.clear(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvImageContour::RemoveActors() +{ + for (unsigned int i = 0; i < mSquaresActorList.size(); i++) { + if (mSlicer != 0) { + if (mSlicer!= NULL) { + if (mSlicer->GetRenderer() != NULL) { + if (mSquaresActorList[i] != NULL) { + mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]); + } + } + } + } } } //------------------------------------------------------------------------------ @@ -62,7 +80,7 @@ void vvImageContour::SetSlicer(vvSlicer * slicer) { //------------------------------------------------------------------------------ -void vvImageContour::SetImage(vvImage * image) { +void vvImageContour::SetImage(vvImage::Pointer image) { for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) { mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]); } @@ -133,6 +151,20 @@ void vvImageContour::ShowActors() { //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvImageContour::SetDepth(double d) +{ + mDepth = d; + // Move the actor to be visible + double position[3] = {0, 0, 0}; + int orientation = ComputeCurrentOrientation(); + position[orientation] = -mDepth; + + for(unsigned int i=0; iSetPosition(position); +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvImageContour::Update(double value) { if (!mSlicer) return; @@ -267,6 +299,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(); @@ -290,8 +323,7 @@ void vvImageContour::UpdateActor(vtkActor * actor, vtkMarchingSquares * squares, vtkImageClip * clipper, double threshold, int orientation, int slice) { - - // Set parameter for the MarchigSquare + // Set parameter for the MarchigSquare squares->SetValue(0, threshold); // Get image extent @@ -311,15 +343,16 @@ void vvImageContour::UpdateActor(vtkActor * actor, s = s-mHiddenImage->GetFirstVTKImageData()->GetOrigin()[orientation]; // from corner second image s = s/mHiddenImage->GetFirstVTKImageData()->GetSpacing()[orientation]; // in voxel - if (s == floor(s)) { - extent2[orientation*2] = extent2[orientation*2+1] = (int)floor(s); - } else { - extent2[orientation*2] = (int)floor(s); - extent2[orientation*2+1] = extent2[orientation*2]; - } + // Rint to the closest slice + extent2[orientation*2+1] = extent2[orientation*2] = (int)lrint(s); // Do not display a contour if there is no contour on this slice - if (extent2[orientation*2+1] > extent3[orientation*2+1]) { + // DD(extent2[orientation*2+1]); + // DD(extent3[orientation*2+1]); + // DD(extent2[orientation*2]); + // DD(extent3[orientation*2]); + if ((extent2[orientation*2+1] > extent3[orientation*2+1]) || + (extent2[orientation*2] < extent3[orientation*2])) { actor->VisibilityOff(); return; } @@ -333,56 +366,16 @@ void vvImageContour::UpdateActor(vtkActor * actor, clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2], extent2[3],extent2[4],extent2[5]); - //std::cout << mTSlice << " " << mSlice << " " << extent2[0] << " " << extent2[1] << " " << extent2[2] << " " << extent2[3] << " " << extent2[4] << " " << extent2[5] << std::endl; - if (mHiddenImageIsUsed) delete extent2; // Move the actor to be visible - double position[3] = {0, 0, 0}; - position[orientation] = -1; - actor->SetPosition(position); + SetDepth(mDepth); + // double position[3] = {0, 0, 0}; + // DD(mDepth); + // position[orientation] = -mDepth; + // 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(); - - - } //------------------------------------------------------------------------------