]> Creatis software - clitk.git/commitdiff
Account for reslicing transform in overlay and fusion (contours and vf
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 4 Sep 2012 09:01:03 +0000 (11:01 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 4 Sep 2012 09:01:03 +0000 (11:01 +0200)
        have not been tested, TODO)

vv/vvSlicer.cxx
vv/vvSlicer.h
vv/vvSlicerManager.cxx

index f84011c0cd4da76107a2931354c905bb00b6e3de..abf6306f360164c63b7bbe5e492931c1a0e6c971 100644 (file)
@@ -82,6 +82,8 @@ vvSlicer::vvSlicer()
   mImage = NULL;
   mReducedExtent = new int[6];
   mCurrentTSlice = 0;
+  mCurrentFusionTSlice = 0;
+  mCurrentOverlayTSlice = 0;
   mUseReducedExtent = false;
 
   mCurrent[0] = -VTK_DOUBLE_MAX;
@@ -148,6 +150,8 @@ vvSlicer::vvSlicer()
 
   mSlicingTransform = vtkSmartPointer<vtkTransform>::New();
   mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
+  mConcatenatedFusionTransform = vtkSmartPointer<vtkTransform>::New();
+  mConcatenatedOverlayTransform = vtkSmartPointer<vtkTransform>::New();
 }
 //------------------------------------------------------------------------------
 
@@ -369,8 +373,13 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay)
       mOverlayReslice->AutoCropOutputOn();
       mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
     }
-    mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()[0]);
+
+    mConcatenatedOverlayTransform->Identity();
+    mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[0]);
+    mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
+    mOverlayReslice->SetResliceTransform(mConcatenatedOverlayTransform);
     mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
+    mImageReslice->UpdateInformation();
 
     if (!mOverlayMapper)
       mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
@@ -416,8 +425,13 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion)
       mFusionReslice->AutoCropOutputOn();
       mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
     }
-    mFusionReslice->SetResliceTransform(mFusion->GetTransform()[0]);
+
+    mConcatenatedFusionTransform->Identity();
+    mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[0]);
+    mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
+    mFusionReslice->SetResliceTransform(mConcatenatedFusionTransform);
     mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
+    mFusionReslice->UpdateInformation();
 
     if (!mFusionMapper)
       mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
@@ -711,12 +725,16 @@ void vvSlicer::SetTSlice(int t)
       mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
   }
   if (mOverlay && mOverlayActor->GetVisibility()) {
-    if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
-      mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] );
+    if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice) {
+      mCurrentOverlayTSlice = mCurrentTSlice;
+      mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
+    }
   }
   if (mFusion && mFusionActor->GetVisibility()) {
-    if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
-      mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]);
+    if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice) {
+      mCurrentFusionTSlice = mCurrentTSlice;
+      mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
+    }
   }
   if (mSurfaceCutActors.size() > 0)
     for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
