]> Creatis software - clitk.git/commitdiff
make difference between 2D and 3D with a single slice image (Dim obtained from ITK...
authordsarrut <dsarrut>
Fri, 22 Oct 2010 08:40:20 +0000 (08:40 +0000)
committerdsarrut <dsarrut>
Fri, 22 Oct 2010 08:40:20 +0000 (08:40 +0000)
common/vvImage.cxx
common/vvImage.h
common/vvImage.txx

index c5a3af73d2349604f63c935952fdc075f71ab770..a51f1e618236fdabcfeff65d747bb7c8dbcff95e 100644 (file)
 ======================================================================-====*/
 #ifndef VVIMAGE_CXX
 #define VVIMAGE_CXX
+
+// vv
 #include "vvImage.h"
+
+// clitk
 #include "clitkCommon.h"
+
+// vtk
 #include <vtkImageData.h>
 #include <vtkImageReslice.h>
-#include <cassert>
-
 #include <vtkTransform.h>
 
+// std
+#include <cassert>
+
 #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;
 }
index cc0ce76028dd3734eeeb342aa80c9de996846d05..a8fc87f46e5288518e89363189513ad43b956371 100644 (file)
@@ -52,7 +52,7 @@ public :
   std::string GetScalarTypeAsITKString();
   int GetNumberOfScalarComponents();
   int GetScalarSize();
-  bool IsTimeSequence();
+  bool IsTimeSequence() const;
   bool IsScalarTypeInteger();
   bool IsScalarTypeInteger(int t);
   vtkSmartPointer<vtkTransform> GetTransform();
@@ -70,6 +70,7 @@ private:
   vtkSmartPointer<vtkTransform> mTransform;
   double mTimeOrigin;
   double mTimeSpacing;
+  uint mImageDimension;
 };
 //------------------------------------------------------------------------------
 
index 4532a68f13819fb53024905b6ed2c29e1db5d00d..1561a13d447a52256d0f02c02b323a63a4aeffe3 100755 (executable)
@@ -4,6 +4,7 @@
 template<class TItkImageType>
 void vvImage::AddItkImage(TItkImageType *input)
 {
+  mImageDimension = TItkImageType::ImageDimension; 
   typedef itk::ImageToVTKImageFilter <TItkImageType> ConverterType;
   typename ConverterType::Pointer converter = ConverterType::New();
   converter->SetInput(input);