]> Creatis software - clitk.git/commitdiff
Landmarks move with the image during registration
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Tue, 23 Feb 2016 10:12:15 +0000 (11:12 +0100)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Tue, 23 Feb 2016 10:12:15 +0000 (11:12 +0100)
vv/vvSlicer.cxx
vv/vvSlicer.h

index 2729bd68925da8f2332576302b50ef9f00c59b6f..314b58ca5cff344e8a43b42885365b26c2c6c392 100644 (file)
@@ -669,12 +669,24 @@ void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
     mLandClipper->SetClipFunction(mClipBox);
     mLandClipper->InsideOutOn();
 #if VTK_MAJOR_VERSION <= 5
-    mLandClipper->SetInput(mLandmarks->GetOutput());
+    mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
+    mLandmarkTransform->SetInput(mLandmarks->GetOutput());
+    mConcatenatedTransform->Identity();
+    mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
+    mConcatenatedTransform->Concatenate(mSlicingTransform);
+    mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
+    mLandClipper->SetInput(mLandmarkTransform->GetOutput());
 
     mLandGlyph->SetSource(mCross->GetOutput());
     mLandGlyph->SetInput(mLandClipper->GetOutput());
 #else
-    mLandClipper->SetInputData(mLandmarks->GetOutput());
+    mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
+    mLandmarkTransform->SetInputData(mLandmarks->GetOutput());
+    mConcatenatedTransform->Identity();
+    mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
+    mConcatenatedTransform->Concatenate(mSlicingTransform);
+    mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
+    mLandClipper->SetInputConnection(mLandmarkTransform->GetOutputPort());
 
     mLandGlyph->SetSourceConnection(mCross->GetOutputPort());
     mLandGlyph->SetInputConnection(mLandClipper->GetOutputPort());
@@ -697,7 +709,6 @@ void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
     mLandActor->SetPickable(0);
     mLandActor->SetVisibility(true);
     this->UpdateDisplayExtent();
-    this->GetRenderer()->AddActor(mLandActor);
   }
 }
 //------------------------------------------------------------------------------
@@ -1802,7 +1813,7 @@ void vvSlicer::UpdateCursorPosition()
 //----------------------------------------------------------------------------
 void vvSlicer::RemoveLandmarks()
 { 
-  vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
+  vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
   if (pd->GetPoints()) {
 
     //First remove all captions:
@@ -1828,12 +1839,12 @@ void vvSlicer::DisplayLandmarks()
   mClipBox->SetBounds(bounds);
 
 
-  vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
+  vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
   if (pd->GetPoints()) {
+    this->GetRenderer()->AddActor(mLandActor);
     //mLandGlyph->SetRange(0,1);
     //mLandGlyph->Modified();
     //mLandGlyph->Update();
-
     mClipBox->Modified();
     mLandClipper->Update();
     mLandMapper->Update();
index 4fadb3e775023661c0689b07e7a5f9075dce6324..5027d16e6fd0256b3bc3f32b75c8a307c9cfc511 100644 (file)
@@ -35,6 +35,7 @@
 #include <vtkImageReslice.h>
 #include <vtkImageMapToColors.h>
 #include <vtkCaptionActor2D.h>
+#include <vtkTransformPolyDataFilter.h>
 
 class vtkActor;
 class vtkActor2D;
@@ -246,6 +247,7 @@ protected:
   //                         ___|__|___ VTK world coordinates (mm) (never displayed)            mCurrent
 
   vtkSmartPointer<vtkTransform> mSlicingTransform;
+  vtkSmartPointer<vtkTransformPolyDataFilter> mLandmarkTransform;
   vtkSmartPointer<vtkImageReslice> mImageReslice;
   vtkSmartPointer<vtkTransform> mConcatenatedTransform;
   vtkSmartPointer<vtkImageReslice> mOverlayReslice;