marRAWFiles Class Reference

#include <marDicomBase.h>

Inheritance diagram for marRAWFiles:
Inheritance graph
[legend]
Collaboration diagram for marRAWFiles:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 marRAWFiles (marParameters *p=NULL)
 ~marRAWFiles ()
virtual bool loadImage (int i)
virtual void loadActualSerie (wxGauge *gauge)
void SetLittreEndianBigEndian (int value)
int GetLittreEndianBigEndian ()
void reset ()
void copyFrom (const marObject &from)
bool save (std::ofstream &os)
bool load (std::ifstream &is)
virtual wxString GetPatientName ()
kVolume * getVolume ()
void SetVolume (kVolume *volume)
bool volumeLoaded ()
void freeVolume ()
std::vector< std::string * > * GetListImages ()
void CleanListImages ()
void ResetLstFileNotReaded ()
std::string GetMsgLstFile ()
void setParameters (marParameters *p)
void copyParameters (marParameters *p)
void makeACopyParameters ()
marParametersgetParameters ()
bool parametersOwned ()
virtual void copyFrom (const marObject &from)=0
bool save (std::string &nw)
bool load (std::string &nr)

Protected Attributes

std::vector< std::string * > _lstString
std::vector< char * > _lstFileNotReaded

Private Attributes

int _littreEndianBigEndian

Detailed Description

Definition at line 53 of file marDicomBase.h.


Constructor & Destructor Documentation

marRAWFiles::marRAWFiles ( marParameters p = NULL  ) 

Definition at line 88 of file marDicomBase.cpp.

References _littreEndianBigEndian.

00089 :  marFilesBase(p)
00090 {
00091         _littreEndianBigEndian=0;
00092 }

marRAWFiles::~marRAWFiles (  ) 

Definition at line 94 of file marDicomBase.cpp.

00095 {
00096 }


Member Function Documentation

void marFilesBase::CleanListImages (  )  [inherited]

Definition at line 45 of file marDicomBase.cpp.

References marFilesBase::_lstString.

Referenced by marRAW2Files::loadActualSerie(), marRAW2AsciiFiles::loadActualSerie(), and loadActualSerie().

00046 {
00047         int i,size;
00048         size=this->_lstString.size();
00049         for(i=0;i<size;i++)
00050         {
00051                 delete _lstString[i];
00052         }
00053         _lstString.clear();
00054 }

Here is the caller graph for this function:

virtual void marObject::copyFrom ( const marObject from  )  [pure virtual, inherited]
void marRAWFiles::copyFrom ( const marObject from  ) 

Definition at line 269 of file marDicomBase.cpp.

00270 {
00271 }

void marObject::copyParameters ( marParameters p  )  [inherited]

Definition at line 42 of file marObject.cpp.

References marObject::_parameters, and marObject::_parametersCopied.

00043 {
00044     if( _parametersCopied && _parameters != NULL ) delete _parameters;
00045     _parameters = new marParameters( );
00046     *_parameters = *p;
00047     _parametersCopied = true;
00048 }

void marFilesBase::freeVolume (  )  [inherited]

Definition at line 31 of file marDicomBase.cpp.

References marFilesBase::_volume.

Referenced by InitExperiment_dll(), marRAW2Files::loadActualSerie(), marRAW2AsciiFiles::loadActualSerie(), loadActualSerie(), and marFilesBase::~marFilesBase().

00031                               {
00032         if( _volume ) delete _volume;
00033         _volume = NULL;
00034 }

Here is the caller graph for this function:

std::vector< std::string * > * marFilesBase::GetListImages (  )  [inherited]

Definition at line 39 of file marDicomBase.cpp.

References marFilesBase::_lstString.

00040 {
00041         return &_lstString;
00042 }

int marRAWFiles::GetLittreEndianBigEndian (  ) 

Definition at line 260 of file marDicomBase.cpp.

References _littreEndianBigEndian.

00261 {
00262         return _littreEndianBigEndian;
00263 }

