]> Creatis software - clitk.git/commitdiff
Modified transform in vvImage. Now a vtkGeneralTransform which composes a vtkGridTran...
authorsrit <srit>
Fri, 9 Jul 2010 08:24:10 +0000 (08:24 +0000)
committersrit <srit>
Fri, 9 Jul 2010 08:24:10 +0000 (08:24 +0000)
Removed CLITK_EXPERIMENTAL condition.

common/CMakeLists.txt
common/vvImage.cxx
common/vvImage.h

index 9ac871a205d7e550b41a1a29a433d0359b2a7ff0..19e6671776266339ee1e19ecd23343978968a864 100644 (file)
@@ -31,7 +31,7 @@ SET(clitkCommon_SRC
 )  
 
 ADD_LIBRARY(clitkCommon STATIC ${clitkCommon_SRC})
-TARGET_LINK_LIBRARIES(clitkCommon vtkCommon vtkImaging ITKBasicFilters)
+TARGET_LINK_LIBRARIES(clitkCommon vtkCommon vtkImaging vtkHybrid ITKBasicFilters)
 
 ADD_LIBRARY(clitkDicomRTStruct STATIC
   clitkDicomRT_Contour.cxx
index 797fa3e9dd35458d383850e6c388fcde946b9654..55a56ef2f3e75cd3351b28b3bd475f6afafbace0 100644 (file)
 #define VVIMAGE_CXX
 #include "vvImage.h"
 #include "clitkCommon.h"
-#include <vtkTransform.h>
 #include <vtkImageData.h>
 #include <vtkImageReslice.h>
 #include <cassert>
 
+#include <vtkGeneralTransform.h>
+#include <vtkTransform.h>
+#include <vtkGridTransform.h>
+
 //--------------------------------------------------------------------
-vvImage::vvImage()
+vvImage::vvImage():mGeneralTransform(vtkSmartPointer<vtkGeneralTransform>::New()),
+                  mTransform       (vtkSmartPointer<vtkTransform>::New()),
+                  mGridTransform   (vtkSmartPointer<vtkGridTransform>::New())
 {
+  mGeneralTransform->Concatenate(mTransform);
+  mGeneralTransform->Concatenate(mGridTransform);
   Init();
 }
 //--------------------------------------------------------------------
@@ -37,9 +44,6 @@ void vvImage::Init()
 {
   mTimeSpacing = 1;
   mTimeOrigin = 0;
-
-  if (CLITK_EXPERIMENTAL)
-    mTransform = vtkSmartPointer<vtkTransform>::New();
 }
 //--------------------------------------------------------------------
 
@@ -53,12 +57,8 @@ vvImage::~vvImage()
 //--------------------------------------------------------------------
 void vvImage::Reset()
 {
-  if (CLITK_EXPERIMENTAL)
-    for (unsigned int i = 0; i < mVtkImages.size(); i++)
-      mVtkImageReslice[i]->GetInput(0)->Delete();
-  else
-    for (unsigned int i = 0; i < mVtkImages.size(); i++)
-      mVtkImages[i]->Delete();
+  for (unsigned int i = 0; i < mVtkImages.size(); i++)
+    mVtkImageReslice[i]->GetInput()->Delete();
 
   mVtkImages.resize(0);
   mVtkImageReslice.resize(0);
@@ -67,7 +67,6 @@ void vvImage::Reset()
 }
 //--------------------------------------------------------------------
 
-
 //--------------------------------------------------------------------
 void vvImage::SetImage(std::vector< vtkImageData* > images)
 {
@@ -81,19 +80,16 @@ void vvImage::SetImage(std::vector< vtkImageData* > images)
 //--------------------------------------------------------------------
 void vvImage::AddImage(vtkImageData* image)
 {
-  if (CLITK_EXPERIMENTAL) {
-    mVtkImageReslice.push_back(vtkSmartPointer<vtkImageReslice>::New());
-
-    mVtkImageReslice.back()->SetInterpolationModeToLinear();
-    mVtkImageReslice.back()->AutoCropOutputOn();
-    mVtkImageReslice.back()->SetBackgroundColor(-1000,-1000,-1000,1);
-    mVtkImageReslice.back()->SetResliceTransform(mTransform);
-    mVtkImageReslice.back()->SetInput(0, image);
-    mVtkImageReslice.back()->Update();
-
-    mVtkImages.push_back( mVtkImageReslice.back()->GetOutput(0) );
-  } else
-    mVtkImages.push_back(image);
+  mVtkImageReslice.push_back(vtkSmartPointer<vtkImageReslice>::New());
+
+  mVtkImageReslice.back()->SetInterpolationModeToLinear();
+  mVtkImageReslice.back()->AutoCropOutputOn();
+  mVtkImageReslice.back()->SetBackgroundColor(-1000,-1000,-1000,1);
+  mVtkImageReslice.back()->SetResliceTransform(mGeneralTransform);
+  mVtkImageReslice.back()->SetInput(0, image);
+  mVtkImageReslice.back()->Update();
+
+  mVtkImages.push_back( mVtkImageReslice.back()->GetOutput(0) );
 }
 //--------------------------------------------------------------------
 
@@ -107,7 +103,7 @@ int vvImage::GetNumberOfSpatialDimensions()
     return dim;
 }
 //--------------------------------------------------------------------
-//
+
 //--------------------------------------------------------------------
 int vvImage::GetNumberOfDimensions() const
 {
@@ -123,6 +119,8 @@ int vvImage::GetNumberOfDimensions() const
   }
   return 0;
 }
