+2004-09-16 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+ * gdcmDocEntrySet::SQDepthLevel and gdcmDocEntrySet::BaseTagKey attributes
+ moved away from gdcmDocEntrySet (since this class is an abstract class
+ acting like an interface). SQDepthLevel and BaseTagKey are now
+ in class
+ - src/gdcmDocEntrySet.[h|cxx] removal of SQDepthLevel and BaseTagKey
+ and associated accessors. Doxygenation of the class.
+ - src/gdcmSQItem.[h|cxx] SQDepthLevel and BaseTagKey and associated
+ accessors added.
+ - src/gdcmSeqEntry.[h|cxx]: constructor doesn't handle depth anymore.
+ Use SQDepthLevel accessor instead. ::Print() adapted.
+ - src/gdcmElementSet.cxx changed according to changes in gdcmSeqEntry.
+ - src/gdcmDocument.cxx changed accordingly.
+
2004-09-13 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
* Preparation of writing a gdcmHeader iterator: generalisation of gdcmTagKey
- The following is the doxygen comment of the typedef declaration
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.cxx,v $
Language: C++
- Date: $Date: 2004/09/14 16:47:08 $
- Version: $Revision: 1.21 $
+ Date: $Date: 2004/09/16 19:21:57 $
+ Version: $Revision: 1.22 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmValEntry.h"
#include "gdcmBinEntry.h"
-//-----------------------------------------------------------------------------
-// Constructor / Destructor
-/**
- * \ingroup gdcmDocEntrySet
- * \brief Constructor from a given gdcmDocEntrySet
- */
-gdcmDocEntrySet::gdcmDocEntrySet(int depthLevel)
-{
- SQDepthLevel = depthLevel + 1; //magic +1 !
-}
-/**
- * \brief Canonical destructor.
- */
-gdcmDocEntrySet::~gdcmDocEntrySet()
-{
-}
-//-----------------------------------------------------------------------------
-// Print
-/*
- * \ingroup gdcmDocEntrySet
- * \brief canonical Printer
- */
-
-
//-----------------------------------------------------------------------------
// Public
-
-
/**
* \brief Build a new Val Entry from all the low level arguments.
* Check for existence of dictionary entry, and build
* @param Group group number of the underlying DictEntry
* @param Elem element number of the underlying DictEntry
*/
-gdcmSeqEntry *gdcmDocEntrySet::NewSeqEntryByNumber(uint16_t Group,
+gdcmSeqEntry* gdcmDocEntrySet::NewSeqEntryByNumber(uint16_t Group,
uint16_t Elem)
{
// Find out if the tag we encountered is in the dictionaries:
- gdcmDictEntry *DictEntry = GetDictEntryByNumber(Group, Elem);
- if (!DictEntry)
+ gdcmDictEntry* DictEntry = GetDictEntryByNumber( Group, Elem );
+ if ( ! DictEntry )
+ {
DictEntry = NewVirtualDictEntry(Group, Elem);
+ }
- gdcmSeqEntry *NewEntry = new gdcmSeqEntry(DictEntry, 1); // FIXME : 1
- if (!NewEntry)
+ gdcmSeqEntry *NewEntry = new gdcmSeqEntry( DictEntry );
+ if ( !NewEntry )
{
dbg.Verbose(1, "gdcmDocument::NewSeqEntryByNumber",
"failed to allocate gdcmSeqEntry");
- return NULL;
+ return 0;
}
return NewEntry;
}
+
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.h,v $
Language: C++
- Date: $Date: 2004/09/14 16:47:08 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2004/09/16 19:21:57 $
+ Version: $Revision: 1.18 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
typedef std::string gdcmBaseTagKey;
//-----------------------------------------------------------------------------
+/**
+ * \ref gdcmDocEntrySet is an abstract base class for \ref gdcmElementSet
+ * and \ref gdcmSQItem which are both containers for gdcmDocEntries.
+ * \ref gdcmElementSet is based on the STL map<> container
+ * (see \ref gdcmElementSet::TagHT), as opposed to \ref gdcmSQItem
+ * which is based on an STL list container (see \ref gdcmSQItem::docEntries).
+ * Since the syntax for adding a new element to a map<> or a list<>
+ * differ, \ref gdcmDocEntrySet is designed as an adapter to unify the
+ * interfaces of \ref gdcmDocEntrySet and \ref gdcmElementSet.
+ * As an illustration of this design, please refer to the implementation
+ * of \ref AddEntry (or any pure virtual method) in both derived classes.
+ * This adapter unification of interfaces enables the parsing of a
+ * DICOM header containing (optionaly heavily nested) sequences to be
+ * written recursively [see \ref gdcmDocument::ParseDES
+ * which calls \ref gdcmDocument::ParseSQ, which in turns calls
+ * \ref gdcmDocument::ParseDES ].
+ *
+ * \note Developpers should strongly resist to the temptation of adding
+ * members to this class since this class is designed as an adapter
+ * in the form of an abstract base class.
+ */
class GDCM_EXPORT gdcmDocEntrySet
{
public:
- gdcmDocEntrySet(int depth = 0);
- virtual ~gdcmDocEntrySet();
+ gdcmDocEntrySet() {}
+ virtual ~gdcmDocEntrySet() {}
/// \brief adds any type of entry to the entry set (pure vitual)
virtual bool AddEntry(gdcmDocEntry *Entry) = 0; // pure virtual
/// \brief write any type of entry to the entry set
virtual void Write (FILE *fp, FileType filetype) = 0;// pure virtual
- /// \brief Gets the depth level of a Dicom Header Entry embedded in a
- /// SeQuence
- int GetDepthLevel() { return SQDepthLevel; }
-
- /// \brief Sets the depth level of a Dicom Header Entry embedded in a
- /// SeQuence
- void SetDepthLevel(int depth) { SQDepthLevel = depth; }
-
- void SetBaseTagKey( gdcmBaseTagKey key ) { BaseTagKey = key; }
- gdcmBaseTagKey GetBaseTagKey( ) { return BaseTagKey; }
-
virtual gdcmDocEntry* GetDocEntryByNumber(uint16_t group,
uint16_t element) = 0;
gdcmDocEntry *GetDocEntryByName(std::string const & name);
gdcmDictEntry *GetDictEntryByName (std::string const & name);
gdcmDictEntry *GetDictEntryByNumber(uint16_t, uint16_t);
- /// Gives the depth level of the element set inside SeQuences
- int SQDepthLevel;
-
- /// \brief A TagKey of a gdcmDocEntry nested in a sequence is prepended
- /// with this BaseTagKey.
- gdcmBaseTagKey BaseTagKey;
-private:
};
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/09/16 06:48:00 $
- Version: $Revision: 1.79 $
+ Date: $Date: 2004/09/16 19:21:57 $
+ Version: $Revision: 1.80 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
long beg = ftell(Fp);
lgt -= beg;
- SQDepthLevel = 0;
-
(void)ParseDES( this, beg, lgt, false); // le Load sera fait a la volee
rewind(Fp);
delete[] a;
return NULL;
}
- /// \TODO Drop any already existing void area! JPR
+ /// \todo Drop any already existing void area! JPR
if( !SetEntryVoidAreaByNumber( a, group, elem ) );
{
dbg.Verbose(0, "gdcmDocument::LoadEntryVoidArea setting failed.");
gdcmDocEntry *newDocEntry = 0;
unsigned long l = 0;
- int depth = set->GetDepthLevel();
while (true)
{
if ( !delim_mode && (ftell(Fp)-offset) >= l_max)
if ( gdcmGlobal::GetVR()->IsVROfGdcmStringRepresentable(vr) )
{
- /////// ValEntry
+ /////////////////////// ValEntry
gdcmValEntry* newValEntry =
new gdcmValEntry( newDocEntry->GetDictEntry() );
newValEntry->Copy( newDocEntry );
- newValEntry->SetKey( set->GetBaseTagKey() + newValEntry->GetKey() );
+
+ // When "set" is a gdcmDocument, then we are at the top of the
+ // hierarchy and the Key is simply of the form ( group, elem )...
+ if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) )
+ {
+ newValEntry->SetKey( newValEntry->GetKey() );
+ }
+ // ...but when "set" is a gdcmSQItem, we are inserting this new
+ // valEntry in a sequence item. Hence the key has the
+ // generalized form (refer to \ref gdcmBaseTagKey):
+ if (gdcmSQItem* parentSQItem = dynamic_cast< gdcmSQItem* > ( set ) )
+ {
+ newValEntry->SetKey( parentSQItem->GetBaseTagKey()
+ + newValEntry->GetKey() );
+ }
+
set->AddEntry( newValEntry );
LoadDocEntry( newValEntry );
if (newValEntry->IsItemDelimitor())
"nor BinEntry. Probably unknown VR.");
}
- ////// BinEntry or UNKOWN VR:
+ //////////////////// BinEntry or UNKOWN VR:
gdcmBinEntry* newBinEntry =
new gdcmBinEntry( newDocEntry->GetDictEntry() );
newBinEntry->Copy( newDocEntry );
- newBinEntry->SetKey( set->GetBaseTagKey() + newBinEntry->GetKey() );
+
+ // When "this" is a gdcmDocument the Key is simply of the
+ // form ( group, elem )...
+ if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) )
+ {
+ newBinEntry->SetKey( newBinEntry->GetKey() );
+ }
+ // but when "this" is a SQItem, we are inserting this new
+ // valEntry in a sequence item, and the kay has the
+ // generalized form (refer to \ref gdcmBaseTagKey):
+ if (gdcmSQItem* parentSQItem = dynamic_cast< gdcmSQItem* > ( set ) )
+ {
+ newBinEntry->SetKey( parentSQItem->GetBaseTagKey()
+ + newBinEntry->GetKey() );
+ }
+
set->AddEntry( newBinEntry );
LoadDocEntry( newBinEntry );
}
}
// no other way to create it ...
gdcmSeqEntry* newSeqEntry =
- new gdcmSeqEntry( newDocEntry->GetDictEntry(),
- set->GetDepthLevel() );
+ new gdcmSeqEntry( newDocEntry->GetDictEntry() );
newSeqEntry->Copy( newDocEntry );
newSeqEntry->SetDelimitorMode( delim_mode );
- newSeqEntry->SetDepthLevel( depth );
- newSeqEntry->SetKey( set->GetBaseTagKey() + newSeqEntry->GetKey() );
+
+ // At the top of the hierarchy, stands a gdcmDocument. When "set"
+ // is a gdcmDocument, then we are building the first depth level.
+ // Hence the gdcmSeqEntry we are building simply has a depth
+ // level of one:
+ if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) )
+ {
+ newSeqEntry->SetDepthLevel( 1 );
+ newSeqEntry->SetKey( newSeqEntry->GetKey() );
+ }
+ // But when "set" is allready a SQItem, we are building a nested
+ // sequence, and hence the depth level of the new gdcmSeqEntry
+ // we are building, is one level deeper:
+ if (gdcmSQItem* parentSQItem = dynamic_cast< gdcmSQItem* > ( set ) )
+ {
+ newSeqEntry->SetDepthLevel( parentSQItem->GetDepthLevel() + 1 );
+ newSeqEntry->SetKey( parentSQItem->GetBaseTagKey()
+ + newSeqEntry->GetKey() );
+ }
if ( l != 0 )
{ // Don't try to parse zero-length sequences
Program: gdcm
Module: $RCSfile: gdcmElementSet.cxx,v $
Language: C++
- Date: $Date: 2004/09/03 14:04:02 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2004/09/16 19:21:57 $
+ Version: $Revision: 1.19 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \ingroup gdcmElementSet
* \brief Constructor from a given gdcmElementSet
*/
+//BOZ depthLevel is not usefull anymore
gdcmElementSet::gdcmElementSet(int depthLevel)
- : gdcmDocEntrySet(depthLevel)
+ : gdcmDocEntrySet()
{
}
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2004/08/27 15:48:44 $
- Version: $Revision: 1.25 $
+ Date: $Date: 2004/09/16 19:21:57 $
+ Version: $Revision: 1.26 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief Constructor from a given gdcmSQItem
*/
gdcmSQItem::gdcmSQItem(int depthLevel )
- : gdcmDocEntrySet(depthLevel)
+ : gdcmDocEntrySet( )
{
- SQDepthLevel = depthLevel +1;
+ SQDepthLevel = depthLevel;
}
/**
Program: gdcm
Module: $RCSfile: gdcmSQItem.h,v $
Language: C++
- Date: $Date: 2004/08/31 15:39:48 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2004/09/16 19:21:57 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// \brief returns the ordinal position of a given SQItem
int GetSQItemNumber() { return SQItemNumber; };
+
/// \brief Sets the ordinal position of a given SQItem
void SetSQItemNumber(int itemNumber) { SQItemNumber = itemNumber; };
+ /// Accessor on \ref SQDepthLevel.
+ int GetDepthLevel() { return SQDepthLevel; }
+
+ /// Accessor on \ref SQDepthLevel.
+ void SetDepthLevel(int depth) { SQDepthLevel = depth; }
+
+ /// Accessor on \ref BaseTagKey.
+ void SetBaseTagKey( gdcmBaseTagKey key ) { BaseTagKey = key; }
+
+ /// Accessor on \ref BaseTagKey.
+ gdcmBaseTagKey GetBaseTagKey( ) { return BaseTagKey; }
+
+
protected:
// Variables
///\brief pointer to the HTable of the gdcmDocument,
/// (because we don't know it within any gdcmObject nor any gdcmSQItem)
TagDocEntryHT *PtagHT;
+
private:
+ /// \brief Sequences can be nested. This \ref SQDepthLevel represents
+ /// the level of the nesting of instances of this class.
+ /// \ref SQDepthLevel and its \ref gdcmSeqEntry::SQDepthLevel
+ /// counterpart are only defined on printing purposes
+ /// (see \ref Print).
+ int SQDepthLevel;
+
+ /// \brief A TagKey of a gdcmDocEntry nested in a sequence is prepended
+ /// with this BaseTagKey.
+ gdcmBaseTagKey BaseTagKey;
};
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.cxx,v $
Language: C++
- Date: $Date: 2004/09/13 12:10:53 $
- Version: $Revision: 1.27 $
+ Date: $Date: 2004/09/16 19:21:57 $
+ Version: $Revision: 1.28 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \ingroup gdcmSeqEntry
* \brief Constructor from a given gdcmSeqEntry
*/
-gdcmSeqEntry::gdcmSeqEntry(gdcmDictEntry* e, int depth)
+gdcmSeqEntry::gdcmSeqEntry( gdcmDictEntry* e )
: gdcmDocEntry(e)
{
UsableLength = 0;
ReadLength = 0xffffffff;
- SQDepthLevel = depth;
+ SQDepthLevel = -1;
delimitor_mode = false;
seq_term = NULL;
/**
* \brief canonical Printer
*/
-void gdcmSeqEntry::Print(std::ostream &os)
+void gdcmSeqEntry::Print( std::ostream &os )
{
// First, Print the Dicom Element itself.
SetPrintLevel(2);
// at end, print the sequence terminator item, if any
if (delimitor_mode) {
- for (int i=0;i<SQDepthLevel+1;i++)
+ for ( int i = 0; i < SQDepthLevel; i++ )
+ {
os << " | " ;
- if (seq_term != NULL) {
+ }
+ if (seq_term != NULL)
+ {
seq_term->Print(os);
os << std::endl;
}
else
- // fusible
+ {
+ // fuse
os << " -------------- should have a sequence terminator item";
+ }
}
}
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.h,v $
Language: C++
- Date: $Date: 2004/09/13 12:10:53 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2004/09/16 19:21:57 $
+ Version: $Revision: 1.17 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
class GDCM_EXPORT gdcmSeqEntry : public gdcmDocEntry
{
public:
- gdcmSeqEntry(gdcmDictEntry* e, int depth);
+ gdcmSeqEntry( gdcmDictEntry* );
gdcmSeqEntry(gdcmDocEntry* d, int depth);
virtual ~gdcmSeqEntry();
/// sequence terminator item
gdcmDocEntry *seq_term;
- /// Gives the depth level of elements inside SeQuences
+ /// \brief Defines the depth level of this \ref gdcmSeqEntry inside
+ /// the (optionaly) nested sequences. \ref SQDepthLevel
+ /// and its \ref gdcmSQItem::SQDepthLevel counterpart
+ /// are only defined on printing purposes (see \ref Print).
int SQDepthLevel;
};