X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Fkernel%2FmarDynData.cpp;h=663036071f571def1353848c349f826b96543d04;hb=c371863c6419d9a17d97c9c81dcf11c1b2489ff6;hp=29f1e6fc96354ae3939b32cb1270c8d12e25d74b;hpb=a4ee3758aa0477f677fb981e2c4d6e29995e8db8;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/kernel/marDynData.cpp b/lib/maracasVisuLib/src/kernel/marDynData.cpp index 29f1e6f..6630360 100644 --- a/lib/maracasVisuLib/src/kernel/marDynData.cpp +++ b/lib/maracasVisuLib/src/kernel/marDynData.cpp @@ -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: marDynData.cpp,v $ Language: C++ - Date: $Date: 2009/05/14 13:54:43 $ - Version: $Revision: 1.2 $ + Date: $Date: 2012/11/15 14:16:12 $ + Version: $Revision: 1.4 $ Copyright: (c) 2002, 2003 License: @@ -44,7 +69,12 @@ void marDynData::loadData( kVolume* vol, int* voi ) reset( ); vtkExtractVOI *crop = vtkExtractVOI::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 crop->SetInput( vol->castVtk( ) ); +#else + crop->SetInputData( vol->castVtk( ) ); +#endif crop->SetVOI( voi ); //crop->SetSampleRate( getParameters( )->getVoxelSize( ), getParameters( )->getVoxelSize( ), getParameters( )->getVoxelSize( )); @@ -57,13 +87,23 @@ void marDynData::loadData( kVolume* vol, int* voi ) // RescalaIntercept = 0; vtkImageShiftScale *scale = vtkImageShiftScale::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 scale->SetInput( crop->GetOutput( ) ); +#else + scale->SetInputData( crop->GetOutput( ) ); +#endif scale->SetScale(RescalaSlope); scale->SetShift(0); scale->SetOutputScalarTypeToShort(); scale->Update(); vtkImageShiftScale *shift = vtkImageShiftScale::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 shift->SetInput( scale->GetOutput( ) ); +#else + shift->SetInputData( scale->GetOutput( ) ); +#endif shift->SetScale(1); shift->SetShift(RescalaIntercept); shift->SetOutputScalarTypeToShort(); @@ -71,7 +111,12 @@ void marDynData::loadData( kVolume* vol, int* voi ) vtkImageThreshold *threshold = vtkImageThreshold::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 threshold->SetInput( shift->GetOutput( ) ); +#else + threshold->SetInputData( shift->GetOutput( ) ); +#endif threshold->ThresholdByUpper (-10000); threshold->ThresholdByLower (-1); threshold->SetInValue(0); @@ -80,7 +125,12 @@ void marDynData::loadData( kVolume* vol, int* voi ) threshold->SetOutputScalarTypeToUnsignedShort(); vtkImageResample* ir = vtkImageResample::New( ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 ir->SetInput( threshold->GetOutput( ) ); +#else + ir->SetInputData( threshold->GetOutput( ) ); +#endif ir->SetDimensionality( 3 ); double voxelSize= getParameters( )->getVoxelSize( ); ir->SetAxisOutputSpacing( 0, voxelSize ); @@ -102,7 +152,13 @@ void marDynData::loadData( kVolume* vol, int* voi ) * Before we were using kgfoCrop which assume extent start at 0,0,0 */ vtkImageChangeInformation* change = vtkImageChangeInformation::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 change->SetInput( ir->GetOutput() ); +#else + change->SetInputData( ir->GetOutput() ); +#endif + change->SetExtentTranslation( -ext[0], -ext[2], -ext[4] ); change->SetOutputSpacing ( voxelSize , voxelSize , voxelSize ); change->Update(); //important @@ -147,8 +203,8 @@ void marDynData::copyFrom( const marObject& from ) bool marDynData::save( std::ofstream& os ) { void* data = _volume->getData1D( ); - uint dims[ 3 ]; - ulong dSize = _volume->getRawSizeInBytes( ); + uint32_t dims[ 3 ]; + ulong dSize = _volume->getRawSizeInBytes( ); // How many bytes for a 'ulong'? // JPR double sizes[ 3 ]; kVolume::Type type = _volume->getType( ); @@ -159,7 +215,7 @@ bool marDynData::save( std::ofstream& os ) sizes[ 1 ] = _volume->getYsize( ); sizes[ 2 ] = _volume->getZsize( ); - os.write( ( const char* )dims, 3 * sizeof( uint ) ); + os.write( ( const char* )dims, 3 * sizeof( uint32_t ) ); os.write( ( const char* )sizes, 3 * sizeof( double ) ); os.write( ( const char* )&type, sizeof( kVolume::Type ) ); os.write( ( const char* )&dSize, sizeof( ulong ) ); @@ -171,19 +227,19 @@ bool marDynData::save( std::ofstream& os ) // ------------------------------------------------------------------------- bool marDynData::load( std::ifstream& is ) { - uchar* data; - uint dims[ 3 ]; + uint8_t* data; + uint32_t dims[ 3 ]; ulong dSize; double sizes[ 3 ]; kVolume::Type type; reset( ); - is.read( ( char* )dims, 3 * sizeof( uint ) ); + is.read( ( char* )dims, 3 * sizeof( uint32_t ) ); is.read( ( char* )sizes, 3 * sizeof( double ) ); is.read( ( char* )&type, sizeof( kVolume::Type ) ); is.read( ( char* )&dSize, sizeof( ulong ) ); - data = new uchar[ dSize ]; + data = new uint8_t[ dSize ]; is.read( ( char* )data, dSize ); _volume = new kVolume( type, dims, sizes, ( void* )data );