ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkPointSetToListSampleAdaptor.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 itkPointSetToListSampleAdaptor_h
19#define itkPointSetToListSampleAdaptor_h
20
21#include <typeinfo>
22
23#include "itkPointSet.h"
24#include "itkListSample.h"
25#include "itkSmartPointer.h"
26
27namespace itk
28{
29namespace Statistics
30{
45
46template <typename TPointSet>
47class ITK_TEMPLATE_EXPORT PointSetToListSampleAdaptor : public ListSample<typename TPointSet::PointType>
48{
49public:
50 ITK_DISALLOW_COPY_AND_MOVE(PointSetToListSampleAdaptor);
51
57
59 itkOverrideGetNameOfClassMacro(PointSetToListSampleAdaptor);
60
62 itkNewMacro(Self);
63
65 using PointSetType = TPointSet;
66 using PointSetPointer = typename TPointSet::Pointer;
67 using PointSetConstPointer = typename TPointSet::ConstPointer;
68 using PointsContainer = typename TPointSet::PointsContainer;
69 using PointsContainerPointer = typename TPointSet::PointsContainerPointer;
70 using PointsContainerConstPointer = typename TPointSet::PointsContainerConstPointer;
71 using PointsContainerIteratorType = typename TPointSet::PointsContainerIterator;
72 using PointsContainerConstIteratorType = typename TPointSet::PointsContainerConstIterator;
73 using PointType = typename TPointSet::PointType;
74
77 using typename Superclass::MeasurementType;
82 using typename Superclass::InstanceIdentifier;
83
85
87 void
88 SetPointSet(const TPointSet * pointSet);
89
91 const TPointSet *
93
96 Size() const override;
97
101 GetMeasurementVector(InstanceIdentifier identifier) const override;
102
106
109 GetTotalFrequency() const override;
110
116 {
118
119 public:
120 ConstIterator(const PointSetToListSampleAdaptor * adaptor) { *this = adaptor->Begin(); }
121
123 {
124 m_Iter = iter.m_Iter;
126 }
127
130 {
131 m_Iter = iter.m_Iter;
133 return *this;
134 }
135
138 {
139 return 1;
140 }
141
144 {
145 return (const MeasurementVectorType &)m_Iter.Value();
146 }
147
150 {
152 }
153
156 {
157 ++m_Iter;
159 return *this;
160 }
161
162 bool
163 operator==(const ConstIterator & it) const
164 {
165 return (m_Iter == it.m_Iter);
166 }
167
169
170 protected:
171 // This method should only be available to the ListSample class
177
178 private:
179 ConstIterator() = delete;
182 };
183
188 class Iterator : public ConstIterator
189 {
191
192 public:
193 Iterator(Self * adaptor)
194 : ConstIterator(adaptor)
195 {}
196
197 Iterator(const Iterator & iter)
198 : ConstIterator(iter)
199 {}
200
201 Iterator &
202 operator=(const Iterator & iter)
203 {
204 this->ConstIterator::operator=(iter);
205 return *this;
206 }
207
208 Iterator() = delete;
209 Iterator(const Self * adaptor) = delete;
211 Iterator(const ConstIterator & it) = delete;
213 operator=(const ConstIterator & it) = delete;
214
215 protected:
219 };
220
222 Iterator
224 {
225 const PointsContainerPointer nonConstPointsDataContainer =
226 const_cast<PointsContainer *>(m_PointsContainer.GetPointer());
227 const Iterator iter(nonConstPointsDataContainer->Begin(), 0);
229
230 return iter;
231 }
232
234 Iterator
236 {
237 const PointsContainerPointer nonConstPointsDataContainer =
238 const_cast<PointsContainer *>(m_PointsContainer.GetPointer());
239
240 const Iterator iter(nonConstPointsDataContainer->End(), m_PointsContainer->Size());
241
242 return iter;
243 }
244
246 ConstIterator
247 Begin() const
248 {
249 const ConstIterator iter(m_PointsContainer->Begin(), 0);
250
251 return iter;
252 }
253
255 ConstIterator
256 End() const
257 {
258 const ConstIterator iter(m_PointsContainer->End(), m_PointsContainer->Size());
259
260 return iter;
261 }
262
263protected:
265
266 ~PointSetToListSampleAdaptor() override = default;
267 void
268 PrintSelf(std::ostream & os, Indent indent) const override;
269
270private:
273
277
280}; // end of class PointSetToListSampleAdaptor
281} // end of namespace Statistics
282} // end of namespace itk
283
284#ifndef ITK_MANUAL_INSTANTIATION
285# include "itkPointSetToListSampleAdaptor.hxx"
286#endif
287
288#endif
Control indentation during Print() invocation.
Definition itkIndent.h:50
Implements transparent reference counting.
typename MeasurementVectorTraitsTypes< MeasurementVectorType >::ValueType MeasurementType
typename MeasurementVectorTraits::InstanceIdentifier InstanceIdentifier
NumericTraits< AbsoluteFrequencyType >::AccumulateType TotalAbsoluteFrequencyType
MeasurementVectorTraits::AbsoluteFrequencyType AbsoluteFrequencyType
ConstIterator(PointsContainerConstIteratorType iter, InstanceIdentifier iid)
Iterator(PointsContainerConstIteratorType iter, InstanceIdentifier iid)=delete
ConstIterator & operator=(const ConstIterator &it)=delete
Iterator(PointsContainerIteratorType iter, InstanceIdentifier iid)
void SetPointSet(const TPointSet *pointSet)
typename MeasurementVectorTraits::InstanceIdentifier InstanceIdentifier
TotalAbsoluteFrequencyType GetTotalFrequency() const override
MeasurementVectorTraits::AbsoluteFrequencyType AbsoluteFrequencyType
typename TPointSet::PointsContainerIterator PointsContainerIteratorType
void PrintSelf(std::ostream &os, Indent indent) const override
typename TPointSet::PointType MeasurementVectorType
AbsoluteFrequencyType GetFrequency(InstanceIdentifier id) const override
const MeasurementVectorType & GetMeasurementVector(InstanceIdentifier identifier) const override
typename TPointSet::PointsContainerConstIterator PointsContainerConstIteratorType
typename TPointSet::PointsContainerPointer PointsContainerPointer
InstanceIdentifier Size() const override
NumericTraits< AbsoluteFrequencyType >::AccumulateType TotalAbsoluteFrequencyType
typename TPointSet::PointsContainerConstPointer PointsContainerConstPointer
ListSample< typename TPointSet::PointType > Superclass
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....