1 /*=========================================================================
4 Module: $RCSfile: exSerieHelper.cxx,v $
6 Date: $Date: 2007/06/22 11:01:57 $
7 Version: $Revision: 1.13 $
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 // Something, using only SerieHelper is not enought !
43 // See also exXcoherentFileSet
46 s = GDCM_NAME_SPACE::SerieHelper::New();
47 s->SetLoadMode(GDCM_NAME_SPACE::LD_ALL); // Load everything for each File
48 //GDCM_NAME_SPACE::TagKey t(0x0020,0x0013);
49 //s->AddRestriction(t, "340", GDCM_NAME_SPACE::GDCM_LESS); // Keep only files where
50 // restriction is true
51 s->SetDirectory(dirName, true); // true : recursive exploration
53 std::cout << " ---------------------------------------- Finish parsing :["
54 << dirName << "]" << std::endl;
57 std::cout << " ---------------------------------------- Finish printing (1)"
61 GDCM_NAME_SPACE::FileList::const_iterator it;
62 GDCM_NAME_SPACE::FileList *l;
63 std::cout << " ---------------------------------------- Recap"
65 l = s->GetFirstSingleSerieUIDFileSet();
69 std::cout << "SerieUID [" << (*it)->GetEntryString(0x0020,0x000e) <<"] Serie Description ["
70 << (*it)->GetEntryString(0x0008,0x103e) << "] "
71 << " : " << l->size() << " files" << std::endl;
72 l = s->GetNextSingleSerieUIDFileSet();
74 std::cout << " ----------------------------------------End Recap"
79 // For all the Single SerieUID Files Sets of the GDCM_NAME_SPACE::Serie
80 l = s->GetFirstSingleSerieUIDFileSet();
84 if ( l->size() > 5 ) // Why not ? Just an example, for testing
86 std::cout << "Sort list : " << nbFiles << " long" << std::endl;
88 //---------------------------------------------------------
89 s->OrderFileList(l); // sort the list (and compute ZSpacing !)
90 //---------------------------------------------------------
92 zspacing = s->GetZSpacing();
93 // Just to show : GetZSpacing from a GDCM_NAME_SPACE::SerieHelper is right
94 std::cout << "GetZSpacing() of sorted SingleSerieUIDFileSet "
95 << "from GDCM_NAME_SPACE::SerieHelper: " << zspacing << std::endl;
96 std::cout << " ('-1' means all the files have the same position)" << std::endl;
97 for (std::vector<GDCM_NAME_SPACE::File* >::iterator it2 = l->begin();
101 // Just to show : GetZSpacing from a GDCM_NAME_SPACE::File may be different
102 std::cout << (*it2)->GetFileName() << " --> GetZSpacing() from GDCM_NAME_SPACE::File : "
103 << (*it2)->GetZSpacing() << std::endl;
106 break; // we only deal with the first one ... Why not ?
108 l = s->GetNextSingleSerieUIDFileSet();
110 std::cout << " ------------------Prints all the Single SerieUID File Sets (sorted or not) -----"
112 s->Print(); // Prints all the Single SerieUID File Sets (sorted or not)
113 std::cout << " -------------------------------------------- Finish printing"