This file is indexed.

/usr/include/ITK-4.5/itkHilbertPath.hxx is in libinsighttoolkit4-dev 4.5.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*=========================================================================
 *
 *  Copyright Insight Software Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#ifndef __itkHilbertPath_hxx
#define __itkHilbertPath_hxx

#include "itkHilbertPath.h"

namespace itk
{

/** Constructor */
template<typename TIndexValue, unsigned int VDimension>
HilbertPath<TIndexValue, VDimension>
::HilbertPath() :
  m_HilbertOrder( 1 )
{
}

template<typename TIndexValue, unsigned int VDimension>
void
HilbertPath<TIndexValue, VDimension>
::ConstructHilbertPath()
{
  SizeValueType numberOfPathVertices = ( 1 << this->m_HilbertOrder );
  for( unsigned int d = 1; d < Dimension; d++ )
    {
    numberOfPathVertices *= static_cast<SizeValueType>( 1 << this->m_HilbertOrder );
    }
  this->m_HilbertPath.resize( numberOfPathVertices );

  SizeValueType counter = 0;

  typename HilbertPathType::iterator it;
  for( it = this->m_HilbertPath.begin(); it != this->m_HilbertPath.end(); ++it )
    {
    *it = this->TransformPathIndexToMultiDimensionalIndex( counter++ );
    }
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::IndexType
HilbertPath<TIndexValue, VDimension>
::TransformPathIndexToMultiDimensionalIndex( const PathIndexType id )
{
  PathIndexType d = 0;
  PathIndexType e = 0;

  IndexType index;
  index.Fill( 0 );

  for( PathIndexType i = 0; i < this->m_HilbertOrder; ++i )
    {
    PathIndexType w = this->GetBitRange( id, Dimension * this->m_HilbertOrder, i * Dimension, ( i + 1 ) * Dimension );
    PathIndexType l = this->GetGrayCode( w );
    l = this->GetInverseTransform( e, d, Dimension, l );
    for( PathIndexType j = 0; j < Dimension; ++j )
      {
      PathIndexType b = this->GetBitRange( l, Dimension, j, j + 1 );
      index[j] = this->SetBit( index[j], this->m_HilbertOrder, i, b );
      }
    e ^= this->GetLeftBitRotation( this->GetEntry( w ), d + 1, Dimension );
    d = ( d + this->GetDirection( w, Dimension ) + 1 ) % Dimension;
    }
  return index;
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::TransformMultiDimensionalIndexToPathIndex( const IndexType & index )
{
  PathIndexType id = 0;

  PathIndexType d = 0;
  PathIndexType e = 0;

  for( PathIndexType i = 0; i < this->m_HilbertOrder; ++i )
    {
    PathIndexType l = 0;
    for( PathIndexType j = 0; j < Dimension; ++j )
      {
      PathIndexType b = this->GetBitRange( index[Dimension - j - 1], this->m_HilbertOrder, i, i + 1 );
      l |= b << j;
      }
    l = this->GetTransform( e, d, Dimension, l );
    PathIndexType w = this->GetInverseGrayCode( l );
    e ^= this->GetLeftBitRotation( this->GetEntry( w ), d + 1, Dimension );
    d = ( d + this->GetDirection( w, Dimension ) + 1 ) % Dimension;
    id = ( id << Dimension ) | w;
    }
  return id;
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetTransform( const PathIndexType entry, const PathIndexType direction, const PathIndexType width, const PathIndexType x )
{
  return ( this->GetRightBitRotation( x ^ entry, direction + 1, width ) );
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetInverseTransform( const PathIndexType entry, const PathIndexType direction, const PathIndexType width, const PathIndexType x )
{
  return ( this->GetLeftBitRotation( x, direction + 1, width ) ^ entry );
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetBitRange( const PathIndexType x, const PathIndexType width, const PathIndexType start, const PathIndexType end )
{
  return ( x >> ( width - end ) & ( ( 1 << ( end - start ) ) - 1 ) );
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetLeftBitRotation( PathIndexType x, PathIndexType i, const PathIndexType width )
{
  return ( ( ( x << ( i % width ) ) | ( x >> ( width - ( i % width ) ) ) ) & ( ( 1 << width ) - 1 ) );
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetRightBitRotation( PathIndexType x, PathIndexType i, const PathIndexType width )
{
  return ( ( ( x >> ( i % width ) ) | ( x << ( width - ( i % width ) ) ) ) & ( ( 1 << width ) - 1 ) );
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::SetBit( const PathIndexType x, const PathIndexType width, const PathIndexType i, const PathIndexType b )
{
  if( b != 0 )
    {
    return ( x | ( 1 << ( width - i - 1 ) ) );
    }
  else
    {
    return ( x & ~( 1 << ( width - i - 1 ) ) );
    }
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetGrayCode( const PathIndexType x )
{
  return ( x ^ ( x >> 1 ) );
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetInverseGrayCode( const PathIndexType x )
{
  if( x == 0 )
    {
    return x;
    }

  PathIndexType m = static_cast<PathIndexType>( vcl_ceil( vcl_log( static_cast<double>(x) ) / vcl_log( 2.0 ) ) ) + 1;

  PathIndexType i = x;
  PathIndexType j = 1;

  while( j < m )
    {
    i ^= ( x >> j );
    ++j;
    }

  return i;
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetTrailingSetBits( const PathIndexType x, const PathIndexType width )
{
  PathIndexType i = 0;
  PathIndexType y = x;

  while( y & 1 && i <= width )
    {
    y >>= 1;
    ++i;
    }
  return i;
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetDirection( const PathIndexType x, const PathIndexType n )
{
  if( x == 0 )
    {
    return 0;
    }
  else if( x % 2 == 0 )
    {
    return ( this->GetTrailingSetBits( x - 1, n ) % n );
    }
  else
    {
    return ( this->GetTrailingSetBits( x, n ) % n );
    }
}

template<typename TIndexValue, unsigned int VDimension>
typename HilbertPath<TIndexValue, VDimension>::PathIndexType
HilbertPath<TIndexValue, VDimension>
::GetEntry( const PathIndexType x )
{
  if( x == 0 )
    {
    return 0;
    }
  else
    {
    return ( this->GetGrayCode( 2 * static_cast<PathIndexType>( ( x - 1 ) / 2 ) ) );
    }
}

/** Standard "PrintSelf" method */
template<typename TIndexValue, unsigned int VDimension>
void
HilbertPath<TIndexValue, VDimension>
::PrintSelf( std::ostream & os, Indent indent ) const
{
  Superclass::PrintSelf( os, indent );

  std::cout << "Hilbert order: " << this->m_HilbertOrder << std::endl;
}
} // end namespace itk

#endif