ITK  4.4.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_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
82  {
83  return m_Chain[input];
84  }
85 
87  virtual IndexType EvaluateToIndex(const InputType & input) const;
88 
93  virtual OffsetType IncrementInput(InputType & input) const;
94 
96  virtual inline InputType EndOfInput() const
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)
141  {
142  m_Start = this->GetZeroIndex();
143  this->Clear();
144  }
146 
147 protected:
148  ChainCodePath();
150  void PrintSelf(std::ostream & os, Indent indent) const;
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
166