This file is indexed.

/usr/include/IGSTK/igstkVideoFrameSpatialObject.txx is in libigstk4-dev 4.4.0-2build2.

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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
/*=========================================================================

  Program:   Image Guided Surgery Software Toolkit
  Module:    $RCSfile: igstkVideoFrameSpatialObject.txx,v $
  Language:  C++
  Date:      $Date: 2009-06-18 20:05:14 $
  Version:   $Revision: 1.2 $

  Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
  See IGSTKCopyright.txt or http://www.igstk.org/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 __igstkVideoFrameSpatialObject_txx
#define __igstkVideoFrameSpatialObject_txx

#include "igstkVideoFrameSpatialObject.h"

namespace igstk
{

template< class TPixelType, unsigned int TChannels >
VideoFrameSpatialObject< TPixelType, TChannels >
::VideoFrameSpatialObject() :
  m_StateMachine(this)
{
  igstkLogMacro( DEBUG, "VideoFrameSpatialObject Constructor called ....\n" );

  VideoFrameSpatialObjectType::Pointer dummy
                                           = VideoFrameSpatialObjectType::New();
  this->RequestSetInternalSpatialObject(dummy);

  m_Width=0;
  m_Height=0;

  this->m_VideoImagerTool=NULL;
  m_PixelSizeX = 0;
  m_PixelSizeY = 0;
  m_NumberOfScalarComponents = 0;

  if( m_NumberOfChannels == 3 )
  {
    m_ItkRGBExporter = ITKRGBExportFilterType::New();
    m_VtkRGBImporter = VTKImportFilterType::New();

    /** Connect the given itk::VTKImageExport filter to the given
      * vtkImageImport filter */
    m_VtkRGBImporter->SetUpdateInformationCallback(
                              m_ItkRGBExporter->GetUpdateInformationCallback());
    m_VtkRGBImporter->SetPipelineModifiedCallback(
                               m_ItkRGBExporter->GetPipelineModifiedCallback());
    m_VtkRGBImporter->SetWholeExtentCallback(
                                    m_ItkRGBExporter->GetWholeExtentCallback());
    m_VtkRGBImporter->SetSpacingCallback(
                                        m_ItkRGBExporter->GetSpacingCallback());
    m_VtkRGBImporter->SetOriginCallback(m_ItkRGBExporter->GetOriginCallback());
    m_VtkRGBImporter->SetScalarTypeCallback(
                                     m_ItkRGBExporter->GetScalarTypeCallback());
    m_VtkRGBImporter->SetNumberOfComponentsCallback(
                             m_ItkRGBExporter->GetNumberOfComponentsCallback());
    m_VtkRGBImporter->SetPropagateUpdateExtentCallback(
                          m_ItkRGBExporter->GetPropagateUpdateExtentCallback());
    m_VtkRGBImporter->SetUpdateDataCallback(
                                     m_ItkRGBExporter->GetUpdateDataCallback());
    m_VtkRGBImporter->SetDataExtentCallback(
                                     m_ItkRGBExporter->GetDataExtentCallback());
    m_VtkRGBImporter->SetBufferPointerCallback(
                                  m_ItkRGBExporter->GetBufferPointerCallback());
    m_VtkRGBImporter->SetCallbackUserData(
                                       m_ItkRGBExporter->GetCallbackUserData());
    }
  else if(m_NumberOfChannels == 1)
    {
    m_ItkExporter = ITKExportFilterType::New();
    m_VtkImporter = VTKImportFilterType::New();

    m_VtkImporter->SetUpdateInformationCallback(
                                 m_ItkExporter->GetUpdateInformationCallback());
    m_VtkImporter->SetPipelineModifiedCallback(
                                  m_ItkExporter->GetPipelineModifiedCallback());
    m_VtkImporter->SetWholeExtentCallback(
                                       m_ItkExporter->GetWholeExtentCallback());
    m_VtkImporter->SetSpacingCallback(m_ItkExporter->GetSpacingCallback());
    m_VtkImporter->SetOriginCallback(m_ItkExporter->GetOriginCallback());
    m_VtkImporter->SetScalarTypeCallback(
                                        m_ItkExporter->GetScalarTypeCallback());
    m_VtkImporter->SetNumberOfComponentsCallback(
                                m_ItkExporter->GetNumberOfComponentsCallback());
    m_VtkImporter->SetPropagateUpdateExtentCallback(
                             m_ItkExporter->GetPropagateUpdateExtentCallback());
    m_VtkImporter->SetUpdateDataCallback(
                                        m_ItkExporter->GetUpdateDataCallback());
    m_VtkImporter->SetDataExtentCallback(
                                        m_ItkExporter->GetDataExtentCallback());
    m_VtkImporter->SetBufferPointerCallback(
                                     m_ItkExporter->GetBufferPointerCallback());
    m_VtkImporter->SetCallbackUserData(m_ItkExporter->GetCallbackUserData());
    }
  else
    {
    igstkLogMacro( DEBUG, "VideoFrameSpatialObject::Constructor called "
            "with wrong channel number. Only 1 (grayscale) and 3 (RGB)"
            "are allowed! \n" );
    }

  m_StateMachine.SetReadyToRun();
}

