/usr/include/IGSTK/igstkSpatialObjectReader.txx is in libigstk4-dev 4.4.0-6.
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 | /*=========================================================================
Program: Image Guided Surgery Software Toolkit
Module: $RCSfile: igstkSpatialObjectReader.txx,v $
Language: C++
Date: $Date: 2008-05-05 20:41:09 $
Version: $Revision: 1.9 $
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 __igstkSpatialObjectReader_txx
#define __igstkSpatialObjectReader_txx
#include "igstkSpatialObjectReader.h"
namespace igstk
{
/** Constructor */
template <unsigned int TDimension, typename TPixelType>
SpatialObjectReader< TDimension, TPixelType >
::SpatialObjectReader() : m_StateMachine(this)
{
// Create the ITK SpatialObject file reader
m_SpatialObjectReader = SpatialObjectReaderType::New();
//Set the state descriptors
igstkAddStateMacro( Idle );
igstkAddStateMacro( ObjectFileNameRead );
igstkAddStateMacro( ObjectRead );
igstkAddStateMacro( ObjectAttemptingRead );
// List of Inputs
igstkAddInputMacro( ReadObjectRequest );
igstkAddInputMacro( ObjectReadingError );
igstkAddInputMacro( ObjectReadingSuccess );
igstkAddInputMacro( ObjectFileNameValid );
igstkAddInputMacro( ObjectFileNameIsEmpty );
igstkAddInputMacro( ObjectFileNameIsDirectory );
igstkAddInputMacro( ObjectFileNameDoesNotExist );
igstkAddInputMacro( GetOutput );
// Transitions from Idle State
igstkAddTransitionMacro( Idle, ObjectFileNameValid,
ObjectFileNameRead, SetFileName );
igstkAddTransitionMacro( Idle, ObjectFileNameIsEmpty,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( Idle, ObjectFileNameIsDirectory,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( Idle, ObjectFileNameDoesNotExist,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( Idle, ReadObjectRequest,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( Idle, ObjectReadingError,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( Idle, ObjectReadingSuccess,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( Idle, GetOutput,
Idle, ReportInvalidRequest );
// Transitions from ObjectFileNameRead State
igstkAddTransitionMacro( ObjectFileNameRead, ReadObjectRequest,
ObjectAttemptingRead, AttemptReadObject );
igstkAddTransitionMacro( ObjectFileNameRead, ObjectReadingError,
ObjectFileNameRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectFileNameRead, ObjectReadingSuccess,
ObjectFileNameRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectFileNameRead, ObjectFileNameValid,
ObjectFileNameRead, SetFileName );
igstkAddTransitionMacro( ObjectFileNameRead, ObjectFileNameIsEmpty,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectFileNameRead, ObjectFileNameIsDirectory,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectFileNameRead, ObjectFileNameDoesNotExist,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectFileNameRead, GetOutput,
ObjectFileNameRead, ReportInvalidRequest );
// Transitions from ObjectRead State
igstkAddTransitionMacro( ObjectRead, ObjectFileNameValid,
ObjectFileNameRead, SetFileName );
igstkAddTransitionMacro( ObjectRead, ObjectFileNameIsEmpty,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectRead, ObjectFileNameIsDirectory,
Idle, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectRead, ObjectFileNameDoesNotExist,
Idle, ReportInvalidRequest );
// The following transition assumes that objects do not change after being
// read the first time.
igstkAddTransitionMacro( ObjectRead, ReadObjectRequest,
ObjectRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectRead, ObjectReadingSuccess,
ObjectRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectRead, ObjectReadingError,
ObjectRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectRead, GetOutput,
ObjectRead, ReportObject );
// Transitions from ObjectAttemptingRead State
igstkAddTransitionMacro( ObjectAttemptingRead, ObjectReadingError,
Idle, ReportObjectReadingError );
igstkAddTransitionMacro( ObjectAttemptingRead, ObjectReadingSuccess,
ObjectRead, ReportObjectReadingSuccess );
// if we are waiting, reading an object, we ignore new filenames
// regardless of whether they are valid or invalid (two next transitions).
igstkAddTransitionMacro( ObjectAttemptingRead, ObjectFileNameValid,
ObjectAttemptingRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectAttemptingRead, ObjectFileNameIsEmpty,
ObjectAttemptingRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectAttemptingRead, ObjectFileNameIsDirectory,
ObjectAttemptingRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectAttemptingRead, ObjectFileNameDoesNotExist,
ObjectAttemptingRead, ReportInvalidRequest );
// if we are waiting, reading an object, we ignore a redundant request for
// reading the object. We are already responding to a previous read request.
igstkAddTransitionMacro( ObjectAttemptingRead, ReadObjectRequest,
ObjectAttemptingRead, ReportInvalidRequest );
igstkAddTransitionMacro( ObjectAttemptingRead, GetOutput,
ObjectAttemptingRead, ReportInvalidRequest );
// Select the initial state of the state machine
igstkSetInitialStateMacro( Idle );
// Finish the programming and get ready to run
m_StateMachine.SetReadyToRun();
}
/** Destructor */
template <unsigned int TDimension, typename TPixelType>
SpatialObjectReader<TDimension,TPixelType>::~SpatialObjectReader()
{
}
/* This function reports invalid requests */
template <unsigned int TDimension, typename TPixelType>
void
SpatialObjectReader<TDimension,TPixelType>
::ReportInvalidRequestProcessing()
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
ReportInvalidRequestProcessing called...\n");
this->InvokeEvent( ObjectInvalidRequestErrorEvent() );
}
template <unsigned int TDimension, typename TPixelType>
void
SpatialObjectReader<TDimension,TPixelType>
::ReportObjectReadingErrorProcessing()
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
ReportObjectReadingErrorProcessing: called...\n");
this->InvokeEvent( ObjectReadingErrorEvent() );
}
template <unsigned int TDimension, typename TPixelType>
void
SpatialObjectReader<TDimension,TPixelType>
::ReportObjectReadingSuccessProcessing()
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
ReportObjectReadingSuccessProcessing: called...\n");
this->InvokeEvent( ObjectReadingSuccessEvent() );
}
template <unsigned int TDimension, typename TPixelType>
void SpatialObjectReader<TDimension,TPixelType>
::RequestSetFileName( const FileNameType & filename )
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
RequestSetFileName called...\n");
m_FileNameToBeSet = filename;
if( filename.empty() )
{
this->m_StateMachine.PushInput( this->m_ObjectFileNameIsEmptyInput );
this->m_StateMachine.ProcessInputs();
return;
}
if( !itksys::SystemTools::FileExists( filename.c_str() ) )
{
this->m_StateMachine.PushInput( this->m_ObjectFileNameDoesNotExistInput );
this->m_StateMachine.ProcessInputs();
return;
}
if( itksys::SystemTools::FileIsDirectory( filename.c_str() ))
{
this->m_StateMachine.PushInput( this->m_ObjectFileNameIsDirectoryInput );
this->m_StateMachine.ProcessInputs();
return;
}
this->m_StateMachine.PushInput( this->m_ObjectFileNameValidInput );
this->m_StateMachine.ProcessInputs();
}
template <unsigned int TDimension, typename TPixelType>
void SpatialObjectReader<TDimension,TPixelType>
::SetFileNameProcessing()
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
SetFileNameProcessing called...\n");
m_FileName = m_FileNameToBeSet;
}
/** Read the spatialobject file */
template <unsigned int TDimension, typename TPixelType>
void SpatialObjectReader<TDimension,TPixelType>
::AttemptReadObjectProcessing()
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
AttemptReadObjectProcessing called...\n");
m_SpatialObjectReader->SetFileName( m_FileName.c_str() );
try
{
m_SpatialObjectReader->Update();
}
catch( itk::ExceptionObject & )
{
this->m_StateMachine.PushInput( this->m_ObjectReadingErrorInput );
return;
}
this->m_StateMachine.PushInput( this->m_ObjectReadingSuccessInput );
}
/** Read the spatialobject file */
template <unsigned int TDimension, typename TPixelType>
void SpatialObjectReader<TDimension,TPixelType>
::ReportObjectProcessing()
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
ReportObjectProcessing called...\n");
}
/** Request to read the object file */
template <unsigned int TDimension, typename TPixelType>
void SpatialObjectReader<TDimension,TPixelType>
::RequestReadObject()
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
RequestReadObject called...\n");
this->m_StateMachine.PushInput( this->m_ReadObjectRequestInput);
this->m_StateMachine.ProcessInputs();
}
/** Request to read the object file */
template <unsigned int TDimension, typename TPixelType>
void SpatialObjectReader<TDimension,TPixelType>
::RequestGetOutput()
{
igstkLogMacro( DEBUG, "igstk::SpatialObjectReader::\
RequestGetOutput called...\n");
this->m_StateMachine.PushInput( this->m_GetOutputInput);
this->m_StateMachine.ProcessInputs();
}
/** Print Self function */
template <unsigned int TDimension, typename TPixelType>
void
SpatialObjectReader<TDimension,TPixelType>
::PrintSelf( std::ostream& os, itk::Indent indent ) const
{
Superclass::PrintSelf(os, indent);
}
} // end namespace igstk
#endif
|