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::Statistics
28{
43
44template <typename TPointSet>
45class ITK_TEMPLATE_EXPORT PointSetToListSampleAdaptor : public ListSample<typename TPointSet::PointType>
46{
47public:
48 ITK_DISALLOW_COPY_AND_MOVE(PointSetToListSampleAdaptor);
49
55
57 itkOverrideGetNameOfClassMacro(PointSetToListSampleAdaptor);
58
60 itkNewMacro(Self);
61
63 using PointSetType = TPointSet;
64 using PointSetPointer = typename TPointSet::Pointer;
65 using PointSetConstPointer = typename TPointSet::ConstPointer;
66 using PointsContainer = typename TPointSet::PointsContainer;
67 using PointsContainerPointer = typename TPointSet::PointsContainerPointer;
68 using PointsContainerConstPointer = typename TPointSet::PointsContainerConstPointer;
69 using PointsContainerIteratorType = typename TPointSet::PointsContainerIterator;
70 using PointsContainerConstIteratorType = typename TPointSet::PointsContainerConstIterator;
71 using PointType = typename TPointSet::PointType;
72
75 using typename Superclass::MeasurementType;
80 using typename Superclass::InstanceIdentifier;
81
83
85 void
86 SetPointSet(const TPointSet * pointSet);
87
89 const TPointSet *
91
94 Size() const override;
95
99 GetMeasurementVector(InstanceIdentifier identifier) const override;
100
104
107 GetTotalFrequency() const override;
108
114 {
116
117 public:
118 ConstIterator() = delete;
119 ConstIterator(const PointSetToListSampleAdaptor * adaptor) { *this = adaptor->Begin(); }
120
125
127 operator=(const ConstIterator & iter) = default;
128
129 [[nodiscard]] AbsoluteFrequencyType
131 {
132 return 1;
133 }
134
135 [[nodiscard]] const MeasurementVectorType &
137 {
138 return (const MeasurementVectorType &)m_Iter.Value();
139 }
140
141 [[nodiscard]] InstanceIdentifier
143 {
145 }
146
149 {
150 ++m_Iter;
152 return *this;
153 }
154
155 bool
156 operator==(const ConstIterator & it) const
157 {
158 return (m_Iter == it.m_Iter);
159 }
160
162
163 protected:
164 // This method should only be available to the ListSample class
169
170 private:
173 };
174
179 class Iterator : public ConstIterator
180 {
182
183 public:
184 Iterator(Self * adaptor)
185 : ConstIterator(adaptor)
186 {}
187
188 Iterator(const Iterator & iter)
189 : ConstIterator(iter)
190 {}
191
192 Iterator &
193 operator=(const Iterator & iter)
194 {
195 this->ConstIterator::operator=(iter);
196 return *this;
197 }
198
199 Iterator() = delete;
200 Iterator(const Self * adaptor) = delete;
202 Iterator(const ConstIterator & it) = delete;
204 operator=(const ConstIterator & it) = delete;
205
206 protected:
210 };
211
213 Iterator
215 {
216 const PointsContainerPointer nonConstPointsDataContainer =
217 const_cast<PointsContainer *>(m_PointsContainer.GetPointer());
218 const Iterator iter(nonConstPointsDataContainer->Begin(), 0);
219
220 return iter;
221 }
222
224 Iterator
226 {
227 const PointsContainerPointer nonConstPointsDataContainer =
228 const_cast<PointsContainer *>(m_PointsContainer.GetPointer());
229
230 const Iterator iter(nonConstPointsDataContainer->End(), m_PointsContainer->Size());
231
232 return iter;
233 }
234
236 ConstIterator
237 Begin() const
238 {
239 const ConstIterator iter(m_PointsContainer->Begin(), 0);
240
241 return iter;
242 }
243
245 ConstIterator
246 End() const
247 {
248 const ConstIterator iter(m_PointsContainer->End(), m_PointsContainer->Size());
249
250 return iter;
251 }
252
253protected:
255
256 ~PointSetToListSampleAdaptor() override = default;
257 void
258 PrintSelf(std::ostream & os, Indent indent) const override;
259
260private:
263
267
270}; // end of class PointSetToListSampleAdaptor
271} // namespace itk::Statistics
272
273#ifndef ITK_MANUAL_INSTANTIATION
274# include "itkPointSetToListSampleAdaptor.hxx"
275#endif
276
277#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)
ConstIterator & operator=(const ConstIterator &iter)=default
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