From: dsarrut Date: Mon, 19 Apr 2010 07:14:44 +0000 (+0000) Subject: - set correct spacing/origin for 4D X-Git-Tag: v1.2.0~715 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=039781919d2f8aded60740ec0e1f283bc5d410bb;p=clitk.git - set correct spacing/origin for 4D --- diff --git a/common/vvFromITK.h b/common/vvFromITK.h index c611eee..4add891 100644 --- a/common/vvFromITK.h +++ b/common/vvFromITK.h @@ -79,6 +79,8 @@ template 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 { diff --git a/common/vvImage.cxx b/common/vvImage.cxx index 9b9ca82..1d718bc 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -25,6 +25,8 @@ //-------------------------------------------------------------------- vvImage::vvImage() { mVtkImages.resize(0); + mTimeSpacing = 1; + mTimeOrigin = 0; } //-------------------------------------------------------------------- @@ -147,7 +149,7 @@ std::vector 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 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]); } diff --git a/common/vvImage.h b/common/vvImage.h index b56f38c..7cb3e95 100644 --- a/common/vvImage.h +++ b/common/vvImage.h @@ -17,6 +17,7 @@ ======================================================================-====*/ #ifndef VVIMAGE_H #define VVIMAGE_H + #include #include #include @@ -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 mVtkImages; + double mTimeOrigin; + double mTimeSpacing; };