ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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::watershed
26{
45template <typename TScalar>
46class ITK_TEMPLATE_EXPORT SegmentTree : public DataObject
47{
48public:
49 ITK_DISALLOW_COPY_AND_MOVE(SegmentTree);
50
57 itkNewMacro(Self);
58 itkOverrideGetNameOfClassMacro(SegmentTree);
59 using ScalarType = TScalar;
60
71
73 using DequeType = std::deque<merge_t>;
74 using Iterator = typename DequeType::iterator;
75 using ConstIterator = typename DequeType::const_iterator;
76 using ValueType = typename DequeType::value_type;
77
80 {
81 merge_comp() = default;
82 bool
83 operator()(const merge_t & a, const merge_t & b)
84 {
85 return b.saliency < a.saliency;
86 }
87 };
88
90 struct sort_comp
91 {
92 bool
93 operator()(const merge_t & a, const merge_t & b)
94 {
95 return a.saliency < b.Saliency;
96 }
97 };
98
100 typename DequeType::size_type
101 Size() const
102 {
103 return m_Deque.size();
104 }
105
108 bool
109 Empty() const
110 {
111 return m_Deque.empty();
112 }
113
116 const merge_t &
117 Front() const
118 {
119 return m_Deque.front();
120 }
121
124 const merge_t &
125 Back() const
126 {
127 return m_Deque.back();
128 }
129
131 merge_t &
133 {
134 return m_Deque.front();
135 }
136
138 merge_t &
140 {
141 return m_Deque.back();
142 }
143
145 void
147 {
148 m_Deque.push_front(t);
149 }
150
152 void
154 {
155 m_Deque.push_back(t);
156 }
157
159 void
161 {
162 m_Deque.pop_front();
163 }
164
166 void
168 {
169 m_Deque.pop_back();
170 }
171
173 Iterator
175 {
176 return m_Deque.begin();
177 }
178
180 ConstIterator
181 Begin() const
182 {
183 return m_Deque.begin();
184 }
185
188 Iterator
190 {
191 return m_Deque.end();
192 }
193
196 ConstIterator
197 End() const
198 {
199 return m_Deque.end();
200 }
201
203 void
205 {
206 m_Deque.clear();
207 }
208
211 void
212 Initialize() override;
213
214protected:
215 SegmentTree() = default;
216 ~SegmentTree() override = default;
217
218 void
219 PrintSelf(std::ostream & os, Indent indent) const override;
220
222};
223} // namespace itk::watershed
224
225#ifndef ITK_MANUAL_INSTANTIATION
226# include "itkWatershedSegmentTree.hxx"
227#endif
228
229#endif
Control indentation during Print() invocation.
Definition itkIndent.h:50
Implements transparent reference counting.
void PushFront(const ValueType &t)
void PrintSelf(std::ostream &os, Indent indent) const override
void Initialize() override
~SegmentTree() override=default
void PushBack(const ValueType &t)
DequeType::size_type Size() const
typename DequeType::const_iterator ConstIterator
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)