std::string marFilesBase::GetMsgLstFile (  )  [inherited]

Definition at line 65 of file marDicomBase.cpp.

References marFilesBase::_lstFileNotReaded.

Referenced by LoadRangeImage::ForceToFinisReadActiveImages().

00066 {
00067         int i,sizeLst;
00068 //EEDx44
00069         std::string msgLstFile="";
00070         sizeLst=_lstFileNotReaded.size();
00071         for (i=0;i<sizeLst;i++)
00072         {
00073                 msgLstFile = msgLstFile + *(_lstFileNotReaded[i]) ;
00074                 msgLstFile = msgLstFile + "\n";
00075         }
00076 
00077         return msgLstFile;
00078 }

Here is the caller graph for this function:

marParameters* marObject::getParameters (  )  [inline, inherited]
virtual wxString marFilesBase::GetPatientName (  )  [inline, virtual, inherited]

Definition at line 26 of file marDicomBase.h.

00026 {return _T(""); };

kVolume * marFilesBase::getVolume (  )  [inherited]
bool marObject::load ( std::string &  nr  )  [inherited]

Definition at line 67 of file marObject.cpp.

References marObject::load().

Referenced by marObject::load().

00068 {
00069     std::ifstream is( nr.c_str( ) );
00070 
00071     if( is ) {
00072 
00073         load( is );
00074         is.close( );
00075         return( true );
00076 
00077     } // fi
00078 
00079     return( false );
00080 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool marRAWFiles::load ( std::ifstream &  is  )  [virtual]

Implements marObject.

Definition at line 278 of file marDicomBase.cpp.

00279 {
00280         return true;
00281 }

void marRAWFiles::loadActualSerie ( wxGauge *  gauge  )  [virtual]

Reimplemented from marFilesBase.

Reimplemented in marRAW2Files, and marRAW2AsciiFiles.

Definition at line 181 of file marDicomBase.cpp.

References marFilesBase::_lstString, marFilesBase::CleanListImages(), marParameters::e_RescaleIntercept, marParameters::e_RescaleSlope, marParameters::e_voxel_x_dimension, marParameters::e_voxel_y_dimension, marParameters::e_voxel_z_dimension, marFilesBase::freeVolume(), marObject::getParameters(), marParameters::setDoubleParam(), SetLittreEndianBigEndian(), and marFilesBase::SetVolume().

00182 {
00183 
00184         // Read File List
00185         FILE *ff;
00186         ff = fopen( _lstString[0] -> c_str() , "r"); 
00187         std::string directory(*(_lstString[1]) );
00188         char tmp[255];
00189 
00190         fscanf(ff,"%s",tmp);
00191         fscanf(ff,"%s",tmp);
00192         //int type =    atoi(tmp);  // 0 // JPRx
00193 
00194         fscanf(ff,"%s",tmp);
00195         fscanf(ff,"%s",tmp);
00196         int wx  =       atoi(tmp);
00197         fscanf(ff,"%s",tmp);
00198         fscanf(ff,"%s",tmp);
00199         int wy  =       atoi(tmp);
00200 
00201         fscanf(ff,"%s",tmp);
00202         fscanf(ff,"%s",tmp);
00203         double spx      =       atof(tmp);
00204         fscanf(ff,"%s",tmp);
00205         fscanf(ff,"%s",tmp);
00206         double spy      =       atof(tmp);
00207         fscanf(ff,"%s",tmp);
00208         fscanf(ff,"%s",tmp);
00209         double spz      =       atof(tmp);
00210 
00211         fscanf(ff,"%s",tmp);
00212         fscanf(ff,"%s",tmp);
00213         int LB  =       atoi(tmp);
00214 
00215         this->SetLittreEndianBigEndian(LB);
00216 
00217 
00218         int wz=0;
00219         this->CleanListImages();
00220         while ( !feof(ff) )
00221         {
00222                 fscanf(ff,"%s",tmp);
00223                 std::string *tmpStr =  new std::string(tmp);
00224                 (*tmpStr) = "/"+(*tmpStr);
00225                 (*tmpStr) = (directory)+(*tmpStr);
00226                 _lstString.push_back( tmpStr);
00227                 wz++;
00228         }
00229 
00230         fclose(ff);
00231 
00232 
00233         // Create Free Memory block image
00234         freeVolume();
00235 
00236         if (wz==0)
00237         {
00238                 wz=1;
00239         }
00240 
00241         kVolume *vol =new kVolume( kVolume::USHORT, wx, wy, wz,spx, spy, spz, malloc(sizeof(unsigned short)*wx*wy*wz ) );
00242         SetVolume( vol );
00243 
00244 
00245         // Define Spacing
00246         getParameters( )->setDoubleParam( marParameters::e_voxel_x_dimension, spx );
00247         getParameters( )->setDoubleParam( marParameters::e_voxel_y_dimension, spy );
00248         getParameters( )->setDoubleParam( marParameters::e_voxel_z_dimension, spz );
00249 
00250         // Define Intercept Slope
00251         getParameters( )->setDoubleParam( marParameters::e_RescaleIntercept , 0 );
00252         getParameters( )->setDoubleParam( marParameters::e_RescaleSlope     , 1 );
00253 }

Here is the call graph for this function:

bool marRAWFiles::loadImage ( int  i  )  [virtual]

Reimplemented from marFilesBase.

Reimplemented in marRAW2Files, and marRAW2AsciiFiles.

Definition at line 99 of file marDicomBase.cpp.

References _littreEndianBigEndian, marFilesBase::_lstFileNotReaded, marFilesBase::_lstString, and marFilesBase::getVolume().

00100 {
00101 
00102         int dim[3];
00103 
00104         vtkImageData *vol = getVolume( )->castVtk();
00105         void *p_vol=(void*)getVolume( )->castVtk()->GetScalarPointer(0,0,i);
00106         vol->GetDimensions(dim);
00107 
00108         int dataSize = sizeof(unsigned short)*dim[0]*dim[1];
00109         bool ok=true;
00110 
00111 /*
00112         std::string *ss = _lstString[i];
00113         FILE *ff=fopen( (char*)(ss->c_str())  , "r+" );
00114         fread( (char*)p_vol , dataSize,1, ff);
00115         fclose(ff);
00116 */
00117 
00118         std::string *ss = _lstString[i];
00119         vtkVolume16Reader *reader = vtkVolume16Reader::New ();
00120         reader->SetDataDimensions ( dim[0] , dim[1] );
00121         if (_littreEndianBigEndian == 0) {
00122             reader->SetDataByteOrderToLittleEndian ( );
00123         } else {
00124                 reader->SetDataByteOrderToBigEndian();
00125         }
00126         reader->SetFilePrefix ( (char*)(ss->c_str())  );
00127         reader->SetFilePattern("%s");
00128     reader->SetImageRange ( 0, 0 );
00129     reader->SetDataSpacing ( 1, 1, 1 );
00130     reader->Update ();
00131         void *pp_vol=(void*)reader->GetOutput()->GetScalarPointer(0,0,0);
00132         memcpy(p_vol,pp_vol,dataSize);
00133         reader->Delete();
00134 
00135 
00136 /*
00137 
00138         std::string *ss = _lstString[i];
00139         vtkGsmisReader *reader = vtkGsmisReader::New();
00140         reader->SetFileName( (char*)(ss->c_str())  );
00141         vtkImageData *ima=reader->GetOutput();
00142         ima->Update();
00143         void *pp_vol=(void*)ima->GetScalarPointer(0,0,0);
00144         memcpy(p_vol,pp_vol,dataSize);
00145 //      reader->Delete();
00146 */
00147 
00148 
00149 
00150 /*
00151         int             ii;
00152         char    tmp;
00153         char    *pp = (char*)p_vol;
00154         unsigned short   *valueA;
00155         dataSize        = dim[0]*dim[1];
00156         for (ii=0;ii<dataSize;ii++)
00157         {
00158                 tmp             = *pp;
00159                 *pp             = *(pp+1);
00160                 *(pp+1) = tmp;
00161 
00162                 valueA=(unsigned short*)pp;
00163                 *valueA=*valueA-32000;
00164                 if (*valueA>=32000)
00165                 {
00166                         *valueA=0;
00167                 } 
00168 
00169                 pp              = pp+2;
00170         }
00171 */
00172 
00173         if (ok==false) {
00174                 _lstFileNotReaded.push_back( (char*)(ss->c_str()) );
00175         }
00176 
00177         return ok;
00178 }

Here is the call graph for this function:

void marObject::makeACopyParameters (  )  [inline, inherited]

Definition at line 48 of file marObject.h.

00049     {
00050             copyParameters( _parameters );
00051     }

bool marObject::parametersOwned (  )  [inline, inherited]

Definition at line 56 of file marObject.h.

00056 { return( _parametersCopied ); };

void marRAWFiles::reset (  )  [virtual]

Virtual general methods (must be defined in each sub-class).

Implements marObject.

Definition at line 265 of file marDicomBase.cpp.

00266 {
00267 }

void marFilesBase::ResetLstFileNotReaded (  )  [inherited]

Definition at line 58 of file marDicomBase.cpp.

References marFilesBase::_lstFileNotReaded.

Referenced by LoadRangeImage::Start().

00059 {
00060         _lstFileNotReaded.clear();
00061 }

Here is the caller graph for this function:

bool marObject::save ( std::string &  nw  )  [inherited]

Persistence methods

Definition at line 51 of file marObject.cpp.

References marObject::save().

00052 {
00053     std::ofstream os( nw.c_str( ) );
00054 
00055     if( os ) {
00056 
00057         save( os );
00058         os.close( );
00059         return( true );
00060 
00061     } // fi
00062 
00063     return( false );
00064 }

Here is the call graph for this function:

bool marRAWFiles::save ( std::ofstream &  os  )  [virtual]

Virtual persistence methods (must be defined in each sub-class).

Implements marObject.

Definition at line 273 of file marDicomBase.cpp.

00274 {
00275         return true;
00276 }

void marRAWFiles::SetLittreEndianBigEndian ( int  value  ) 

Definition at line 255 of file marDicomBase.cpp.

References _littreEndianBigEndian.

Referenced by loadActualSerie().

00256 {
00257         _littreEndianBigEndian = value;
00258 }

Here is the caller graph for this function:

void marObject::setParameters ( marParameters p  )  [inherited]

Parameters assignation methods.

You can assign a marParameters object by reference (setParameters) or by value (copyParameters). Besides, if you want to make your actual reference to be by value, call makeACopyParameters.

Definition at line 34 of file marObject.cpp.

References marObject::_parameters, and marObject::_parametersCopied.

00035 {
00036     if( _parametersCopied && _parameters != NULL ) delete _parameters;
00037     _parameters = p;
00038     _parametersCopied = false;
00039 }

void marFilesBase::SetVolume ( kVolume *  volume  )  [inherited]

Definition at line 23 of file marDicomBase.cpp.

References marFilesBase::_volume.

Referenced by marRAW2Files::loadActualSerie(), marRAW2AsciiFiles::loadActualSerie(), loadActualSerie(), marSimpleDicom::loadVolumeDXMM(), and wxMaracasFrame::OnStartExperiment().

00023                                               {
00024         _volume=volume;
00025 }

Here is the caller graph for this function:

bool marFilesBase::volumeLoaded (  )  [inherited]

Definition at line 27 of file marDicomBase.cpp.

References marFilesBase::_volume.

00027                                 {
00028         return( _volume != NULL );
00029 }


Member Data Documentation

std::vector< char*> marFilesBase::_lstFileNotReaded [protected, inherited]
std::vector< std::string*> marFilesBase::_lstString [protected, inherited]

The documentation for this class was generated from the following files:

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1