X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Fkernel%2Fvolume.cxx;h=9bdafc34c38ec2b639d2de885b3466a2c0a93f28;hb=f9901e756bb82bd333310b47607875331616bb29;hp=13257d29f6c86f3fd67b344d3ce3fbd01d818c31;hpb=e59fe4a0a69ae0180c502e68c57faff544b935ca;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/kernel/volume.cxx b/lib/maracasVisuLib/src/kernel/volume.cxx index 13257d2..9bdafc3 100644 --- a/lib/maracasVisuLib/src/kernel/volume.cxx +++ b/lib/maracasVisuLib/src/kernel/volume.cxx @@ -1,10 +1,35 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + /*========================================================================= Program: wxMaracas Module: $RCSfile: volume.cxx,v $ Language: C++ - Date: $Date: 2008/11/14 15:57:12 $ - Version: $Revision: 1.2 $ + Date: $Date: 2012/11/15 14:16:13 $ + Version: $Revision: 1.10 $ Copyright: (c) 2002, 2003 License: @@ -39,22 +64,13 @@ const vtkIdType kVolume::VTKTypes[] = { VTK_CHAR, VTK_FLOAT, VTK_DOUBLE, #endif // KGFO_USE_VTK -#ifdef KGFO_USE_IDO - -// ------------------------------------------------------------------------- -const int kVolume::IDOTypes[] = { VOL_CHAR, VOL_FLOAT, VOL_DOUBLE, VOL_LONG, - VOL_SHORT, VOL_UCHAR, VOL_ULONG, - VOL_USHORT }; - -#endif // KGFO_USE_IDO - // ------------------------------------------------------------------------- const void* kVolume::BLANK = ( void* ) 0; const void* kVolume::NOALLOC = ( void* )-1; const int kVolume::SIZETypes[] = { sizeof( char ), sizeof( float ), sizeof( double ), sizeof( int ), - sizeof( short ), sizeof( uchar ), - sizeof( uint ), sizeof( ushort ) }; + sizeof( short ), sizeof( uint8_t ), + sizeof( uint32_t ), sizeof( uint16_t ) }; // --------------------------------------------------------------------------- template< class FROM, class TO > @@ -99,15 +115,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; @@ -117,18 +133,18 @@ kVolume::kVolume( ) // ------------------------------------------------------------------------- kVolume::kVolume( Type type, - uint xdim, uint ydim, uint zdim, + uint32_t xdim, uint32_t ydim, uint32_t 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; @@ -145,20 +161,20 @@ kVolume::kVolume( Type type, // ------------------------------------------------------------------------- kVolume::kVolume( Type type, - const uint *dims, + const uint32_t *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( _dims, dims, 3 * sizeof( uint32_t ) ); memcpy( _sizes, sizes, 3 * sizeof( double ) ); if( data != NOALLOC ) { @@ -173,15 +189,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 ); } @@ -202,7 +219,7 @@ void kVolume::copyFrom( const kVolume& org ) _columns = 0; _images = 0; - memcpy( _dims, org._dims, 3 * sizeof( uint ) ); + memcpy( _dims, org._dims, 3 * sizeof( uint32_t ) ); memcpy( _sizes, org._sizes, 3 * sizeof( double ) ); if( org._raw ) { @@ -222,20 +239,20 @@ bool kVolume::sameDimension( const kVolume& comp ) } // ------------------------------------------------------------------------- -double kVolume::getPixel( uint x, uint y, uint z ) const +double kVolume::getPixel( uint32_t x, uint32_t y, uint32_t z ) const { double p; switch( _type ) { - case CHAR: p = ( double )( ( char*** )_images )[ z ][ y ][ x ]; break; - case FLOAT: p = ( double )( ( float*** )_images )[ z ][ y ][ x ]; break; - case DOUBLE: p = ( double )( ( double*** )_images )[ z ][ y ][ x ]; break; - case INT: p = ( double )( ( int*** )_images )[ z ][ y ][ x ]; break; - case SHORT: p = ( double )( ( short*** )_images )[ z ][ y ][ x ]; break; - case UCHAR: p = ( double )( ( uchar*** )_images )[ z ][ y ][ x ]; break; - case UINT: p = ( double )( ( uint*** )_images )[ z ][ y ][ x ]; break; - case USHORT: p = ( double )( ( ushort*** )_images )[ z ][ y ][ x ]; break; + case CHAR: p = ( double )( ( int8_t*** )_images )[ z ][ y ][ x ]; break; + case FLOAT: p = ( double )( ( float*** )_images )[ z ][ y ][ x ]; break; + case DOUBLE: p = ( double )( ( double*** )_images )[ z ][ y ][ x ]; break; + case INT: p = ( double )( ( int32_t*** )_images )[ z ][ y ][ x ]; break; + case SHORT: p = ( double )( ( int16_t*** )_images )[ z ][ y ][ x ]; break; + case UCHAR: p = ( double )( ( uint8_t*** )_images )[ z ][ y ][ x ]; break; + case UINT: p = ( double )( ( uint32_t*** )_images )[ z ][ y ][ x ]; break; + case USHORT: p = ( double )( ( uint16_t*** )_images )[ z ][ y ][ x ]; break; default: p = 0.0; break; } // fswitch @@ -244,19 +261,19 @@ double kVolume::getPixel( uint x, uint y, uint z ) const } // ------------------------------------------------------------------------- -void kVolume::setPixel( double v, uint x, uint y, uint z ) +void kVolume::setPixel( double v, uint32_t x, uint32_t y, uint32_t z ) { switch( _type ) { - case CHAR: ( ( char*** )_images )[ z ][ y ][ x ] = ( char )v; break; - case FLOAT: ( ( float*** )_images )[ z ][ y ][ x ] = ( float )v; break; - case DOUBLE: ( ( double*** )_images )[ z ][ y ][ x ] = ( double )v; break; - case INT: ( ( int*** )_images )[ z ][ y ][ x ] = ( int )v; break; - case SHORT: ( ( short*** )_images )[ z ][ y ][ x ] = ( short )v; break; - case UCHAR: ( ( uchar*** )_images )[ z ][ y ][ x ] = ( uchar )v; break; - case UINT: ( ( uint*** )_images )[ z ][ y ][ x ] = ( uint )v; break; - case USHORT: ( ( ushort*** )_images )[ z ][ y ][ x ] = ( ushort )v; break; + case CHAR: ( ( int8_t*** )_images )[ z ][ y ][ x ] = ( int8_t )v; break; + case FLOAT: ( ( float*** )_images )[ z ][ y ][ x ] = ( float )v; break; + case DOUBLE: ( ( double*** )_images )[ z ][ y ][ x ] = ( double )v; break; + case INT: ( ( int32_t*** )_images )[ z ][ y ][ x ] = ( int32_t )v; break; + case SHORT: ( ( int16_t*** )_images )[ z ][ y ][ x ] = ( int16_t )v; break; + case UCHAR: ( ( uint8_t*** )_images )[ z ][ y ][ x ] = ( uint8_t )v; break; + case UINT: ( ( uint32_t*** )_images )[ z ][ y ][ x ] = ( uint32_t )v; break; + case USHORT: ( ( uint16_t*** )_images )[ z ][ y ][ x ] = ( uint16_t )v; break; default: break; } // fswitch @@ -270,20 +287,21 @@ void kVolume::convertCast( Type type ) void* buffer; ulong size = getRawSize( ); - buffer = ( void* )new uchar[ size * SIZETypes[ type ] ]; + buffer = ( void* )new uint8_t[ size * SIZETypes[ type ] ]; switch( _type ) { case CHAR: switch( type ) { - case SHORT: convertCastT( ( char* )_raw, ( short* )buffer, size ); break; - case INT: convertCastT( ( char* )_raw, ( int* )buffer, size ); break; - case USHORT: convertCastT( ( char* )_raw, ( ushort* )buffer, size ); break; - case UINT: convertCastT( ( char* )_raw, ( uint* )buffer, size ); break; - 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; + case SHORT: convertCastT( ( char* )_raw, ( int16_t* )buffer, size ); break; + case INT: convertCastT( ( char* )_raw, ( int32_t* )buffer, size ); break; + case USHORT: convertCastT( ( char* )_raw, ( uint16_t* )buffer, size ); break; + case UINT: convertCastT( ( char* )_raw, ( uint32_t* )buffer, size ); break; + case FLOAT: convertCastT( ( char* )_raw, ( float* )buffer, size ); break; + case DOUBLE: convertCastT( ( char* )_raw, ( double* )buffer, size ); break; + case UCHAR: convertCastT( ( char* )_raw, ( uint8_t* )buffer, size ); break; + default : break; } // fswitch break; @@ -291,98 +309,98 @@ void kVolume::convertCast( Type type ) case SHORT: switch( type ) { - case CHAR: convertCastT( ( short* )_raw, ( char* )buffer, size ); break; - case INT: convertCastT( ( short* )_raw, ( int* )buffer, size ); break; - case USHORT: convertCastT( ( short* )_raw, ( ushort* )buffer, size ); break; - case UINT: convertCastT( ( short* )_raw, ( uint* )buffer, size ); break; - 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; - + case CHAR: convertCastT( ( int16_t* )_raw, ( uint8_t* )buffer, size ); break; + case INT: convertCastT( ( int16_t* )_raw, ( int32_t* )buffer, size ); break; + case USHORT: convertCastT( ( int16_t* )_raw, ( uint16_t* )buffer, size ); break; + case UINT: convertCastT( ( int16_t* )_raw, ( uint32_t* )buffer, size ); break; + case FLOAT: convertCastT( ( int16_t* )_raw, ( float* )buffer, size ); break; + case DOUBLE: convertCastT( ( int16_t* )_raw, ( double* )buffer, size ); break; + case UCHAR: convertCastT( ( int16_t* )_raw, ( uint8_t* )buffer, size ); break; + default : break; } // fswitch break; case INT: switch( type ) { - case CHAR: convertCastT( ( int* )_raw, ( char* )buffer, size ); break; - case SHORT: convertCastT( ( int* )_raw, ( short* )buffer, size ); break; - case USHORT: convertCastT( ( int* )_raw, ( ushort* )buffer, size ); break; - case UINT: convertCastT( ( int* )_raw, ( uint* )buffer, size ); break; - 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; - + case CHAR: convertCastT( ( int32_t* )_raw, ( int8_t* )buffer, size ); break; + case SHORT: convertCastT( ( int32_t* )_raw, ( int16_t* )buffer, size ); break; + case USHORT: convertCastT( ( int32_t* )_raw, ( uint16_t* )buffer, size ); break; + case UINT: convertCastT( ( int32_t* )_raw, ( uint32_t* )buffer, size ); break; + case FLOAT: convertCastT( ( int32_t* )_raw, ( float* )buffer, size ); break; + case DOUBLE: convertCastT( ( int32_t* )_raw, ( double* )buffer, size ); break; + case UCHAR: convertCastT( ( int32_t* )_raw, ( uint8_t* )buffer, size ); break; + default : break; } // fswitch break; case USHORT: switch( type ) { - case CHAR: convertCastT( ( ushort* )_raw, ( char* )buffer, size ); break; - case SHORT: convertCastT( ( ushort* )_raw, ( short* )buffer, size ); break; - case INT: convertCastT( ( ushort* )_raw, ( int* )buffer, size ); break; - case UINT: convertCastT( ( ushort* )_raw, ( uint* )buffer, size ); break; - 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; - + case CHAR: convertCastT( ( uint16_t* )_raw, ( int8_t* )buffer, size ); break; + case SHORT: convertCastT( ( uint16_t* )_raw, ( int16_t* )buffer, size ); break; + case INT: convertCastT( ( uint16_t* )_raw, ( int32_t* )buffer, size ); break; + case UINT: convertCastT( ( uint16_t* )_raw, ( uint32_t* )buffer, size ); break; + case FLOAT: convertCastT( ( uint16_t* )_raw, ( float* )buffer, size ); break; + case DOUBLE: convertCastT( ( uint16_t* )_raw, ( double* )buffer, size ); break; + case UCHAR: convertCastT( ( uint16_t* )_raw, ( uint8_t* )buffer, size ); break; + default : break; } // fswitch break; case UINT: switch( type ) { - case CHAR: convertCastT( ( uint* )_raw, ( char* )buffer, size ); break; - case SHORT: convertCastT( ( uint* )_raw, ( short* )buffer, size ); break; - case INT: convertCastT( ( uint* )_raw, ( int* )buffer, size ); break; - case USHORT: convertCastT( ( uint* )_raw, ( ushort* )buffer, size ); break; - 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; - + case CHAR: convertCastT( ( uint32_t* )_raw, ( int8_t* )buffer, size ); break; + case SHORT: convertCastT( ( uint32_t* )_raw, ( int16_t* )buffer, size ); break; + case INT: convertCastT( ( uint32_t* )_raw, ( int32_t* )buffer, size ); break; + case USHORT: convertCastT( ( uint32_t* )_raw, ( uint16_t* )buffer, size ); break; + case FLOAT: convertCastT( ( uint32_t* )_raw, ( float* )buffer, size ); break; + case DOUBLE: convertCastT( ( uint32_t* )_raw, ( double* )buffer, size ); break; + case UCHAR: convertCastT( ( uint32_t* )_raw, ( uint8_t* )buffer, size ); break; + default : break; } // fswitch break; case FLOAT: switch( type ) { - case CHAR: convertCastT( ( float* )_raw, ( char* )buffer, size ); break; - case SHORT: convertCastT( ( float* )_raw, ( short* )buffer, size ); break; - case INT: convertCastT( ( float* )_raw, ( int* )buffer, size ); break; - case USHORT: convertCastT( ( float* )_raw, ( ushort* )buffer, size ); break; - case UINT: convertCastT( ( float* )_raw, ( uint* )buffer, size ); break; + case CHAR: convertCastT( ( float* )_raw, ( int8_t* )buffer, size ); break; + case SHORT: convertCastT( ( float* )_raw, ( int16_t* )buffer, size ); break; + case INT: convertCastT( ( float* )_raw, ( int32_t* )buffer, size ); break; + case USHORT: convertCastT( ( float* )_raw, ( uint16_t* )buffer, size ); break; + case UINT: convertCastT( ( float* )_raw, ( uint32_t* )buffer, size ); break; case DOUBLE: convertCastT( ( float* )_raw, ( double* )buffer, size ); break; - case UCHAR: convertCastT( ( float* )_raw, ( uchar* )buffer, size ); break; - + case UCHAR: convertCastT( ( float* )_raw, ( uint8_t* )buffer, size ); break; + default : break; } // fswitch break; case DOUBLE: switch( type ) { - case CHAR: convertCastT( ( double* )_raw, ( char* )buffer, size ); break; - case SHORT: convertCastT( ( double* )_raw, ( short* )buffer, size ); break; - case INT: convertCastT( ( double* )_raw, ( int* )buffer, size ); break; - case USHORT: convertCastT( ( double* )_raw, ( ushort* )buffer, size ); break; - case UINT: convertCastT( ( double* )_raw, ( uint* )buffer, size ); break; + case CHAR: convertCastT( ( double* )_raw, ( int8_t* )buffer, size ); break; + case SHORT: convertCastT( ( double* )_raw, ( int16_t* )buffer, size ); break; + case INT: convertCastT( ( double* )_raw, ( int32_t* )buffer, size ); break; + case USHORT: convertCastT( ( double* )_raw, ( uint16_t* )buffer, size ); break; + case UINT: convertCastT( ( double* )_raw, ( uint32_t* )buffer, size ); break; case FLOAT: convertCastT( ( double* )_raw, ( float* )buffer, size ); break; - case UCHAR: convertCastT( ( double* )_raw, ( uchar* )buffer, size ); break; - + case UCHAR: convertCastT( ( double* )_raw, ( uint8_t* )buffer, size ); break; + default : break; } // fswitch break; case UCHAR: switch( type ) { - case CHAR: convertCastT( ( uchar* )_raw, ( char* )buffer, size ); break; - case SHORT: convertCastT( ( uchar* )_raw, ( short* )buffer, size ); break; - case INT: convertCastT( ( uchar* )_raw, ( int* )buffer, size ); break; - case USHORT: convertCastT( ( uchar* )_raw, ( ushort* )buffer, size ); break; - 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; - + case CHAR: convertCastT( ( uint8_t* )_raw, ( int8_t* )buffer, size ); break; + case SHORT: convertCastT( ( uint8_t* )_raw, ( int16_t* )buffer, size ); break; + case INT: convertCastT( ( uint8_t* )_raw, ( int32_t* )buffer, size ); break; + case USHORT: convertCastT( ( uint8_t* )_raw, ( uint16_t* )buffer, size ); break; + case UINT: convertCastT( ( uint8_t* )_raw, ( uint32_t* )buffer, size ); break; + case FLOAT: convertCastT( ( uint8_t* )_raw, ( float* )buffer, size ); break; + case DOUBLE: convertCastT( ( uint8_t* )_raw, ( double* )buffer, size ); break; + default : break; } // fswitch break; @@ -415,119 +433,119 @@ void kVolume::convertScale( Type type, double min, double max ) void* buffer; ulong size = getRawSize( ); - buffer = ( void* )new uchar[ size * SIZETypes[ type ] ]; + buffer = ( void* )new uint8_t[ size * SIZETypes[ type ] ]; switch( _type ) { case CHAR: switch( type ) { - case CHAR: convertScaleT( ( char* )_raw, ( char* )buffer, size, smin, tmin, a ); break; - case SHORT: convertScaleT( ( char* )_raw, ( short* )buffer, size, smin, tmin, a ); break; - case INT: convertScaleT( ( char* )_raw, ( int* )buffer, size, smin, tmin, a ); break; - case USHORT: convertScaleT( ( char* )_raw, ( ushort* )buffer, size, smin, tmin, a ); break; - case UINT: convertScaleT( ( char* )_raw, ( uint* )buffer, size, smin, tmin, a ); break; - case FLOAT: convertScaleT( ( char* )_raw, ( float* )buffer, size, smin, tmin, a ); break; - case DOUBLE: convertScaleT( ( char* )_raw, ( double* )buffer, size, smin, tmin, a ); break; - case UCHAR: convertScaleT( ( char* )_raw, ( uchar* )buffer, size, smin, tmin, a ); break; + case CHAR: convertScaleT( ( int8_t* )_raw, ( int8_t* )buffer, size, smin, tmin, a ); break; + case SHORT: convertScaleT( ( int8_t* )_raw, ( int16_t* )buffer, size, smin, tmin, a ); break; + case INT: convertScaleT( ( int8_t* )_raw, ( int32_t* )buffer, size, smin, tmin, a ); break; + case USHORT: convertScaleT( ( int8_t* )_raw, ( uint16_t* )buffer, size, smin, tmin, a ); break; + case UINT: convertScaleT( ( int8_t* )_raw, ( uint32_t* )buffer, size, smin, tmin, a ); break; + case FLOAT: convertScaleT( ( int8_t* )_raw, ( float* )buffer, size, smin, tmin, a ); break; + case DOUBLE: convertScaleT( ( int8_t* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case UCHAR: convertScaleT( ( int8_t* )_raw, ( uint8_t* )buffer, size, smin, tmin, a ); break; } // fswitch break; case SHORT: switch( type ) { - case CHAR: convertScaleT( ( short* )_raw, ( char* )buffer, size, smin, tmin, a ); break; - case SHORT: convertScaleT( ( short* )_raw, ( short* )buffer, size, smin, tmin, a ); break; - case INT: convertScaleT( ( short* )_raw, ( int* )buffer, size, smin, tmin, a ); break; - case USHORT: convertScaleT( ( short* )_raw, ( ushort* )buffer, size, smin, tmin, a ); break; - case UINT: convertScaleT( ( short* )_raw, ( uint* )buffer, size, smin, tmin, a ); break; - case FLOAT: convertScaleT( ( short* )_raw, ( float* )buffer, size, smin, tmin, a ); break; - case DOUBLE: convertScaleT( ( short* )_raw, ( double* )buffer, size, smin, tmin, a ); break; - case UCHAR: convertScaleT( ( short* )_raw, ( uchar* )buffer, size, smin, tmin, a ); break; + case CHAR: convertScaleT( ( int16_t* )_raw, ( int8_t* )buffer, size, smin, tmin, a ); break; + case SHORT: convertScaleT( ( int16_t* )_raw, ( int16_t* )buffer, size, smin, tmin, a ); break; + case INT: convertScaleT( ( int16_t* )_raw, ( int32_t* )buffer, size, smin, tmin, a ); break; + case USHORT: convertScaleT( ( int16_t* )_raw, ( uint16_t* )buffer, size, smin, tmin, a ); break; + case UINT: convertScaleT( ( int16_t* )_raw, ( uint32_t* )buffer, size, smin, tmin, a ); break; + case FLOAT: convertScaleT( ( int16_t* )_raw, ( float* )buffer, size, smin, tmin, a ); break; + case DOUBLE: convertScaleT( ( int16_t* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case UCHAR: convertScaleT( ( int16_t* )_raw, ( uint8_t* )buffer, size, smin, tmin, a ); break; } // fswitch break; case INT: switch( type ) { - case CHAR: convertScaleT( ( int* )_raw, ( char* )buffer, size, smin, tmin, a ); break; - case SHORT: convertScaleT( ( int* )_raw, ( short* )buffer, size, smin, tmin, a ); break; - case INT: convertScaleT( ( int* )_raw, ( int* )buffer, size, smin, tmin, a ); break; - case USHORT: convertScaleT( ( int* )_raw, ( ushort* )buffer, size, smin, tmin, a ); break; - case UINT: convertScaleT( ( int* )_raw, ( uint* )buffer, size, smin, tmin, a ); break; - case FLOAT: convertScaleT( ( int* )_raw, ( float* )buffer, size, smin, tmin, a ); break; - case DOUBLE: convertScaleT( ( int* )_raw, ( double* )buffer, size, smin, tmin, a ); break; - case UCHAR: convertScaleT( ( int* )_raw, ( uchar* )buffer, size, smin, tmin, a ); break; + case CHAR: convertScaleT( ( int32_t* )_raw, ( int8_t* )buffer, size, smin, tmin, a ); break; + case SHORT: convertScaleT( ( int32_t* )_raw, ( int16_t* )buffer, size, smin, tmin, a ); break; + case INT: convertScaleT( ( int32_t* )_raw, ( int32_t* )buffer, size, smin, tmin, a ); break; + case USHORT: convertScaleT( ( int32_t* )_raw, ( uint16_t* )buffer, size, smin, tmin, a ); break; + case UINT: convertScaleT( ( int32_t* )_raw, ( uint32_t* )buffer, size, smin, tmin, a ); break; + case FLOAT: convertScaleT( ( int32_t* )_raw, ( float* )buffer, size, smin, tmin, a ); break; + case DOUBLE: convertScaleT( ( int32_t* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case UCHAR: convertScaleT( ( int32_t* )_raw, ( uint8_t* )buffer, size, smin, tmin, a ); break; } // fswitch break; case USHORT: switch( type ) { - case CHAR: convertScaleT( ( ushort* )_raw, ( char* )buffer, size, smin, tmin, a ); break; - case SHORT: convertScaleT( ( ushort* )_raw, ( short* )buffer, size, smin, tmin, a ); break; - case INT: convertScaleT( ( ushort* )_raw, ( int* )buffer, size, smin, tmin, a ); break; - case USHORT: convertScaleT( ( ushort* )_raw, ( ushort* )buffer, size, smin, tmin, a ); break; - case UINT: convertScaleT( ( ushort* )_raw, ( uint* )buffer, size, smin, tmin, a ); break; - case FLOAT: convertScaleT( ( ushort* )_raw, ( float* )buffer, size, smin, tmin, a ); break; - case DOUBLE: convertScaleT( ( ushort* )_raw, ( double* )buffer, size, smin, tmin, a ); break; - case UCHAR: convertScaleT( ( ushort* )_raw, ( uchar* )buffer, size, smin, tmin, a ); break; + case CHAR: convertScaleT( ( uint16_t* )_raw, ( int8_t* )buffer, size, smin, tmin, a ); break; + case SHORT: convertScaleT( ( uint16_t* )_raw, ( int16_t* )buffer, size, smin, tmin, a ); break; + case INT: convertScaleT( ( uint16_t* )_raw, ( int32_t* )buffer, size, smin, tmin, a ); break; + case USHORT: convertScaleT( ( uint16_t* )_raw, ( uint16_t* )buffer, size, smin, tmin, a ); break; + case UINT: convertScaleT( ( uint16_t* )_raw, ( uint32_t* )buffer, size, smin, tmin, a ); break; + case FLOAT: convertScaleT( ( uint16_t* )_raw, ( float* )buffer, size, smin, tmin, a ); break; + case DOUBLE: convertScaleT( ( uint16_t* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case UCHAR: convertScaleT( ( uint16_t* )_raw, ( uint8_t* )buffer, size, smin, tmin, a ); break; } // fswitch break; case UINT: switch( type ) { - case CHAR: convertScaleT( ( uint* )_raw, ( char* )buffer, size, smin, tmin, a ); break; - case SHORT: convertScaleT( ( uint* )_raw, ( short* )buffer, size, smin, tmin, a ); break; - case INT: convertScaleT( ( uint* )_raw, ( int* )buffer, size, smin, tmin, a ); break; - case USHORT: convertScaleT( ( uint* )_raw, ( ushort* )buffer, size, smin, tmin, a ); break; - case UINT: convertScaleT( ( uint* )_raw, ( uint* )buffer, size, smin, tmin, a ); break; - case FLOAT: convertScaleT( ( uint* )_raw, ( float* )buffer, size, smin, tmin, a ); break; - case DOUBLE: convertScaleT( ( uint* )_raw, ( double* )buffer, size, smin, tmin, a ); break; - case UCHAR: convertScaleT( ( uint* )_raw, ( uchar* )buffer, size, smin, tmin, a ); break; + case CHAR: convertScaleT( ( uint32_t* )_raw, ( int8_t* )buffer, size, smin, tmin, a ); break; + case SHORT: convertScaleT( ( uint32_t* )_raw, ( int16_t* )buffer, size, smin, tmin, a ); break; + case INT: convertScaleT( ( uint32_t* )_raw, ( int32_t* )buffer, size, smin, tmin, a ); break; + case USHORT: convertScaleT( ( uint32_t* )_raw, ( uint16_t* )buffer, size, smin, tmin, a ); break; + case UINT: convertScaleT( ( uint32_t* )_raw, ( uint32_t* )buffer, size, smin, tmin, a ); break; + case FLOAT: convertScaleT( ( uint32_t* )_raw, ( float* )buffer, size, smin, tmin, a ); break; + case DOUBLE: convertScaleT( ( uint32_t* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case UCHAR: convertScaleT( ( uint32_t* )_raw, ( uint8_t* )buffer, size, smin, tmin, a ); break; } // fswitch break; case UCHAR: switch( type ) { - case CHAR: convertScaleT( ( uchar* )_raw, ( char* )buffer, size, smin, tmin, a ); break; - case SHORT: convertScaleT( ( uchar* )_raw, ( short* )buffer, size, smin, tmin, a ); break; - case INT: convertScaleT( ( uchar* )_raw, ( int* )buffer, size, smin, tmin, a ); break; - case USHORT: convertScaleT( ( uchar* )_raw, ( ushort* )buffer, size, smin, tmin, a ); break; - case UINT: convertScaleT( ( uchar* )_raw, ( uint* )buffer, size, smin, tmin, a ); break; - case FLOAT: convertScaleT( ( uchar* )_raw, ( float* )buffer, size, smin, tmin, a ); break; - case DOUBLE: convertScaleT( ( uchar* )_raw, ( double* )buffer, size, smin, tmin, a ); break; - case UCHAR: convertScaleT( ( uchar* )_raw, ( uchar* )buffer, size, smin, tmin, a ); break; + case CHAR: convertScaleT( ( uint8_t* )_raw, ( int8_t* )buffer, size, smin, tmin, a ); break; + case SHORT: convertScaleT( ( uint8_t* )_raw, ( int16_t* )buffer, size, smin, tmin, a ); break; + case INT: convertScaleT( ( uint8_t* )_raw, ( int32_t* )buffer, size, smin, tmin, a ); break; + case USHORT: convertScaleT( ( uint8_t* )_raw, ( uint16_t* )buffer, size, smin, tmin, a ); break; + case UINT: convertScaleT( ( uint8_t* )_raw, ( uint32_t* )buffer, size, smin, tmin, a ); break; + case FLOAT: convertScaleT( ( uint8_t* )_raw, ( float* )buffer, size, smin, tmin, a ); break; + case DOUBLE: convertScaleT( ( uint8_t* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case UCHAR: convertScaleT( ( uint8_t* )_raw, ( uint8_t* )buffer, size, smin, tmin, a ); break; } // fswitch break; case DOUBLE: switch( type ) { - case CHAR: convertScaleT( ( double* )_raw, ( char* )buffer, size, smin, tmin, a ); break; - case SHORT: convertScaleT( ( double* )_raw, ( short* )buffer, size, smin, tmin, a ); break; - case INT: convertScaleT( ( double* )_raw, ( int* )buffer, size, smin, tmin, a ); break; - case USHORT: convertScaleT( ( double* )_raw, ( ushort* )buffer, size, smin, tmin, a ); break; - case UINT: convertScaleT( ( double* )_raw, ( uint* )buffer, size, smin, tmin, a ); break; - case FLOAT: convertScaleT( ( double* )_raw, ( float* )buffer, size, smin, tmin, a ); break; - case DOUBLE: convertScaleT( ( double* )_raw, ( double* )buffer, size, smin, tmin, a ); break; - case UCHAR: convertScaleT( ( uchar* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case CHAR: convertScaleT( ( double* )_raw, ( int8_t* )buffer, size, smin, tmin, a ); break; + case SHORT: convertScaleT( ( double* )_raw, ( int16_t* )buffer, size, smin, tmin, a ); break; + case INT: convertScaleT( ( double* )_raw, ( int32_t* )buffer, size, smin, tmin, a ); break; + case USHORT: convertScaleT( ( double* )_raw, ( uint16_t* )buffer, size, smin, tmin, a ); break; + case UINT: convertScaleT( ( double* )_raw, ( uint32_t* )buffer, size, smin, tmin, a ); break; + case FLOAT: convertScaleT( ( double* )_raw, ( float* )buffer, size, smin, tmin, a ); break; + case DOUBLE: convertScaleT( ( double* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case UCHAR: convertScaleT( ( double* )_raw, ( uint8_t* )buffer, size, smin, tmin, a ); break; } // fswitch break; case FLOAT: switch( type ) { - case CHAR: convertScaleT( ( float* )_raw, ( char* )buffer, size, smin, tmin, a ); break; - case SHORT: convertScaleT( ( float* )_raw, ( short* )buffer, size, smin, tmin, a ); break; - case INT: convertScaleT( ( float* )_raw, ( int* )buffer, size, smin, tmin, a ); break; - case USHORT: convertScaleT( ( float* )_raw, ( ushort* )buffer, size, smin, tmin, a ); break; - case UINT: convertScaleT( ( float* )_raw, ( uint* )buffer, size, smin, tmin, a ); break; + case CHAR: convertScaleT( ( float* )_raw, ( int8_t* )buffer, size, smin, tmin, a ); break; + case SHORT: convertScaleT( ( float* )_raw, ( int16_t* )buffer, size, smin, tmin, a ); break; + case INT: convertScaleT( ( float* )_raw, ( int32_t* )buffer, size, smin, tmin, a ); break; + case USHORT: convertScaleT( ( float* )_raw, ( uint16_t* )buffer, size, smin, tmin, a ); break; + case UINT: convertScaleT( ( float* )_raw, ( uint32_t* )buffer, size, smin, tmin, a ); break; case FLOAT: convertScaleT( ( float* )_raw, ( float* )buffer, size, smin, tmin, a ); break; case DOUBLE: convertScaleT( ( float* )_raw, ( double* )buffer, size, smin, tmin, a ); break; - case UCHAR: convertScaleT( ( float* )_raw, ( double* )buffer, size, smin, tmin, a ); break; + case UCHAR: convertScaleT( ( float* )_raw, ( uint8_t* )buffer, size, smin, tmin, a ); break; } // fswitch break; @@ -548,14 +566,14 @@ void kVolume::getMinMax( double& min, double& max ) const switch( _type ) { - case CHAR: getMinMaxT( ( char* )_raw, size, min, max ); break; - case FLOAT: getMinMaxT( ( float* )_raw, size, min, max ); break; - case DOUBLE: getMinMaxT( ( double* )_raw, size, min, max ); break; - case INT: getMinMaxT( ( int* )_raw, size, min, max ); break; - case SHORT: getMinMaxT( ( short* )_raw, size, min, max ); break; - case UCHAR: getMinMaxT( ( uchar* )_raw, size, min, max ); break; - case UINT: getMinMaxT( ( uint* )_raw, size, min, max ); break; - case USHORT: getMinMaxT( ( ushort* )_raw, size, min, max ); break; + case CHAR: getMinMaxT( ( int8_t* )_raw, size, min, max ); break; + case FLOAT: getMinMaxT( ( float* )_raw, size, min, max ); break; + case DOUBLE: getMinMaxT( ( double* )_raw, size, min, max ); break; + case INT: getMinMaxT( ( int32_t* )_raw, size, min, max ); break; + case SHORT: getMinMaxT( ( int16_t* )_raw, size, min, max ); break; + case UCHAR: getMinMaxT( ( uint8_t* )_raw, size, min, max ); break; + case UINT: getMinMaxT( ( uint32_t* )_raw, size, min, max ); break; + case USHORT: getMinMaxT( ( uint16_t* )_raw, size, min, max ); break; } // fswitch } @@ -607,7 +625,7 @@ double kVolume::getMax( ) const for( v( 1 ) = minY; v( 1 ) <= maxY; v( 1 )++ ) for( v( 2 ) = minZ; v( 2 ) <= maxZ; v( 2 )++ ) if( ( v - vP ).norm2( ) <= r ) { - tmp = this->getPixel( ( uint )v(0), ( uint )v(1), ( uint )v(2)); + tmp = this->getPixel( ( uint32_t )v(0), ( uint32_t )v(1), ( uint32_t )v(2)); maxint = ( tmp > maxint || start )? tmp: maxint; start = false; } // fi @@ -671,7 +689,7 @@ void kVolume::allocate( ) if( _creator == SELF ) { - _raw = ( void* )new uchar[ size ]; + _raw = ( void* )new uint8_t[ size ]; memset( _raw, 0, size ); } // fi @@ -682,69 +700,38 @@ void kVolume::buildIndex( ) { ulong size; - size = ( _dims[ CZ ] * sizeof( uchar** ) ) + + size = ( _dims[ CZ ] * sizeof( uint8_t** ) ) + ( _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 + _images = ( void*** )new uint8_t[ size ]; _columns = ( void** )( _images + _dims[ CZ ] ); void** plane = _columns; - for( uint z = 0; z < _dims[ CZ ]; z++ ) { + for( uint32_t z = 0; z < _dims[ CZ ]; z++ ) { _images[ z ] = plane; plane += _dims[ CY ]; } // rof void* line = _raw; - for( uint y = 0; y < _dims[ CZ ] * _dims[ CY ]; y++ ) { + for( uint32_t y = 0; y < _dims[ CZ ] * _dims[ CY ]; y++ ) { _columns[ y ] = line; - line = ( void* )( ( uchar* ) line + + line = ( void* )( ( uint8_t* ) line + _dims[ CX ] * SIZETypes[ _type ] ); } // rof - -#ifdef KGFO_USE_IDO - - } else - _images = ( void*** )( &_privateIdo[ 1 ] ); - -#endif // KGFO_USE_IDO #ifdef KGFO_USE_VTK - vtkCharArray* carray; - vtkDoubleArray* darray; - vtkFloatArray* farray; - vtkIntArray* iarray; - vtkShortArray* sarray; - vtkUnsignedCharArray* ucarray; - vtkUnsignedIntArray* uiarray; - vtkUnsignedShortArray* usarray; + vtkCharArray *carray; + vtkDoubleArray *darray; + vtkFloatArray *farray; + vtkIntArray *iarray; + vtkShortArray *sarray; + vtkUnsignedCharArray *ucarray; + vtkUnsignedIntArray *uiarray; + vtkUnsignedShortArray *usarray; size = _dims[ CX ] * _dims[ CY ] * _dims[ CZ ]; @@ -754,82 +741,279 @@ void kVolume::buildIndex( ) _vtk->SetDimensions( _dims[ CX ], _dims[ CY ], _dims[ CZ ] ); _vtk->SetSpacing( _sizes[ CX ], _sizes[ CY ], _sizes[ CZ ] ); + if (_type==CHAR) + { + carray = vtkCharArray::New( ); + carray->SetArray( ( char* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + carray->SetNumberOfComponents( 1 ); + _vtk->SetScalarType( VTK_CHAR ); +#else + vtkInformation* infoC=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoC, VTK_CHAR, 1); +#endif + _vtk->GetPointData( )->SetScalars( carray ); + carray->Delete( ); + } + + if (_type==UCHAR) + { + ucarray = vtkUnsignedCharArray::New( ); + ucarray->SetArray( ( uint8_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + ucarray->SetNumberOfComponents( 1 ); + _vtk->SetScalarType( VTK_UNSIGNED_CHAR ); +#else + vtkInformation* infoUC=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoUC, VTK_UNSIGNED_CHAR, 1); +#endif + _vtk->GetPointData( )->SetScalars( ucarray ); + ucarray->Delete( ); + } + + + + + + if (_type==SHORT) + { + sarray = vtkShortArray::New( ); + sarray->SetArray( ( int16_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + sarray->SetNumberOfComponents( 1 ); + _vtk->SetScalarType( VTK_SHORT ); +#else + vtkInformation* infoS=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoS, VTK_SHORT, 1); +#endif + _vtk->GetPointData( )->SetScalars( sarray ); + sarray->Delete( ); +} + + if (_type==INT) + { + iarray = vtkIntArray::New( ); + iarray->SetArray( ( int32_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + iarray->SetNumberOfComponents( 1 ); + _vtk->SetScalarType( VTK_INT ); +#else + vtkInformation* infoI=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoI, VTK_INT, 1); +#endif + _vtk->GetPointData( )->SetScalars( iarray ); + iarray->Delete( ); + } + + + if (_type==USHORT) + { + usarray = vtkUnsignedShortArray::New( ); + usarray->SetArray( ( uint16_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + usarray->SetNumberOfComponents( 1 ); + _vtk->SetScalarType( VTK_UNSIGNED_SHORT ); +#else + vtkInformation* infoUS=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoUS, VTK_UNSIGNED_SHORT, 1); +#endif + _vtk->GetPointData( )->SetScalars( usarray ); + usarray->Delete( ); + } + + + if (_type==UINT) + { + uiarray = vtkUnsignedIntArray::New( ); + uiarray->SetArray( ( uint32_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + uiarray->SetNumberOfComponents( 1 ); + _vtk->SetScalarType( VTK_UNSIGNED_INT ); +#else + vtkInformation* infoUI=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoUI, VTK_UNSIGNED_INT, 1); +#endif + _vtk->GetPointData( )->SetScalars( uiarray ); + uiarray->Delete( ); + } + + + if (_type==FLOAT) + { + farray = vtkFloatArray::New( ); + farray->SetArray( ( float* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + farray->SetNumberOfComponents( 1 ); + _vtk->SetScalarType( VTK_FLOAT ); +#else + vtkInformation* infoF=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoF, VTK_FLOAT, 1); +#endif + _vtk->GetPointData( )->SetScalars( farray ); + farray->Delete( ); + } + + + if (_type==DOUBLE) + { + darray = vtkDoubleArray::New( ); + darray->SetArray( ( double* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + darray->SetNumberOfComponents( 1 ); + _vtk->SetScalarType( VTK_DOUBLE ); +#else + vtkInformation* infoD=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoD, VTK_DOUBLE, 1); +#endif + + + _vtk->GetPointData( )->SetScalars( darray ); + darray->Delete( ); + } + + + + + + +/* switch( _type ) { case CHAR: carray = vtkCharArray::New( ); - carray->SetNumberOfComponents( 1 ); carray->SetArray( ( char* )( _raw ), size, 1 ); + +//EED 2017-01-01 Migration VTK7 +//#if VTK_MAJOR_VERSION <= 5 + carray->SetNumberOfComponents( 1 ); _vtk->SetScalarType( VTK_CHAR ); +#else + vtkInformation* infoC=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoC, VTK_CHAR, 1); +#endif + _vtk->GetPointData( )->SetScalars( carray ); carray->Delete( ); break; case UCHAR: ucarray = vtkUnsignedCharArray::New( ); + ucarray->SetArray( ( uint8_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 ucarray->SetNumberOfComponents( 1 ); - ucarray->SetArray( ( uchar* )( _raw ), size, 1 ); _vtk->SetScalarType( VTK_UNSIGNED_CHAR ); +#else + vtkInformation* infoUC=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoUC, VTK_UNSIGNED_CHAR, 1); +#endif _vtk->GetPointData( )->SetScalars( ucarray ); ucarray->Delete( ); break; case SHORT: sarray = vtkShortArray::New( ); + sarray->SetArray( ( int16_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 sarray->SetNumberOfComponents( 1 ); - sarray->SetArray( ( short* )( _raw ), size, 1 ); _vtk->SetScalarType( VTK_SHORT ); +#else + vtkInformation* infoS=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoS, VTK_SHORT, 1); +#endif _vtk->GetPointData( )->SetScalars( sarray ); sarray->Delete( ); break; case INT: iarray = vtkIntArray::New( ); + iarray->SetArray( ( int32_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 iarray->SetNumberOfComponents( 1 ); - iarray->SetArray( ( int* )( _raw ), size, 1 ); _vtk->SetScalarType( VTK_INT ); +#else + vtkInformation* infoI=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoI, VTK_INT, 1); +#endif _vtk->GetPointData( )->SetScalars( iarray ); iarray->Delete( ); break; case USHORT: usarray = vtkUnsignedShortArray::New( ); + usarray->SetArray( ( uint16_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 usarray->SetNumberOfComponents( 1 ); - usarray->SetArray( ( ushort* )( _raw ), size, 1 ); _vtk->SetScalarType( VTK_UNSIGNED_SHORT ); +#else + vtkInformation* infoUS=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoUS, VTK_UNSIGNED_SHORT, 1); +#endif _vtk->GetPointData( )->SetScalars( usarray ); usarray->Delete( ); break; case UINT: uiarray = vtkUnsignedIntArray::New( ); + uiarray->SetArray( ( uint32_t* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 uiarray->SetNumberOfComponents( 1 ); - uiarray->SetArray( ( uint* )( _raw ), size, 1 ); _vtk->SetScalarType( VTK_UNSIGNED_INT ); +#else + vtkInformation* infoUI=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoUI, VTK_UNSIGNED_INT, 1); +#endif _vtk->GetPointData( )->SetScalars( uiarray ); uiarray->Delete( ); break; case FLOAT: farray = vtkFloatArray::New( ); - farray->SetNumberOfComponents( 1 ); farray->SetArray( ( float* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + farray->SetNumberOfComponents( 1 ); _vtk->SetScalarType( VTK_FLOAT ); +#else + vtkInformation* infoF=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoF, VTK_FLOAT, 1); +#endif _vtk->GetPointData( )->SetScalars( farray ); farray->Delete( ); break; case DOUBLE: darray = vtkDoubleArray::New( ); - darray->SetNumberOfComponents( 1 ); darray->SetArray( ( double* )( _raw ), size, 1 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + darray->SetNumberOfComponents( 1 ); _vtk->SetScalarType( VTK_DOUBLE ); +#else + vtkInformation* infoD=_vtk->GetInformation(); + vtkDataObject::SetPointDataActiveScalarInfo(infoD, VTK_DOUBLE, 1); +#endif + + _vtk->GetPointData( )->SetScalars( darray ); darray->Delete( ); break; } // fswitch - +*/ + } // fi #endif // KGFO_USE_VTK @@ -839,49 +1023,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 - + delete[] ( uint8_t* )_images; if( _raw && _creator == SELF ) //EED purify 12/sept/2006 -// delete[] ( uchar* )_raw; +// delete[] ( uint8_t* )_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; @@ -904,9 +1071,9 @@ kVolume::kVolume( vtkImageData* org ) } // fswitch org->GetDimensions( itmp ); - _dims[ CX ] = ( uint )itmp[ 0 ]; - _dims[ CY ] = ( uint )itmp[ 1 ]; - _dims[ CZ ] = ( uint )itmp[ 2 ]; + _dims[ CX ] = ( uint32_t )itmp[ 0 ]; + _dims[ CY ] = ( uint32_t )itmp[ 1 ]; + _dims[ CZ ] = ( uint32_t )itmp[ 2 ]; org->GetSpacing( ftmp ); _sizes[ CX ] = ( double )ftmp[ 0 ]; _sizes[ CY ] = ( double )ftmp[ 1 ]; @@ -937,17 +1104,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( ) ) { @@ -964,9 +1131,9 @@ void kVolume::copyFrom( vtkImageData* org ) } // fswitch org->GetDimensions( itmp ); - _dims[ CX ] = ( uint )itmp[ 0 ]; - _dims[ CY ] = ( uint )itmp[ 1 ]; - _dims[ CZ ] = ( uint )itmp[ 2 ]; + _dims[ CX ] = ( uint32_t )itmp[ 0 ]; + _dims[ CY ] = ( uint32_t )itmp[ 1 ]; + _dims[ CZ ] = ( uint32_t )itmp[ 2 ]; org->GetSpacing( ftmp ); _sizes[ CX ] = ( double )ftmp[ 0 ]; _sizes[ CY ] = ( double )ftmp[ 1 ]; @@ -978,110 +1145,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