ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkWatershedSegmentTree.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkWatershedSegmentTree_h
19 #define itkWatershedSegmentTree_h
20 
21 #include "itkProcessObject.h"
22 #include <deque>
23 #include <functional>
24 
25 namespace itk
26 {
27 namespace watershed
28 {
46 template< typename TScalar >
47 class ITK_TEMPLATE_EXPORT SegmentTree:public DataObject
48 {
49 public:
51  typedef SegmentTree Self;
55  itkNewMacro(Self);
56  itkTypeMacro(WatershedSegmentTree, DataObject);
57  typedef TScalar ScalarType;
59 
63  struct merge_t {
67  };
69 
71  typedef std::deque< merge_t > DequeType;
72  typedef typename DequeType::iterator Iterator;
73  typedef typename DequeType::const_iterator ConstIterator;
74  typedef typename DequeType::value_type ValueType;
75 
77  struct merge_comp:public std:: binary_function< bool, const merge_t &,
78  const merge_t & > {
80  bool operator()(const merge_t & a, const merge_t & b)
81  {
82  return b.saliency < a.saliency;
83  }
84  };
86 
88  struct sort_comp:public std:: binary_function< bool, const merge_t &,
89  const merge_t & > {
90  bool operator()(const merge_t & a, const merge_t & b)
91  {
92  return a.saliency < b.Saliency;
93  }
94  };
95 
97  typename DequeType::size_type Size() const
98  { return m_Deque.size(); }
99 
102  bool Empty() const
103  { return m_Deque.empty(); }
104 
107  const merge_t & Front() const
108  { return m_Deque.front(); }
109 
112  const merge_t & Back() const
113  { return m_Deque.back(); }
114 
117  { return m_Deque.front(); }
118 
121  { return m_Deque.back(); }
122 
124  void PushFront(const ValueType & t)
125  { m_Deque.push_front(t); }
126 
128  void PushBack(const ValueType & t)
129  { m_Deque.push_back(t); }
130 
132  void PopFront()
133  { m_Deque.pop_front(); }
134 
136  void PopBack()
137  { m_Deque.pop_back(); }
138 
141  { return m_Deque.begin(); }
142 
145  { return m_Deque.begin(); }
146 
150  { return m_Deque.end(); }
151 
155  { return m_Deque.end(); }
156 
158  void Clear()
159  { m_Deque.clear(); }
160 
163  virtual void Initialize() ITK_OVERRIDE;
164 
165 protected:
167  virtual ~SegmentTree() ITK_OVERRIDE {}
168  SegmentTree(const Self &) {}
169  void operator=(const Self &) {}
170  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
171 
173 };
174 } // end namespace watershed
175 } // end namespace itk
176 
177 #ifndef ITK_MANUAL_INSTANTIATION
178 #include "itkWatershedSegmentTree.hxx"
179 #endif
180 
181 #endif
const merge_t & Front() const
bool operator()(const merge_t &a, const merge_t &b)
void PushBack(const ValueType &t)
bool operator()(const merge_t &a, const merge_t &b)
DequeType::const_iterator ConstIterator
SizeValueType IdentifierType
Definition: itkIntTypes.h:147
void PushFront(const ValueType &t)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
SmartPointer< const Self > ConstPointer
DequeType::size_type Size() const
Base class for all data objects in ITK.