]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/kernel/volume.cxx
Avoid troubles while fighting against Initialization List.
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / volume.cxx
index 13257d29f6c86f3fd67b344d3ce3fbd01d818c31..8155ec3bc402e81826580337a012bb99d4cc4438 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: volume.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/11/14 15:57:12 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/03/15 14:12:30 $
+  Version:   $Revision: 1.6 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -39,14 +39,14 @@ const vtkIdType kVolume::VTKTypes[] = { VTK_CHAR, VTK_FLOAT, VTK_DOUBLE,
 
 #endif // KGFO_USE_VTK
 
-#ifdef KGFO_USE_IDO
+//#ifdef KGFO_USE_IDO
 
 // -------------------------------------------------------------------------
-const int kVolume::IDOTypes[] = { VOL_CHAR, VOL_FLOAT, VOL_DOUBLE, VOL_LONG,
-                                 VOL_SHORT, VOL_UCHAR, VOL_ULONG,
-                                 VOL_USHORT };
+//const int kVolume::IDOTypes[] = { VOL_CHAR, VOL_FLOAT, VOL_DOUBLE, VOL_LONG,
+//                               VOL_SHORT, VOL_UCHAR, VOL_ULONG,
+//                               VOL_USHORT };
 
-#endif // KGFO_USE_IDO
+//#endif // KGFO_USE_IDO
 
 // -------------------------------------------------------------------------
 const void* kVolume::BLANK   = ( void* ) 0;
@@ -99,15 +99,15 @@ template< class TYPE >
 
 // -------------------------------------------------------------------------
 kVolume::kVolume( )
-    : _type( UCHAR ), _creator( SELF ),
-#ifdef KGFO_USE_VTK
-      _vtk( NULL ),
-#endif // KGFO_USE_VTK
-#ifdef KGFO_USE_IDO
-      _privateIdo( NULL ),
-#endif // KGFO_USE_IDO
-      _raw( NULL ), _columns( NULL ),
+    : _type( UCHAR ), 
+      _creator( SELF ),
+      _raw( NULL ), 
+      _columns( NULL ),
       _images( NULL )
+#ifdef KGFO_USE_VTK
+                  ,
+      _vtk( NULL )      
+#endif // KGFO_USE_VTK      
 {
     _dims[ CX ] = 1; _dims[ CY ] = 1; _dims[ CZ ] = 1;
     _sizes[ CX ] = 1; _sizes[ CY ] = 1; _sizes[ CZ ] = 1;
@@ -120,15 +120,15 @@ kVolume::kVolume( Type type,
                  uint xdim, uint ydim, uint zdim,
                  double xsize, double ysize, double zsize,
                  void* data )
-    : _type( type ), _creator( SELF ),
-#ifdef KGFO_USE_VTK
-      _vtk( NULL ),
-#endif // KGFO_USE_VTK
-#ifdef KGFO_USE_IDO
-      _privateIdo( NULL ),
-#endif // KGFO_USE_IDO
-      _raw( NULL ), _columns( NULL ),
+    : _type( type ), 
+      _creator( SELF ),
+      _raw( NULL ), 
+      _columns( NULL ),
       _images( NULL )
+#ifdef KGFO_USE_VTK
+                    ,
+      _vtk( NULL )
+#endif // KGFO_USE_VTK      
 {
     _dims[ CX ] = xdim; _dims[ CY ] = ydim; _dims[ CZ ] = zdim;
     _sizes[ CX ] = xsize; _sizes[ CY ] = ysize; _sizes[ CZ ] = zsize;
@@ -148,15 +148,15 @@ kVolume::kVolume( Type type,
                  const uint *dims,
                  const double *sizes,
                  void* data )
-    : _type( type ), _creator( SELF ),
-#ifdef KGFO_USE_VTK
-      _vtk( NULL ),
-#endif // KGFO_USE_VTK
-#ifdef KGFO_USE_IDO
-      _privateIdo( NULL ),
-#endif // KGFO_USE_IDO
+    : _type( type ), 
+      _creator( SELF ),
       _raw( NULL ), _columns( NULL ),
       _images( NULL )
+#ifdef KGFO_USE_VTK
+                   ,
+      _vtk( NULL )
+#endif // KGFO_USE_VTK      
+      
 {
     memcpy( _dims, dims, 3 * sizeof( uint ) );
     memcpy( _sizes, sizes, 3 * sizeof( double ) );
@@ -173,15 +173,16 @@ kVolume::kVolume( Type type,
 
 // -------------------------------------------------------------------------
 kVolume::kVolume( const kVolume& org )
-    : _type( UCHAR ), _creator( SELF ),
-#ifdef KGFO_USE_VTK
-      _vtk( NULL ),
-#endif // KGFO_USE_VTK
-#ifdef KGFO_USE_IDO
-      _privateIdo( NULL ),
-#endif // KGFO_USE_IDO
-      _raw( NULL ), _columns( NULL ),
+    : _type( UCHAR ), 
+      _creator( SELF ),
+      _raw( NULL ), 
+      _columns( NULL ),
       _images( NULL )
+#ifdef KGFO_USE_VTK
+                   ,
+      _vtk( NULL )
+#endif // KGFO_USE_VTK      
+  
 {
     copyFrom( org );
 }
@@ -284,6 +285,7 @@ void kVolume::convertCast( Type type )
            case FLOAT:  convertCastT( ( char* )_raw, ( float* )buffer, size ); break;
            case DOUBLE: convertCastT( ( char* )_raw, ( double* )buffer, size ); break;
            case UCHAR:  convertCastT( ( char* )_raw, ( uchar* )buffer, size ); break;
+           default : break;
 
            } // fswitch
            break;
@@ -298,7 +300,7 @@ void kVolume::convertCast( Type type )
            case FLOAT:  convertCastT( ( short* )_raw, ( float* )buffer, size ); break;
            case DOUBLE: convertCastT( ( short* )_raw, ( double* )buffer, size ); break;
            case UCHAR:  convertCastT( ( short* )_raw, ( uchar* )buffer, size ); break;
-
+           default : break;
            } // fswitch
            break;
 
@@ -312,7 +314,7 @@ void kVolume::convertCast( Type type )
            case FLOAT:  convertCastT( ( int* )_raw, ( float* )buffer, size ); break;
            case DOUBLE: convertCastT( ( int* )_raw, ( double* )buffer, size ); break;
            case UCHAR:  convertCastT( ( int* )_raw, ( uchar* )buffer, size ); break;
-
+           default : break;
            } // fswitch
            break;
 
@@ -326,7 +328,7 @@ void kVolume::convertCast( Type type )
            case FLOAT:  convertCastT( ( ushort* )_raw, ( float* )buffer, size ); break;
            case DOUBLE: convertCastT( ( ushort* )_raw, ( double* )buffer, size ); break;
            case UCHAR:  convertCastT( ( ushort* )_raw, ( uchar* )buffer, size ); break;
-
+           default : break;
            } // fswitch
            break;
 
@@ -340,7 +342,7 @@ void kVolume::convertCast( Type type )
            case FLOAT:  convertCastT( ( uint* )_raw, ( float* )buffer, size ); break;
            case DOUBLE: convertCastT( ( uint* )_raw, ( double* )buffer, size ); break;
            case UCHAR:  convertCastT( ( uint* )_raw, ( uchar* )buffer, size ); break;
-
+           default : break;
            } // fswitch
            break;
 
