]> Creatis software - clitk.git/commitdiff
- set correct spacing/origin for 4D
authordsarrut <dsarrut>
Mon, 19 Apr 2010 07:14:44 +0000 (07:14 +0000)
committerdsarrut <dsarrut>
Mon, 19 Apr 2010 07:14:44 +0000 (07:14 +0000)
common/vvFromITK.h
common/vvImage.cxx
common/vvImage.h

index c611eee6370f853cd375461b9f775f496260d827..4add8912c43c09e75e452f63ef18d0bd2d1f60d5 100644 (file)
@@ -79,6 +79,8 @@ template<unsigned int Dim, class PixelType> vvImage::Pointer vvImageFromITK(type
             image->DeepCopy(connector->GetOutput());
             vv_image->AddImage(image);
         }
+        vv_image->SetTimeSpacing(input->GetSpacing()[Dim-1]);
+        vv_image->SetTimeOrigin(input->GetOrigin()[Dim-1]);        
     }
     else //Dim == 1,2,3 and not time_sequence
     {
index 9b9ca8289956b832b19e9dca0b6b47300208c6e1..1d718bce26d6fb5d24498d02bbe01e5f3bddf5dc 100644 (file)
@@ -25,6 +25,8 @@
 //--------------------------------------------------------------------
 vvImage::vvImage() {
   mVtkImages.resize(0);
+  mTimeSpacing = 1;
+  mTimeOrigin = 0;
 }
 //--------------------------------------------------------------------
 
@@ -147,7 +149,7 @@ std::vector<double> vvImage::GetSpacing() {
   for (int i = 0; i < dim; i++)
     {
       if (i == 3)
-        spacing.push_back(1);
+        spacing.push_back(mTimeSpacing);
       else
         spacing.push_back(mVtkImages[0]->GetSpacing()[i]);
     }
@@ -163,7 +165,7 @@ std::vector<double> vvImage::GetOrigin() const {
   for (int i = 0; i < dim; i++)
     {
       if (i == 3)
-        origin.push_back(0);
+        origin.push_back(mTimeOrigin);
       else
         origin.push_back(mVtkImages[0]->GetOrigin()[i]);
     }
index b56f38c2ff753f2f58329155409e8743ed1e319c..7cb3e95a472faa85b16ac9d4c9b5093f9922d740 100644 (file)
@@ -17,6 +17,7 @@
 ======================================================================-====*/
 #ifndef VVIMAGE_H
 #define VVIMAGE_H
+
 #include <iostream>
 #include <vector>
 #include <itkObjectFactory.h>
@@ -50,10 +51,15 @@ public :
   bool IsScalarTypeInteger();
   bool IsScalarTypeInteger(int t);
 
+  void SetTimeSpacing(double s) { mTimeSpacing = s; }
+  void SetTimeOrigin(double o) { mTimeOrigin = o; }
+
 private:
   vvImage();
   ~vvImage();
   std::vector<vtkImageData*> mVtkImages;
+  double mTimeOrigin;
+  double mTimeSpacing;
 
 };