template< class TPixelType, unsigned int TChannels >
VideoFrameSpatialObject< TPixelType, TChannels>
::~VideoFrameSpatialObject()
{
  igstkLogMacro( DEBUG, "VideoFrameSpatialObject Destructor called ....\n" );

  if( m_NumberOfChannels == 3 )
    {
    if( m_VtkRGBImporter )
      {
      m_VtkRGBImporter->Delete();
      m_VtkRGBImporter = NULL;
      }

    if( m_RGBPixelContainer )
      {
      delete [] m_RGBPixelContainer;
      m_RGBPixelContainer = NULL;
      }
    }
  else if( m_NumberOfChannels == 1 )
    {
    if( m_VtkImporter )
      {
      m_VtkImporter->Delete();
      }
    }
}

template< class TPixelType, unsigned int TChannels >
void
VideoFrameSpatialObject< TPixelType, TChannels>
::Initialize()
{
  igstkLogMacro( DEBUG, "VideoFrameSpatialObject::Initialize called ....\n" );

  m_Size[0]  = m_Width;  // size along X
  m_Size[1]  = m_Height;  // size along Y

  m_Start.Fill( 0 );

  m_Region.SetIndex( m_Start );
  m_Region.SetSize(  m_Size  );

  double origin[ DIMENSION ];
  origin[0] = 0.0;    // X coordinate
  origin[1] = 0.0;    // Y coordinate

  double spacing[ DIMENSION ];
  spacing[0] = 1.0;    // along X direction
  spacing[1] = 1.0;    // along Y direction

  if( m_NumberOfChannels == 3 )
  {
    m_RGBPixelContainer = new RGBPixelType[m_Width * m_Height];//

    m_RawBuffer = (TPixelType*)malloc(m_Width * m_Height * 3);
    for(unsigned int i = 0; i< m_Width * m_Height * 3; i++)
    {
    if(i%2==0)
      m_RawBuffer[i]='h';
    else
      m_RawBuffer[i]='a';
    }

    m_RGBImportFilter = RGBImportFilterType::New();

    m_RGBImportFilter->SetRegion( m_Region );

    m_RGBImportFilter->SetOrigin( origin );

    m_RGBImportFilter->SetSpacing( spacing );

    int j=0;
    for( unsigned int i=0; i < m_Width * m_Height * 3; i+=3 )
      {
      RGBPixelType temp;
      temp[0]=m_RawBuffer[i];
      temp[1]=m_RawBuffer[i+1];
      temp[2]=m_RawBuffer[i+2];
      m_RGBPixelContainer[j]=temp;
      j++;
      }
    m_RGBImportFilter->SetImportPointer(m_RGBPixelContainer,
                                        m_Width * m_Height,
                                        false );
    m_RGBImportFilter->Update();

    this->m_RGBImage = m_RGBImportFilter->GetOutput();

    m_ItkRGBExporter->SetInput( m_RGBImportFilter->GetOutput() );
    m_VtkRGBImporter->UpdateWholeExtent();

    m_VTKImage = m_VtkRGBImporter->GetOutput();
    }
  else if (m_NumberOfChannels == 1)
    {
    m_ImportFilter = ImportFilterType::New();

    m_ImportFilter->SetRegion( m_Region );

    m_ImportFilter->SetOrigin( origin );

    m_ImportFilter->SetSpacing( spacing );

    m_ImportFilter->SetImportPointer(m_RawBuffer,
                      m_Width * m_Height,
                                        false);
    m_ImportFilter->Update();

    this->m_Image = m_ImportFilter->GetOutput();

    m_ItkExporter->SetInput( m_ImportFilter->GetOutput() );
    m_VtkImporter->UpdateWholeExtent();

    m_VTKImage = m_VtkImporter->GetOutput();
    }
  else
    {
    igstkLogMacro( DEBUG, "VideoFrameSpatialObject::Initialize called "
      "with wrong channel number. Only 1 (grayscale) and 3 (RGB)"
      "are allowed! \n" );
    }
}

