ITK  5.0.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  using Self = SegmentTree;
55  itkNewMacro(Self);
56  itkTypeMacro(WatershedSegmentTree, DataObject);
57  using ScalarType = TScalar;
59 
63  struct merge_t {
67  };
69 
71  using DequeType = std::deque< merge_t >;
72  using Iterator = typename DequeType::iterator;
73  using ConstIterator = typename DequeType::const_iterator;
74  using ValueType = typename DequeType::value_type;
75 
77  struct merge_comp:public std:: binary_function< bool, const merge_t &,
78  const merge_t & > {
79  merge_comp() = default;
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  void Initialize() override;
164 
165 protected:
166  SegmentTree() = default;
167  ~SegmentTree() override = default;
168  SegmentTree(const Self &) {}
169  void operator=(const Self &) {}
170  void PrintSelf(std::ostream & os, Indent indent) const 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
typename DequeType::value_type ValueType
bool operator()(const merge_t &a, const merge_t &b)
void PushBack(const ValueType &t)
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:41
bool operator()(const merge_t &a, const merge_t &b)
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
void PushFront(const ValueType &t)
typename DequeType::iterator Iterator
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename DequeType::const_iterator ConstIterator
Base class for most ITK classes.
Definition: itkObject.h:60
DequeType::size_type Size() const
Base class for all data objects in ITK.