ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkHilbertPath_h 00019 #define __itkHilbertPath_h 00020 00021 #include "itkPath.h" 00022 00023 #include "itkNumericTraits.h" 00024 00025 namespace itk 00026 { 00052 template<class TIndexValue = unsigned int, unsigned int VDimension = 3> 00053 class ITK_EXPORT HilbertPath 00054 : public Path<TIndexValue, Index<VDimension>, VDimension> 00055 { 00056 public: 00057 00059 typedef HilbertPath<TIndexValue, VDimension> Self; 00060 typedef Path<unsigned int, Index<VDimension>, VDimension> Superclass; 00061 typedef SmartPointer<Self> Pointer; 00062 typedef SmartPointer<const Self> ConstPointer; 00063 00065 itkTypeMacro( HilbertPath, Path ); 00066 00068 itkNewMacro( Self ); 00069 00071 itkStaticConstMacro( Dimension, unsigned int, VDimension ); 00072 00074 typedef typename Superclass::OutputType OutputType; 00075 typedef typename Superclass::InputType InputType; 00076 00078 typedef InputType PathIndexType; 00079 typedef OutputType IndexType; 00080 typedef unsigned int HilbertOrderType; 00081 typedef std::vector<IndexType> HilbertPathType; 00082 typedef typename HilbertPathType::size_type HilbertPathSizeType; 00083 typedef typename Superclass::OffsetType OffsetType; 00084 00085 // Functions inherited from Path 00086 00088 virtual OutputType Evaluate( const PathIndexType & input ) const 00089 { 00090 return this->m_HilbertPath[input]; 00091 } 00092 00093 virtual OutputType EvaluateToIndex( const PathIndexType & input ) const 00094 { 00095 return this->m_HilbertPath[input]; 00096 } 00097 00099 virtual InputType EvaluateInverse( const IndexType & input ) 00100 { 00101 return this->TransformMultiDimensionalIndexToPathIndex( input ); 00102 } 00103 00105 virtual inline InputType EndOfInput() const 00106 { 00107 return this->NumberOfSteps(); // 0 is before the first step, 1 is after it 00108 } 00109 00113 virtual OffsetType IncrementInput( InputType & itkNotUsed( input ) ) const 00114 { 00115 itkExceptionMacro( "Not implemented." ); 00116 } 00117 00119 virtual inline void Clear() 00120 { 00121 this->m_HilbertPath.clear(); 00122 this->Modified(); 00123 } 00125 00127 virtual inline HilbertPathSizeType NumberOfSteps() const 00128 { 00129 return m_HilbertPath.size(); 00130 } 00131 00133 virtual void Initialize( void ) 00134 { 00135 this->Clear(); 00136 this->ConstructHilbertPath(); 00137 } 00139 00143 itkSetClampMacro( HilbertOrder, HilbertOrderType, 1, NumericTraits<HilbertOrderType>::max() ); 00144 itkGetConstMacro( HilbertOrder, HilbertOrderType ); 00146 00148 IndexType TransformPathIndexToMultiDimensionalIndex( const PathIndexType id ); 00149 00151 PathIndexType TransformMultiDimensionalIndexToPathIndex( const IndexType & index ); 00152 00153 protected: 00154 HilbertPath(); 00155 ~HilbertPath() {} 00156 void PrintSelf( std::ostream & os, Indent indent ) const; 00157 00158 private: 00159 HilbertPath( const Self & ); //purposely not implemented 00160 void operator=( const Self & ); //purposely not implemented 00161 00162 void ConstructHilbertPath(); 00163 00164 PathIndexType GetTransform( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType ); 00165 00166 PathIndexType GetInverseTransform( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType ); 00167 00168 PathIndexType GetGrayCode( const PathIndexType ); 00169 00170 PathIndexType GetInverseGrayCode( const PathIndexType ); 00171 00172 PathIndexType SetBit( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType ); 00173 00174 PathIndexType GetRightBitRotation( PathIndexType, PathIndexType, const PathIndexType ); 00175 00176 PathIndexType GetLeftBitRotation( PathIndexType, PathIndexType, const PathIndexType ); 00177 00178 PathIndexType GetTrailingSetBits( const PathIndexType, const PathIndexType ); 00179 00180 PathIndexType GetDirection( const PathIndexType, const PathIndexType ); 00181 00182 PathIndexType GetEntry( const PathIndexType ); 00183 00184 PathIndexType GetBitRange( const PathIndexType, const PathIndexType, const PathIndexType, const PathIndexType ); 00185 00186 HilbertOrderType m_HilbertOrder; 00187 HilbertPathType m_HilbertPath; 00188 }; 00189 } // end namespace itk 00190 00191 // Define instantiation macro for this template. 00192 #define ITK_TEMPLATE_HilbertPath(_, EXPORT, TypeX, TypeY) \ 00193 namespace itk \ 00194 { \ 00195 _( 1 ( class EXPORT HilbertPath< ITK_TEMPLATE_1 TypeX > ) ) \ 00196 namespace Templates \ 00197 { \ 00198 typedef HilbertPath< ITK_TEMPLATE_1 TypeX > \ 00199 HilbertPath##TypeY; \ 00200 } \ 00201 } 00202 00203 #if ITK_TEMPLATE_EXPLICIT 00204 #include "Templates/itkHilbertPath+-.h" 00205 #endif 00206 00207 #if ITK_TEMPLATE_TXX 00208 #include "itkHilbertPath.hxx" 00209 #endif 00210 00211 #endif 00212