ITK  4.13.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:
54  itkStaticConstMacro(Dimension, unsigned int, VDimension);
55 
59 
62 
64  itkTypeMacro(ChainCodePath, Path);
65 
67  typedef typename Superclass::OutputType OutputType;
68  typedef typename Superclass::InputType InputType;
69 
73 
74  typedef std::vector< OffsetType > ChainCodeType;
75 
76  typedef typename ChainCodeType::size_type ChainCodeSizeType;
77 
78  // Functions inherited from Path
79 
81  virtual OutputType Evaluate(const InputType & input) const ITK_OVERRIDE
82  {
83  return m_Chain[input];
84  }
85 
87  virtual IndexType EvaluateToIndex(const InputType & input) const ITK_OVERRIDE;
88 
93  virtual OffsetType IncrementInput(InputType & input) const ITK_OVERRIDE;
94 
96  virtual InputType EndOfInput() const ITK_OVERRIDE
97  {
98  return static_cast<InputType>(NumberOfSteps()); // 0 is before the first step, 1 is after it
99  }
100 
102  itkNewMacro(Self);
103 
105  itkSetMacro(Start, IndexType);
106  itkGetConstReferenceMacro(Start, IndexType);
108 
110  virtual inline void InsertStep(InputType position, OffsetType step)
111  {
112  m_Chain.insert(m_Chain.begin() + position, step);
113  this->Modified();
114  }
116 
118  virtual inline void ChangeStep(InputType position, OffsetType step)
119  {
120  m_Chain[position] = step;
121  this->Modified();
122  }
124 
126  virtual inline void Clear()
127  {
128  m_Chain.clear();
129  this->Modified();
130  }
132 
134  virtual inline ChainCodeSizeType NumberOfSteps() const
135  {
136  return m_Chain.size();
137  }
138 
140  virtual void Initialize(void) ITK_OVERRIDE
141  {
142  m_Start = this->GetZeroIndex();
143  this->Clear();
144  }
146 
147 protected:
148  ChainCodePath();
149  ~ChainCodePath() ITK_OVERRIDE {}
150  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
151 
152 private:
153  ITK_DISALLOW_COPY_AND_ASSIGN(ChainCodePath);
154 
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
Index< VDimension > IndexType
Represent a path as a sequence of connected image index offsets.
Superclass::OutputType OutputType
virtual OutputType Evaluate(const InputType &input) const override
Superclass::InputType InputType
std::vector< OffsetType > ChainCodeType
SmartPointer< const Self > ConstPointer
virtual void InsertStep(InputType position, OffsetType step)
SmartPointer< Self > Pointer
Represent a path through ND Space.
Definition: itkPath.h:53
ChainCodePath< VDimension > Self
ChainCodeType::size_type ChainCodeSizeType
virtual void Initialize(void) override
virtual void ChangeStep(InputType position, OffsetType step)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ChainCodeType m_Chain
virtual ChainCodeSizeType NumberOfSteps() const
virtual InputType EndOfInput() const override
Path< unsigned int, Offset< VDimension >, VDimension > Superclass
virtual void Clear()