From: jpr Date: Wed, 2 Nov 2005 10:08:18 +0000 (+0000) Subject: exXCoherentFileSet can be used to check splitting on a given Tag value. X-Git-Tag: OpenJPEG.Version1.2~91 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=69154413fff2862b6f9c9e68d097eb772e258e74;p=gdcm.git exXCoherentFileSet can be used to check splitting on a given Tag value. --- diff --git a/Example/exXCoherentFileSet.cxx b/Example/exXCoherentFileSet.cxx index ce0ad133..b2af110e 100755 --- a/Example/exXCoherentFileSet.cxx +++ b/Example/exXCoherentFileSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exXCoherentFileSet.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 15:57:20 $ - Version: $Revision: 1.1 $ + Date: $Date: 2005/11/02 10:08:18 $ + Version: $Revision: 1.2 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,27 +20,108 @@ #include "gdcmDebug.h" #include +#include "gdcmArgMgr.h" + int main(int argc, char *argv[]) { - gdcm::SerieHelper *s; + + START_USAGE(usage) + "\n exXCoherentFileSet :\n ", + "Shows the various 'XCoherent' Filesets within a directory ", + "usage: exXCoherentFileSet {dirin=inputDirectoryName} ", + " { tag= group-elem | pos | ori } ", + " [ { [noshadowseq] | [noshadow][noseq] } ] [debug] ", + " ", + " inputDirectoryName : user wants to analyze *all* the files ", + " within the directory ", + " pos : user wants to split each Single SerieUID Fileset on the ", + " 'Image Position ' ", + " ori : user wants to split each Single SerieUID Fileset on the ", + " 'Image Orientation ' ", + " tag : group-elem (in hexa, no space) ", + " the user wants to split on ", + " 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 ", + " debug : user wants to run the program in 'debug mode' ", + FINISH_USAGE + + // ----- Initialize Arguments Manager ------ - std::string dirName; - if (argc > 1) - dirName = argv[1]; - else + gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv); + + if (am->ArgMgrDefined("usage") || argc == 1) { - dirName = GDCM_DATA_ROOT; + am->ArgMgrUsage(usage); // Display 'usage' + delete am; + return 0; } - if (argc > 2) + if (am->ArgMgrDefined("debug")) gdcm::Debug::DebugOn(); + + int loadMode = gdcm::LD_ALL; + if ( am->ArgMgrDefined("noshadowseq") ) + loadMode |= gdcm::LD_NOSHADOWSEQ; + else + { + if ( am->ArgMgrDefined("noshadow") ) + loadMode |= gdcm::LD_NOSHADOW; + if ( am->ArgMgrDefined("noseq") ) + loadMode |= gdcm::LD_NOSEQ; + } + + char *dirName = am->ArgMgrGetString("dirin",(char *)0); + if (dirName == 0) + { + std::cout <ArgMgrDefined("pos"); + bool ori = am->ArgMgrDefined("ori"); + bool tag = am->ArgMgrDefined("tag"); + + int nb; + uint16_t *groupelem; + if (tag) + { + groupelem = am->ArgMgrGetXInt16Enum("tag", &nb); + if (nb != 1) + { + std::cout << "TAG : one and only one group,elem!" << std::endl; + delete am; + return 0; + } + } + + + /* if unused Param we give up */ + if ( am->ArgMgrPrintUnusedLabels() ) + { + am->ArgMgrUsage(usage); + delete am; + return 0; + } + + delete am; // ------ we don't need Arguments Manager any longer ------ + + + gdcm::SerieHelper *s; + s = new gdcm::SerieHelper(); s->SetLoadMode(gdcm::LD_ALL); // Load everything for each File //s->AddRestriction(tagKey, valueToCheck); // Keep only files where // restriction is true s->SetDirectory(dirName, true); // true : recursive exploration +/* std::cout << " ---------------------------------------- " << "'Single UID' Filesets found in :[" << dirName << "]" << std::endl; @@ -48,11 +129,13 @@ int main(int argc, char *argv[]) s->Print(); std::cout << " ------------------------------------- Result after splitting" << std::endl; - +*/ int nbFiles; std::string fileName; // For all the Single SerieUID Files Sets of the gdcm::Serie gdcm::FileList *l = s->GetFirstSingleSerieUIDFileSet(); + + gdcm::XCoherentFileSetmap xcm; while (l) { nbFiles = l->size() ; @@ -61,19 +144,33 @@ int main(int argc, char *argv[]) std::cout << "Split the 'Single SerieUID' FileSet :[" << s->GetCurrentSerieUIDFileSetUID() << "] " << nbFiles << " long" << std::endl; - std::cout << "-----------------------------------" << std::endl; - gdcm::XCoherentFileSetmap xcm = s->SplitOnOrientation(l); - //gdcm::XCoherentFileSetmap xcm = s->SplitOnPosition(l); - + std::cout << "-----------------------------------" << std::endl; + + if (ori) + xcm = s->SplitOnOrientation(l); + if (pos) + xcm = s->SplitOnPosition(l); + if (tag) + xcm = s->SplitOnTagValue(l, groupelem[0],groupelem[1] ); + for (gdcm::XCoherentFileSetmap::iterator i = xcm.begin(); i != xcm.end(); ++i) { - std::cout << "Orientation : [" << (*i).first << "]" << std::endl; + if (ori) + std::cout << "Orientation : "; + if (pos) + std::cout << "Position : "; + if (tag) + std::cout << "Tag (" << std::hex << groupelem[0] + << "|" << groupelem[1] << ") value : "; + + std::cout << "[" << (*i).first << "]" << std::endl; // Nowadays OrderFileList() causes trouble, since some files // (MIP views) don't have 'Position', now considered as mandatory - // Commented out for the moment. + // Commented out for the moment. + //s->OrderFileList((*i).second); // sort the XCoherent Fileset for (std::vector::iterator it = ((*i).second)->begin();