ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkChainCodePath.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
48 template< unsigned int VDimension >
49 class ITK_TEMPLATE_EXPORT ChainCodePath:public
50  Path< unsigned int, Offset< VDimension >, VDimension >
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_ASSIGN(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 
83  OutputType Evaluate(const InputType & input) const override
84  {
85  return m_Chain[input];
86  }
87 
89  IndexType EvaluateToIndex(const InputType & input) const override;
90 
95  OffsetType IncrementInput(InputType & input) const override;
96 
98  InputType EndOfInput() const override
99  {
100  return static_cast<InputType>(NumberOfSteps()); // 0 is before the first step, 1 is after it
101  }
102 
104  itkNewMacro(Self);
105 
107  itkSetMacro(Start, IndexType);
108  itkGetConstReferenceMacro(Start, IndexType);
110 
112  virtual inline void InsertStep(InputType position, OffsetType step)
113  {
114  m_Chain.insert(m_Chain.begin() + position, step);
115  this->Modified();
116  }
118 
120  virtual inline void ChangeStep(InputType position, OffsetType step)
121  {
122  m_Chain[position] = step;
123  this->Modified();
124  }
126 
128  virtual inline void Clear()
129  {
130  m_Chain.clear();
131  this->Modified();
132  }
134 
136  virtual inline ChainCodeSizeType NumberOfSteps() const
137  {
138  return m_Chain.size();
139  }
140 
142  void Initialize() override
143  {
144  m_Start = this->GetZeroIndex();
145  this->Clear();
146  }
148 
149 protected:
150  ChainCodePath();
151  ~ChainCodePath() override = default;
152  void PrintSelf(std::ostream & os, Indent indent) const override;
153 
154 private:
155  IndexType m_Start; // origin image index for the path
156  ChainCodeType m_Chain; // the chain code (vector of offsets)
157 };
158 } // end namespace itk
159 
160 #ifndef ITK_MANUAL_INSTANTIATION
161 #include "itkChainCodePath.hxx"
162 #endif
163 
164 #endif
typename Superclass::InputType InputType
OutputType Evaluate(const InputType &input) const override
Represent a path as a sequence of connected image index offsets.
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:66
virtual void InsertStep(InputType position, OffsetType step)
Represent a path through ND Space.
Definition: itkPath.h:53
InputType EndOfInput() const override
void Initialize() override
std::vector< OffsetType > ChainCodeType
typename ChainCodeType::size_type ChainCodeSizeType
typename Superclass::OutputType OutputType
virtual void ChangeStep(InputType position, OffsetType step)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ChainCodeType m_Chain
virtual ChainCodeSizeType NumberOfSteps() const
Base class for most ITK classes.
Definition: itkObject.h:60
Base class for all data objects in ITK.
virtual void Clear()