@@ -354,7 +356,7 @@ void kVolume::convertCast( Type type )
            case UINT:   convertCastT( ( float* )_raw, ( uint* )buffer, size ); break;
            case DOUBLE: convertCastT( ( float* )_raw, ( double* )buffer, size ); break;
            case UCHAR:  convertCastT( ( float* )_raw, ( uchar* )buffer, size ); break;
-
+           default : break;
            } // fswitch
            break;
 
@@ -368,7 +370,7 @@ void kVolume::convertCast( Type type )
            case UINT:   convertCastT( ( double* )_raw, ( uint* )buffer, size ); break;
            case FLOAT:  convertCastT( ( double* )_raw, ( float* )buffer, size ); break;
            case UCHAR:  convertCastT( ( double* )_raw, ( uchar* )buffer, size ); break;
-
+           default : break;
            } // fswitch
            break;
 
@@ -382,7 +384,7 @@ void kVolume::convertCast( Type type )
            case UINT:   convertCastT( ( uchar* )_raw, ( uint* )buffer, size ); break;
            case FLOAT:  convertCastT( ( uchar* )_raw, ( float* )buffer, size ); break;
            case DOUBLE: convertCastT( ( uchar* )_raw, ( double* )buffer, size ); break;
-
+           default : break;
            } // fswitch
            break;
      
