ITK  5.2.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  * http://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 
27 namespace itk
28 {
49 template <unsigned int VDimension>
50 class ITK_TEMPLATE_EXPORT ChainCodePath : public Path<unsigned int, Offset<VDimension>, VDimension>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(ChainCodePath);
54 
56  static constexpr unsigned int Dimension = VDimension;
57 
61 
64 
66  itkTypeMacro(ChainCodePath, Path);
67 
69  using OutputType = typename Superclass::OutputType;
70  using InputType = 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 
90  IndexType
91  EvaluateToIndex(const InputType & input) const override;
92 
97  OffsetType
98  IncrementInput(InputType & input) const override;
99 
101  InputType
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);
114 
116  virtual inline void
118  {
119  m_Chain.insert(m_Chain.begin() + position, step);
120  this->Modified();
121  }
123 
125  virtual inline void
127  {
128  m_Chain[position] = step;
129  this->Modified();
130  }
132 
134  virtual inline void
136  {
137  m_Chain.clear();
138  this->Modified();
139  }
141 
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  }
157 
158 protected:
159  ChainCodePath();
160  ~ChainCodePath() override = default;
161  void
162  PrintSelf(std::ostream & os, Indent indent) const override;
163 
164 private:
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
itkObjectFactory.h
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:66
itk::Path
Represent a path through ND Space.
Definition: itkPath.h:54
itk::ChainCodePath::m_Chain
ChainCodeType m_Chain
Definition: itkChainCodePath.h:166
itk::ChainCodePath< 2 >::OffsetType
OutputType OffsetType
Definition: itkChainCodePath.h:73
itkOffset.h
itk::ChainCodePath< 2 >::InputType
typename Superclass::InputType InputType
Definition: itkChainCodePath.h:70
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ChainCodePath::EndOfInput
InputType EndOfInput() const override
Definition: itkChainCodePath.h:102
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ChainCodePath::InsertStep
virtual void InsertStep(InputType position, OffsetType step)
Definition: itkChainCodePath.h:117
itk::ChainCodePath::m_Start
IndexType m_Start
Definition: itkChainCodePath.h:165
itk::ChainCodePath< 2 >::ChainCodeType
std::vector< OffsetType > ChainCodeType
Definition: itkChainCodePath.h:76
itk::ChainCodePath::ChangeStep
virtual void ChangeStep(InputType position, OffsetType step)
Definition: itkChainCodePath.h:126
itkPath.h
itk::ChainCodePath< 2 >::OutputType
typename Superclass::OutputType OutputType
Definition: itkChainCodePath.h:69
itk::ChainCodePath< 2 >::ChainCodeSizeType
typename ChainCodeType::size_type ChainCodeSizeType
Definition: itkChainCodePath.h:78
itk::ChainCodePath::NumberOfSteps
virtual ChainCodeSizeType NumberOfSteps() const
Definition: itkChainCodePath.h:144
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ChainCodePath::Evaluate
OutputType Evaluate(const InputType &input) const override
Definition: itkChainCodePath.h:84
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::ChainCodePath::Initialize
void Initialize() override
Definition: itkChainCodePath.h:151
itk::ChainCodePath::Clear
virtual void Clear()
Definition: itkChainCodePath.h:135
itk::ChainCodePath
Represent a path as a sequence of connected image index offsets.
Definition: itkChainCodePath.h:50
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293