marDynData Class Reference

#include <marDynData.h>

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

List of all members.

Public Member Functions

 marDynData (marParameters *p=NULL)
 ~marDynData ()
void loadData (kVolume *vol, int *voi)
float getActualVoxel ()
kVolume * getVolume ()
void reset ()
void copyFrom (const marObject &from)
bool save (std::ofstream &os)
bool load (std::ifstream &is)
marImageDataGetMarImageData ()
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)

Private Attributes

marImageData_marimagedata
kVolume * _volume

Detailed Description

Definition at line 27 of file marDynData.h.


Constructor & Destructor Documentation

marDynData::marDynData ( marParameters p = NULL  ) 

Definition at line 27 of file marDynData.cpp.

References _marimagedata.

00027                                          : marObject( p ), _volume( NULL )
00028 {
00029         _marimagedata = new marImageData(NULL); 
00030 }

marDynData::~marDynData (  ) 

Definition at line 33 of file marDynData.cpp.

References _marimagedata, and reset().

00034 {
00035 //      _marimagedata->SetImageData(NULL);
00036         delete _marimagedata;
00037         reset( );
00038 }

Here is the call graph for this function:


Member Function Documentation

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

Definition at line 140 of file marDynData.cpp.

References _volume, and reset().

00141 {
00142   reset( );
00143   _volume = new kVolume( *( ( ( marDynData& )from )._volume ) );
00144 }

Here is the call graph for this function:

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 }

float marDynData::getActualVoxel (  )  [inline]

Definition at line 39 of file marDynData.h.

References marObject::getParameters(), and marParameters::getVoxelSize().

00039 { return getParameters()->getVoxelSize( ); }

Here is the call graph for this function:

marImageData * marDynData::GetMarImageData (  ) 

Definition at line 198 of file marDynData.cpp.

References _marimagedata.

Referenced by wxSTLWidget_03::ConfigureVTK(), and wxQuantificationWidgetCT::MoveSlider().

00199 {
00200         return _marimagedata;
00201 }

Here is the caller graph for this function:

marParameters* marObject::getParameters (  )  [inline, inherited]
kVolume* marDynData::getVolume (  )  [inline]
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 marDynData::load ( std::ifstream &  is  )  [virtual]

Implements marObject.

Definition at line 172 of file marDynData.cpp.

References _volume, and reset().

Referenced by marExperiment::load().

00173 {
00174     uchar* data;
00175     uint dims[ 3 ];
00176     ulong dSize;
00177     double sizes[ 3 ];
00178     kVolume::Type type;
00179 
00180     reset( );
00181 
00182     is.read( ( char* )dims, 3 * sizeof( uint ) );
00183     is.read( ( char* )sizes, 3 * sizeof( double ) );
00184     is.read( ( char* )&type, sizeof( kVolume::Type ) );
00185     is.read( ( char* )&dSize, sizeof( ulong ) );
00186     data = new uchar[ dSize ];
00187     is.read( ( char* )data, dSize );
00188         
00189     _volume = new kVolume( type, dims, sizes, ( void* )data );
00190         
00191     //cleaning
00192     delete[] data;
00193 
00194     return( true );
00195 }

Here is the call graph for this function:

Here is the caller graph for this function:

void marDynData::loadData ( kVolume *  vol,
int *  voi 
)

Before we were using kgfoCrop which assume extent start at 0,0,0

Definition at line 41 of file marDynData.cpp.

References _marimagedata, _volume, marImageData::AddImageData(), marObject::getParameters(), marParameters::getRescaleIntercept(), marParameters::getRescaleSlope(), marParameters::getVoxelSize(), reset(), marImageData::SetSpcOriginal(), and marImageData::SetVoiOriginal().

Referenced by marExperiment::initExperiment().

