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=7fbe85cc1276d06e2b598a3bb3a4cfdf977d50bf;hpb=66588eac91068d9b7f9d45bffc5e09c27511eaac;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/kernel/volume.cxx b/lib/maracasVisuLib/src/kernel/volume.cxx index 7fbe85c..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: 2010/04/20 16:11:40 $ - Version: $Revision: 1.8 $ + Date: $Date: 2012/11/15 14:16:13 $ + Version: $Revision: 1.10 $ Copyright: (c) 2002, 2003 License: @@ -220,12 +245,12 @@ double kVolume::getPixel( uint32_t x, uint32_t y, uint32_t z ) const switch( _type ) { - 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 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; @@ -269,12 +294,12 @@ void kVolume::convertCast( Type type ) case CHAR: switch( type ) { - case SHORT: convertCastT( ( char* )_raw, ( int16_t* )buffer, size ); break; - case INT: convertCastT( ( char* )_raw, ( int32_t* )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 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; @@ -284,13 +309,13 @@ void kVolume::convertCast( Type type ) case SHORT: switch( type ) { - case CHAR: convertCastT( ( int16_t* )_raw, ( uint8_t* )buffer, size ); break; - case INT: convertCastT( ( int16_t* )_raw, ( int32_t* )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; + 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; @@ -699,14 +724,14 @@ void kVolume::buildIndex( ) #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 ]; @@ -716,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->SetNumberOfComponents( 1 ); 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( ); break; case SHORT: sarray = vtkShortArray::New( ); - sarray->SetNumberOfComponents( 1 ); 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( ); break; case INT: iarray = vtkIntArray::New( ); - iarray->SetNumberOfComponents( 1 ); 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( ); break; case USHORT: usarray = vtkUnsignedShortArray::New( ); - usarray->SetNumberOfComponents( 1 ); 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( ); break; case UINT: uiarray = vtkUnsignedIntArray::New( ); - uiarray->SetNumberOfComponents( 1 ); 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( ); 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