2 //-----------------------------------------------------------------------------
6 #include "gdcmCommon.h"
7 #include "gdcmGlobal.h"
8 #include "gdcmDocEntrySet.h"
9 #include "gdcmException.h"
10 #include "gdcmDocEntry.h"
11 #include "gdcmSeqEntry.h"
12 #include "gdcmValEntry.h"
13 #include "gdcmBinEntry.h"
15 //-----------------------------------------------------------------------------
16 // Constructor / Destructor
18 * \ingroup gdcmDocEntrySet
19 * \brief Constructor from a given gdcmDocEntrySet
21 gdcmDocEntrySet::gdcmDocEntrySet() {
24 * \brief Canonical destructor.
26 gdcmDocEntrySet::~gdcmDocEntrySet(){
28 //-----------------------------------------------------------------------------
31 * \ingroup gdcmDocEntrySet
32 * \brief canonical Printer
36 //-----------------------------------------------------------------------------
38 //bool gdcmDocEntrySet::AddEntry(gdcmDocEntry *Entry){return true;}
40 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
48 * \brief Parses an EntrySet (Document header or SQ Item )
49 * \ and load element values (a voir !)
50 * @return false anything wrong happens
53 /* just to keep the code
55 bool gdcmDocEntrySet::LoadDocEntrySet(bool exception_on_error)
56 throw(gdcmFormatError) {
57 (void)exception_on_error;
59 gdcmDocEntry *newDocEntry = (gdcmDocEntry *)0;
60 gdcmValEntry *newValEntry = (gdcmValEntry *)0;
61 gdcmBinEntry *newBinEntry = (gdcmBinEntry *)0;
62 gdcmSeqEntry *newSeqEntry = (gdcmSeqEntry *)0;
65 while (newDocEntry = ReadNextDocEntry()) {
66 // TODO (?) : liberation du DocEntry ainsi cree,
67 // apres copie dans un ValEntry, SeqEntry, BinEntry
68 vr = newDocEntry->GetVR();
73 newSeqEntry = new gdcmSeqEntry((gdcmDictEntry*)NULL);
75 dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
76 "failed to allocate gdcmSeqEntry");
79 newSeqEntry->Copy(newDocEntry);
81 // SEQUENCE; appel 'récursif' de ??? pour charger la 'valeur'
82 // (ensemble d' ITEMs, en fait,
83 // chaque ITEM etant chargé avec LoadDocEntrySet)
85 //SkipDocEntry(newSeqEntry); // voir ce qu'on fait pour une SeQuence
86 AddEntry(newSeqEntry); // on appele la fonction generique,
87 // ou une fonction spécialisée ?
89 } else if (vr == "AE" || vr == "AS" || vr == "DA" || vr == "PN" ||
90 vr == "UI" || vr == "TM" || vr == "SH" || vr == "LO" ||
91 vr == "CS" || vr == "IS" || vr == "LO" || vr == "LT" ||
92 vr == "SH" || vr == "ST" ||
93 vr == "SL" || vr == "SS" || vr == "UL" || vr == "US"
97 newValEntry = new gdcmValEntry((gdcmDictEntry*)NULL);
99 dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
100 "failed to allocate gdcmValEntry");
103 newValEntry->Copy(newDocEntry);
104 //SkipDocEntry(newValEntry); //le skip devrait etre fait dans le Read
105 AddEntry(newValEntry); // on appele la fonction generique,
106 // ou une fonction spécialisée ?
108 // Maybe the following VR do correspond to a BinEntry
110 //AT Attribute Tag; // 2 16-bit unsigned short integers
111 //FL Floating Point Single; // 32-bit IEEE 754:1985 float
112 //FD Floating Point Double; // 64-bit IEEE 754:1985 double
113 //UN Unknown; // Any length of bytes
114 //UT Unlimited Text; // At most 2^32 -1 chars
115 //OB Other Byte String; // String of bytes (VR independant)
116 //OW Other Word String; // String of 16-bit words (VR dependant)
120 newBinEntry = new gdcmBinEntry((gdcmDictEntry*)NULL);
122 dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
123 "failed to allocate gdcmBinEntry");
126 newBinEntry->Copy(newDocEntry);
127 // SkipDocEntry(newBinEntry); //le skip devrait etre fait dans le Read
128 AddEntry(newBinEntry); // on appele la fonction generique,
129 // ou une fonction spécialisée ?
135 // TODO : il n'y a plus de Chained List qui contient toutes les Entries
136 // Le chargement des valeurs devra se faire à la volée
137 // Be carefull : merging this two loops may cause troubles ...
141 for (ListTag::iterator i = GetListEntry().begin();
142 i != GetListEntry().end();
151 /* TO DO : deporter den fin de parsing du DOCUMENT (pas du EntrySet)
153 // --------------------------------------------------------------
154 // Special Patch to allow gdcm to read ACR-LibIDO formated images
156 // if recognition code tells us we deal with a LibIDO image
157 // we switch lineNumber and columnNumber
160 RecCode = GetEntryByNumber(0x0008, 0x0010); // recognition code
161 if (RecCode == "ACRNEMA_LIBIDO_1.1" ||
162 RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares
163 // with "little-endian strings"
165 filetype = ACR_LIBIDO;
166 std::string rows = GetEntryByNumber(0x0028, 0x0010);
167 std::string columns = GetEntryByNumber(0x0028, 0x0011);
168 SetEntryByNumber(columns, 0x0028, 0x0010);
169 SetEntryByNumber(rows , 0x0028, 0x0011);
171 // ----------------- End of Special Patch ----------------
182 //-----------------------------------------------------------------------------