@@ -684,33 +686,9 @@ void kVolume::buildIndex( )
 
     size = ( _dims[ CZ ] * sizeof( uchar** ) ) +
        ( _dims[ CZ ] * _dims[ CY ] * sizeof( void* ) );
-
-#ifdef KGFO_USE_IDO
-
-    if( _creator == SELF || _creator == VTK ) {
-               
-       size += sizeof( PRIVATE_VOLUME );
-               
-       _privateIdo = ( PRIVATE_VOLUME* ) new uchar[ size ];
-       _privateIdo->UsedNbZ = 0;  // Warning, I don't really know
-       _privateIdo->UsedNbY = 0;  // the reason to use these three
-       _privateIdo->UsedNbX = 0;  // fields. - lflorez
-       _privateIdo->subObject = 1;
-       _privateIdo->DimX = _dims[ CX ];
-       _privateIdo->DimY = _dims[ CY ];
-       _privateIdo->DimZ = _dims[ CZ ];
-       _privateIdo->_message = 0;
-       _privateIdo->_fichier = 0;
-       _privateIdo->Type = IDOTypes[ _type ];
-               
-       _images = ( void*** ) &( _privateIdo[ 1 ] );
-               
-#else
                
        _images = ( void*** )new uchar[ size ];
                
-#endif // KGFO_USE_IDO
-               
        _columns = ( void** )( _images + _dims[ CZ ] );
        void** plane = _columns;
        for( uint z = 0; z < _dims[ CZ ]; z++ ) {
@@ -727,13 +705,6 @@ void kVolume::buildIndex( )
                              _dims[ CX ] * SIZETypes[ _type ] );
                        
        } // rof
-               
-#ifdef KGFO_USE_IDO
-               
-    } else
-       _images = ( void*** )( &_privateIdo[ 1 ] );
-       
-#endif // KGFO_USE_IDO
        
 #ifdef KGFO_USE_VTK
        
@@ -839,49 +810,32 @@ void kVolume::buildIndex( )
 void kVolume::deallocate( )
 {
 #ifdef KGFO_USE_VTK
-
     if( _vtk ) _vtk->Delete();
     _vtk = NULL;
-
 #endif // KGFO_USE_VTK
-
-#ifdef KGFO_USE_IDO
-
-    if( _creator == SELF || _creator == VTK ) {
-
-       delete[] _privateIdo;
-       _privateIdo = NULL;
-       
-    } // fi
-
-#else
-
     delete[] ( uchar* )_images;
-
-#endif // KGFO_USE_IDO
-
     if( _raw && _creator == SELF )
 
 //EED purify 12/sept/2006
 //     delete[] ( uchar* )_raw;
 
-       free ( _raw );
+    free ( _raw );
 
-    _creator   = SELF;
-    _raw               = NULL;
-    _columns   = NULL;
-    _images            = NULL;
+    _creator = SELF;
+    _raw     = NULL;
+    _columns = NULL;
+    _images  = NULL;
 }
 
 #ifdef KGFO_USE_VTK
 
 // -------------------------------------------------------------------------
 kVolume::kVolume( vtkImageData* org )
-    : _raw( 0 ), _columns( 0 ), _images( 0 ),
+    :
       _creator( VTK ),
