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 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
49 * \brief Parses an EntrySet (Document header or SQ Item )
50 * \ and load element values (a voir !)
51 * @return false anything wrong happens
54 /* just to keep the code
56 bool gdcmDocEntrySet::LoadDocEntrySet(bool exception_on_error)
57 throw(gdcmFormatError) {
58 (void)exception_on_error;
60 gdcmDocEntry *newDocEntry = (gdcmDocEntry *)0;
61 gdcmValEntry *newValEntry = (gdcmValEntry *)0;
62 gdcmBinEntry *newBinEntry = (gdcmBinEntry *)0;
63 gdcmSeqEntry *newSeqEntry = (gdcmSeqEntry *)0;
66 while (newDocEntry = ReadNextDocEntry()) {
67 // TODO (?) : liberation du DocEntry ainsi cree,
68 // apres copie dans un ValEntry, SeqEntry, BinEntry
69 vr = newDocEntry->GetVR();
74 newSeqEntry = new gdcmSeqEntry((gdcmDictEntry*)NULL);
76 dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
77 "failed to allocate gdcmSeqEntry");
80 newSeqEntry->Copy(newDocEntry);
82 // SEQUENCE; appel 'récursif' de ??? pour charger la 'valeur'
83 // (ensemble d' ITEMs, en fait,
84 // chaque ITEM etant chargé avec LoadDocEntrySet)
86 //SkipDocEntry(newSeqEntry); // voir ce qu'on fait pour une SeQuence
87 AddEntry(newSeqEntry); // on appele la fonction generique,
88 // ou une fonction spécialisée ?
90 } else if (vr == "AE" || vr == "AS" || vr == "DA" || vr == "PN" ||
91 vr == "UI" || vr == "TM" || vr == "SH" || vr == "LO" ||
92 vr == "CS" || vr == "IS" || vr == "LO" || vr == "LT" ||
93 vr == "SH" || vr == "ST" ||
94 vr == "SL" || vr == "SS" || vr == "UL" || vr == "US"
98 newValEntry = new gdcmValEntry((gdcmDictEntry*)NULL);
100 dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
101 "failed to allocate gdcmValEntry");
104 newValEntry->Copy(newDocEntry);
105 //SkipDocEntry(newValEntry); //le skip devrait etre fait dans le Read
106 AddEntry(newValEntry); // on appele la fonction generique,
107 // ou une fonction spécialisée ?
109 // Maybe the following VR do correspond to a BinEntry
111 //AT Attribute Tag; // OK // 2 16-bit unsigned short integers
112 //FL Floating Point Single; // 32-bit IEEE 754:1985 float
113 //FD Floating Point Double; // 64-bit IEEE 754:1985 double
114 //UN Unknown; // Any length of bytes
115 //UT Unlimited Text; // At most 2^32 -1 chars
116 //OB Other Byte String; // String of bytes (VR independant)
117 //OW Other Word String; // String of 16-bit words (VR dependant)
121 newBinEntry = new gdcmBinEntry((gdcmDictEntry*)NULL);
123 dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
124 "failed to allocate gdcmBinEntry");
127 newBinEntry->Copy(newDocEntry);
128 // SkipDocEntry(newBinEntry); //le skip devrait etre fait dans le Read
129 AddEntry(newBinEntry); // on appele la fonction generique,
130 // ou une fonction spécialisée ?
136 // TODO : il n'y a plus de Chained List qui contient toutes les Entries
137 // Le chargement des valeurs devra se faire à la volée
138 // Be carefull : merging this two loops may cause troubles ...
142 for (ListTag::iterator i = GetListEntry().begin();
143 i != GetListEntry().end();
152 /* TO DO : deporter den fin de parsing du DOCUMENT (pas du EntrySet)
154 // --------------------------------------------------------------
155 // Special Patch to allow gdcm to read ACR-LibIDO formated images
157 // if recognition code tells us we deal with a LibIDO image
158 // we switch lineNumber and columnNumber
161 RecCode = GetEntryByNumber(0x0008, 0x0010); // recognition code
162 if (RecCode == "ACRNEMA_LIBIDO_1.1" ||
163 RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares
164 // with "little-endian strings"
166 filetype = ACR_LIBIDO;
167 std::string rows = GetEntryByNumber(0x0028, 0x0010);
168 std::string columns = GetEntryByNumber(0x0028, 0x0011);
169 SetEntryByNumber(columns, 0x0028, 0x0010);
170 SetEntryByNumber(rows , 0x0028, 0x0011);
172 // ----------------- End of Special Patch ----------------
183 //-----------------------------------------------------------------------------