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

itkWatershedSegmentTree.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkWatershedSegmentTree.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-17 16:12:25 $
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 __itkWatershedSegmentTree_h
00018 #define __itkWatershedSegmentTree_h
00019 
00020 #include "itkObjectFactory.h"
00021 #include "itkDataObject.h"
00022 #include "itkProcessObject.h"
00023 #include <deque>
00024 #include <functional>
00025 
00026 namespace itk
00027 {
00028 namespace watershed
00029 {
00046 template <class TScalarType>
00047 class ITK_EXPORT SegmentTree : public DataObject
00048 {
00049 public:
00051   typedef SegmentTree              Self;
00052   typedef DataObject               Superclass;
00053   typedef SmartPointer<Self>       Pointer;
00054   typedef SmartPointer<const Self> ConstPointer;
00055   itkNewMacro(Self);
00056   itkTypeMacro(WatershedSegmentTree, DataObject);
00057   typedef TScalarType ScalarType;
00059 
00063   struct merge_t
00064     {
00065     unsigned long from;
00066     unsigned long to;
00067     ScalarType saliency;
00068     };
00070 
00072   typedef std::deque<merge_t>                DequeType;
00073   typedef typename DequeType::iterator       Iterator;
00074   typedef typename DequeType::const_iterator ConstIterator;
00075   typedef typename DequeType::value_type     ValueType;
00076 
00078   struct merge_comp : public std::binary_function<bool, const merge_t&,
00079                       const merge_t& >
00080     {
00081     merge_comp() {}
00082     bool operator()(const merge_t &a, const merge_t &b)
00083       {
00084       return b.saliency < a.saliency;
00085       }
00086     };
00088 
00090   struct sort_comp : public std::binary_function<bool, const merge_t&,
00091                      const merge_t& >
00092     {
00093     bool operator()(const merge_t &a, const merge_t &b)
00094       {
00095       return a.saliency < b.Saliency;
00096       }
00097     };
00098 
00100   typename DequeType::size_type Size() const
00101     { return m_Deque.size(); }
00102 
00105   bool Empty() const
00106     { return m_Deque.empty();    }
00107 
00110   const merge_t &Front() const
00111     { return m_Deque.front(); }
00112 
00115   const merge_t &Back() const
00116     { return m_Deque.back(); } 
00117 
00119   merge_t &Front()
00120     { return m_Deque.front(); }
00121 
00123   merge_t &Back()
00124     { return m_Deque.back(); }
00125 
00127   void PushFront(const ValueType &t)
00128     { m_Deque.push_front(t); }
00129 
00131   void PushBack( const ValueType &t)
00132     { m_Deque.push_back(t); }
00133 
00135   void PopFront()
00136     { m_Deque.pop_front(); }
00137 
00139   void PopBack()
00140     { m_Deque.pop_back(); }
00141 
00143   Iterator Begin()
00144     { return m_Deque.begin(); }
00145 
00147   ConstIterator Begin() const
00148     { return m_Deque.begin(); }
00149 
00152   Iterator End()
00153     { return m_Deque.end(); }
00154 
00157   ConstIterator End() const
00158     { return m_Deque.end(); }
00159 
00161   void Clear()
00162     { m_Deque.clear(); }
00163 
00166   void Initialize();
00167 
00168 protected:
00169   SegmentTree() {}
00170   virtual ~SegmentTree() {}
00171   SegmentTree(const Self&) {}
00172   void operator=(const Self&) {}
00173   void PrintSelf(std::ostream& os, Indent indent) const;
00174 
00175   DequeType m_Deque;
00176 };
00177 }// end namespace watershed
00178 }// end namespace itk
00179 
00180 #ifndef ITK_MANUAL_INSTANTIATION
00181 #include "itkWatershedSegmentTree.txx"
00182 #endif
00183 
00184 #endif
00185 

Generated at Fri Apr 16 20:03:16 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000