From 25e6b21607eea7d39428c109e4bc0ebe00f54ed9 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Fri, 22 Oct 2010 08:40:20 +0000 Subject: [PATCH] make difference between 2D and 3D with a single slice image (Dim obtained from ITK reader) --- common/vvImage.cxx | 45 +++++++++++++++++++++++++++++---------------- common/vvImage.h | 3 ++- common/vvImage.txx | 1 + 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/common/vvImage.cxx b/common/vvImage.cxx index c5a3af7..a51f1e6 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -17,14 +17,21 @@ ======================================================================-====*/ #ifndef VVIMAGE_CXX #define VVIMAGE_CXX + +// vv #include "vvImage.h" + +// clitk #include "clitkCommon.h" + +// vtk #include #include -#include - #include +// std +#include + #define NO_RESLICE 1 //-------------------------------------------------------------------- @@ -40,6 +47,7 @@ void vvImage::Init() { mTimeSpacing = 1; mTimeOrigin = 0; + mImageDimension = 0; } //-------------------------------------------------------------------- @@ -64,11 +72,12 @@ void vvImage::Reset() //-------------------------------------------------------------------- int vvImage::GetNumberOfSpatialDimensions() { - int dim=GetNumberOfDimensions(); - if (IsTimeSequence()) - return dim-1; - else - return dim; + return mImageDimension; + // int dim=GetNumberOfDimensions(); + // if (IsTimeSequence()) + // return dim+1; + // else + // return dim; } //-------------------------------------------------------------------- @@ -76,14 +85,18 @@ int vvImage::GetNumberOfSpatialDimensions() int vvImage::GetNumberOfDimensions() const { if (mVtkImages.size()) { - int dimension = 2; - int extent[6]; - mVtkImages[0]->GetWholeExtent(extent); - if (extent[5] - extent[4] >= 1) - dimension++; - if (mVtkImages.size() > 1) - dimension++; - return dimension; + if (IsTimeSequence()) + return mImageDimension+1; + else + return mImageDimension; + // int dimension = 3; + // int extent[6]; + // mVtkImages[0]->GetWholeExtent(extent); + // if (extent[5] - extent[4] >= 1) + // dimension++; + // // if (mVtkImages.size() > 1) + // // dimension++; + // return dimension; } return 0; } @@ -186,7 +199,7 @@ unsigned long vvImage::GetActualMemorySize() //-------------------------------------------------------------------- -bool vvImage::IsTimeSequence() +bool vvImage::IsTimeSequence() const { return mVtkImages.size()>1; } diff --git a/common/vvImage.h b/common/vvImage.h index cc0ce76..a8fc87f 100644 --- a/common/vvImage.h +++ b/common/vvImage.h @@ -52,7 +52,7 @@ public : std::string GetScalarTypeAsITKString(); int GetNumberOfScalarComponents(); int GetScalarSize(); - bool IsTimeSequence(); + bool IsTimeSequence() const; bool IsScalarTypeInteger(); bool IsScalarTypeInteger(int t); vtkSmartPointer GetTransform(); @@ -70,6 +70,7 @@ private: vtkSmartPointer mTransform; double mTimeOrigin; double mTimeSpacing; + uint mImageDimension; }; //------------------------------------------------------------------------------ diff --git a/common/vvImage.txx b/common/vvImage.txx index 4532a68..1561a13 100755 --- a/common/vvImage.txx +++ b/common/vvImage.txx @@ -4,6 +4,7 @@ template void vvImage::AddItkImage(TItkImageType *input) { + mImageDimension = TItkImageType::ImageDimension; typedef itk::ImageToVTKImageFilter ConverterType; typename ConverterType::Pointer converter = ConverterType::New(); converter->SetInput(input); -- 2.47.1