This file is indexed.

/usr/include/InsightToolkit/SpatialObject/itkSceneSpatialObject.txx is in libinsighttoolkit3-dev 3.20.1-1.

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
406
407
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkSceneSpatialObject.txx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __itkSceneSpatialObject_txx
#define __itkSceneSpatialObject_txx

#include "itkSceneSpatialObject.h"
#include <algorithm>

namespace itk
{
  
/** Constructor */
template <unsigned int TSpaceDimension>
SceneSpatialObject<TSpaceDimension>
::SceneSpatialObject()
{
}

/** Destructor */
template <unsigned int TSpaceDimension>
SceneSpatialObject<TSpaceDimension>
::~SceneSpatialObject()
{
}

/** Add a spatial object to the SceneSpatialObject */
template <unsigned int TSpaceDimension>
void 
SceneSpatialObject<TSpaceDimension>
::AddSpatialObject( SpatialObject<TSpaceDimension> * pointer )
{
  m_Objects.push_back( pointer );
  this->Modified();
}

/** Remove a spatial object from the SceneSpatialObject */
template <unsigned int TSpaceDimension>
void 
SceneSpatialObject<TSpaceDimension>
::RemoveSpatialObject( SpatialObject<TSpaceDimension> * pointer )
{
  typename ObjectListType::iterator it;
  it = std::find(m_Objects.begin(),m_Objects.end(),pointer);

  if( it != m_Objects.end() )
    {
    if( *it == pointer )
      {
      m_Objects.erase( it );
      this->Modified();
      }
    }
  else
    { 
    //throw an exception object to let user know that 
    // he tried to remove an object
    // which is not in the list of the children.
    }
}


/** Return the modification time of the SceneSpatialObject */
template <unsigned int TSpaceDimension>
unsigned long
SceneSpatialObject<TSpaceDimension>
::GetMTime( void ) const
{
  typename ObjectListType::const_iterator it = m_Objects.begin();
  typename ObjectListType::const_iterator itEnd = m_Objects.end();
 
  unsigned long latestTime = Superclass::GetMTime();
  unsigned long localTime;
  while(it!=itEnd)
    {
    localTime = (*it)->GetMTime();
    if( localTime > latestTime )
      {
      latestTime = localTime;
      }
    it++;
    } 
  return latestTime;
}

/** Returns a new list of objects in the scene */
template <unsigned int TSpaceDimension>
typename SceneSpatialObject<TSpaceDimension>::ObjectListType *
SceneSpatialObject<TSpaceDimension>
::GetObjects( unsigned int depth, char * name )
{
  ObjectListType * newList = new ObjectListType;

  typename ObjectListType::const_iterator it = m_Objects.begin();
  typename ObjectListType::const_iterator itEnd = m_Objects.end();

  while(it != itEnd)
    {
    if(name == NULL || strstr(typeid(**it).name(), name))
      {
      newList->push_back(*it);
      }
    if(depth>0)
      {
      typedef typename SpatialObject<TSpaceDimension>::ChildrenListType
        ChildListType;
      ChildListType * childList = 
        dynamic_cast<SpatialObject<TSpaceDimension> *>((*it).GetPointer())->
        GetChildren(depth-1, name);
      typename ChildListType::const_iterator cIt = childList->begin();
      typename ChildListType::const_iterator cItEnd = childList->end();

      while(cIt != cItEnd)
        {
        newList->push_back(dynamic_cast< ObjectType * >((*cIt).GetPointer()));
        cIt++;
        }

      delete childList;
      }
    it++;
    }

  return newList;
}

/** Set the children list */
template <unsigned int TSpaceDimension>
void
SceneSpatialObject<TSpaceDimension>
::SetObjects( ObjectListType & children )
{ 
  m_Objects = children;
}

/** Return the number of objects in the SceneSpatialObject */
template <unsigned int TSpaceDimension>
unsigned int
SceneSpatialObject<TSpaceDimension>
::GetNumberOfObjects( unsigned int depth, char * name )
{
  typename ObjectListType::const_iterator it = m_Objects.begin();
  typename ObjectListType::const_iterator itEnd = m_Objects.end();

  unsigned int cnt = 0;
  while(it != itEnd)
    {
    if(name == NULL || strstr(typeid(**it).name(), name))
      {
      cnt++;
      }
    it++;
    }

  it = m_Objects.begin();
  itEnd = m_Objects.end();
  if( depth > 0 )
    {
    while(it != itEnd)
      {
      cnt += 
        (dynamic_cast<SpatialObject<TSpaceDimension> * >((*it).GetPointer()))->
                                           GetNumberOfChildren( depth-1, name );
      it++;
      }
    }

  return cnt;
} 

/** Print the object */
template <unsigned int TSpaceDimension>
void
SceneSpatialObject<TSpaceDimension>
::PrintSelf( std::ostream& os, Indent indent ) const
{
  os << indent << "Number of objects: " 
     << m_Objects.size() << std::endl;
  os << indent << "List of objects: ";

  typename ObjectListType::const_iterator it = m_Objects.begin();
  typename ObjectListType::const_iterator itEnd = m_Objects.end();

  while(it != itEnd)
    {
    os << "[" << (*it) << "] ";
    it++;
    }
  os << std::endl;

  Superclass::PrintSelf(os, indent);
}

/** Return a SpatialObject in the SceneSpatialObject 
 *  given a parent ID */
template <unsigned int TSpaceDimension>
SpatialObject<TSpaceDimension> *
SceneSpatialObject<TSpaceDimension>
::GetObjectById(int Id)
{
  typename ObjectListType::iterator it = m_Objects.begin();
  typename ObjectListType::iterator itEnd = m_Objects.end();

  typedef typename SpatialObjectType::ChildrenListType ChildListType;
  ChildListType * cList;
  typename ChildListType::iterator cIt;
  typename ChildListType::iterator cItEnd;
    
  while( it != itEnd )
    {
    if( (*it)->GetId() == Id )
      { 
      return *it;
      }
    else
      {
      //cList = (dynamic_cast<SpatialObject<TSpaceDimension> *>(*it))->
      //  GetChildren(SpatialObjectType::MaximumDepth); 
      cList = (*it)->GetChildren(SpatialObjectType::MaximumDepth); 
      cIt = cList->begin();
      cItEnd = cList->end();
      while(cIt != cItEnd)
        {
        if( (*cIt)->GetId() == Id )
          {
          SpatialObject<TSpaceDimension> * tmp;
          tmp = *cIt;
          delete cList;
          return tmp;
          }
        cIt++;
        }

      delete cList;
      }

    it++;
    }

  return NULL;
}
template <unsigned int TSpaceDimension>
bool
SceneSpatialObject<TSpaceDimension>
::FixHierarchy(void)
{
  typename ObjectListType::iterator it = m_Objects.begin();
  typename ObjectListType::iterator oldIt;
  typename ObjectListType::iterator itEnd = m_Objects.end();

  bool ret = true;
  while( it != itEnd)
    {
    int pID = (*it)->GetParentId();
    if(pID >= 0)
      {
      SpatialObject<TSpaceDimension> * pObj =
        static_cast<SpatialObject<TSpaceDimension> * >
        (this->GetObjectById(pID));
      if(pObj == NULL)
        {
        ret = false;
        it++;
        }
      else
        {
        pObj->AddSpatialObject(dynamic_cast<SpatialObject<TSpaceDimension> *>
                               ((*it).GetPointer()));
        oldIt = it;
        it++;
        m_Objects.erase( oldIt );
        }
      }
    else
      {
      it++;
      }
    }

  return ret;
}


/** Check if the parent objects have a defined ID */
template <unsigned int TSpaceDimension>
bool
SceneSpatialObject<TSpaceDimension>
::CheckIdValidity(void)
{
  typename ObjectListType::iterator it = m_Objects.begin();
  typename ObjectListType::iterator itEnd = m_Objects.end();

  bool ret = true;
  while( it != itEnd)
    {
    // For every object in the scene we check the ID validity
    typename ObjectType::ChildrenListType* children = (*it)->GetChildren();
    typename ObjectType::ChildrenListType::const_iterator
                                               itChild = children->begin();
    
    while( itChild != children->end())
      {
      if( (*itChild)->HasParent())
        {
        if((*itChild)->GetParent()->GetId()<0)
          {
          delete children;
          return false;
          }
        }
      itChild++;
      }
    delete children;
    it++;
    }
  return ret;
}

template <unsigned int TSpaceDimension>
void
SceneSpatialObject<TSpaceDimension>
::FixIdValidity(void)
{
  typename ObjectListType::iterator it = m_Objects.begin();
  typename ObjectListType::iterator itEnd = m_Objects.end();

  while( it != itEnd)
    {
    // For every object in the scene we check the ID validity
    typename ObjectType::ChildrenListType* children = (*it)->GetChildren();
    typename ObjectType::ChildrenListType::iterator itChild = children->begin();
    
    while( itChild != children->end())
      {
      if( (*itChild)->HasParent())
        {
        if((*itChild)->GetParent()->GetId()<0)
          {
          (*itChild)->GetParent()->SetId(this->GetNextAvailableId());
          }
        }
      itChild++;
      }
    delete children;
    it++;
    }
}


/** Return the next available Id. For speed reason the MaxID+1 is returned */
template <unsigned int TSpaceDimension>
int
SceneSpatialObject<TSpaceDimension>
::GetNextAvailableId()
{
  int Id = 0;

  typename ObjectListType::iterator it = m_Objects.begin();
  typename ObjectListType::iterator itEnd = m_Objects.end();

  while( it != itEnd)
    {
    typename ObjectType::ChildrenListType* children = (*it)->GetChildren();
    typename ObjectType::ChildrenListType::iterator 
                                               itChild = children->begin();
    
    while( itChild != children->end())
      {
      if((*itChild)->GetId() >= Id)
        {
        Id = (*itChild)->GetId()+1;
        }
      itChild++;
      }
    delete children;
    it++;
    }
  return Id;
}

/** Clear function : Remove all the objects in the scene */
template <unsigned int TSpaceDimension>
void
SceneSpatialObject<TSpaceDimension>
::Clear()
{
  m_Objects.clear();
  this->Modified();
}


} // end of namespace itk 

#endif