]> Creatis software - clitk.git/blob - common/vvImage.h
Clear previous commits for clitkDicom2Image
[clitk.git] / common / vvImage.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef VVIMAGE_H
19 #define VVIMAGE_H
20
21 #include <iostream>
22 #include <vector>
23 #include <itkObjectFactory.h>
24 #include <itkProcessObject.h>
25 #include <itkMinimumMaximumImageCalculator.h>
26 #include <itkCastImageFilter.h>
27
28 #define VTK_EXCLUDE_STRSTREAM_HEADERS
29 #include <vtkSmartPointer.h>
30 #include <vtkTransform.h>
31
32 class vtkImageData;
33
34 //------------------------------------------------------------------------------
35 class vvImage : public itk::LightObject
36 {
37 public :
38   typedef vvImage Self;
39   typedef itk::SmartPointer<Self> Pointer;
40   typedef itk::ProcessObject::Pointer ConverterPointer;
41   itkNewMacro(Self);
42   
43   struct DimensionDispatchBase {};
44   template< unsigned int VDimension >
45   struct DimensionDispatch:public DimensionDispatchBase {};
46
47   void Init();
48   void Reset();
49   template<class TItkImageType> void AddItkImage(TItkImageType *input);
50   void AddVtkImage(vtkImageData* input);
51   const std::vector<vtkImageData*>& GetVTKImages();
52   vtkImageData* GetFirstVTKImageData();
53   int GetNumberOfDimensions() const;
54   int GetNumberOfSpatialDimensions();
55   void GetScalarRange(double* range);
56   template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRangeBase(itk::Image<TPixelType,VImageDimension> *input);
57   template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRange(DimensionDispatchBase, itk::Image<TPixelType,VImageDimension> *input);
58   template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRange(DimensionDispatch< 1 >, itk::Image<TPixelType,VImageDimension> *input);
59   unsigned long GetActualMemorySize();
60   std::vector<double> GetSpacing();
61   std::vector<double> GetOrigin() const;
62   std::vector<int> GetSize();
63   std::vector< std::vector<double> > GetDirection();
64   std::string GetScalarTypeAsITKString();
65   int GetNumberOfScalarComponents();
66   int GetScalarSize();
67   bool IsTimeSequence() const;
68   bool IsScalarTypeInteger();
69   bool IsScalarTypeInteger(int t);
70   const std::vector< vtkSmartPointer<vtkTransform> >& GetTransform();
71   void SetTimeSpacing(double s) { mTimeSpacing = s; }
72   void SetTimeOrigin(double o) { mTimeOrigin = o; }
73   bool HaveSameSizeAndSpacingThan(vvImage * other);
74   //META DATA
75   itk::MetaDataDictionary* GetFirstMetaDataDictionary();
76
77 private:
78   vvImage();
79   ~vvImage();
80
81   std::vector< ConverterPointer > mItkToVtkConverters;
82   std::vector< vtkImageData* > mVtkImages;
83   std::vector< vtkSmartPointer<vtkTransform> > mTransform;
84   //META DATA
85   std::vector< itk::MetaDataDictionary* > mDictionary;
86
87   double mTimeOrigin;
88   double mTimeSpacing;
89   unsigned int mImageDimension;
90   double mrange[2];
91 };
92 //------------------------------------------------------------------------------
93
94 #include "vvImage.txx"
95
96 #endif