ITK  4.8.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 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 inline InputType EndOfInput() const ITK_OVERRIDE
97  {
98  return 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();
150  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
151 
152 private:
153  ChainCodePath(const Self &); //purposely not implemented
154  void operator=(const Self &); //purposely not implemented
155 
156  IndexType m_Start; // origin image index for the path
157  ChainCodeType m_Chain; // the chain code (vector of offsets)
158 };
159 } // end namespace itk
160 
161 #ifndef ITK_MANUAL_INSTANTIATION
162 #include "itkChainCodePath.hxx"
163 #endif
164 
165 #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
virtual IndexType EvaluateToIndex(const InputType &input) const override
Superclass::InputType InputType
void operator=(const Self &)
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
static const unsigned int Dimension
ChainCodeType::size_type ChainCodeSizeType
virtual void Modified() const
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 OffsetType IncrementInput(InputType &input) const override
virtual ChainCodeSizeType NumberOfSteps() const
void PrintSelf(std::ostream &os, Indent indent) const override
virtual InputType EndOfInput() const override
Path< unsigned int, Offset< VDimension >, VDimension > Superclass
virtual void Clear()