00042  {
00043    int ext[6];
00044    reset( );
00045  
00046    vtkExtractVOI *crop = vtkExtractVOI::New();
00047    crop->SetInput( vol->castVtk( ) );
00048 
00049    crop->SetVOI( voi );
00050    //crop->SetSampleRate( getParameters( )->getVoxelSize( ), getParameters( )->getVoxelSize( ), getParameters( )->getVoxelSize( ));
00051    
00052    float RescalaSlope           =  getParameters()->getRescaleSlope();
00053    float RescalaIntercept       =  getParameters()->getRescaleIntercept();
00054 
00055 //EED
00056 //      RescalaSlope            = 1;
00057 //      RescalaIntercept        = 0;
00058 
00059    vtkImageShiftScale *scale = vtkImageShiftScale::New();
00060    scale->SetInput( crop->GetOutput( ) );
00061    scale->SetScale(RescalaSlope);
00062    scale->SetShift(0);
00063    scale->SetOutputScalarTypeToShort();
00064    scale->Update();
00065    vtkImageShiftScale *shift = vtkImageShiftScale::New();
00066    shift->SetInput( scale->GetOutput( ) );
00067    shift->SetScale(1); 
00068    shift->SetShift(RescalaIntercept);
00069    shift->SetOutputScalarTypeToShort();
00070    shift->Update();
00071 
00072 
00073    vtkImageThreshold *threshold = vtkImageThreshold::New();
00074    threshold->SetInput( shift->GetOutput( ) );
00075    threshold->ThresholdByUpper (-10000); 
00076    threshold->ThresholdByLower (-1); 
00077    threshold->SetInValue(0);   
00078    threshold->ReplaceOutOff ();
00079    threshold->ReplaceInOn ();
00080    threshold->SetOutputScalarTypeToUnsignedShort();
00081    
00082    vtkImageResample* ir = vtkImageResample::New( );
00083    ir->SetInput( threshold->GetOutput( ) );
00084    ir->SetDimensionality( 3 );
00085    double voxelSize= getParameters( )->getVoxelSize( );
00086    ir->SetAxisOutputSpacing( 0, voxelSize );
00087    ir->SetAxisOutputSpacing( 1, voxelSize );
00088    ir->SetAxisOutputSpacing( 2, voxelSize );
00089 
00090 
00091 //      ir->SetAxisMagnificationFactor(0,1/getParameters( )->getVoxelSize( )); 
00092 
00093 //EEDx1
00094    ir->InterpolateOn( );
00095 //   ir->InterpolateOff( );
00096 
00097 
00098    ir->Update( );    //important
00099    ir->GetOutput()->GetExtent( ext );
00100  
00104    vtkImageChangeInformation* change = vtkImageChangeInformation::New();
00105    change->SetInput( ir->GetOutput() );
00106    change->SetExtentTranslation( -ext[0], -ext[2], -ext[4] );
00107    change->SetOutputSpacing ( voxelSize , voxelSize , voxelSize );
00108    change->Update();    //important
00109  
00110    _volume = new kVolume( change->GetOutput( ) );
00111 
00112         _marimagedata->AddImageData( _volume->castVtk() );
00113         double spc[3];
00114         vol->castVtk()->GetSpacing(spc);
00115         _marimagedata->SetSpcOriginal( spc );
00116         _marimagedata->SetVoiOriginal(voi);
00117 
00118 
00119    crop         -> Delete();
00120    ir           -> Delete();
00121    change       -> Delete();
00122    shift        -> Delete();
00123    scale        -> Delete();
00124    threshold-> Delete();
00125  }

Here is the call graph for this function:

Here is the caller 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 marDynData::reset (  )  [virtual]

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

Implements marObject.

Definition at line 129 of file marDynData.cpp.

References _volume.

Referenced by copyFrom(), load(), loadData(), and ~marDynData().

00130 {
00131   //Efface car _volume est juste un pointeur ver _volume de marGdcmDicom qui
00132   //est detruit par le reset correspondant
00133 // PS ->   #ifndef DXMM
00134 // PS ->   if( _volume ) delete _volume;
00135 // PS ->   #endif
00136   _volume = NULL;
00137 }

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 marDynData::save ( std::ofstream &  os  )  [virtual]

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

Implements marObject.

Definition at line 147 of file marDynData.cpp.

References _volume.

Referenced by marExperiment::save().

00148 {
00149     void* data = _volume->getData1D( );
00150     uint dims[ 3 ];
00151     ulong dSize = _volume->getRawSizeInBytes( );
00152     double sizes[ 3 ];
00153     kVolume::Type type = _volume->getType( );
00154 
00155     dims[ 0 ] = _volume->getXdim( );
00156     dims[ 1 ] = _volume->getYdim( );
00157     dims[ 2 ] = _volume->getZdim( );
00158     sizes[ 0 ] = _volume->getXsize( );
00159     sizes[ 1 ] = _volume->getYsize( );
00160     sizes[ 2 ] = _volume->getZsize( );
00161 
00162     os.write( ( const char* )dims, 3 * sizeof( uint ) );
00163     os.write( ( const char* )sizes, 3 * sizeof( double ) );
00164     os.write( ( const char* )&type, sizeof( kVolume::Type ) );
00165     os.write( ( const char* )&dSize, sizeof( ulong ) );
00166     os.write( ( const char* )data, dSize );
00167 
00168     return( true );
00169 }

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 }


Member Data Documentation

Definition at line 55 of file marDynData.h.

Referenced by GetMarImageData(), loadData(), marDynData(), and ~marDynData().

kVolume* marDynData::_volume [private]

Definition at line 56 of file marDynData.h.

Referenced by copyFrom(), load(), loadData(), reset(), and save().


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

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1