ITK  4.9.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 
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 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 
149 
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 
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)
virtual InputType EndOfInput() const override
virtual OutputType EvaluateToIndex(const PathIndexType &input) const override
HilbertPathType::size_type HilbertPathSizeType
Offset< VDimension > OffsetType
Definition: itkPath.h:76
Represent an n-dimensional Hilbert path for a given order.
void PrintSelf(std::ostream &os, Indent indent) const override
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)
PathIndexType GetTransform(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType)
PathIndexType GetInverseGrayCode(const PathIndexType)
OutputType IndexType
PathIndexType GetDirection(const PathIndexType, const PathIndexType)
PathIndexType GetTrailingSetBits(const PathIndexType, const PathIndexType)
Superclass::OffsetType OffsetType
virtual OutputType Evaluate(const PathIndexType &input) const override
std::vector< IndexType > HilbertPathType
TOutput OutputType
Definition: itkPath.h:72
Represent a path through ND Space.
Definition: itkPath.h:53
HilbertPathType m_HilbertPath
virtual void Clear()
HilbertPath< TIndexValue, VDimension > Self
virtual void Initialize(void) override
InputType PathIndexType
PathIndexType GetEntry(const PathIndexType)
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)
virtual OffsetType IncrementInput(InputType &) const override
unsigned int HilbertOrderType
TInput InputType
Definition: itkPath.h:66
virtual HilbertPathSizeType NumberOfSteps() const
Base class for all data objects in ITK.
HilbertOrderType m_HilbertOrder