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

itkWatershedBoundary.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkWatershedBoundary.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-01-27 19:30:17 $
00007   Version:   $Revision: 1.17 $
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 __itkWatershedBoundary_h
00018 #define __itkWatershedBoundary_h
00019 
00020 #if defined(_MSC_VER)
00021 #pragma warning ( disable : 4786 )
00022 #endif
00023 
00024 #include <list>
00025 #include <vector>
00026 #include "itkImage.h"
00027 #include "itkObjectFactory.h"
00028 #include "itkDataObject.h"
00029 #include "itkProcessObject.h"
00030 #include "itk_hash_map.h"
00031 
00032 namespace itk
00033 {
00034 namespace watershed
00035 {
00055 template <class TScalarType, unsigned int TDimension>
00056 class ITK_EXPORT Boundary : public DataObject
00057 {
00058 public:
00063   itkStaticConstMacro(Dimension, unsigned int, TDimension);
00064 
00069   typedef std::pair<unsigned, unsigned>                        IndexType;
00070   typedef typename Image<unsigned long, TDimension>::IndexType ImageIndexType;
00071   typedef TScalarType                                          ScalarType;
00072 
00074   struct face_pixel_t
00075     {
00076 
00091     short flow;
00092 
00094     unsigned long label;
00095     };
00096 
00098   struct flat_region_t
00099     {
00100 
00104     std::list<unsigned long> offset_list;
00105 
00108     ScalarType bounds_min;
00109 
00112     unsigned long min_label;
00113 
00115     ScalarType value;
00116     };
00117 
00120   typedef Image<face_pixel_t, TDimension> face_t;
00121 
00123   typedef itk::hash_map<unsigned long,             flat_region_t,
00124                         itk::hash<unsigned long> > flat_hash_t;
00125   typedef typename flat_hash_t::value_type         FlatHashValueType;
00126 
00129   typedef Boundary                 Self;
00130   typedef DataObject               Superclass;
00131   typedef SmartPointer<Self>       Pointer;
00132   typedef SmartPointer<const Self> ConstPointer;
00133   itkNewMacro(Self);
00134   itkTypeMacro(WatershedBoundary, DataObject);
00136 
00138   typedef typename face_t::Pointer FacePointer;
00139 
00140   
00142   FacePointer GetFace(const IndexType &idx)
00143   {      return this->GetFace(idx.first, idx.second);    }
00144 
00148   FacePointer GetFace(unsigned dimension, unsigned highlow)
00149     {
00150     if (highlow == 0) return m_Faces[dimension].first;
00151     else return m_Faces[dimension].second;
00152     }
00154 
00155   void SetFace(FacePointer f, const IndexType &idx)
00156     { this->SetFace(f, idx.first, idx.second); }
00157   
00158   void SetFace(FacePointer f, unsigned dimension, unsigned highlow)
00159     {
00160     if (highlow ==0 ) m_Faces[dimension].first = f;
00161     else m_Faces[dimension].second = f;
00162     this->Modified();
00163     }
00164   
00166   flat_hash_t *GetFlatHash(const IndexType &idx)
00167     { return this->GetFlatHash(idx.first, idx.second); }
00168   flat_hash_t *GetFlatHash(unsigned dimension, unsigned highlow)
00169     {
00170     if (highlow == 0) return &(m_FlatHashes[dimension].first);
00171     else return &(m_FlatHashes[dimension].second);
00172     }
00173   void SetFlatHash(flat_hash_t & l, const IndexType &idx)
00174     { this->SetFlatHash(l, idx.first, idx.second); }  
00175   void SetFlatHash(flat_hash_t & l, unsigned dimension,
00176                    unsigned highlow)
00177     {
00178     if (highlow ==0 ) m_FlatHashes[dimension].first = l;
00179     else m_FlatHashes[dimension].second = l;
00180     this->Modified();
00181     }
00183 
00188   void SetValid(bool & l, const IndexType &idx)
00189     { this->SetValid(l, idx.first, idx.second); }  
00190   void SetValid(bool b, unsigned dimension,
00191                 unsigned highlow)
00192     {
00193     if (highlow ==0 ) m_Valid[dimension].first = b;
00194     else m_Valid[dimension].second = b;
00195     this->Modified();
00196     }
00197   bool GetValid(const IndexType &idx) const
00198     { return this->GetValid(idx.first, idx.second); }
00199   bool GetValid(unsigned dimension, unsigned highlow) const
00200     {
00201     if (highlow == 0) return m_Valid[dimension].first;
00202     else return m_Valid[dimension].second;
00203     }
00205 
00206 protected:
00207   Boundary();
00208   virtual ~Boundary() {}
00209   Boundary(const Self&) {}
00210   void operator=(const Self&) {}
00211   void PrintSelf(std::ostream& os, Indent indent) const;
00212 
00214   std::vector<std::pair<FacePointer, FacePointer> > m_Faces;
00215 
00218   std::vector<std::pair<flat_hash_t, flat_hash_t> >  m_FlatHashes;
00219 
00222   std::vector<std::pair<bool,bool> >  m_Valid;
00223 
00224 };
00225 }// end namespace watershed
00226 }// end namespace itk
00227 
00228 #ifndef ITK_MANUAL_INSTANTIATION
00229 #include "itkWatershedBoundary.txx"
00230 #endif
00231 
00232 #endif
00233 

Generated at Tue Sep 15 05:29:04 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000