From 592d64a8f955928fd68eac07d74e72c89a8e01d3 Mon Sep 17 00:00:00 2001 From: jpr Date: Tue, 25 Oct 2005 15:57:20 +0000 Subject: [PATCH] Commit *very first* version of an example for using the splitting of a 'single SerieUID' fileset depending on the 'Orientation' --- Example/exXCoherentFileSet.cxx | 95 ++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 Example/exXCoherentFileSet.cxx diff --git a/Example/exXCoherentFileSet.cxx b/Example/exXCoherentFileSet.cxx new file mode 100755 index 00000000..ce0ad133 --- /dev/null +++ b/Example/exXCoherentFileSet.cxx @@ -0,0 +1,95 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: exXCoherentFileSet.cxx,v $ + Language: C++ + Date: $Date: 2005/10/25 15:57:20 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "gdcmSerieHelper.h" +#include "gdcmFile.h" +#include "gdcmDebug.h" +#include + +int main(int argc, char *argv[]) +{ + gdcm::SerieHelper *s; + + std::string dirName; + if (argc > 1) + dirName = argv[1]; + else + { + dirName = GDCM_DATA_ROOT; + } + + if (argc > 2) + gdcm::Debug::DebugOn(); + + 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; + + 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(); + while (l) + { + nbFiles = l->size() ; + if ( l->size() > 3 ) // Why not ? Just an example, for testing + { + 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); + + for (gdcm::XCoherentFileSetmap::iterator i = xcm.begin(); + i != xcm.end(); + ++i) + { + std::cout << "Orientation : [" << (*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. + //s->OrderFileList((*i).second); // sort the XCoherent Fileset + + for (std::vector::iterator it = ((*i).second)->begin(); + it != ((*i).second)->end(); + ++it) + { + fileName = (*it)->GetFileName(); + std::cout << " " << fileName << std::endl; + } + std::cout << std::endl; + } + } + l = s->GetNextSingleSerieUIDFileSet(); + } + + delete s; + + return 0; +} -- 2.45.1