From 3b1f653b219f72d841e3b52ef2ae20d2c7c91220 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 24 Oct 2007 08:03:10 +0000 Subject: [PATCH] Coding style + minor modif --- Example/Dense2007ToDicom.cxx | 31 +++++++++---- Example/SplitIntoXCoherentDirectories.cxx | 48 ++++++++++---------- Example/ToInTag.cxx | 6 +-- Example/exXCoherentFileSet.cxx | 53 ++++++++++------------- 4 files changed, 72 insertions(+), 66 deletions(-) diff --git a/Example/Dense2007ToDicom.cxx b/Example/Dense2007ToDicom.cxx index cb58bb01..6cc49ff6 100755 --- a/Example/Dense2007ToDicom.cxx +++ b/Example/Dense2007ToDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: Dense2007ToDicom.cxx,v $ Language: C++ - Date: $Date: 2007/10/15 13:55:35 $ - Version: $Revision: 1.3 $ + Date: $Date: 2007/10/24 08:03:10 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -603,14 +603,27 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st std::cout << "Max X,Y,Z " << maxX << " " << maxY << " " << maxZ << std::endl; std::cout << "Size X,Y,Z " << maxX-minX << " " << maxY-minY << " " << maxZ-minZ << std::endl; - uint16_t *img = new uint16_t[int(maxX)*int(maxY)]; +// uint16_t *img = new uint16_t[int(maxX+0.5)*int(maxY+0.5)]; + uint16_t *img = new uint16_t[int(maxX*4.)*int(maxY*4.)]; // Set whole image to 0 - for(int i3=0;i3InsertEntryString(str.str(),0x0028,0x0011,"US"); // Columns str.str(""); - str << (int)(maxY); + str << (int)(maxY*4.); file->InsertEntryString(str.str(),0x0028,0x0010,"US"); // Rows // Set the pixel type @@ -657,7 +670,7 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st fileH = GDCM_NAME_SPACE::FileHelper::New(file); // cast is just to avoid warnings (*no* conversion) //fileH->SetImageData((uint8_t *)img,int(maxX*maxY)*sizeof(uint16_t)); // troubles when maxX, mayY are *actually* float! - fileH->SetImageData((uint8_t *)img,int(maxX)*int(maxY)*sizeof(uint16_t)); + fileH->SetImageData((uint8_t *)img,int(maxX*4.)*int(maxY*4.)*sizeof(uint16_t)); fileH->SetWriteModeToRaw(); fileH->SetWriteTypeToDcmExplVR(); diff --git a/Example/SplitIntoXCoherentDirectories.cxx b/Example/SplitIntoXCoherentDirectories.cxx index 4fc1d515..47de2ea0 100755 --- a/Example/SplitIntoXCoherentDirectories.cxx +++ b/Example/SplitIntoXCoherentDirectories.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: SplitIntoXCoherentDirectories.cxx,v $ Language: C++ - Date: $Date: 2007/10/19 11:53:42 $ - Version: $Revision: 1.2 $ + Date: $Date: 2007/10/24 08:03:10 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -34,14 +34,14 @@ int main(int argc, char *argv[]) "usage: exXCoherentFileSet {dirin=inputDirectoryName} ", " dirout=outputDirectoryName ", " { tag=group-elem | pos | ori } [sort] ", - " [{ write | copy }] [studyUID = ] ", + " [{ write | copy }] [studyUID = ] ", " [ { [noshadowseq] | [noshadow][noseq] } ] [debug] ", " ", " dirin : user wants to analyze *all* the files ", " within the directory ", " copy : user wants to copy the files into a directories tree ", " write : user wants to rewrite the files into a directories tree ", - " each directory with the same 'Series Instance UID' ", + " each directory with the same 'Series Instance UID' ", " dirout : will be created if doesn't exist ", " pos : user wants to split each Single SerieUID Fileset on the ", " 'Image Position ' ", @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) bool ori = ( 0 != am->ArgMgrDefined("ori") ); bool sort = ( 0 != am->ArgMgrDefined("sort") ); bool copy = ( 0 != am->ArgMgrDefined("copy") ); - bool write = ( 0 != am->ArgMgrDefined("write") ); + bool write = ( 0 != am->ArgMgrDefined("write") ); bool verbose = ( 0 != am->ArgMgrDefined("verbose") ); bool tag = ( 0 != am->ArgMgrDefined("tag") ); @@ -143,8 +143,7 @@ int main(int argc, char *argv[]) delete am; // ------ we don't need Arguments Manager any longer ------ - - + GDCM_NAME_SPACE::SerieHelper *s; s = GDCM_NAME_SPACE::SerieHelper::New(); @@ -161,26 +160,26 @@ int main(int argc, char *argv[]) { if (verbose) std::cout << *it << std::endl; - + if (write) { loadMode = GDCM_NAME_SPACE::LD_ALL; // load any DataElement maxSize = 0x7fff; // load any length } else { loadMode = GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW ; - maxSize = 0x0100; + maxSize = 0x0100; } f = GDCM_NAME_SPACE::File::New(); f->SetLoadMode(loadMode); - f->SetMaxSizeLoadEntry(maxSize); + f->SetMaxSizeLoadEntry(maxSize); f->SetFileName( *it ); f->Load(); - l->push_back(f); + l->push_back(f); } std::string systemCommand; std::string filenameout; - if (write || copy) { + if (write || copy) { if (verbose) std::cout << "Check for output directory :[" << dirNameout << "]." < End of checking supposed-to-be-directory names int nbFiles; @@ -225,12 +224,12 @@ int main(int argc, char *argv[]) std::string serieUID; std::string currentSerieWriteDir = ""; std::string xCoherentWriteDir = ""; - std::string xCoherentName = ""; + std::string xCoherentName = ""; std::string serieDirectory; std::string lastFilename; std::string rep("_"); int controlCount = 0; - + // 'Study Instance UID' // The user is allowed to create his own Study, // keeping the same 'Study Instance UID' for various images @@ -293,9 +292,9 @@ GDCM_NAME_SPACE::Debug::DebugOn(); xcm = s->SplitOnTagValue(l, groupelem[0],groupelem[1] ); } - + GDCM_NAME_SPACE::FileHelper *fh; - + for (GDCM_NAME_SPACE::XCoherentFileSetmap::iterator i = xcm.begin(); i != xcm.end(); ++i) @@ -334,7 +333,7 @@ GDCM_NAME_SPACE::Debug::DebugOn(); // OrderFileList() causes trouble, since some files // (eg:MIP views) don't have 'Position', now considered as mandatory // --> Activated on user demand. - + if (sort) { s->OrderFileList((*i).second); // sort the XCoherent Fileset std::cout << "ZSpacing for the file set " << s->GetZSpacing() @@ -353,10 +352,10 @@ GDCM_NAME_SPACE::Debug::DebugOn(); // --- for write lastFilename = GDCM_NAME_SPACE::Util::GetName( fileName ); - filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename; + filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename; if (write) { - fh = GDCM_NAME_SPACE::FileHelper::New( (*it2) ); + fh = GDCM_NAME_SPACE::FileHelper::New( (*it2) ); fh->SetKeepOverlays( true ); fh->InsertEntryString(strSerieUID,0x0020,0x000e,"UI"); unsigned int dataSize = fh->GetImageDataRawSize(); @@ -371,16 +370,15 @@ GDCM_NAME_SPACE::Debug::DebugOn(); << std::endl; } fh->Delete(); - } + } else if (copy) { systemCommand = "cp " + fileName + " " + filenameout; system( systemCommand.c_str()); - } + } if (verbose) std::cout << "3 " << systemCommand << std::endl; - } - + } std::cout << std::endl; } } @@ -388,7 +386,7 @@ GDCM_NAME_SPACE::Debug::DebugOn(); if ( controlCount == 0 ) std::cout << "No suitable file was found!" << std::endl; - + s->Delete(); return 0; } diff --git a/Example/ToInTag.cxx b/Example/ToInTag.cxx index 8d2ae3ea..1b4f292d 100755 --- a/Example/ToInTag.cxx +++ b/Example/ToInTag.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: ToInTag.cxx,v $ Language: C++ - Date: $Date: 2007/09/28 14:09:20 $ - Version: $Revision: 1.19 $ + Date: $Date: 2007/10/24 08:03:10 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -599,7 +599,7 @@ int main(int argc, char *argv[]) + GDCM_NAME_SPACE::GDCM_FILESEPARATOR + currentPhaseEncodingDirection; systemCommand = "mkdir " + currentPhaseEncodingDirectionWriteDir; - system (systemCommand.c_str()); + system (systemCommand.c_str()); } previousPhaseEncodingDirection = currentPhaseEncodingDirection; diff --git a/Example/exXCoherentFileSet.cxx b/Example/exXCoherentFileSet.cxx index f4949fea..3604db07 100755 --- a/Example/exXCoherentFileSet.cxx +++ b/Example/exXCoherentFileSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exXCoherentFileSet.cxx,v $ Language: C++ - Date: $Date: 2007/10/19 15:15:16 $ - Version: $Revision: 1.13 $ + Date: $Date: 2007/10/24 08:03:10 $ + Version: $Revision: 1.14 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,12 +21,9 @@ #include #include "gdcmDirList.h" #include "gdcmUtil.h" - #include "gdcmArgMgr.h" - - int main(int argc, char *argv[]) -{ +{ START_USAGE(usage) "\n exXCoherentFileSet :\n ", @@ -53,7 +50,7 @@ int main(int argc, char *argv[]) " noshadowseq: user doesn't want to load Private Sequences ", " noshadow : user doesn't want to load Private groups (odd number) ", " noseq : user doesn't want to load Sequences ", - " verbose : user wants to run the program in 'verbose mode' ", + " verbose : user wants to run the program in 'verbose mode' ", " debug : developper wants to run the program in 'debug mode' ", FINISH_USAGE @@ -74,7 +71,7 @@ int main(int argc, char *argv[]) int loadMode = GDCM_NAME_SPACE::LD_ALL; if ( am->ArgMgrDefined("noshadowseq") ) loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ; - else + else { if ( am->ArgMgrDefined("noshadow") ) loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW; @@ -144,17 +141,17 @@ int main(int argc, char *argv[]) s = GDCM_NAME_SPACE::SerieHelper::New(); s->SetLoadMode(GDCM_NAME_SPACE::LD_ALL); // Load everything for each File - //GDCM_NAME_SPACE::TagKey t(0x0020,0x0013); + //GDCM_NAME_SPACE::TagKey t(0x0020,0x0013); //s->AddRestriction(t, "340", GDCM_NAME_SPACE::GDCM_LESS); // Keep only files where // restriction is true - + s->SetDirectory(dirName, true); // true : recursive exploration // The Dicom file set is splitted into several 'Single SerieUID Files Sets' // (a 'Single SerieUID Files Set' per SerieUID) // In some cases, it's not enough, since, in some cases // we can find scout view with the same SerieUID - + /* std::cout << " ---------------------------------------- " << "'Single UID' Filesets found in :[" @@ -166,8 +163,8 @@ int main(int argc, char *argv[]) */ std::string systemCommand; - std::string filenameout; - if (write) { + std::string filenameout; + if (write) { if (verbose) std::cout << "Check for output directory :[" << dirNameout << "]." < End of checking supposed-to-be-directory names - + int nbFiles; std::string fileName; - + // For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie GDCM_NAME_SPACE::FileList *l = s->GetFirstSingleSerieUIDFileSet(); - GDCM_NAME_SPACE::XCoherentFileSetmap xcm; - + std::string serieUID; std::string currentSerieWriteDir = ""; - std::string xCoherentWriteDir = ""; - std::string xCoherentName = ""; + std::string xCoherentWriteDir = ""; + std::string xCoherentName = ""; std::string serieDirectory; std::string lastFilename; - std::string rep("_"); + std::string rep("_"); int controlCount = 0; while (l) // for each 'Single SerieUID FileSet' @@ -265,7 +260,7 @@ int main(int argc, char *argv[]) i != xcm.end(); ++i) { - xCoherentName = (*i).first; + xCoherentName = (*i).first; if (verbose) std::cout << "xCoherentName = " << xCoherentName << std::endl; GDCM_NAME_SPACE::Util::ReplaceSpecChar(serieUID, rep); @@ -299,7 +294,7 @@ int main(int argc, char *argv[]) // OrderFileList() causes trouble, since some files // (eg:MIP views) don't have 'Position', now considered as mandatory // Commented out for the moment. - + if (sort) { s->OrderFileList((*i).second); // sort the XCoherent Fileset std::cout << "ZSpacing for the file set " << s->GetZSpacing() @@ -318,14 +313,14 @@ int main(int argc, char *argv[]) if (write) { lastFilename = GDCM_NAME_SPACE::Util::GetName( fileName ); - filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename; + filenameout = xCoherentWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR+ lastFilename; systemCommand = "cp " + fileName + " " + filenameout; system( systemCommand.c_str()); if (verbose) std::cout << "3 " << systemCommand << std::endl; - } + } // --- end for write - } + } std::cout << std::endl; } } @@ -334,7 +329,7 @@ int main(int argc, char *argv[]) if ( controlCount == 0 ) std::cout << "No suitable file was found!" << std::endl; - + s->Delete(); return 0; -- 2.45.0