template< class TPixelType, unsigned int TChannels >
const unsigned int
VideoFrameSpatialObject< TPixelType, TChannels>
::GetNumberOfChannels() const
{
  return m_NumberOfChannels;
}

template< class TPixelType, unsigned int TChannels >
bool
VideoFrameSpatialObject< TPixelType, TChannels>
::IsEmpty() const
{
  igstkLogMacro( DEBUG, "VideoFrameSpatialObject::IsEmpty called ....\n" );

  if( m_NumberOfChannels == 3 )
    {
    if(m_RGBImage.IsNull())
      {
      return true;
      }
    else
      {
      typename RGBImportFilterType::RegionType    tmpregion;
      tmpregion = m_RGBImage->GetLargestPossibleRegion();
      const unsigned int numberOfPixels = tmpregion.GetNumberOfPixels();
      const bool isEmpty = ( numberOfPixels == 0 );
      return isEmpty;
      }
    }
  else if(m_NumberOfChannels == 1)
    {
    if(m_Image.IsNull())
      {
      return true;
      }
    else
      {
      typename ImportFilterType::RegionType     tmpregion;
      tmpregion = m_Image->GetLargestPossibleRegion();
      const unsigned int numberOfPixels = tmpregion.GetNumberOfPixels();
      const bool isEmpty = ( numberOfPixels == 0 );
      return isEmpty;
      }
    }
  else
    {
    igstkLogMacro( DEBUG, "VideoFrameSpatialObject::UpdateImages called "
            "with wrong channel number. Only 1 (grayscale) and 3 (RGB)"
            "are allowed! \n" );
    }

}

template< class TPixelType, unsigned int TChannels >
TimeStamp::TimePeriodType
VideoFrameSpatialObject< TPixelType, TChannels >
::GetFrameExpirationTime() const
{
  if(this->m_VideoImagerTool.IsNotNull())
    {
    return (m_VideoImagerTool->GetInternalFrame())->GetExpirationTime();
    }
  else
  return igstk::TimeStamp::GetZeroValue();
}

template< class TPixelType, unsigned int TChannels >
TimeStamp::TimePeriodType
VideoFrameSpatialObject< TPixelType, TChannels >
::GetFrameStartTime() const
{
  if(this->m_VideoImagerTool.IsNotNull())
    {
    return (m_VideoImagerTool->GetInternalFrame())->GetStartTime();
    }
  else
  return igstk::TimeStamp::GetLongestPossibleTime();
}

template< class TPixelType, unsigned int TChannels >
void
VideoFrameSpatialObject< TPixelType, TChannels >
::SetVideoImagerTool(igstk::VideoImagerTool::Pointer VideoImagerTool)
{
  this->m_VideoImagerTool = VideoImagerTool;
}

