1 /*=========================================================================
4 Module: $RCSfile: exSerieHelper.cxx,v $
6 Date: $Date: 2007/05/31 12:22:46 $
7 Version: $Revision: 1.10 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
18 #include "gdcmSerieHelper.h"
20 #include "gdcmDirList.h" // for FileList
21 #include "gdcmDebug.h"
24 int main(int argc, char *argv[])
26 GDCM_NAME_SPACE::SerieHelper *s;
33 dirName = GDCM_DATA_ROOT;
37 GDCM_NAME_SPACE::Debug::DebugOn();
40 std::cout << "Dir Name :[" << dirName << "]" << std::endl;
42 s = GDCM_NAME_SPACE::SerieHelper::New();
43 s->SetLoadMode(GDCM_NAME_SPACE::LD_ALL); // Load everything for each File
44 //GDCM_NAME_SPACE::TagKey t(0x0020,0x0013);
45 //s->AddRestriction(t, "340", GDCM_NAME_SPACE::GDCM_LESS); // Keep only files where
46 // restriction is true
47 s->SetDirectory(dirName, true); // true : recursive exploration
49 std::cout << " ---------------------------------------- Finish parsing :["
50 << dirName << "]" << std::endl;
53 std::cout << " ---------------------------------------- Finish printing (1)"
57 GDCM_NAME_SPACE::FileList::const_iterator it;
58 GDCM_NAME_SPACE::FileList *l;
59 std::cout << " ---------------------------------------- Recap"
61 l = s->GetFirstSingleSerieUIDFileSet();
65 std::cout << "SerieUID [" << (*it)->GetEntryString(0x0020,0x000e) <<"] Serie Description ["
66 << (*it)->GetEntryString(0x0008,0x103e) << "] "
67 << " : " << l->size() << " files" << std::endl;
68 l = s->GetNextSingleSerieUIDFileSet();
70 std::cout << " ----------------------------------------End Recap"
74 // For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie
75 l = s->GetFirstSingleSerieUIDFileSet();
79 if ( l->size() > 5 ) // Why not ? Just an example, for testing
81 std::cout << "Sort list : " << nbFiles << " long" << std::endl;
82 s->OrderFileList(l); // sort the list
83 // Just to show : GetZSpacing from a gdcm::SerieHelper is right
84 std::cout << "GetZSpacing() of sorted SingleSerieUIDFileSet "
85 << "from gdcm::SerieHelper: " << s->GetZSpacing() << std::endl;
86 std::cout << " ('-1' means all the files have the same position)" << std::endl;
87 for (std::vector<GDCM_NAME_SPACE::File* >::iterator it = l->begin();
91 // Just to show : GetZSpacing from a gdcm::File may be different
92 std::cout << (*it)->GetFileName() << " --> GetZSpacing() from gdcm::File : "
93 << (*it)->GetZSpacing() << std::endl;
96 break; // we only deal with the first one ... Why not ?
98 l = s->GetNextSingleSerieUIDFileSet();
100 std::cout << " ------------------Prints all the Single SerieUID File Sets (sorted or not) -----"
102 s->Print(); // Prints all the Single SerieUID File Sets (sorted or not)
103 std::cout << " -------------------------------------------- Finish printing"