ITK  6.0.0
Insight Toolkit
itkHilbertPath.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 {
53 template <typename TIndexValue = unsigned int, unsigned int VDimension = 3>
54 class ITK_TEMPLATE_EXPORT HilbertPath : public Path<TIndexValue, Index<VDimension>, VDimension>
55 {
56 public:
57  ITK_DISALLOW_COPY_AND_MOVE(HilbertPath);
58 
64 
66  itkOverrideGetNameOfClassMacro(HilbertPath);
67 
69  itkNewMacro(Self);
70 
72  static constexpr unsigned int Dimension = VDimension;
73 
75  using typename Superclass::OutputType;
76  using typename Superclass::InputType;
77 
81  using HilbertOrderType = unsigned int;
82  using HilbertPathType = std::vector<IndexType>;
83  using HilbertPathSizeType = typename HilbertPathType::size_type;
84  using typename Superclass::OffsetType;
85 
86  // Functions inherited from Path
87 
90  Evaluate(const PathIndexType & input) const override
91  {
92  return this->m_HilbertPath[input];
93  }
94 
95  OutputType
96  EvaluateToIndex(const PathIndexType & input) const override
97  {
98  return this->m_HilbertPath[input];
99  }
100 
102  virtual InputType
103  EvaluateInverse(const IndexType & input)
104  {
105  return this->TransformMultiDimensionalIndexToPathIndex(input);
106  }
107 
109  InputType
110  EndOfInput() const override
111  {
112  return static_cast<InputType>(this->NumberOfSteps()); // 0 is before the first step, 1 is after it
113  }
114 
118  OffsetType
119  IncrementInput(InputType & itkNotUsed(input)) const override
120  {
121  itkExceptionMacro("Not implemented.");
122  }
123 
125  virtual inline void
127  {
128  this->m_HilbertPath.clear();
129  this->Modified();
130  }
134  virtual inline HilbertPathSizeType
136  {
137  return m_HilbertPath.size();
138  }
139 
141  void
142  Initialize() override
143  {
144  this->Clear();
145  this->ConstructHilbertPath();
146  }
152  itkSetClampMacro(HilbertOrder, HilbertOrderType, 1, NumericTraits<HilbertOrderType>::max());
153  itkGetConstMacro(HilbertOrder, HilbertOrderType);
157  IndexType
158  TransformPathIndexToMultiDimensionalIndex(const PathIndexType id);
159 
161  PathIndexType
162  TransformMultiDimensionalIndexToPathIndex(const IndexType & index);
163 
164 protected:
165  HilbertPath();
166  ~HilbertPath() override = default;
167  void
168  PrintSelf(std::ostream & os, Indent indent) const override;
169 
170 private:
171  void
172  ConstructHilbertPath();
173 
174  PathIndexType
175  GetTransform(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType);
176 
177  PathIndexType
178  GetInverseTransform(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType);
179 
180  PathIndexType
181  GetGrayCode(const PathIndexType);
182 
183  PathIndexType
184  GetInverseGrayCode(const PathIndexType);
185 
186  PathIndexType
187  SetBit(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType);
188 
189  PathIndexType
190  GetRightBitRotation(PathIndexType, PathIndexType, const PathIndexType);
191 
192  PathIndexType
193  GetLeftBitRotation(PathIndexType, PathIndexType, const PathIndexType);
194 
195  PathIndexType
196  GetTrailingSetBits(const PathIndexType, const PathIndexType);
197 
198  PathIndexType
199  GetDirection(const PathIndexType, const PathIndexType);
200 
201  PathIndexType
202  GetEntry(const PathIndexType);
203 
204  PathIndexType
205  GetBitRange(const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType);
206 
207  HilbertOrderType m_HilbertOrder{ 1 };
208  HilbertPathType m_HilbertPath{};
209 };
210 } // end namespace itk
211 
212 #ifndef ITK_MANUAL_INSTANTIATION
213 # include "itkHilbertPath.hxx"
214 #endif
215 
216 #endif
itk::HilbertPath::IncrementInput
OffsetType IncrementInput(InputType &) const override
Definition: itkHilbertPath.h:119
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:68
itk::Path
Represent a path through ND Space.
Definition: itkPath.h:54
itk::HilbertPath
Represent an n-dimensional Hilbert path for a given order.
Definition: itkHilbertPath.h:54
itk::HilbertPath::EndOfInput
InputType EndOfInput() const override
Definition: itkHilbertPath.h:110
itk::HilbertPath::Clear
virtual void Clear()
Definition: itkHilbertPath.h:126
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::HilbertPath::HilbertPathType
std::vector< IndexType > HilbertPathType
Definition: itkHilbertPath.h:82
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::HilbertPath::EvaluateInverse
virtual InputType EvaluateInverse(const IndexType &input)
Definition: itkHilbertPath.h:103
itkPath.h
itk::HilbertPath::EvaluateToIndex
OutputType EvaluateToIndex(const PathIndexType &input) const override
Definition: itkHilbertPath.h:96
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::Path< TIndexValue, Index< VDimension >, VDimension >::InputType
TIndexValue InputType
Definition: itkPath.h:72
itk::HilbertPath::HilbertOrderType
unsigned int HilbertOrderType
Definition: itkHilbertPath.h:81
itk::HilbertPath::Evaluate
OutputType Evaluate(const PathIndexType &input) const override
Definition: itkHilbertPath.h:90
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::HilbertPath::PathIndexType
InputType PathIndexType
Definition: itkHilbertPath.h:79
itk::HilbertPath::Initialize
void Initialize() override
Definition: itkHilbertPath.h:142
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itkNumericTraits.h
itk::HilbertPath::NumberOfSteps
virtual HilbertPathSizeType NumberOfSteps() const
Definition: itkHilbertPath.h:135
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::HilbertPath::HilbertPathSizeType
typename HilbertPathType::size_type HilbertPathSizeType
Definition: itkHilbertPath.h:83
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293