-#ifdef KGFO_USE_IDO
-      _privateIdo( NULL ),
-#endif // KGFO_USE_IDO
+      _raw( 0 ), 
+      _columns( 0 ), 
+      _images( 0 ),
       _vtk( 0 )
 {
     //int i, j, k, y;
@@ -937,17 +891,17 @@ void kVolume::copyFrom( vtkImageData* org )
 
     deallocate( );
        
-#ifdef KGFO_USE_IDO
+//#ifdef KGFO_USE_IDO
 
-    _privateIdo = NULL;
+//    _privateIdo = NULL;
 
-#endif // KGFO_USE_IDO
+//#endif // KGFO_USE_IDO
 
-    _vtk               = NULL;
-    _raw               = NULL;
-    _columns   = NULL;
-    _images            = NULL;
-    _creator   = SELF;
+    _vtk     = NULL;
+    _raw     = NULL;
+    _columns = NULL;
+    _images  = NULL;
+    _creator = SELF;
 
     switch( org->GetScalarType( ) ) {
 
@@ -978,110 +932,16 @@ void kVolume::copyFrom( vtkImageData* org )
     // This avoids vtk extent crap conversion...
     org->GetExtent( ext );
     for( i = ext[ 0 ]; i <= ext[ 1 ]; i++ ) {
-
        for( j = ext[ 2 ]; j <= ext[ 3 ]; j++ ) {
-
-           for( k = ext[ 4 ]; k <= ext[ 5 ]; k++ ) {
-               
+           for( k = ext[ 4 ]; k <= ext[ 5 ]; k++ ) {           
                v = org->GetScalarComponentAsDouble( i, j, k, 0 );
-               setPixel( v, i - ext[ 0 ], j - ext[ 2 ], k - ext[ 4 ] );
-               
+               setPixel( v, i - ext[ 0 ], j - ext[ 2 ], k - ext[ 4 ] );                
            } // rof
-
        } // rof
-
     } // rof
 }
 
 #endif // KGFO_USE_VTK
 
-#ifdef KGFO_USE_IDO
-
-// -------------------------------------------------------------------------
-kVolume::kVolume( PPPVOLUME org )
-    : _raw( 0 ), _columns( 0 ), _images( 0 ),
-      _creator( IDO ),
-#ifdef KGFO_USE_VTK
-      _vtk( 0 ),
-#endif // KGFO_USE_VTK
-      _privateIdo( 0 )
-{
-    switch( IdVolType( org ) ) {
-
-    case VOL_UCHAR:  _type = UCHAR;  break;
-    case VOL_CHAR:   _type = CHAR;   break;
-    case VOL_FLOAT:  _type = FLOAT;  break;
-    case VOL_DOUBLE: _type = DOUBLE; break;
-    case VOL_SHORT:  _type = SHORT;  break;
-    case VOL_USHORT: _type = USHORT; break;
-    case VOL_LONG:   _type = INT;    break;
-    case VOL_ULONG:  _type = UINT;   break;
-    default: break;
-
-    } // fswitch
-
-    _dims[ CX ] = IdVolDimX( org );
-    _dims[ CY ] = IdVolDimY( org );
-    _dims[ CZ ] = IdVolDimZ( org );
-    _sizes[ CX ] = 1;
-    _sizes[ CY ] = 1;
-    _sizes[ CZ ] = 1;
-
-    _privateIdo = _IdVolPrivate( org );
-    _raw = ( ( void*** ) &( _privateIdo[ 1 ] ) )[ 0 ][ 0 ];
-    buildIndex( );
-}
-
-// -------------------------------------------------------------------------
-kVolume& kVolume::operator=( PPPVOLUME org )
-{
-    copyFrom( org );
-    return( *this );
-}
-
-// -------------------------------------------------------------------------
-void kVolume::copyFrom( PPPVOLUME org )
-{
-    void* buffer;
-
-    deallocate( );
-
-    _raw               = NULL;
-    _columns   = NULL;
-    _images            = NULL;
-    _creator   = SELF;
-#ifdef KGFO_USE_VTK
-    _vtk = NULL;
-#endif // KGFO_USE_VTK
-    _privateIdo = NULL;
-
-    switch( IdVolType( org ) ) {
-
-    case VOL_UCHAR:  _type = UCHAR;  break;
-    case VOL_CHAR:   _type = CHAR;   break;
-    case VOL_FLOAT:  _type = FLOAT;  break;
-    case VOL_DOUBLE: _type = DOUBLE; break;
-    case VOL_SHORT:  _type = SHORT;  break;
-    case VOL_USHORT: _type = USHORT; break;
-    case VOL_LONG:   _type = INT;    break;
-    case VOL_ULONG:  _type = UINT;   break;
-    default: break;
-
-    } // fswitch
-
-    _dims[ CX ] = IdVolDimX( org );
-    _dims[ CY ] = IdVolDimY( org );
-    _dims[ CZ ] = IdVolDimZ( org );
-    _sizes[ CX ] = 1;
-    _sizes[ CY ] = 1;
-    _sizes[ CZ ] = 1;
-
-    allocate( );
-    buildIndex( );
-    buffer = ( ( void*** ) &( org[ 1 ] ) )[ 0 ][ 0 ];
-    memcpy( _raw, buffer, getRawSizeInBytes( ) );
-}
-
-#endif // KGFO_USE_IDO
 
 // eof - volume.cxx