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

itkNDimensionalSpatialObject.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkNDimensionalSpatialObject.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/10/18 19:21:27 $
00007   Version:   $Revision: 1.4 $
00008 
00009   Copyright (c) 2002 Insight 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  
00018 #ifndef __itkNDimensionalSpatialObject_h 
00019 #define __itkNDimensionalSpatialObject_h 
00020  
00021 #include "itkDataObject.h"
00022 #include "itkObjectFactory.h"
00023 #include "vnl/vnl_vector.h"
00024 #include "itkImageRegion.h"
00025 #include "itkProcessObject.h"
00026 #include "itkIndex.h"
00027 #include "itkSize.h"
00028 #include "itkSpatialObjectProperty.h" 
00029 
00030 namespace itk  
00031 { 
00032 
00042 template <unsigned int PipelineDimension = 3>
00043 class NDimensionalSpatialObject
00044 :public DataObject
00045 { 
00046 
00047 public: 
00048 
00049   typedef NDimensionalSpatialObject<PipelineDimension> Self;
00050   typedef DataObject Superclass; 
00051   
00052   typedef SmartPointer< Self > Pointer;
00053   typedef SmartPointer< const Self > ConstPointer;
00054 //  typedef vnl_vector<double> VectorType;
00055 
00057   typedef Index<PipelineDimension>  IndexType;
00058   typedef typename IndexType::IndexValueType  IndexValueType;
00059   
00062   typedef Offset<PipelineDimension>  OffsetType;
00063   typedef typename OffsetType::OffsetValueType OffsetValueType;
00064   typedef ImageRegion<PipelineDimension> RegionType;
00065   typedef Size<PipelineDimension>    SizeType; 
00066   typedef SpatialObjectProperty< float > PropertyType; 
00067   typedef typename PropertyType::Pointer  PropertyPointer; 
00068 
00069   typedef std::list< Self * > NDimensionalChildrenListType; 
00070 
00072   itkNewMacro( Self );
00073  
00075   itkTypeMacro( Self, Superclass );
00076 
00079   virtual void SetParent( const Self * parent );
00080 
00082   virtual const Self * GetParent( void ) const; 
00083 
00086   virtual bool HasParent( void ) const;
00087 
00089   virtual const char* GetTypeName(void) {return m_TypeName;}
00090 
00092   unsigned int GetDimension(void) const {return m_Dimension;}
00093 
00100   virtual void SetLargestPossibleRegion(const RegionType &region);
00101 
00108   virtual const RegionType& GetLargestPossibleRegion() const
00109     { return m_LargestPossibleRegion;};
00110 
00114   virtual void SetBufferedRegion(const RegionType &region);
00115 
00119   virtual const RegionType& GetBufferedRegion() const
00120   { return m_BufferedRegion;};
00121   
00126   virtual void SetRequestedRegion(const RegionType &region);
00127 
00132   virtual void SetRequestedRegion(DataObject *data);
00133 
00138   virtual const RegionType& GetRequestedRegion() const
00139   { return m_RequestedRegion;};
00140 
00150   const OffsetValueType *GetOffsetTable() const { return m_OffsetTable; };
00151   
00154   OffsetValueType ComputeOffset(const IndexType &ind) const
00155   {
00156     // need to add bounds checking for the region/buffer?
00157     OffsetValueType offset=0;
00158     const IndexType &bufferedRegionIndex = m_BufferedRegion.GetIndex();
00159   
00160     // data is arranged as [][][][slice][row][col]
00161     // with Index[0] = col, Index[1] = row, Index[2] = slice
00162     for (int i=VImageDimension-1; i > 0; i--)
00163       {
00164       offset += (ind[i] - bufferedRegionIndex[i])*m_OffsetTable[i];
00165       }
00166     offset += (ind[0] - bufferedRegionIndex[0]);
00167 
00168     return offset;
00169   }
00170 
00173   IndexType ComputeIndex(OffsetValueType offset) const
00174   {
00175     IndexType index;
00176     const IndexType &bufferedRegionIndex = m_BufferedRegion.GetIndex();
00177     
00178     for (int i=VImageDimension-1; i > 0; i--)
00179       {
00180       index[i] = static_cast<IndexValueType>(offset / m_OffsetTable[i]);
00181       offset -= (index[i] * m_OffsetTable[i]);
00182       index[i] += bufferedRegionIndex[i];
00183       }
00184     index[0] = bufferedRegionIndex[0] + static_cast<IndexValueType>(offset);
00185 
00186     return index;
00187   }
00188 
00198   virtual void CopyInformation(const DataObject *data);
00199 
00207   virtual void UpdateOutputInformation();
00208 
00212   virtual void SetRequestedRegionToLargestPossibleRegion();
00213 
00223   virtual bool RequestedRegionIsOutsideOfTheBufferedRegion();
00224 
00233   virtual bool VerifyRequestedRegion();
00234 
00235 
00237   PropertyType * GetProperty( void );
00238 
00240   void SetProperty( const PropertyType * property ); 
00241 
00243   void SetParentId(int parentid) {m_ParentId=parentid;}
00244   int  GetParentId(void) {return m_ParentId;}
00245 
00247   itkGetMacro(Id,int);
00248   itkSetMacro(Id,int);
00249 
00251   NDimensionalChildrenListType & GetNDimensionalChildren( void ) {return m_NDimensionalChildrenList;}
00252 
00253 
00254 protected: 
00255   
00260   void ComputeOffsetTable();
00261 
00263   NDimensionalSpatialObject(); 
00264 
00266   virtual ~NDimensionalSpatialObject(); 
00267 
00268   ConstPointer m_Parent; 
00269   char m_TypeName[255];
00270 
00271   unsigned int m_Dimension;
00272 
00273   double  m_OffsetTable[3+1];
00274 
00275   RegionType          m_LargestPossibleRegion;
00276   RegionType          m_RequestedRegion;
00277   RegionType          m_BufferedRegion;
00278     
00279 
00280   NDimensionalChildrenListType m_NDimensionalChildrenList;
00281 
00282   PropertyPointer m_Property; 
00283 
00285   int m_ParentId;
00286 
00288   int m_Id;
00289 
00290 }; 
00291 
00292 } // end of namespace itk
00293 
00294 #ifndef ITK_MANUAL_INSTANTIATION 
00295   #include "itkNDimensionalSpatialObject.txx" 
00296 #endif 
00297  
00298 #endif // __itkNDimensionalSpatialObject_h

Generated at Wed Mar 12 01:13:08 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000