]> Creatis software - gdcm.git/blob - Testing/TestDict.cxx
Fix mistypings
[gdcm.git] / Testing / TestDict.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestDict.cxx,v $
5   Language:  C++
6   Date:      $Date: 2007/05/23 14:18:06 $
7   Version:   $Revision: 1.13 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18 #include "gdcmGlobal.h"
19 #include "gdcmDictSet.h"
20 #include "gdcmDict.h"
21 #include "gdcmDictEntry.h"
22
23 #include <iostream>
24 #include <iomanip>
25
26 int TestDict(int , char *[])
27
28
29    std::cout << "----- Test Default Dicom Dictionary : ----------" << std::endl;
30    // Just to improve test coverage:
31    GDCM_NAME_SPACE::Dict *tempDict = GDCM_NAME_SPACE::Dict::New("dummyFileNameThatDoesntExist");
32    // Default dict is supposed to be used.
33    tempDict->Print();
34    std::cout << "---- end Test Default Dicom Dictionary : -------" << std::endl;
35
36    // Lets delete it.
37    tempDict->Delete();
38
39  
40    // Print the DictSet
41    std::cout<<"#######################################################\n";
42    GDCM_NAME_SPACE::DictSet *dicts=GDCM_NAME_SPACE::Global::GetDicts();
43    if(!dicts)
44    {
45       std::cout<<"DictSet hasn't be found... Failed\n";
46       return(1);
47    }
48
49    std::cout<<"DictSet content :\n";
50
51    GDCM_NAME_SPACE::Dict *d = dicts->GetFirstDict();
52    if (!d)
53    {
54       std::cout << "Dictset is empty" << std::endl;
55       return 1;
56    }
57
58    std::cout << "----------- Print DictSet contents: ----------" << std::endl;
59    dicts->Print();
60    std::cout << "----------- End Print DictSet contents: ------" << std::endl;
61
62    while (d)
63    {
64       std::cout << "------------- a Dict is found : ----------" << std::endl;
65       d->Print();
66       d = dicts->GetNextDict();
67    }
68
69    // Print the Dict (public)
70    std::cout<<"#######################################################\n";
71    GDCM_NAME_SPACE::Dict *pubDict=dicts->GetDefaultPubDict();
72    if(!pubDict)
73    {
74       std::cout<<"The public Dict hasn't be found... Failed\n";
75       return(1);
76    }
77    std::cout<<"Public Dict content :\n";
78 //   pubDict->Print();
79
80    // Print the DictEntry (0x10,0x20)
81    std::cout<<"#######################################################\n";
82    const int ENTRY_GR = 0x10;
83    const int ENTRY_EL = 0x20;
84    GDCM_NAME_SPACE::TagKey key = GDCM_NAME_SPACE::DictEntry::TranslateToKey(ENTRY_GR,ENTRY_EL);
85    GDCM_NAME_SPACE::DictEntry *entry=pubDict->GetEntry(ENTRY_GR,ENTRY_EL);
86    if(!entry)
87    {
88       std::cout<<"The DictEntry hasn't be found... Failed\n";
89       return(1);
90    }
91    std::cout<<"Entry "<<key<<" content :\n";
92    entry->Print();
93
94    // Print all the DictEntry
95    std::cout<<"#######################################################\n";
96    entry=pubDict->GetFirstEntry();
97    while(entry)
98    {
99       std::cout << std::hex << entry->GetGroup() << "|" << entry->GetElement()
100                 << " [" << entry->GetVR() << "] - VM [" << entry->GetVM()
101                 << "] : " << entry->GetName() << " ( " << entry->GetKey() << ")\n";
102       entry=pubDict->GetNextEntry();
103    }
104
105 /*   // Let's play with DicEntry stuff !
106    // First, we try to break an Entry.
107    entry=pubDict->GetFirstEntry();
108    entry->SetVR("PN");
109    // Should warn us !*/
110
111    return(0);
112 }