Program: gdcm
Module: $RCSfile: exXCoherentFileSet.cxx,v $
Language: C++
- Date: $Date: 2007/10/01 09:33:20 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2007/10/30 14:55:20 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include <iostream>
#include "gdcmDirList.h"
#include "gdcmUtil.h"
-
#include "gdcmArgMgr.h"
-
-
int main(int argc, char *argv[])
-{
+{
START_USAGE(usage)
"\n exXCoherentFileSet :\n ",
"Shows the various 'XCoherent' Filesets within a directory ",
- "Optionaly copis the images in a Directories tree ",
+ "Optionaly copies the images in a Directories tree ",
"usage: exXCoherentFileSet {dirin=inputDirectoryName} ",
" dirout=outputDirectoryName ",
" { tag=group-elem | pos | ori } [sort] [write] ",
" 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
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;
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 :["
*/
std::string systemCommand;
- std::string filenameout;
- if (write) {
+ std::string filenameout;
+ if (write) {
if (verbose)
std::cout << "Check for output directory :[" << dirNameout << "]."
<<std::endl;
else
{
if (verbose)
- std::cout << "Output Directory [" << dirNameout
+ std::cout << "Output Directory [" << dirNameout
<< "] already exists; Used as is."
<< std::endl;
- }
+ }
}
-
// --> 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'
if (write)
{
currentSerieWriteDir = currentSerieWriteDir + dirNameout;
- unsigned int l = strlen(dirNameout)-1;
- if ( dirNameout[l] != '/' && dirNameout[l] != '\\')
+ unsigned int lg = strlen(dirNameout)-1;
+ if ( dirNameout[lg] != '/' && dirNameout[lg] != '\\')
currentSerieWriteDir = currentSerieWriteDir + GDCM_NAME_SPACE::GDCM_FILESEPARATOR;
currentSerieWriteDir = currentSerieWriteDir + serieUID;
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);
// 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()
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;
}
}
if ( controlCount == 0 )
std::cout << "No suitable file was found!" << std::endl;
-
+
s->Delete();
return 0;