ITK  4.10.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<typename TIndexValue = unsigned int, unsigned int VDimension = 3>
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 
75  typedef typename Superclass::InputType InputType;
76 
78  typedef InputType PathIndexType;
79  typedef OutputType IndexType;
80  typedef unsigned int HilbertOrderType;
81  typedef std::vector<IndexType> HilbertPathType;
82  typedef typename HilbertPathType::size_type HilbertPathSizeType;
84 
85  // Functions inherited from Path
86 
88  virtual OutputType Evaluate( const PathIndexType & input ) const ITK_OVERRIDE
89  {
90  return this->m_HilbertPath[input];
91  }
92 
93  virtual OutputType EvaluateToIndex( const PathIndexType & input ) const ITK_OVERRIDE
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 ITK_OVERRIDE
106  {
107  return static_cast<InputType>( this->NumberOfSteps() ); // 0 is before the first step, 1 is after it
108  }
109 
113  virtual OffsetType IncrementInput( InputType & itkNotUsed( input ) ) const ITK_OVERRIDE
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 ) ITK_OVERRIDE
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 ITK_OVERRIDE;
157 
158 private:
159  HilbertPath( const Self & ) ITK_DELETE_FUNCTION;
160  void operator=( const Self & ) ITK_DELETE_FUNCTION;
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 
186  HilbertOrderType m_HilbertOrder;
187  HilbertPathType m_HilbertPath;
188 };
189 } // end namespace itk
190 
191 #ifndef ITK_MANUAL_INSTANTIATION
192 #include "itkHilbertPath.hxx"
193 #endif
194 
195 #endif
PathIndexType SetBit(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType)
HilbertPathType::size_type HilbertPathSizeType
Offset< VDimension > OffsetType
Definition: itkPath.h:76
Represent an n-dimensional Hilbert path for a given order.
PathIndexType GetRightBitRotation(PathIndexType, PathIndexType, const PathIndexType)
IndexType TransformPathIndexToMultiDimensionalIndex(const PathIndexType id)
SmartPointer< const Self > ConstPointer
PathIndexType GetInverseTransform(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType)
static const unsigned int Dimension
PathIndexType GetGrayCode(const PathIndexType)
virtual OutputType EvaluateToIndex(const PathIndexType &input) const override
PathIndexType GetTransform(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType)
PathIndexType GetInverseGrayCode(const PathIndexType)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes...
Definition: itkArray.h:30
OutputType IndexType
void operator=(const Self &) ITK_DELETE_FUNCTION
PathIndexType GetDirection(const PathIndexType, const PathIndexType)
PathIndexType GetTrailingSetBits(const PathIndexType, const PathIndexType)
Superclass::OffsetType OffsetType
std::vector< IndexType > HilbertPathType
TOutput OutputType
Definition: itkPath.h:72
Represent a path through ND Space.
Definition: itkPath.h:53
HilbertPathType m_HilbertPath
virtual InputType EndOfInput() const override
virtual void Clear()
HilbertPath< TIndexValue, VDimension > Self
virtual OffsetType IncrementInput(InputType &) const override
virtual void Initialize(void) override
InputType PathIndexType
PathIndexType GetEntry(const PathIndexType)
virtual OutputType Evaluate(const PathIndexType &input) const override
PathIndexType GetBitRange(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType)
SmartPointer< Self > Pointer
virtual void Modified() const
void ConstructHilbertPath()
PathIndexType GetLeftBitRotation(PathIndexType, PathIndexType, const PathIndexType)
virtual InputType EvaluateInverse(const IndexType &input)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Path< unsigned int, Index< VDimension >, VDimension > Superclass
Superclass::OutputType OutputType
Superclass::InputType InputType
Define additional traits for native types such as int or float.
PathIndexType TransformMultiDimensionalIndexToPathIndex(const IndexType &index)
unsigned int HilbertOrderType
TInput InputType
Definition: itkPath.h:66
virtual HilbertPathSizeType NumberOfSteps() const
void PrintSelf(std::ostream &os, Indent indent) const override
HilbertOrderType m_HilbertOrder