ITK  4.13.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>
53 class ITK_TEMPLATE_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 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 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();
155  ~HilbertPath() ITK_OVERRIDE {}
156  void PrintSelf( std::ostream & os, Indent indent ) const ITK_OVERRIDE;
157 
158 private:
159  ITK_DISALLOW_COPY_AND_ASSIGN(HilbertPath);
160 
161  void ConstructHilbertPath();
162 
163  PathIndexType GetTransform( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
164 
165  PathIndexType GetInverseTransform( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
166 
167  PathIndexType GetGrayCode( const PathIndexType );
168 
169  PathIndexType GetInverseGrayCode( const PathIndexType );
170 
171  PathIndexType SetBit( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
172 
173  PathIndexType GetRightBitRotation( PathIndexType, PathIndexType, const PathIndexType );
174 
175  PathIndexType GetLeftBitRotation( PathIndexType, PathIndexType, const PathIndexType );
176 
177  PathIndexType GetTrailingSetBits( const PathIndexType, const PathIndexType );
178 
179  PathIndexType GetDirection( const PathIndexType, const PathIndexType );
180 
181  PathIndexType GetEntry( const PathIndexType );
182 
183  PathIndexType GetBitRange( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
184 
187 };
188 } // end namespace itk
189 
190 #ifndef ITK_MANUAL_INSTANTIATION
191 #include "itkHilbertPath.hxx"
192 #endif
193 
194 #endif
virtual InputType EndOfInput() const override
virtual OutputType EvaluateToIndex(const PathIndexType &input) const override
HilbertPathType::size_type HilbertPathSizeType
Represent an n-dimensional Hilbert path for a given order.
SmartPointer< const Self > ConstPointer
~HilbertPath() override
OutputType IndexType
Superclass::OffsetType OffsetType
virtual OutputType Evaluate(const PathIndexType &input) const override
std::vector< IndexType > HilbertPathType
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
SmartPointer< Self > Pointer
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.
virtual OffsetType IncrementInput(InputType &) const override
unsigned int HilbertOrderType
virtual HilbertPathSizeType NumberOfSteps() const
Base class for all data objects in ITK.
HilbertOrderType m_HilbertOrder