X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FexMoveImagesToSingleSerieUID.cxx;h=18cbc35321d469822dc7625b85873296766958ca;hb=7807e926c2319c5adfc037665992307222bc8f27;hp=0e38341370ba2786e197c9946dc103f14a3dfd54;hpb=7802cf7e80609b42a3d9ab4d175b69226dca584a;p=gdcm.git diff --git a/Example/exMoveImagesToSingleSerieUID.cxx b/Example/exMoveImagesToSingleSerieUID.cxx index 0e383413..18cbc353 100755 --- a/Example/exMoveImagesToSingleSerieUID.cxx +++ b/Example/exMoveImagesToSingleSerieUID.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exMoveImagesToSingleSerieUID.cxx,v $ Language: C++ - Date: $Date: 2006/07/17 13:21:05 $ - Version: $Revision: 1.1 $ + Date: $Date: 2007/10/01 09:33:20 $ + Version: $Revision: 1.6 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -33,9 +33,9 @@ Converts the a Dicom file inside a single-level Directory exMoveImagesToSingleSerieUID dirin=inputDirectoryName dirout=outputDirectoryName - [studyUID = ] [patName = ] [Zspacing = ] - [ { [noshadowseq] | [noshadow][noseq] } ] [debug] - [verbose]", + [studyUID = ] [patName = ] [Zspacing = ] + [ { [noshadowseq] | [noshadow][noseq] } ] [debug] + [verbose]", dirin : single-level Directory containing the images @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) START_USAGE(usage) "\n exMoveImagesToSingleSerieUID :\n ", " Converts the Dicom files inside a single-level Directory ", - " into a 'Single Study UID - Single SerieUID ", + " into a 'Single Study UID - Single SerieUID' file set ", " usage: exMoveImagesToSingleSerieUID ", " dirin=inputDirectoryName ", " dirout=outputDirectoryName ", @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) // ----- Initialize Arguments Manager ------ - gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv); + GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv); if (am->ArgMgrDefined("usage") || argc == 1) { @@ -114,31 +114,33 @@ int main(int argc, char *argv[]) } if (am->ArgMgrDefined("debug")) - gdcm::Debug::DebugOn(); - int verbose = am->ArgMgrDefined("verbose"); + GDCM_NAME_SPACE::Debug::DebugOn(); + + bool verbose = ( 0 != am->ArgMgrDefined("verbose") ); std::string patName = am->ArgMgrGetString("patname", "g^PatientName"); float zSpacing = am->ArgMgrGetFloat("zSpacing", 1.0); - const char *dirIn = am->ArgMgrGetString("dirin"); + const char *dirIn = am->ArgMgrGetString("dirin"); const char *dirOut = am->ArgMgrGetString("dirout"); - - bool userDefinedStudy = am->ArgMgrDefined("studyUID"); + + bool userDefinedStudy = ( 0 != am->ArgMgrDefined("userDefinedStudy") ); const char *studyUID = am->ArgMgrGetString("studyUID"); // not described *on purpose* in the Usage ! - bool userDefinedSerie = am->ArgMgrDefined("serieUID"); + bool userDefinedSerie = ( 0 != am->ArgMgrDefined("userDefinedSerie") ); + const char *serieUID = am->ArgMgrGetString("serieUID"); - int loadMode = gdcm::LD_ALL; + int loadMode = GDCM_NAME_SPACE::LD_ALL; if ( am->ArgMgrDefined("noshadowseq") ) - loadMode |= gdcm::LD_NOSHADOWSEQ; + loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ; else { if ( am->ArgMgrDefined("noshadow") ) - loadMode |= gdcm::LD_NOSHADOW; + loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW; if ( am->ArgMgrDefined("noseq") ) - loadMode |= gdcm::LD_NOSEQ; + loadMode |= GDCM_NAME_SPACE::LD_NOSEQ; } /* if unused Param we give up */ @@ -155,7 +157,7 @@ int main(int argc, char *argv[]) //std::cout << "dirIn [" << dirIn << "]" << std::endl; - if ( ! gdcm::DirList::IsDirectory(dirIn) ) + if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(dirIn) ) { std::cout << "KO : [" << dirIn << "] is not a Directory." << std::endl; return 0; @@ -171,13 +173,13 @@ int main(int argc, char *argv[]) std::string strDirNameout(dirOut); // to please gcc 4 std::cout << "Check for output directory :[" << dirOut << "]." <SetLoadMode(loadMode); f->SetFileName( it->c_str() ); @@ -240,14 +241,15 @@ int main(int argc, char *argv[]) if ( !f->Load() ) { if (verbose) - std::cout << "fail to load [" << it->c_str() << "]" << std::endl; + std::cout << "fail to load [" << it->c_str() << "]" << std::endl; f->Delete(); continue; } - // Load the pixels in RAM. - - fh = gdcm::FileHelper::New(f); + // Load the pixels in RAM. + + fh = GDCM_NAME_SPACE::FileHelper::New(f); + fh->SetKeepOverlays( true ); uint8_t *imageData = fh->GetImageDataRaw(); // Don't convert (Gray Pixels + LUT) into (RGB pixels) ?!? if (!imageData) std::cout << "fail to read [" << it->c_str() << std::endl; @@ -276,7 +278,7 @@ int main(int argc, char *argv[]) char charImagePosition[256]; - sprintf(charImagePosition,"%f\\0.0\\0.0",zPositionComponent); + sprintf(charImagePosition,"0.0\\0.0\\%f",zPositionComponent); zPositionComponent += zSpacing; if (! f->CheckIfEntryExist(0x0020,0x0032) ) //0020 0032 DS 3 Image Position (Patient) @@ -292,10 +294,10 @@ int main(int argc, char *argv[]) // ================================================================================================== - fh->SetContentType(gdcm::UNMODIFIED_PIXELS_IMAGE); + fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE); - lastFilename = gdcm::Util::GetName( fullFilename ); - std::string fullWriteFilename = strDirNameout + gdcm::GDCM_FILESEPARATOR + lastFilename = GDCM_NAME_SPACE::Util::GetName( fullFilename ); + std::string fullWriteFilename = strDirNameout + GDCM_NAME_SPACE::GDCM_FILESEPARATOR + lastFilename; if (verbose) std::cout << "Write : [" << fullWriteFilename << "]" << std::endl; @@ -309,4 +311,5 @@ int main(int argc, char *argv[]) fh->Delete(); f->Delete(); } + return 1; }