Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkImageIORegion.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageIORegion.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/01/10 09:44:01 $
00007   Version:   $Revision: 1.15 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkImageIORegion_h
00018 #define __itkImageIORegion_h
00019 
00020 #include <algorithm>
00021 #include "itkRegion.h"
00022 #include "itkObjectFactory.h"
00023 
00024 namespace itk
00025 {
00026 
00044 class ITK_EXPORT ImageIORegion: public Region
00045 {
00046 public:
00048   typedef ImageIORegion Self;
00049   typedef Region        Superclass;
00050 
00052   itkTypeMacro(ImageIORegion, Region);
00053 
00055   unsigned int GetImageDimension() const
00056   { return m_ImageDimension; }
00057 
00061   unsigned int GetRegionDimension() const
00062   { 
00063     unsigned long dim=0;
00064     for (unsigned long i=0; i<m_ImageDimension; i++)
00065       {
00066       if ( m_Size[i] > 1 ) dim++;
00067       }
00068     return dim;
00069   }
00071 
00073   typedef std::vector<long>  IndexType;
00074 
00076   typedef std::vector<long>  SizeType;
00077 
00079   virtual Superclass::RegionType GetRegionType() const
00080   {return Superclass::ITK_STRUCTURED_REGION;}
00081 
00084   ImageIORegion(unsigned int dimension)
00085   {
00086     m_ImageDimension = dimension;
00087     m_Index.resize(m_ImageDimension);
00088     m_Size.resize(m_ImageDimension);
00089     std::fill(m_Index.begin(), m_Index.end(), 0);
00090     std::fill(m_Size.begin(), m_Size.end(), 0);
00091   }
00093 
00096   ImageIORegion()
00097   {
00098     m_ImageDimension = 2;
00099     m_Index.resize(2);
00100     m_Size.resize(2);
00101     std::fill(m_Index.begin(), m_Index.end(), 0);
00102     std::fill(m_Size.begin(), m_Size.end(), 0);
00103   }
00105 
00108   virtual ~ImageIORegion(){};
00109 
00112   ImageIORegion(const Self& region): Region()
00113   { 
00114     m_Index =region.m_Index; 
00115     m_Size = region.m_Size; 
00116     m_ImageDimension = region.m_ImageDimension;
00117   }
00118 
00121   void operator=(const Self& region) 
00122   { 
00123     m_Index = region.m_Index;  
00124     m_Size = region.m_Size;
00125     m_ImageDimension = region.m_ImageDimension;
00126   };
00127 
00129   void SetIndex(const IndexType &index) 
00130   { m_Index = index; };
00131 
00133   const IndexType& GetIndex() const
00134   { return m_Index; };
00135 
00138   void SetSize(const SizeType &size)
00139   { m_Size = size; };
00140 
00142   const SizeType& GetSize() const
00143   { return m_Size;}
00144 
00148   long GetSize(unsigned long i) const
00149   { return m_Size[i]; }
00150   long GetIndex(unsigned long i) const
00151   { return m_Index[i]; }
00152   void SetSize(const unsigned long i, long size)
00153   {m_Size[i] = size;}
00154   void SetIndex(const unsigned long i, long idx)
00155   {m_Index[i] = idx;}
00157 
00159   bool
00160   operator==(const Self &region) const
00161   {
00162     bool same = 1;
00163     same = (m_Index == region.m_Index);
00164     same = same && (m_Size == region.m_Size);
00165     same = same && (m_ImageDimension == region.m_ImageDimension);
00166     return same;
00167   }
00169 
00171   bool
00172   operator!=(const Self &region) const
00173   {
00174     bool same = 1;
00175     same = (m_Index == region.m_Index);
00176     same = same && (m_Size == region.m_Size);
00177     same = same && (m_ImageDimension == region.m_ImageDimension);
00178     return !same;
00179   }
00181 
00183   bool
00184   IsInside(const IndexType &index) const
00185   {
00186     for(unsigned int i=0; i<m_ImageDimension; i++)
00187       {
00188       if( index[i] < m_Index[i] ) 
00189         {
00190         return false;
00191         }
00192       if( index[i] >= m_Index[i] + m_Size[i] ) 
00193         {
00194         return false;
00195         }
00196       }
00197     return true;
00198   }
00200 
00203 //  unsigned long GetNumberOfPixels() const;
00204 
00205 protected:
00210   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00211 
00212 private:
00213   unsigned int m_ImageDimension;
00214   std::vector<long> m_Index;
00215   std::vector<long> m_Size;
00216 };
00217 
00218 
00219 // Declare operator<<
00220 extern std::ostream & operator<<(std::ostream &os, const ImageIORegion &region); 
00221 
00222 } // end namespace itk
00223 
00224 #endif
00225 
00226 

Generated at Mon Mar 12 00:51:01 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000