From: jpr Date: Wed, 5 May 2004 07:45:55 +0000 (+0000) Subject: The shows goes on X-Git-Tag: Version0.5.bp~188 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=5154dc89c0a2a565e9e79024ba8910f405279dd2;p=gdcm.git The shows goes on --- diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index ffd36020..7351409e 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -133,7 +133,7 @@ void gdcmDocEntry::Print(std::ostream & os) { /** * \ingroup gdcmDocEntry - * \brief Gets the full length of the HeaderEntry (not only value length) + * \brief Gets the full length of the DocEntry (not only value length) */ guint32 gdcmDocEntry::GetFullLength(void) { guint32 l; @@ -148,6 +148,21 @@ guint32 gdcmDocEntry::GetFullLength(void) { return(l); } +/** + * \ingroup gdcmDocEntry + * \brief Copies all the attributes from an other DocEntry + */ + +void Copy (gdcmDocEntry* e) { + this->entry = e->entry; + this->UsableLength = e->UsableLength; + this->ReadLength = e->ReadLength; + this->ImplicitVR = e->ImplicitVR; + this->Offset = e->Offset; + this->printLevel = e->printLevel; + this->SQDepthLevel = e->SQDepthLevel; +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index e412e5fd..18decf01 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -122,6 +122,8 @@ public: guint32 GetFullLength(void); + void Copy(gdcmDocEntry *doc); + private: // FIXME: In fact we should be more specific and use : // friend gdcmDocEntry * gdcmHeader::ReadNextElement(void); diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index 605df95a..e0266a54 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -48,99 +48,77 @@ bool gdcmDocument::LoadDocEntrySet(bool exception_on_error) throw(gdcmFormatErro if (!CheckSwap()) return false; - guint16 g, n; + gdcmDocEntry *newDocEntry = (gdcmDocEntry *)0; gdcmValEntry *newValEntry = (gdcmValEntry *)0; gdcmBinEntry *newBinEntry = (gdcmBinEntry *)0; gdcmSeqEntry *newSeqEntry = (gdcmSeqEntry *)0; - gdcmDictEntry *NewTag = (gdcmDictEntry *)0; - char VR[3]; - long PositionOnEntry; - -// while ( (newHeaderEntry = ReadNextHeaderEntry()) ) { - while (1) { - - // ----------------------- was ReadNextHeaderEntry ----------------- - g = ReadInt16(); - n = ReadInt16(); - if (errno == 1) - // We reached the EOF (or an error occured) therefore - // header parsing has to be considered as finished. - break; - - // Find out if the tag we encountered is in the dictionaries: - DictEntry = GetDictEntryByNumber(Group, Elem); - if (!DictEntry) - DictEntry = NewVirtualDictEntry(Group, Elem); - if (!DictEntry) { + //gdcmDictEntry *NewTag = (gdcmDictEntry *)0; + + while (newDocEntry = ReadNextDocEntry())) { + // TODO (?) : liberation du DocEntry ainsi cree, + // apres copie dans un ValEntry, SeqEntry, BinEntry + vr = newDocEntry->getVR(); + + if (vr == "SQ" ) { + // --- SeqEntry + + newSeqEntry = (gdcmSeqEntry *)0; + if (!NewSeqEntry) { dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet", - "failed to allocate gdcmDictEntry"); + "failed to allocate gdcmSeqEntry"); return false; - } - - // Right now, - vr = DictEntry->GetVR(); // Suppose we get it, suppose it's the same one - // that's in the Explicit VR part of the Header - // TODO - // Resoudre pb quand inadequation entre Explicit VR et Dict - - if (filetype != ExplicitVR) {} // jamais de risque de conflit - // pour les autres cas, - // refaire l'equiv de gdcmParser::FindHeaderEntryVR - // qui contient CheckHeaderEntryVR - // le pb, c'est qu'on a besoin de la VR pour fabriquer l'Entry - - if (vr == "SQ" ) { - // --- SeqEntry + } + newSeqEntry->Copy(newDocEntry); // TODO // SEQUENCE; appel 'récursif' de ??? pour charger la 'valeur' // (ensemble d' ITEMs, en fait, // chaque ITEM etant chargé avec LoadDocEntrySet) - - + + SkipDocEntry(newSeqEntry); // voir ce qu'on fait pour une SeQuence + AddDocEntry(newSeqEntry); + } else if (vr == "AE" || vr == "AS" || vr == "DA" || vr == "PN" || - vr == "UI" || vr == "TM" ) { - // --- ValEntry - NewValEntry = new gdcmValEntry(DictEntry); + vr == "UI" || vr == "TM" ) { + // --- ValEntry + + newValEntry = (gdcmValEntry *)0; if (!NewValEntry) { dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet", "failed to allocate gdcmValEntry"); return false; - } - FindHeaderEntryVR(NewEntry); - FindHeaderEntryLength(NewEntry); - } - - - else { + } + newValEntry->Copy(newDocEntry); + SkipDocEntry(newValEntry); + AddDocEntry(newValEntry); + + } else { // --- BinEntry + NewBinEntry = new gdcmBinEntry(DictEntry); if (!NewValEntry) { dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet", "failed to allocate gdcmBinEntry"); return false; - } - } - - - -// ------------- end of former ReadNextHeaderEntry ----------------- - - SkipHeaderEntry(newHeaderEntry); - if ( (ignoreShadow==0) || (newHeaderEntry->GetGroup()%2) == 0) { - AddHeaderEntry(newHeaderEntry); - } + } + newBinEntry->Copy(newDocEntry); + SkipDocEntry(newBinEntry); + AddDocEntry(newBinEntry); + } } rewind(fp); + + + // TODO : il n'y a plus de Chained List qui contient toutes les Entries + // Le chargement des valeurs devra se faire à la volée // Be carefull : merging this two loops may cause troubles ... for (ListTag::iterator i = GetListEntry().begin(); i != GetListEntry().end(); ++i) { - LoadHeaderEntry(*i); + LoadDocEntry(*i); } rewind(fp); - - + // -------------------------------------------------------------- // Special Patch to allow gdcm to read ACR-LibIDO formated images // diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index 7d7dd19a..cd3bbd7d 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -8,7 +8,9 @@ class GDCM_EXPORT gdcmElementSet : public gdcmDocEntrySet { public: - + gdcmElementSet(void); + ~gdcmElementSet(void); + protected: private: diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index 8b77a1c2..16d30ef9 100644 --- a/src/gdcmSQItem.cxx +++ b/src/gdcmSQItem.cxx @@ -11,14 +11,24 @@ /** * \ingroup gdcmSQItem * \brief Constructor from a given gdcmSQItem - * @param in Pointer to existing dictionary entry */ gdcmSQItem::gdcmSQItem() : gdcmDocEntry( ) { } - +/** + * \brief Canonical destructor. + */ +gdcmSQItem::~gdcmSQItem() +{ + for(ListDocEntry::iterator cc = docEntries.begin(); + cc != docEntries.end(); + ++cc) + { + delete *cc; + } +} //----------------------------------------------------------------------------- diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index 8f70af99..06246c1a 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -26,11 +26,10 @@ gdcmSeqEntry::gdcmSeqEntry() : gdcmDocEntry( ) { */ gdcmSeqEntry::~gdcmSeqEntry() { -/* for(tous les Items) + for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc) { delete *cc; } - */ } //-----------------------------------------------------------------------------