ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkHilbertPath.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 __itkHilbertPath_h
19 #define __itkHilbertPath_h
20 
21 #include "itkPath.h"
22 
23 #include "itkNumericTraits.h"
24 
25 namespace itk
26 {
52 template<class TIndexValue = unsigned int, unsigned int VDimension = 3>
53 class ITK_EXPORT HilbertPath
54 : public Path<TIndexValue, Index<VDimension>, VDimension>
55 {
56 public:
57 
63 
65  itkTypeMacro( HilbertPath, Path );
66 
68  itkNewMacro( Self );
69 
71  itkStaticConstMacro( Dimension, unsigned int, VDimension );
72 
74  typedef typename Superclass::OutputType OutputType;
75  typedef typename Superclass::InputType InputType;
76 
80  typedef unsigned int HilbertOrderType;
81  typedef std::vector<IndexType> HilbertPathType;
82  typedef typename HilbertPathType::size_type HilbertPathSizeType;
83  typedef typename Superclass::OffsetType OffsetType;
84 
85  // Functions inherited from Path
86 
88  virtual OutputType Evaluate( const PathIndexType & input ) const
89  {
90  return this->m_HilbertPath[input];
91  }
92 
93  virtual OutputType EvaluateToIndex( const PathIndexType & input ) const
94  {
95  return this->m_HilbertPath[input];
96  }
97 
99  virtual InputType EvaluateInverse( const IndexType & input )
100  {
101  return this->TransformMultiDimensionalIndexToPathIndex( input );
102  }
103 
105  virtual inline InputType EndOfInput() const
106  {
107  return this->NumberOfSteps(); // 0 is before the first step, 1 is after it
108  }
109 
113  virtual OffsetType IncrementInput( InputType & itkNotUsed( input ) ) const
114  {
115  itkExceptionMacro( "Not implemented." );
116  }
117 
119  virtual inline void Clear()
120  {
121  this->m_HilbertPath.clear();
122  this->Modified();
123  }
125 
127  virtual inline HilbertPathSizeType NumberOfSteps() const
128  {
129  return m_HilbertPath.size();
130  }
131 
133  virtual void Initialize( void )
134  {
135  this->Clear();
136  this->ConstructHilbertPath();
137  }
139 
143  itkSetClampMacro( HilbertOrder, HilbertOrderType, 1, NumericTraits<HilbertOrderType>::max() );
144  itkGetConstMacro( HilbertOrder, HilbertOrderType );
146 
148  IndexType TransformPathIndexToMultiDimensionalIndex( const PathIndexType id );
149 
151  PathIndexType TransformMultiDimensionalIndexToPathIndex( const IndexType & index );
152 
153 protected:
154  HilbertPath();
156  void PrintSelf( std::ostream & os, Indent indent ) const;
157 
158 private:
159  HilbertPath( const Self & ); //purposely not implemented
160  void operator=( const Self & ); //purposely not implemented
161 
162  void ConstructHilbertPath();
163 
164  PathIndexType GetTransform( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
165 
166  PathIndexType GetInverseTransform( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
167 
168  PathIndexType GetGrayCode( const PathIndexType );
169 
170  PathIndexType GetInverseGrayCode( const PathIndexType );
171 
172  PathIndexType SetBit( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
173 
174  PathIndexType GetRightBitRotation( PathIndexType, PathIndexType, const PathIndexType );
175 
176  PathIndexType GetLeftBitRotation( PathIndexType, PathIndexType, const PathIndexType );
177 
178  PathIndexType GetTrailingSetBits( const PathIndexType, const PathIndexType );
179 
180  PathIndexType GetDirection( const PathIndexType, const PathIndexType );
181 
182  PathIndexType GetEntry( const PathIndexType );
183 
184  PathIndexType GetBitRange( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
185 
188 };
189 } // end namespace itk
190 
191 // Define instantiation macro for this template.
192 #define ITK_TEMPLATE_HilbertPath(_, EXPORT, TypeX, TypeY) \
193  namespace itk \
194  { \
195  _( 1 ( class EXPORT HilbertPath< ITK_TEMPLATE_1 TypeX > ) ) \
196  namespace Templates \
197  { \
198  typedef HilbertPath< ITK_TEMPLATE_1 TypeX > \
199  HilbertPath##TypeY; \
200  } \
201  }
202 
203 #if ITK_TEMPLATE_EXPLICIT
204 #include "Templates/itkHilbertPath+-.h"
205 #endif
206 
207 #if ITK_TEMPLATE_TXX
208 #include "itkHilbertPath.hxx"
209 #endif
210 
211 #endif
212