+//--------------------------------------------------------------------
+
 //--------------------------------------------------------------------
 void vvImage::GetScalarRange(double* range)
 {
@@ -136,6 +134,7 @@ void vvImage::GetScalarRange(double* range)
     if (temp[1] > range[1]) range[1]=temp[1];
   }
 }
+//--------------------------------------------------------------------
 
 //--------------------------------------------------------------------
 std::string vvImage::GetScalarTypeAsITKString()
@@ -233,7 +232,6 @@ const std::vector<vtkImageData*>& vvImage::GetVTKImages()
 }
 //--------------------------------------------------------------------
 
-
 //--------------------------------------------------------------------
 vtkImageData* vvImage::GetFirstVTKImageData()
 {
@@ -241,7 +239,6 @@ vtkImageData* vvImage::GetFirstVTKImageData()
 }
 //--------------------------------------------------------------------
 
-
 //--------------------------------------------------------------------
 bool vvImage::IsScalarTypeInteger()
 {
@@ -279,10 +276,9 @@ vtkSmartPointer<vtkTransform> vvImage::GetTransform()
 //--------------------------------------------------------------------
 
 //--------------------------------------------------------------------
-void vvImage::SetTransform(vtkSmartPointer<vtkTransform> transform)
+vtkSmartPointer<vtkGridTransform> vvImage::GetGridTransform()
 {
-  mTransform = transform;
-  this->UpdateReslice();
+  return mGridTransform;
 }
 //--------------------------------------------------------------------
 
index 7dbba1f3577c2ce65b7280071fb0e81375b76f52..07987c78cda75b16c5d40d3c5f3949643dc083e8 100644 (file)
@@ -25,9 +25,9 @@
 
 class vtkImageData;
 class vtkImageReslice;
+class vtkGeneralTransform;
 class vtkTransform;
-class vtkImageReslice;
-class vtkAbstractTransform;
+class vtkGridTransform;
 
 //------------------------------------------------------------------------------
 class vvImage : public itk::LightObject
@@ -57,6 +57,7 @@ public :
   bool IsScalarTypeInteger();
   bool IsScalarTypeInteger(int t);
   vtkSmartPointer<vtkTransform> GetTransform();
+  vtkSmartPointer<vtkGridTransform> GetGridTransform();
   void SetTransform(vtkSmartPointer<vtkTransform> transform);
   void SetTimeSpacing(double s) { mTimeSpacing = s; }
   void SetTimeOrigin(double o) { mTimeOrigin = o; }
@@ -68,7 +69,9 @@ private:
 
   std::vector<vtkImageData*> mVtkImages;
   std::vector< vtkSmartPointer<vtkImageReslice> > mVtkImageReslice;
+  vtkSmartPointer<vtkGeneralTransform> mGeneralTransform;
   vtkSmartPointer<vtkTransform> mTransform;
+  vtkSmartPointer<vtkGridTransform> mGridTransform;
   double mTimeOrigin;
   double mTimeSpacing;
 };