template< class TPixelType, unsigned int TChannels >
void
VideoFrameSpatialObject< TPixelType, TChannels >
::RequestGetITKImage()
{
  igstkLogMacro( DEBUG,
                 "VideoFrameSpatialObject::RequestGetITKImage() called ....\n");

  this->UpdateImages();

  if( m_NumberOfChannels == 3 )
    {
    ITKRGBImageModifiedEvent  event;
    event.Set( this->m_RGBImage );
    this->InvokeEvent( event );
    }
  else if(m_NumberOfChannels == 1)
    {
    ITKImageModifiedEvent  event;
    event.Set( this->m_Image );
    this->InvokeEvent( event );
    }
  else
    {
    igstkLogMacro( DEBUG, "VideoFrameSpatialObject::UpdateImages called "
            "with wrong channel number. Only 1 (grayscale) and 3 (RGB)"
            "are allowed! \n" );
    }
}

template< class TPixelType, unsigned int TChannels >
void
VideoFrameSpatialObject< TPixelType, TChannels >
::RequestGetVTKImage()  const
{
  igstkLogMacro( DEBUG,
                 "VideoFrameSpatialObject::RequestGetVTKImage() called ....\n");

  Self * self = const_cast< Self * >( this );
  self->UpdateImages();

  VTKImageModifiedEvent  m_VtkImageLoadedEvent;
  m_VtkImageLoadedEvent.Set( m_VTKImage );
  this->InvokeEvent( m_VtkImageLoadedEvent );
}

template< class TPixelType, unsigned int TChannels >
void
VideoFrameSpatialObject< TPixelType, TChannels>
::UpdateImages()
{
  if(this->m_VideoImagerTool.IsNotNull())
    {
    m_RawBuffer=(unsigned char*)
               (m_VideoImagerTool->GetTemporalCalibratedFrame())->GetImagePtr();
    }
  else
    {
    igstkLogMacro( DEBUG, "VideoFrameSpatialObject::UpdateImages():"
                                    << "VideoImagerTool is not set properly\n");
    }

  if( m_NumberOfChannels == 3 )
    {
    int j=0;
    for( unsigned int i=0; i < m_Width * m_Height * 3; i+=3 )
      {
      RGBPixelType temp;
      temp[0]=m_RawBuffer[i];
      temp[1]=m_RawBuffer[i+1];
      temp[2]=m_RawBuffer[i+2];
      m_RGBPixelContainer[j]=temp;
      j++;
      }
    m_RGBImportFilter->SetImportPointer(m_RGBPixelContainer,
                                        m_Width * m_Height,
                                        false );
    m_RGBImportFilter->Update();
    this->m_RGBImage = m_RGBImportFilter->GetOutput();

    m_ItkRGBExporter->SetInput( m_RGBImportFilter->GetOutput() );
    m_VtkRGBImporter->UpdateWholeExtent();
    m_VtkRGBImporter->Update();

    m_VTKImage = m_VtkRGBImporter->GetOutput();

    }
  else if(m_NumberOfChannels == 1)
    {
    m_ImportFilter->SetImportPointer(m_RawBuffer,
                    m_Width * m_Height,
                                      false);
    m_ImportFilter->Update();

    this->m_Image = m_ImportFilter->GetOutput();

    m_ItkExporter->SetInput( m_ImportFilter->GetOutput() );
    m_VtkImporter->UpdateWholeExtent();

    m_VTKImage = m_VtkImporter->GetOutput();
    }
  else
    {
    igstkLogMacro( DEBUG, "VideoFrameSpatialObject::UpdateImages called "
          "with wrong channel number. Only 1 (grayscale) and 3 (RGB)"
          "are allowed! \n" );
    }
}

template< class TPixelType, unsigned int TChannels >
TPixelType*
VideoFrameSpatialObject< TPixelType, TChannels>
::GetImagePtr()
{
  igstkLogMacro( DEBUG, "VideoFrameSpatialObject::GetImagePtr called ....\n");

  return m_RawBuffer;
}

} // end namespace igstk

#endif