ITK  5.0.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  ITK_DISALLOW_COPY_AND_ASSIGN(HilbertPath);
58 
64 
66  itkTypeMacro( HilbertPath, Path );
67 
69  itkNewMacro( Self );
70 
72  static constexpr unsigned int Dimension = VDimension;
73 
75  using OutputType = typename Superclass::OutputType;
76  using InputType = typename Superclass::InputType;
77 
81  using HilbertOrderType = unsigned int;
82  using HilbertPathType = std::vector<IndexType>;
83  using HilbertPathSizeType = typename HilbertPathType::size_type;
84  using OffsetType = typename Superclass::OffsetType;
85 
86  // Functions inherited from Path
87 
89  OutputType Evaluate( const PathIndexType & input ) const override
90  {
91  return this->m_HilbertPath[input];
92  }
93 
94  OutputType EvaluateToIndex( const PathIndexType & input ) const override
95  {
96  return this->m_HilbertPath[input];
97  }
98 
100  virtual InputType EvaluateInverse( const IndexType & input )
101  {
102  return this->TransformMultiDimensionalIndexToPathIndex( input );
103  }
104 
106  InputType EndOfInput() const override
107  {
108  return static_cast<InputType>( this->NumberOfSteps() ); // 0 is before the first step, 1 is after it
109  }
110 
114  OffsetType IncrementInput( InputType & itkNotUsed( input ) ) const override
115  {
116  itkExceptionMacro( "Not implemented." );
117  }
118 
120  virtual inline void Clear()
121  {
122  this->m_HilbertPath.clear();
123  this->Modified();
124  }
126 
128  virtual inline HilbertPathSizeType NumberOfSteps() const
129  {
130  return m_HilbertPath.size();
131  }
132 
134  void Initialize() override
135  {
136  this->Clear();
137  this->ConstructHilbertPath();
138  }
140 
144  itkSetClampMacro( HilbertOrder, HilbertOrderType, 1, NumericTraits<HilbertOrderType>::max() );
145  itkGetConstMacro( HilbertOrder, HilbertOrderType );
147 
149  IndexType TransformPathIndexToMultiDimensionalIndex( const PathIndexType id );
150 
152  PathIndexType TransformMultiDimensionalIndexToPathIndex( const IndexType & index );
153 
154 protected:
155  HilbertPath();
156  ~HilbertPath() override = default;
157  void PrintSelf( std::ostream & os, Indent indent ) const override;
158 
159 private:
160  void ConstructHilbertPath();
161 
162  PathIndexType GetTransform( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
163 
164  PathIndexType GetInverseTransform( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
165 
166  PathIndexType GetGrayCode( const PathIndexType );
167 
168  PathIndexType GetInverseGrayCode( const PathIndexType );
169 
170  PathIndexType SetBit( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
171 
172  PathIndexType GetRightBitRotation( PathIndexType, PathIndexType, const PathIndexType );
173 
174  PathIndexType GetLeftBitRotation( PathIndexType, PathIndexType, const PathIndexType );
175 
176  PathIndexType GetTrailingSetBits( const PathIndexType, const PathIndexType );
177 
178  PathIndexType GetDirection( const PathIndexType, const PathIndexType );
179 
180  PathIndexType GetEntry( const PathIndexType );
181 
182  PathIndexType GetBitRange( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType );
183 
184  HilbertOrderType m_HilbertOrder{ 1 };
186 };
187 } // end namespace itk
188 
189 #ifndef ITK_MANUAL_INSTANTIATION
190 #include "itkHilbertPath.hxx"
191 #endif
192 
193 #endif
OutputType IndexType
Represent an n-dimensional Hilbert path for a given order.
unsigned int HilbertOrderType
Define numeric traits for std::vector.
void Initialize() override
typename Superclass::OutputType OutputType
typename HilbertPathType::size_type HilbertPathSizeType
InputType EndOfInput() const override
Represent a path through ND Space.
Definition: itkPath.h:53
HilbertPathType m_HilbertPath
virtual void Clear()
OutputType EvaluateToIndex(const PathIndexType &input) const override
OffsetType IncrementInput(InputType &) const override
OutputType Evaluate(const PathIndexType &input) const override
std::vector< IndexType > HilbertPathType
virtual InputType EvaluateInverse(const IndexType &input)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::OffsetType OffsetType
InputType PathIndexType
Base class for most ITK classes.
Definition: itkObject.h:60
virtual HilbertPathSizeType NumberOfSteps() const
Base class for all data objects in ITK.
typename Superclass::InputType InputType