This file is indexed.

/usr/include/ITK-4.5/itkBoundingBox.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
/*=========================================================================
 *
 *  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.
 *
 *=========================================================================*/
/*=========================================================================
 *
 *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
 *
 *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
 *
 *  For complete copyright, license and disclaimer of warranty information
 *  please refer to the NOTICE file at the top of the ITK source tree.
 *
 *=========================================================================*/
#ifndef __itkBoundingBox_hxx
#define __itkBoundingBox_hxx
#include "itkBoundingBox.h"

namespace itk
{
/**
 * Print out the bounding box.
 */
template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
void
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::PrintSelf(std::ostream & os, Indent indent) const
{
  Superclass::PrintSelf(os, indent);

  os << indent << "Bounding Box: ( ";
  for ( unsigned int i = 0; i < PointDimension; i++ )
    {
    os << m_Bounds[2 * i] << "," << m_Bounds[2 * i + 1] << " ";
    }
  os << " )" << std::endl;
}

/**
 * Access routine to set the points container.
 */
template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
void
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::SetPoints(const PointsContainer *points)
{
  itkDebugMacro("setting Points container to " << points);
  if ( m_PointsContainer.GetPointer() != points )
    {
    m_PointsContainer = points;
    this->Modified();
    }
}

/** Access routine to get the points container. */
template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
const typename BoundingBox< TPointIdentifier, VPointDimension, TCoordRep,
                            TPointsContainer >::PointsContainer *
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::GetPoints(void) const
{
  itkDebugMacro("returning Points container of " << m_PointsContainer);

  return m_PointsContainer.GetPointer();
}

/** Compute and get the corners of the bounding box */
template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
const typename BoundingBox< TPointIdentifier, VPointDimension, TCoordRep,
                            TPointsContainer >::PointsContainer *
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::GetCorners(void)
{
  m_CornersContainer->clear();

  PointType center = this->GetCenter();
  PointType radius;

  for ( unsigned int i = 0; i < VPointDimension; i++ )
    {
    radius[i] = m_Bounds[2 * i + 1] - center[i];
    }

  for ( unsigned int j = 0; j < vcl_pow(2.0, (double)VPointDimension); j++ )
    {
    PointType pnt;
    for ( unsigned int i = 0; i < VPointDimension; i++ )
      {
      pnt[i] = center[i] + vcl_pow( -1.0, ( (double)( j / ( int( vcl_pow(2.0, (double)i) ) ) ) ) )
               * radius[i];
      }

    // Push back is not defined so we insert at the end of the list
    m_CornersContainer->InsertElement(m_CornersContainer->Size(), pnt);
    }

  return m_CornersContainer.GetPointer();
}

/** */
template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::BoundingBox():m_PointsContainer(NULL)
{
  m_Bounds.Fill(NumericTraits< CoordRepType >::Zero);
  m_CornersContainer = PointsContainer::New();
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::~BoundingBox()
{}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
bool
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::ComputeBoundingBox(void) const
{
  if ( !m_PointsContainer )
    {
    if ( this->GetMTime() > m_BoundsMTime )
      {
      m_Bounds.Fill(NumericTraits< CoordRepType >::Zero);
      m_BoundsMTime.Modified();
      }
    return false;
    }

  if ( this->GetMTime() > m_BoundsMTime )
    {
    //iterate over points determining min/max
    //start by initializing the values
    if ( m_PointsContainer->Size() < 1 )
      {
      m_Bounds.Fill(NumericTraits< CoordRepType >::Zero);
      m_BoundsMTime.Modified();
      return false;
      }

    PointsContainerConstIterator        ci = m_PointsContainer->Begin();
    Point< TCoordRep, VPointDimension > point = ci->Value();      //point value
    for ( unsigned int i = 0; i < PointDimension; i++ )
      {
      m_Bounds[2 * i] = point[i];
      m_Bounds[2 * i + 1] = point[i];
      }
    ++ci;

    //use a const iterator to grab the points and compute
    //the bounding box.
    while ( ci != m_PointsContainer->End() )
      {
      point = ci->Value();     //point value
      for ( unsigned int i = 0; i < PointDimension; i++ )
        {
        if ( point[i] < m_Bounds[2 * i] )
          {
          m_Bounds[2 * i] = point[i];
          }
        if ( point[i] > m_Bounds[2 * i + 1] )
          {
          m_Bounds[2 * i + 1] = point[i];
          }
        }
      ++ci;
      } //for all points in container

    m_BoundsMTime.Modified();
    }

  return true;
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
typename BoundingBox< TPointIdentifier, VPointDimension, TCoordRep,
                      TPointsContainer >::PointType
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::GetCenter(void) const
{
  this->ComputeBoundingBox();

  PointType center;
  for ( unsigned int i = 0; i < PointDimension; i++ )
    {
    center[i] = ( m_Bounds[2 * i] + m_Bounds[2 * i + 1] ) / 2.0;
    }

  return center;
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
typename BoundingBox< TPointIdentifier, VPointDimension, TCoordRep,
                      TPointsContainer >::PointType
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::GetMinimum(void) const
{
  this->ComputeBoundingBox();

  PointType minimum;
  for ( unsigned int i = 0; i < PointDimension; i++ )
    {
    minimum[i] = m_Bounds[2 * i];
    }

  return minimum;
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
void
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::SetMinimum(const PointType & point)
{
  for ( unsigned int i = 0; i < PointDimension; i++ )
    {
    m_Bounds[2 * i] = point[i];
    }

  m_BoundsMTime.Modified();
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
typename BoundingBox< TPointIdentifier, VPointDimension, TCoordRep,
                      TPointsContainer >::PointType
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::GetMaximum(void) const
{
  this->ComputeBoundingBox();

  PointType maximum;
  for ( unsigned int i = 0; i < PointDimension; i++ )
    {
    maximum[i] = m_Bounds[2 * i + 1];
    }

  return maximum;
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
void
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::SetMaximum(const PointType & point)
{
  for ( unsigned int i = 0; i < PointDimension; i++ )
    {
    m_Bounds[2 * i + 1] = point[i];
    }

  m_BoundsMTime.Modified();
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
void
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::ConsiderPoint(const PointType & point)
{
  bool changed = false;

  for ( unsigned int i = 0; i < PointDimension; i++ )
    {
    if ( point[i] < m_Bounds[2 * i] )
      {
      m_Bounds[2 * i] = point[i];
      changed = true;
      }
    if ( point[i] > m_Bounds[2 * i + 1] )
      {
      m_Bounds[2 * i + 1] = point[i];
      changed = true;
      }
    }

  if ( changed )
    {
    m_BoundsMTime.Modified();
    }
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
typename BoundingBox< TPointIdentifier, VPointDimension, TCoordRep,
                      TPointsContainer >::AccumulateType
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::GetDiagonalLength2(void) const
{
  typename NumericTraits< CoordRepType >::AccumulateType
  dist2 = NumericTraits< CoordRepType >::Zero;

  if ( this->ComputeBoundingBox() )
    {
    for ( unsigned int i = 0; i < PointDimension; i++ )
      {
      dist2 += ( m_Bounds[2 * i] - m_Bounds[2 * i + 1] )
               * ( m_Bounds[2 * i] - m_Bounds[2 * i + 1] );
      }
    }

  return dist2;
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
bool
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::IsInside(const PointType & point) const
{
  unsigned int j = 0;
  unsigned int i = 0;

  while ( i < PointDimension )
    {
    if ( point[i] < m_Bounds[j++] )
      {
      return false;
      }
    if ( point[i] > m_Bounds[j++] )
      {
      return false;
      }
    i++;
    }
  return true;
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
ModifiedTimeType
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::GetMTime(void) const
{
  ModifiedTimeType latestTime = Object::GetMTime();

  if ( m_PointsContainer )
    {
    if ( latestTime < m_PointsContainer->GetMTime() )
      {
      latestTime = m_PointsContainer->GetMTime();
      }
    }
  return latestTime;
}

template< typename TPointIdentifier, int VPointDimension,
          typename TCoordRep, typename TPointsContainer >
typename BoundingBox< TPointIdentifier, VPointDimension, TCoordRep,
                      TPointsContainer >::Pointer
BoundingBox< TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer >
::DeepCopy(void) const
{
  Pointer clone = Self::New();

  // Connect the same points container into the clone
  clone->SetPoints(this->m_PointsContainer);

  // Copy the corners into the clone.
  clone->m_CornersContainer->clear();

  PointsContainerConstIterator itr = this->m_CornersContainer->Begin();
  PointsContainerConstIterator end = this->m_CornersContainer->End();

  clone->m_CornersContainer->Reserve( this->m_CornersContainer->Size() );
  PointsContainerIterator dest = clone->m_CornersContainer->Begin();

  while ( itr != end )
    {
    dest.Value() = itr.Value();
    ++itr;
    }

  // Copy the bounds into the clone
  for ( unsigned int i = 0; i < 2 * PointDimension; i++ )
    {
    clone->m_Bounds[i] = this->m_Bounds[i];
    }

  return clone;
}
} // end namespace itk

#endif