@@ -734,6 +752,20 @@ int vvSlicer::GetTSlice()
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+int vvSlicer::GetFusionTSlice()
+{
+  return mCurrentFusionTSlice;
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+int vvSlicer::GetOverlayTSlice()
+{
+  return mCurrentOverlayTSlice;
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvSlicer::SetSliceOrientation(int orientation)
 {
@@ -1197,7 +1229,7 @@ void vvSlicer::SetOverlayColorLevel(double level)
 //----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
-// Returns the min an the max value in a 41x41 region around the mouse pointer
+// Returns the min an the max value in a 20%x20% region around the mouse pointer
 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
 {
   //Get mouse pointer position in view coordinates
index 0a0bcca86395deffd27d00230ffbc6e62eeaf2c1..71f7ece7e4ecbe22e75fab3406a143d11d8ad5b6 100644 (file)
@@ -99,6 +99,8 @@ public:
   void SetSliceOrientation(int orientation);
   void AdjustResliceToSliceOrientation(vtkImageReslice *reslice);
   int GetTSlice();
+  int GetFusionTSlice();
+  int GetOverlayTSlice();
   ///Reimplemented from vtkImageViewer2 to add polydata support
   void SetSlice(int s);
   int GetTMax() {
@@ -142,6 +144,8 @@ public:
 
   vtkTransform * GetSlicingTransform() { return mSlicingTransform; }
   vtkTransform * GetConcatenatedTransform() { return mConcatenatedTransform; }
+  vtkTransform * GetConcatenatedFusionTransform() { return mConcatenatedFusionTransform; }
+  vtkTransform * GetConcatenatedOverlayTransform() { return mConcatenatedOverlayTransform; }
 
   void SetCurrentPosition(double x, double y, double z, int t);
   double* GetCurrentPosition();
@@ -211,19 +215,21 @@ protected:
   //                            Λ  Λ
   //                            |  | vvImage.GetTransform()
   //                            |  |
-  // GetConcatenatedTransform() | _|___ VV world coordinates (mm) (displayed in VV)
+  // GetConcatenatedTransform() | _|___ VV world coordinates (mm) (displayed in VV)             mCurrentBeforeSlicingTransform
   //                            |  Λ
   //                            |  | GetSlicingTransform()
   //                            |  |
-  //                         ___|__|___ VTK world coordinates (mm) (never displayed)
+  //                         ___|__|___ VTK world coordinates (mm) (never displayed)            mCurrent
 
-  vtkSmartPointer<vtkImageReslice> mImageReslice;
   vtkSmartPointer<vtkTransform> mSlicingTransform;
+  vtkSmartPointer<vtkImageReslice> mImageReslice;
   vtkSmartPointer<vtkTransform> mConcatenatedTransform;
   vtkSmartPointer<vtkImageReslice> mOverlayReslice;
+  vtkSmartPointer<vtkTransform> mConcatenatedOverlayTransform;
   vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
   vtkSmartPointer<vvBlendImageActor> mOverlayActor;
   vtkSmartPointer<vtkImageReslice> mFusionReslice;
+  vtkSmartPointer<vtkTransform> mConcatenatedFusionTransform;
   vtkSmartPointer<vtkImageMapToColors> mFusionMapper;
   vtkSmartPointer<vtkImageActor> mFusionActor;
   vtkSmartPointer<vtkCornerAnnotation> ca;
@@ -247,6 +253,8 @@ protected:
   std::vector<vvMeshActor*> mSurfaceCutActors;
 
   int mCurrentTSlice;
+  int mCurrentFusionTSlice;
+  int mCurrentOverlayTSlice;
   double mCurrent[3];
   double mCurrentBeforeSlicingTransform[3];
   double mCursor[4];
index 5affb4be4bc9fbcc431c7569f56b6be7540dfac5..1c642215b4b904a0e44797c973937ca4855a6989 100644 (file)
@@ -1146,19 +1146,20 @@ void vvSlicerManager::SetPreset(int preset)
 void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey)
 {
   double min, max;
-  int t = this->GetTSlice();
   if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) {
+    int t = mSlicers[slicer]->GetFusionTSlice();
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetFusion()->GetVTKImages()[t],
-                                                          this->mSlicers[slicer]->GetFusion()->GetTransform()[t]);
+                                                          this->mSlicers[slicer]->GetConcatenatedFusionTransform());
     this->SetFusionWindow(max-min);
     this->SetFusionLevel(0.5*(min+max));
     this->SetColorMap(mColorMap);
   }
   else if(bCtrlKey && this->mSlicers[slicer]->GetOverlay()) {
+    int t = mSlicers[slicer]->GetOverlayTSlice();
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetOverlay()->GetVTKImages()[t],
-                                                          this->mSlicers[slicer]->GetOverlay()->GetTransform()[t]);
+                                                          this->mSlicers[slicer]->GetConcatenatedOverlayTransform());
     if(this->mSlicers[slicer]->GetLinkOverlayWindowLevel()){
       this->SetColorWindow(max-min);
       this->SetColorLevel(0.5*(min+max));
@@ -1168,6 +1169,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK
     }
   }
   else {
+    int t = this->GetTSlice();
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetImage()->GetVTKImages()[t],
                                                           this->mSlicers[slicer]->GetConcatenatedTransform());