itkWatershedSegmentTree.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 {
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 template <class TScalarType>
00044 class ITK_EXPORT SegmentTree : public DataObject
00045 {
00046 public:
00048 typedef SegmentTree Self;
00049 typedef DataObject Superclass;
00050 typedef SmartPointer<Self> Pointer;
00051 typedef SmartPointer<const Self> ConstPointer;
00052 itkNewMacro(Self);
00053 itkTypeMacro(WatershedSegmentTree, DataObject);
00054 typedef TScalarType ScalarType;
00056
00060 struct merge_t
00061 {
00062 unsigned long from;
00063 unsigned long to;
00064 ScalarType saliency;
00065 };
00067
00069 typedef std::deque<merge_t> DequeType;
00070 typedef typename DequeType::iterator Iterator;
00071 typedef typename DequeType::const_iterator ConstIterator;
00072 typedef typename DequeType::value_type ValueType;
00073
00075 struct merge_comp : public std::binary_function<bool, const merge_t&,
00076 const merge_t& >
00077 {
00078 bool operator()(const merge_t &a, const merge_t &b)
00079 {
00080 return b.saliency < a.saliency;
00081 }
00082 };
00083
00085 struct sort_comp : public std::binary_function<bool, const merge_t&,
00086 const merge_t& >
00087 {
00088 bool operator()(const merge_t &a, const merge_t &b)
00089 {
00090 return a.saliency < b.Saliency;
00091 }
00092 };
00093
00095 typename DequeType::size_type Size() const
00096 { return m_Deque.size(); }
00097
00100 bool Empty() const
00101 { return m_Deque.empty(); }
00102
00105 const merge_t &Front() const
00106 { return m_Deque.front(); }
00107
00110 const merge_t &Back() const
00111 { return m_Deque.back(); }
00112
00114 merge_t &Front()
00115 { return m_Deque.front(); }
00116
00118 merge_t &Back()
00119 { return m_Deque.back(); }
00120
00122 void PushFront(const ValueType &t)
00123 { m_Deque.push_front(t); }
00124
00126 void PushBack( const ValueType &t)
00127 { m_Deque.push_back(t); }
00128
00130 void PopFront()
00131 { m_Deque.pop_front(); }
00132
00134 void PopBack()
00135 { m_Deque.pop_back(); }
00136
00138 Iterator Begin()
00139 { return m_Deque.begin(); }
00140
00142 ConstIterator Begin() const
00143 { return m_Deque.begin(); }
00144
00147 Iterator End()
00148 { return m_Deque.end(); }
00149
00152 ConstIterator End() const
00153 { return m_Deque.end(); }
00154
00156 void Clear()
00157 { m_Deque.clear(); }
00158
00161 void Initialize();
00162
00163 protected:
00164 SegmentTree() {}
00165 virtual ~SegmentTree() {}
00166 SegmentTree(const Self&) {}
00167 void operator=(const Self&) {}
00168 void PrintSelf(std::ostream& os, Indent indent) const;
00169
00170 DequeType m_Deque;
00171 };
00172 }
00173 }
00174
00175 #ifndef ITK_MANUAL_INSTANTIATION
00176 #include "itkWatershedSegmentTree.txx"
00177 #endif
00178
00179 #endif
00180