ITK  6.0.0
Insight Toolkit
itkChainCodePath.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 itkChainCodePath_h
19#define itkChainCodePath_h
20
21#include "itkPath.h"
22#include "itkOffset.h"
23#include "itkObjectFactory.h"
24
25#include <vector>
26
27namespace itk
28{
49template <unsigned int VDimension>
50class ITK_TEMPLATE_EXPORT ChainCodePath : public Path<unsigned int, Offset<VDimension>, VDimension>
51{
52public:
53 ITK_DISALLOW_COPY_AND_MOVE(ChainCodePath);
54
56 static constexpr unsigned int Dimension = VDimension;
57
61
64
66 itkOverrideGetNameOfClassMacro(ChainCodePath);
67
69 using typename Superclass::OutputType;
70 using typename Superclass::InputType;
71
75
76 using ChainCodeType = std::vector<OffsetType>;
77
78 using ChainCodeSizeType = typename ChainCodeType::size_type;
79
80 // Functions inherited from Path
81
84 Evaluate(const InputType & input) const override
85 {
86 return m_Chain[input];
87 }
88
91 EvaluateToIndex(const InputType & input) const override;
92
98 IncrementInput(InputType & input) const override;
99
102 EndOfInput() const override
103 {
104 return static_cast<InputType>(NumberOfSteps()); // 0 is before the first step, 1 is after it
105 }
106
108 itkNewMacro(Self);
109
111 itkSetMacro(Start, IndexType);
112 itkGetConstReferenceMacro(Start, IndexType);
116 virtual inline void
118 {
119 m_Chain.insert(m_Chain.begin() + position, step);
120 this->Modified();
121 }
125 virtual inline void
127 {
128 m_Chain[position] = step;
129 this->Modified();
130 }
134 virtual inline void
136 {
137 m_Chain.clear();
138 this->Modified();
139 }
143 virtual inline ChainCodeSizeType
145 {
146 return m_Chain.size();
147 }
148
150 void
151 Initialize() override
152 {
153 m_Start = this->GetZeroIndex();
154 this->Clear();
155 }
158protected:
160 ~ChainCodePath() override = default;
161 void
162 PrintSelf(std::ostream & os, Indent indent) const override;
163
164private:
165 IndexType m_Start{}; // origin image index for the path
166 ChainCodeType m_Chain{}; // the chain code (vector of offsets)
167};
168} // end namespace itk
169
170#ifndef ITK_MANUAL_INSTANTIATION
171# include "itkChainCodePath.hxx"
172#endif
173
174#endif
Represent a path as a sequence of connected image index offsets.
IndexType EvaluateToIndex(const InputType &input) const override
OffsetType IncrementInput(InputType &input) const override
std::vector< OffsetType > ChainCodeType
void Initialize() override
virtual void Clear()
virtual void ChangeStep(InputType position, OffsetType step)
OutputType Evaluate(const InputType &input) const override
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void InsertStep(InputType position, OffsetType step)
virtual ChainCodeSizeType NumberOfSteps() const
InputType EndOfInput() const override
~ChainCodePath() override=default
typename ChainCodeType::size_type ChainCodeSizeType
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
Represent a path through ND Space.
Definition: itkPath.h:55
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....