ITK  6.0.0
Insight Toolkit
itkWatershedSegmentTree.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
25namespace itk
26{
27namespace watershed
28{
47template <typename TScalar>
48class ITK_TEMPLATE_EXPORT SegmentTree : public DataObject
49{
50public:
51 ITK_DISALLOW_COPY_AND_MOVE(SegmentTree);
52
58 itkNewMacro(Self);
59 itkOverrideGetNameOfClassMacro(SegmentTree);
60 using ScalarType = TScalar;
66 struct merge_t
67 {
71 };
75 using DequeType = std::deque<merge_t>;
76 using Iterator = typename DequeType::iterator;
77 using ConstIterator = typename DequeType::const_iterator;
78 using ValueType = typename DequeType::value_type;
79
82 {
83 merge_comp() = default;
84 bool
85 operator()(const merge_t & a, const merge_t & b)
86 {
87 return b.saliency < a.saliency;
88 }
89 };
93 struct sort_comp
94 {
95 bool
96 operator()(const merge_t & a, const merge_t & b)
97 {
98 return a.saliency < b.Saliency;
99 }
100 };
101
103 typename DequeType::size_type
104 Size() const
105 {
106 return m_Deque.size();
107 }
108
111 bool
112 Empty() const
113 {
114 return m_Deque.empty();
115 }
116
119 const merge_t &
120 Front() const
121 {
122 return m_Deque.front();
123 }
124
127 const merge_t &
128 Back() const
129 {
130 return m_Deque.back();
131 }
132
134 merge_t &
136 {
137 return m_Deque.front();
138 }
139
141 merge_t &
143 {
144 return m_Deque.back();
145 }
146
148 void
150 {
151 m_Deque.push_front(t);
152 }
153
155 void
157 {
158 m_Deque.push_back(t);
159 }
160
162 void
164 {
165 m_Deque.pop_front();
166 }
167
169 void
171 {
172 m_Deque.pop_back();
173 }
174
176 Iterator
178 {
179 return m_Deque.begin();
180 }
181
183 ConstIterator
184 Begin() const
185 {
186 return m_Deque.begin();
187 }
188
191 Iterator
193 {
194 return m_Deque.end();
195 }
196
199 ConstIterator
200 End() const
201 {
202 return m_Deque.end();
203 }
204
206 void
208 {
209 m_Deque.clear();
210 }
211
214 void
215 Initialize() override;
216
217protected:
218 SegmentTree() = default;
219 ~SegmentTree() override = default;
220
221 void
222 PrintSelf(std::ostream & os, Indent indent) const override;
223
224 DequeType m_Deque{};
225};
226} // end namespace watershed
227} // end namespace itk
228
229#ifndef ITK_MANUAL_INSTANTIATION
230# include "itkWatershedSegmentTree.hxx"
231#endif
232
233#endif
Base class for all data objects in ITK.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Base class for most ITK classes.
Definition: itkObject.h:62
void PushFront(const ValueType &t)
void PrintSelf(std::ostream &os, Indent indent) const override
typename DequeType::iterator Iterator
typename DequeType::value_type ValueType
void Initialize() override
~SegmentTree() override=default
void PushBack(const ValueType &t)
DequeType::size_type Size() const
typename DequeType::const_iterator ConstIterator
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
bool operator()(const merge_t &a, const merge_t &b)
bool operator()(const merge_t &a, const merge_t &b)