CASToR  1.0
Tomographic Reconstruction (PET/SPECT)
iDeformationTemplate.cc
Go to the documentation of this file.
00001 
00002 /*
00003   Implementation of class iDeformationTemplate
00004 
00005   - separators: X
00006   - doxygen: X
00007   - default initialization: none
00008   - CASTOR_DEBUG: none
00009   - CASTOR_VERBOSE: X
00010 */
00011 
00018 #include "iDeformationTemplate.hh"
00019 
00020 
00021 // =====================================================================
00022 // ---------------------------------------------------------------------
00023 // ---------------------------------------------------------------------
00024 // =====================================================================
00025 /*
00026   \fn iDeformationTemplate
00027   \brief Constructor of iDeformationTemplate. Simply set all data members to default values.
00028 */
00029 iDeformationTemplate::iDeformationTemplate() : vDeformation()
00030 {
00031 }
00032 
00033 
00034 
00035 
00036 // =====================================================================
00037 // ---------------------------------------------------------------------
00038 // ---------------------------------------------------------------------
00039 // =====================================================================
00040 /*
00041   \fn ~iDeformationTemplate
00042   \brief Destructor of iDeformationTemplate. Free memory from all allocated tabs.
00043 */
00044 iDeformationTemplate::~iDeformationTemplate() 
00045 {
00046 }
00047 
00048 
00049 
00050 
00051 // =====================================================================
00052 // ---------------------------------------------------------------------
00053 // ---------------------------------------------------------------------
00054 // =====================================================================
00059 void iDeformationTemplate::ShowHelp()
00060 {
00061   // ===================================================================
00062   // Here, display some help and guidance to how to use this deformation and what it does
00063   // ===================================================================
00064   
00065   cout << "This class is a template class dedicated to add your own custom deformation model." << endl;
00066 }
00067 
00068 
00069 
00070 
00071 // =====================================================================
00072 // ---------------------------------------------------------------------
00073 // ---------------------------------------------------------------------
00074 // =====================================================================
00075 /*
00076   \fn ReadAndCheckConfigurationFile
00077   \param a_configurationFile
00078   \brief This function is an implementation of the pure virtual mother function. It is used to read options from a configuration file.
00079   \return 0 if success, other value otherwise.
00080 */
00081 int iDeformationTemplate::ReadAndCheckConfigurationFile(const string& a_fileOptions)
00082 {
00083   if(m_verbose >=2) Cout("iDeformationTemplate::ReadAndCheckConfigurationFile ..."<< endl); 
00084   
00085   // ===================================================================
00086   // Implement here the reading of any options specific to this deformation model 
00087   // (i.e : parameters or path to deformation files), through a configuration file
00088   // The ReadDataASCIIFile() functions could be helpful to recover data from a file
00089   // ===================================================================
00090   
00091   // Normal end
00092   return 0;  
00093 }
00094 
00095 
00096 
00097 
00098 // =====================================================================
00099 // ---------------------------------------------------------------------
00100 // ---------------------------------------------------------------------
00101 // =====================================================================
00102 /*
00103   \fn ReadAndCheckOptionsList
00104   \param a_optionsList
00105   \brief This function is an implementation of the pure virtual mother function. It is used to read options from a list of options.
00106   \return 0 if success, other value otherwise.
00107 */
00108 int iDeformationTemplate::ReadAndCheckOptionsList(const string& a_listOptions)
00109 {
00110   if(m_verbose >=2) Cout("iDeformationTemplate::ReadAndCheckOptionsList ..."<< endl); 
00111   
00112   // ===================================================================
00113   // Implement here the reading of any options specific to this deformation model, through a list of options separated by commas
00114   // The ReadStringOption() function could be helpful to parse the list of parameters in an array
00115   // ===================================================================
00116   
00117   // Normal end
00118   return 0;
00119 }
00120 
00121 
00122 
00123 
00124 // =====================================================================
00125 // ---------------------------------------------------------------------
00126 // ---------------------------------------------------------------------
00127 // =====================================================================
00128 /*
00129   \fn CheckSpecificParameters
00130   \brief This function is an implementation of the pure virtual mother function. It is used to
00131          check parameters of the child deformation model before initialization.
00132   \return 0 if success, other value otherwise.
00133 */
00134 int iDeformationTemplate::CheckSpecificParameters()
00135 {
00136   if(m_verbose >=2) Cout("iDeformationTemplate::CheckSpecificParameters ..."<< endl); 
00137 
00138   // ===================================================================
00139   // Implement here checks over parameters which should be read using either
00140   // ReadAndCheckConfigurationFile() and ReadAndCheckOptionsList() functions
00141   // ===================================================================
00142   
00143   // Normal end
00144   m_checked = true;
00145   return 0;
00146 }
00147 
00148 
00149 
00150 
00151 // =====================================================================
00152 // ---------------------------------------------------------------------
00153 // ---------------------------------------------------------------------
00154 // =====================================================================
00155 /*
00156   \fn Initialize
00157   \brief This function is an implementation of the pure virtual mother function. It is used to
00158          initialize specific stuff to the child deformation model.
00159   \return 0 if success, other value otherwise.
00160 */
00161 int iDeformationTemplate::Initialize()
00162 {
00163   if(m_verbose >=2) Cout("iDeformationTemplate::Initialize ..."<< endl); 
00164 
00165   // ===================================================================
00166   // Implement here the allocation/initialization of whatever member variables specifically used by this deformation model
00167   // ===================================================================
00168   
00169   if (!m_checked)
00170   {
00171     Cerr("***** iDeformationTemplate::Initialize() -> Parameters should be checked before Initialize() !" << endl);
00172     return 1;
00173   }
00174   
00175   // Normal end
00176   m_initialized = true;
00177   return 0;
00178 }
00179 
00180 
00181 
00182 
00183 // =====================================================================
00184 // ---------------------------------------------------------------------
00185 // ---------------------------------------------------------------------
00186 // =====================================================================
00187 /*
00188   \fn ApplyDeformations
00189   \param ap_inputImage : input image to deform
00190   \param ap_outputImage : image in which the output of the deformation should be recovered
00191   \param a_direction : a direction for the deformation to perform (forward or backward)
00192   \param a_defIdx : index of the deformation
00193   \brief This function is an implementation of the pure virtual mother function. The actual deformation should be implemented here 
00194   \return 0 if success, other value otherwise.
00195 */
00196 int iDeformationTemplate::ApplyDeformations(FLTNB* ap_inputImage, FLTNB* ap_outputImage, int a_direction, int a_defIdx)
00197 {
00198   #ifdef CASTOR_VERBOSE
00199   if(m_verbose >=4) Cout("iDeformationTemplate::ApplyDeformations ..."<< endl); 
00200   #endif
00201 
00202   // ===================================================================
00203   // The deformation model should be implemented here, with the help of any private functions if required
00204   
00205   /* The 'a_defIdx' parameter defines the deformation index of the transformation
00206   * The 'a_direction' parameter is an integer which indicates the direction of the deformation to perform, i.e :
00207   * - FORWARD_DEFORMATION (from the reference position to the 'a_defIdx' position) 
00208   * - BACKWARD_DEFORMATION (from the 'a_defIdx' position to the reference position) 
00209   * The integers FORWARD_DEFORMATION & BACKWARD_DEFORMATION are macros defined in the beginning of vDeformation.hh
00210   */
00211   
00212   // The deformation should be applied to the ap_inputImage matrix, and the resulting image should be recovered in ap_outputImage matrix
00213 
00214   /* IMAGE DIMENSIONS :
00215   * For code efficiency and readability, the spatial index of a voxel is a cumulative 1D index. That is to say, given a voxel [indexX,indexY,indexZ],
00216   * its cumulative 1D index is computed by 'index = indexZ*nbVoxXY + indexY*nbVoxX + indexX'.
00217   *
00218   * The image dimensions can be recovered from the mp_ID class
00219   * Total number of voxels         : mp_ID->GetNbVoxXYZ()
00220   * Number of voxels in a slice    : mp_ID->GetNbVoxXY()
00221   * Number of voxels on the X-axis : mp_ID->GetNbVoxX()
00222   */
00223   
00224   // Any error should return a value >0.
00225   // ===================================================================
00226   
00227   // Normal end
00228   return 0;
00229 }
 All Classes Files Functions Variables Typedefs Defines