)
SET(libgdcm_la_SOURCES
- gdcmDicomDirElement.cxx
- gdcmDicomDir.cxx
- gdcmDicomDirMeta.cxx
- gdcmDicomDirPatient.cxx
- gdcmDicomDirStudy.cxx
- gdcmDicomDirSerie.cxx
- gdcmDicomDirImage.cxx
gdcmDirList.cxx
- gdcmObject.cxx
gdcmDebug.cxx
gdcmDict.cxx
gdcmDictEntry.cxx
gdcmDocEntry.cxx
gdcmDocEntrySet.cxx
gdcmBinEntry.cxx
- gdcmDocument.cxx
gdcmSeqEntry.cxx
gdcmSQItem.cxx
gdcmElementSet.cxx
gdcmValEntry.cxx
-)
+ gdcmDicomDirElement.cxx
+ gdcmDocument.cxx
+ gdcmDicomDir.cxx
+ gdcmDicomDirMeta.cxx
+ gdcmDicomDirPatient.cxx
+ gdcmDicomDirStudy.cxx
+ gdcmDicomDirSerie.cxx
+ gdcmDicomDirImage.cxx
+ gdcmObject.cxx
+ )
ADD_LIBRARY(gdcm ${libgdcm_la_SOURCES} )
IF(UNIX)
Program: gdcm
Module: $RCSfile: gdcmBinEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/21 12:38:28 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.13 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void gdcmBinEntry::Print(std::ostream &os)
{
- gdcmValEntry::Print(os);
+ //gdcmValEntry::Print(os); // replaced by PrintCommonPart
+ // to avoid bugging the display
+ PrintCommonPart(os);
std::ostringstream s;
if (voidArea != NULL)
{
- s << " [gdcm::Binary data loaded with lenght is "
+ s << " [gdcm::Binary data loaded with length is "
<< GetLength() << "]"
<< std::endl;
}
}
os << s.str();
}
+
+/*
+ * \brief canonical Writer
+ */
+void gdcmBinEntry::Write(FILE *fp, FileType filetype) {
+ void *voidArea = GetVoidArea();
+ int lgr=GetLength();
+ if (voidArea != NULL)
+ { // there is a 'non string' LUT, overlay, etc
+ fwrite ( voidArea,(size_t)lgr ,(size_t)1 ,fp); // Elem value
+ return;
+ }
+}
//-----------------------------------------------------------------------------
// Public
Program: gdcm
Module: $RCSfile: gdcmBinEntry.h,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:47 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public:
gdcmBinEntry(gdcmDictEntry* e);
- gdcmBinEntry(gdcmDocEntry* d);
+ gdcmBinEntry(gdcmDocEntry* d);
+
~gdcmBinEntry(void);
void Print(std::ostream &os = std::cout);
+ virtual void Write(FILE *fp, FileType filetype);
/// \brief Returns the area value of the current Dicom Header Entry
/// when it's not string-translatable (e.g : a LUT table)
Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2004/06/19 23:51:03 $
- Version: $Revision: 1.48 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.49 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
gdcmDocument(exception_on_error)
{
+
Initialize();
+
std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
AddDicomDirMeta();
for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) {
WriteEntry(*i,_fp, gdcmExplicitVR);
}
- itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
- while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
+ itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
+ while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) {
WriteEntry(*i,_fp, gdcmExplicitVR);
}
for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) {
WriteEntry(*i,_fp, gdcmExplicitVR);
}
- ++itImage;
- }
- ++itSerie;
+ ++itImage;
+ }
+ ++itSerie;
}
- ++itStudy;
+ ++itStudy;
}
++itPatient;
}
gdcmValEntry *entry;
std::string val;
- switch(type)
- {
+ switch(type){
case GDCM_DICOMDIR_PATIENT:
elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
break;
return;
}
- for(it=elemList.begin();it!=elemList.end();++it)
- {
+ for(it=elemList.begin();it!=elemList.end();++it) {
+ cout << "it " << endl;
tmpGr=it->group;
tmpEl=it->elem;
dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
- entry=new gdcmValEntry(dictEntry);
+ entry=new gdcmValEntry(dictEntry); // Be sure it's never a BinEntry !
+
entry->SetOffset(0); // just to avoid further missprinting
if(header)
if(dictEntry)
{
- if(dictEntry->GetGroup()==0xfffe)
- {
+ if(dictEntry->GetGroup()==0xfffe) {
entry->SetLength(entry->GetValue().length());
- }
- else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
+ }
+ else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
{
entry->SetLength(4);
}
- else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
+ else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
{
entry->SetLength(2);
}
- else if(dictEntry->GetVR()=="SQ")
+ else if(dictEntry->GetVR()=="SQ")
{
entry->SetLength(0xffffffff);
}
- else
+ else
{
entry->SetLength(entry->GetValue().length());
}
AddDicomDirImageToEnd(s);
break;
case gdcmDicomDir::GDCM_DICOMDIR_NONE:
- AddDicomDirImageToEnd(s); //FIXME
+ AddDicomDirImageToEnd(s); //FIXME
break;
}
}
}
}
//bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
- SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
+ SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
return;
*/
}
Program: gdcm
Module: $RCSfile: gdcmDict.cxx,v $
Language: C++
- Date: $Date: 2004/06/21 04:43:02 $
- Version: $Revision: 1.36 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.37 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
from >> element;
from >> vr;
from >> fourth;
- eatwhite(from);
+ eatwhite(from);
getline(from, name); /// MEMORY LEAK in std::getline<>
gdcmDictEntry * newEntry = new gdcmDictEntry(group, element,
Program: gdcm
Module: $RCSfile: gdcmDocEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:47 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.8 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
os << s.str();
}
+/**
+ * \ingroup gdcmDocEntry
+ * \brief Writes the common part of any gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
+ */
+void gdcmDocEntry::Write(FILE *fp, FileType filetype) {
+ std::cout << "gdcmDocEntry::Write : Is that what you wanted to do ? " << std::endl;
+ WriteCommonPart(fp, filetype);
+}
+
+/**
+ * \ingroup gdcmDocEntry
+ * \brief Writes the common part of any gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
+ */
+void gdcmDocEntry::WriteCommonPart(FILE *fp, FileType filetype) {
+
+ guint16 group = GetGroup();
+ VRKey vr = GetVR();
+ guint16 el = GetElement();
+ guint32 lgr = GetReadLength();
+
+ if ( (group == 0xfffe) && (el == 0x0000) )
+ // Fix in order to make some MR PHILIPS images e-film readable
+ // see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm:
+ // we just *always* ignore spurious fffe|0000 tag !
+ return;
+
+//
+// ----------- Writes the common part
+//
+ fwrite ( &group,(size_t)2 ,(size_t)1 ,fp); //group
+ fwrite ( &el, (size_t)2 ,(size_t)1 ,fp); //element
+
+ if ( filetype == gdcmExplicitVR ) {
+
+ // Special case of delimiters:
+ if (group == 0xfffe) {
+ // Delimiters have NO Value Representation
+ // Hence we skip writing the VR.
+ // In order to avoid further troubles, we choose to write them
+ // as 'no-length' Item Delimitors (we pad by writing 0xffffffff)
+ // The end of a given Item will be found when :
+ // - a new Item Delimitor Item is encountered (the Seq goes on)
+ // - a Sequence Delimitor Item is encountered (the Seq just ended)
+
+ // TODO : verify if the Sequence Delimitor Item was forced during Parsing
+
+ int ff=0xffffffff;
+ fwrite (&ff,(size_t)4 ,(size_t)1 ,fp);
+ return;
+ }
+
+ guint16 z=0;
+ guint16 shortLgr = lgr;
+ if (vr == "unkn") { // Unknown was 'written'
+ // deal with Little Endian
+ fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,fp);
+ fwrite ( &z, (size_t)2 ,(size_t)1 ,fp);
+ } else {
+ fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,fp);
+
+// TODO : better we set SQ length to ffffffff
+// and write a Sequence Delimitor Item at the end of the Sequence!
+ if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") )
+ {
+ fwrite ( &z, (size_t)2 ,(size_t)1 ,fp);
+ fwrite ( &lgr,(size_t)4 ,(size_t)1 ,fp);
+ } else {
+ fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,fp);
+ }
+ }
+ }
+ else // IMPLICIT VR
+ {
+ fwrite ( &lgr,(size_t)4 ,(size_t)1 ,fp);
+ }
+}
+
//-----------------------------------------------------------------------------
// Public
Program: gdcm
Module: $RCSfile: gdcmDocEntry.h,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:47 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include <stdio.h>
#include "gdcmDictEntry.h"
-//#include "gdcmValEntry.h"
+
class gdcmHeader;
+class gdcmValEntry;
+class gdcmBinEntry;
+class gdcmSeqEntry;
//-----------------------------------------------------------------------------
/**
/// Returns the Dicom Element number of the current Dicom Header Entry
inline guint16 GetElement(void) { return entry->GetElement();};
-
+
/// Returns the 'key' of the current Dicom Header Entry
inline std::string GetKey(void) { return entry->GetKey(); };
inline size_t GetOffset(void) { return Offset; };
/// \brief Returns the actual value length of the current Dicom Header Entry
- /// \warning this value is not *allways* the one stored in the Dicom Header
+ /// \warning this value is not *always* the one stored in the Dicom Header
/// in case of well knowned bugs
inline guint32 GetLength(void) { return UsableLength; };
int GetPrintLevel(void) { return(printLevel); };
virtual void Print (std::ostream & os = std::cout);
+ virtual void Write(FILE *fp, FileType filetype);
void gdcmDocEntry::PrintCommonPart(std::ostream & os);
+ void gdcmDocEntry::WriteCommonPart(FILE *fp, FileType filetype);
guint32 GetFullLength(void);
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.cxx,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:47 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
+
+
+/**
+ * \brief Build a new Element Value from all the low level arguments.
+ * Check for existence of dictionary entry, and build
+ * a default one when absent.
+ * @param Group group number of the underlying DictEntry
+ * @param Elem element number of the underlying DictEntry
+ */
+gdcmValEntry *gdcmDocEntrySet::NewValEntryByNumber(guint16 Group, guint16 Elem)
+{
+ // Find out if the tag we encountered is in the dictionaries:
+ gdcmDictEntry *DictEntry = GetDictEntryByNumber(Group, Elem);
+ if (!DictEntry)
+ DictEntry = NewVirtualDictEntry(Group, Elem);
+
+ gdcmValEntry *NewEntry = new gdcmValEntry(DictEntry);
+ if (!NewEntry)
+ {
+ dbg.Verbose(1, "gdcmDocument::NewValEntryByNumber",
+ "failed to allocate gdcmValEntry");
+ return NULL;
+ }
+ return NewEntry;
+}
+
+
+/**
+ * \brief Build a new Element Value from all the low level arguments.
+ * Check for existence of dictionary entry, and build
+ * a default one when absent.
+ * @param Group group number of the underlying DictEntry
+ * @param Elem element number of the underlying DictEntry
+ */
+gdcmBinEntry *gdcmDocEntrySet::NewBinEntryByNumber(guint16 Group, guint16 Elem)
+{
+ // Find out if the tag we encountered is in the dictionaries:
+ gdcmDictEntry *DictEntry = GetDictEntryByNumber(Group, Elem);
+ if (!DictEntry)
+ DictEntry = NewVirtualDictEntry(Group, Elem);
+
+ gdcmBinEntry *NewEntry = new gdcmBinEntry(DictEntry);
+ if (!NewEntry)
+ {
+ dbg.Verbose(1, "gdcmDocument::NewBinEntryByNumber",
+ "failed to allocate gdcmBinEntry");
+ return NULL;
+ }
+ return NewEntry;
+}
//-----------------------------------------------------------------------------
// Protected
+/**
+ * \brief Gets a Dicom Element inside a SQ Item Entry, by name
+ * @return
+ */
+ gdcmDocEntry *gdcmDocEntrySet::GetDocEntryByName(std::string name) {
+ gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
+ gdcmDictEntry *dictEntry = (*PubDict).GetDictEntryByName(name);
+ if( dictEntry == NULL)
+ return NULL;
+ return GetDocEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement());
+}
+
+
+/**
+ * \brief Get the value of a Dicom Element inside a SQ Item Entry, by name
+ * @param name : name of the searched element.
+ * @return
+ */
+
+std::string gdcmDocEntrySet::GetEntryByName(TagName name) {
+ gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
+ gdcmDictEntry *dictEntry = (*PubDict).GetDictEntryByName(name);
+
+ if( dictEntry == NULL)
+ return GDCM_UNFOUND;
+ return GetEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement());
+}
+
+
+/**
+ * \brief Request a new virtual dict entry to the dict set
+ * @param group group number of the underlying DictEntry
+ * @param element element number of the underlying DictEntry
+ * @param vr VR of the underlying DictEntry
+ * @param fourth owner group
+ * @param name english name
+ */
+gdcmDictEntry *gdcmDocEntrySet::NewVirtualDictEntry(guint16 group, guint16 element,
+ std::string vr,
+ std::string fourth,
+ std::string name)
+{
+ return gdcmGlobal::GetDicts()->NewVirtualDictEntry(group,element,vr,fourth,name);
+}
+
+/// \brief
+
+//
+// Probabely move, as is, to gdcmDocEntrySet, as a non virtual method
+// an remove gdcmDocument::NewDocEntryByNumber
+gdcmDocEntry *gdcmDocEntrySet::NewDocEntryByNumber(guint16 group,
+ guint16 elem) {
+
+ // Find out if the tag we encountered is in the dictionaries:
+ gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
+ gdcmDictEntry *DictEntry = (*PubDict).GetDictEntryByNumber(group, elem);
+ if (!DictEntry)
+ DictEntry = NewVirtualDictEntry(group, elem);
+
+ gdcmDocEntry *NewEntry = new gdcmDocEntry(DictEntry);
+ if (!NewEntry)
+ {
+ dbg.Verbose(1, "gdcmSQItem::NewDocEntryByNumber",
+ "failed to allocate gdcmDocEntry");
+ return (gdcmDocEntry*)0;
+ }
+ return NewEntry;
+}
+
+/// \brief
+gdcmDocEntry *gdcmDocEntrySet::NewDocEntryByName (std::string Name) {
+
+ gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
+ gdcmDictEntry *NewTag = (*PubDict).GetDictEntryByName(Name);
+ if (!NewTag)
+ NewTag = NewVirtualDictEntry(0xffff, 0xffff, "LO", "unkn", Name);
+
+ gdcmDocEntry* NewEntry = new gdcmDocEntry(NewTag);
+ if (!NewEntry)
+ {
+ dbg.Verbose(1, "gdcmSQItem::ObtainDocEntryByName",
+ "failed to allocate gdcmDocEntry");
+ return (gdcmDocEntry *)0;
+ }
+ return NewEntry;
+}
+
+
+/**
+ * \brief Searches both the public and the shadow dictionary (when they
+ * exist) for the presence of the DictEntry with given name.
+ * The public dictionary has precedence on the shadow one.
+ * @param Name name of the searched DictEntry
+ * @return Corresponding DictEntry when it exists, NULL otherwise.
+ */
+gdcmDictEntry *gdcmDocEntrySet::GetDictEntryByName(std::string Name)
+{
+ gdcmDictEntry *found = (gdcmDictEntry *)0;
+ gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
+ if (!PubDict)
+ {
+ dbg.Verbose(0, "gdcmDocument::GetDictEntry",
+ "we SHOULD have a default dictionary");
+ }
+ else
+ found = PubDict->GetDictEntryByName(Name);
+ return found;
+}
+
+/**
+ * \brief Searches both the public and the shadow dictionary (when they
+ * exist) for the presence of the DictEntry with given
+ * group and element. The public dictionary has precedence on the
+ * shadow one.
+ * @param group group number of the searched DictEntry
+ * @param element element number of the searched DictEntry
+ * @return Corresponding DictEntry when it exists, NULL otherwise.
+ */
+gdcmDictEntry *gdcmDocEntrySet::GetDictEntryByNumber(guint16 group,guint16 element)
+{
+ gdcmDictEntry *found = (gdcmDictEntry *)0;
+ gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
+ if (!PubDict)
+ {
+ dbg.Verbose(0, "gdcmDocument::GetDictEntry",
+ "we SHOULD have a default dictionary");
+ }
+ else
+ found = PubDict->GetDictEntryByNumber(group, element);
+ return found;
+}
+
//-----------------------------------------------------------------------------
// Private
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.h,v $
Language: C++
- Date: $Date: 2004/06/21 04:43:02 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.12 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// \brief prints any type of entry to the entry set (pure vitual)
virtual void Print (std::ostream & os = std::cout) = 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
inline int GetDepthLevel(void) { return SQDepthLevel; }
/// \brief Sets the depth level of a Dicom Header Entry embedded in a
/// SeQuence
inline void SetDepthLevel(int depth) { SQDepthLevel = depth; }
-
-protected:
- /// \brief Build a new Element Value from all the low level arguments.
- /// Check for existence of dictionary entry, and build
- /// a default one when absent (pure virtual)
- virtual gdcmDocEntry *NewDocEntryByNumber(guint16 group,
- guint16 element)=0; // pure virtual
- /// \brief Build a new Element Value from all the low level arguments.
- /// Check for existence of dictionary entry, and build
- /// a default one when absent (pure virtual)
- virtual gdcmDocEntry *NewDocEntryByName (std::string Name)=0;// pure virtual
+ virtual gdcmDocEntry *GetDocEntryByNumber(guint16 group,guint16 element) = 0;
+ gdcmDocEntry *GetDocEntryByName(std::string name);
+ virtual std::string GetEntryByNumber(guint16 group,guint16 element) = 0;
+ std::string GetEntryByName(TagName name);
+ gdcmDictEntry *NewVirtualDictEntry(guint16 group,
+ guint16 element,
+ std::string vr = "unkn",
+ std::string fourth = "unkn",
+ std::string name = "unkn");
+
+ protected:
+
+ // DocEntry related utilities
+
+ gdcmValEntry *NewValEntryByNumber(guint16 group,
+ guint16 element);
+ gdcmBinEntry *NewBinEntryByNumber(guint16 group,
+ guint16 element);
+ gdcmDocEntry *NewDocEntryByNumber(guint16 group,
+ guint16 element);
+ gdcmDocEntry *NewDocEntryByName (std::string Name);
+
+ // DictEntry related utilities
+
+ gdcmDictEntry *GetDictEntryByName (std::string Name);
+ gdcmDictEntry *GetDictEntryByNumber(guint16, guint16);
+
/// Gives the depth level of the element set inside SeQuences
int SQDepthLevel;
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/06/21 12:38:29 $
- Version: $Revision: 1.21 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ 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
#define UI1_2_840_10008_1_2_4_91 "1.2.840.10008.1.2.4.91"
// RLE Lossless
#define UI1_2_840_10008_1_2_5 "1.2.840.10008.1.2.5"
-
+// UI1_1_2_840_10008_1_2_5
#define str2num(str, typeNum) *((typeNum *)(str))
//-----------------------------------------------------------------------------
// Recursive clean up of sequences
for (TagDocEntryHT::iterator it = tagHT.begin(); it != tagHT.end(); ++it )
- {
- delete (it->second);
+ {
+ delete it->second;
}
tagHT.clear();
}
return(true);
}
+
/**
* \brief Internal function that checks whether the Transfer Syntax given
* as argument is the one present in the current document.
/**
* \brief Writes in a file all the Header Entries (Dicom Elements)
- * of the Chained List
* @param fp file pointer on an already open file
- * @param type Type of the File to be written
+ * @param filetype Type of the File to be written
* (ACR-NEMA, ExplicitVR, ImplicitVR)
* \return Always true.
*/
-bool gdcmDocument::Write(FILE *fp, FileType type) {
+bool gdcmDocument::WriteF(FileType filetype) {
/// \todo
-/// ==============
-/// The stuff will have to be rewritten using the SeQuence based
-/// tree-like stucture instead of the chained list .
-/// (so we shall remove the Group*HT from the gdcmDocument)
+/// ==============
+/// The stuff is rewritten using the SeQuence based
+/// tree-like stucture (cf : Print )
/// To be checked
/// =============
/// \todo move the following lines (and a lot of others, to be written)
/// to a future function CheckAndCorrectHeader
- /// \todo
- /// Question :
- /// Comment pourrait-on savoir si le DcmHeader vient d'un fichier
- /// DicomV3 ou non (FileType est un champ de gdcmDocument ...)
/// WARNING : Si on veut ecrire du DICOM V3 a partir d'un DcmHeader ACR-NEMA
- /// no way
+ /// no way (check : FileType est un champ de gdcmDocument ...)
/// a moins de se livrer a un tres complique ajout des champs manquants.
/// faire un CheckAndCorrectHeader (?)
- if (type == gdcmImplicitVR)
+ if (filetype == gdcmImplicitVR)
{
std::string implicitVRTransfertSyntax = UI1_2_840_10008_1_2;
ReplaceOrCreateByNumber(implicitVRTransfertSyntax,0x0002, 0x0010);
SetEntryLengthByNumber(18, 0x0002, 0x0010);
}
- if (type == gdcmExplicitVR)
+ if (filetype == gdcmExplicitVR)
{
std::string explicitVRTransfertSyntax = UI1_2_840_10008_1_2_1;
ReplaceOrCreateByNumber(explicitVRTransfertSyntax,0x0002, 0x0010);
/**
* \todo rewrite later, if really usefull
+ * ('Group Length' element is optional in DICOM)
*
- * --> Warning : un-updated odd groups lengths can causes pb
+ * --> Warning : un-updated odd groups lengthes can causes pb
* --> (xmedcon breaks)
* --> to be re- written with future org.
*
- * if ( (type == ImplicitVR) || (type == ExplicitVR) )
- * UpdateGroupLength(false,type);
- * if ( type == ACR)
+ * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) )
+ * UpdateGroupLength(false,filetype);
+ * if ( filetype == ACR)
* UpdateGroupLength(true,ACR);
*/
+
+ Write(fp,filetype); // the gdcmElementSet one !
- WriteEntries(fp,type);
+ /// WriteEntries(fp,type); // old stuff
return true;
}
* @return Corresponding element value representation when it exists,
* and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
*/
-std::string gdcmDocument::GetEntryVRByName(std::string tagName) {
+std::string gdcmDocument::GetEntryVRByName(TagName tagName) {
gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName);
if( dictEntry == NULL)
return GDCM_UNFOUND;
/**
* \brief Sets a 'non string' value to a given Dicom Element
- * @param area
+ * @param area area containing the 'non string' value
* @param group Group number of the searched Dicom Element
* @param element Element number of the searched Dicom Element
* @return
fseek(fp, PositionOnEntry, SEEK_SET);
}
-
-/**
- * \brief Writes in a file (according to the requested format)
- * the group, the element, the value representation and the length
- * of a single gdcmDocEntry passed as argument.
- * @param tag pointer on the gdcmDocEntry to be written
- * @param _fp already open file pointer
- * @param type type of the File to be written
- */
-void gdcmDocument::WriteEntryTagVRLength(gdcmDocEntry *tag,
- FILE *_fp,
- FileType type)
-{
- guint16 group = tag->GetGroup();
- VRKey vr = tag->GetVR();
- guint16 el = tag->GetElement();
- guint32 lgr = tag->GetReadLength();
-
- if ( (group == 0xfffe) && (el == 0x0000) )
- // Fix in order to make some MR PHILIPS images e-film readable
- // see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm:
- // we just *always* ignore spurious fffe|0000 tag !
- return;
-
- fwrite ( &group,(size_t)2 ,(size_t)1 ,_fp); //group
- fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp); //element
-
- if ( type == gdcmExplicitVR ) {
-
- // Special case of delimiters:
- if (group == 0xfffe) {
- // Delimiters have NO Value Representation and have NO length.
- // Hence we skip writing the VR and length and we pad by writing
- // 0xffffffff
-
- int ff=0xffffffff;
- fwrite (&ff,(size_t)4 ,(size_t)1 ,_fp);
- return;
- }
-
- guint16 z=0;
- guint16 shortLgr = lgr;
- if (vr == "unkn") { // Unknown was 'written'
- // deal with Little Endian
- fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
- fwrite ( &z, (size_t)2 ,(size_t)1 ,_fp);
- } else {
- fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,_fp);
- if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") )
- {
- fwrite ( &z, (size_t)2 ,(size_t)1 ,_fp);
- fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
- } else {
- fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
- }
- }
- }
- else // IMPLICIT VR
- {
- fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
- }
-}
-
-/**
- * \brief Writes in a file (according to the requested format)
- * the value of a single gdcmDocEntry passed as argument.
- * @param tag Pointer on the gdcmDocEntry to be written
- * @param _fp Already open file pointer
- * @param type type of the File to be written
- */
-
-// \todo TODO : to be re -written recursively !
-void gdcmDocument::WriteEntryValue(gdcmDocEntry *Entry, FILE *_fp,FileType type)
-{
- (void)type;
- guint16 group = Entry->GetGroup();
- VRKey vr = Entry->GetVR();
- guint32 lgr = Entry->GetReadLength();
-
- if (vr == "SQ")
- // SeQuences have no value:
- return;
- if (group == 0xfffe)
- // Delimiters have no associated value:
- return;
-
-// if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(Entry) ) {
- void *voidArea;
- gdcmBinEntry *BinEntry= (gdcmBinEntry *)Entry;;
- voidArea = BinEntry->GetVoidArea();
- if (voidArea != NULL)
- { // there is a 'non string' LUT, overlay, etc
- fwrite ( voidArea,(size_t)lgr ,(size_t)1 ,_fp); // Elem value
- return;
- }
-// }
-
- if (vr == "US" || vr == "SS")
- {
- // some 'Short integer' fields may be mulivaluated
- // each single value is separated from the next one by '\'
- // we split the string and write each value as a short int
- std::vector<std::string> tokens;
- tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
- Tokenize (((gdcmValEntry *)Entry)->GetValue(), tokens, "\\");
- for (unsigned int i=0; i<tokens.size();i++)
- {
- guint16 val_uint16 = atoi(tokens[i].c_str());
- void *ptr = &val_uint16;
- fwrite ( ptr,(size_t)2 ,(size_t)1 ,_fp);
- }
- tokens.clear();
- return;
- }
- if (vr == "UL" || vr == "SL")
- {
- // Some 'Integer' fields may be multivaluated (multiple instances
- // of integers). But each single integer value is separated from the
- // next one by '\' (backslash character). Hence we split the string
- // along the '\' and write each value as an int:
- std::vector<std::string> tokens;
- tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
- Tokenize (((gdcmValEntry *)Entry)->GetValue(), tokens, "\\");
- for (unsigned int i=0; i<tokens.size();i++)
- {
- guint32 val_uint32 = atoi(tokens[i].c_str());
- void *ptr = &val_uint32;
- fwrite ( ptr,(size_t)4 ,(size_t)1 ,_fp);
- }
- tokens.clear();
- return;
- }
- fwrite (((gdcmValEntry *)Entry)->GetValue().c_str(),
- (size_t)lgr ,(size_t)1, _fp); // Elem value
-}
-
-/**
- * \brief Writes in a file (according to the requested format)
- * a single gdcmDocEntry passed as argument.
- * \sa WriteEntryValue, WriteEntryTagVRLength.
- * @param tag Pointer on the gdcmDocEntry to be written
- * @param _fp Already open file pointer
- * @param type type of the File to be written
- */
-
-bool gdcmDocument::WriteEntry(gdcmDocEntry *tag, FILE *_fp,FileType type)
-{
- guint32 length = tag->GetLength();
-
- if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(tag) )
- {
- // The value of a tag MUST (see the DICOM norm) be an odd number of
- // bytes. When this is not the case, pad with an additional byte:
- if(length%2==1) {
- ValEntry->SetValue(ValEntry->GetValue()+"\0");
- ValEntry->SetLength(ValEntry->GetReadLength()+1);
- }
- WriteEntryTagVRLength(ValEntry, _fp, type);
- WriteEntryValue(ValEntry, _fp, type);
- return true;
- }
-
- if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(tag) )
- {
- (void)BinEntry; //not used
- /// \todo FIXME : when voidArea belong to gdcmBinEntry only, fix
- /// voidArea length
- //
- // The value of a tag MUST (see the DICOM norm) be an odd number of
- // bytes. When this is not the case, pad with an additional byte:
-/*
- if(length%2==1) {
- tag->SetValue(tag->GetValue()+"\0");
- tag->SetLength(tag->GetReadLength()+1);
- }
-*/
- WriteEntryTagVRLength(tag, _fp, type);
- WriteEntryValue(tag, _fp, type);
- return true;
- }
-
- return false; //default behavior ?
-}
-
-/**
- * \brief writes on disc according to the requested format
- * (ACR-NEMA, ExplicitVR, ImplicitVR) the image
- * using the Chained List
- * \warning does NOT add the missing elements in the header :
- * it's up to the user doing it !
- * (function CheckHeaderCoherence to be written)
- * \warning DON'T try, right now, to write a DICOM image
- * from an ACR Header (meta elements will be missing!)
- * @param type type of the File to be written
- * (ACR-NEMA, ExplicitVR, ImplicitVR)
- * @param _fp already open file pointer
- */
-
-bool gdcmDocument::WriteEntries(FILE *_fp,FileType type)
-{
- /// \todo FIXME : explore recursively the whole structure...
- /// \todo (?) check write failures (after *each* fwrite)
-
- dbg.Verbose(0, "gdcmDocument::WriteEntries: entering.");
- for (TagDocEntryHT::iterator it = tagHT.begin(); it != tagHT.end(); ++it )
- {
- gdcmDocEntry * entry = it->second;
-
- if ( type == gdcmACR ){
- if (entry->GetGroup() < 0x0008)
- // Ignore pure DICOM V3 groups
- continue;
- if (entry->GetGroup() %2)
- // Ignore the "shadow" groups
- continue;
- if (entry->GetVR() == "SQ" ) // ignore Sequences
- continue;
- }
- if (! WriteEntry(entry, _fp, type) ) {
- dbg.Verbose(0, "gdcmDocument::WriteEntries: write failure.");
- return false;
- }
- }
- return true;
-}
-
-
/**
* \brief Swaps back the bytes of 4-byte long integer accordingly to
* processor order.
a=0;
}
return(a);
-}
+}
/**
* \brief Unswaps back the bytes of 4-byte long integer accordingly to
/**
* \brief Parses a DocEntrySet (Zero-level DocEntries or SQ Item DocEntries)
- * @return false if file is not ACR-NEMA / PAPYRUS / DICOM
+ * @return length of the parsed set.
*/
long gdcmDocument::ParseDES(gdcmDocEntrySet *set, long offset, long l_max, bool delim_mode) {
NewDocEntry = ReadNextDocEntry();
if(delim_mode) {
if (NewDocEntry->isSequenceDelimitor()) {
- /// \todo add the Sequence Delimitor
- /// \todo find the trick to put it properly !
set->SetSequenceDelimitationItem(NewDocEntry);
break;
}
itemSQ = new gdcmSQItem(set->GetDepthLevel());
itemSQ->AddEntry(NewDocEntry);
- /// \todo no value, no voidArea. Think of it while printing !
l= NewDocEntry->GetReadLength();
if (l == 0xffffffff)
return NewEntry;
}
-/**
- * \brief Build a new Element Value from all the low level arguments.
- * Check for existence of dictionary entry, and build
- * a default one when absent.
- * @param Name Name of the underlying DictEntry
- */
-gdcmDocEntry *gdcmDocument::NewDocEntryByName(std::string Name)
-{
- gdcmDictEntry *NewTag = GetDictEntryByName(Name);
- if (!NewTag)
- NewTag = NewVirtualDictEntry(0xffff, 0xffff, "LO", "unkn", Name);
-
- gdcmDocEntry* NewEntry = new gdcmDocEntry(NewTag);
- if (!NewEntry)
- {
- dbg.Verbose(1, "gdcmDocument::ObtainDocEntryByName",
- "failed to allocate gdcmDocEntry");
- return (gdcmDocEntry *)0;
- }
- return NewEntry;
-}
-
-/**
- * \brief Request a new virtual dict entry to the dict set
- * @param group group number of the underlying DictEntry
- * @param element element number of the underlying DictEntry
- * @param vr VR of the underlying DictEntry
- * @param fourth owner group
- * @param name english name
- */
-gdcmDictEntry *gdcmDocument::NewVirtualDictEntry(guint16 group, guint16 element,
- std::string vr,
- std::string fourth,
- std::string name)
-{
- return gdcmGlobal::GetDicts()->NewVirtualDictEntry(group,element,vr,fourth,name);
-}
-
-/**
- * \brief Build a new Element Value from all the low level arguments.
- * Check for existence of dictionary entry, and build
- * a default one when absent.
- * @param Group group number of the underlying DictEntry
- * @param Elem element number of the underlying DictEntry
- */
-gdcmDocEntry* gdcmDocument::NewDocEntryByNumber(guint16 Group, guint16 Elem)
-{
- // Find out if the tag we encountered is in the dictionaries:
- gdcmDictEntry *DictEntry = GetDictEntryByNumber(Group, Elem);
- if (!DictEntry)
- DictEntry = NewVirtualDictEntry(Group, Elem);
-
- gdcmDocEntry *NewEntry = new gdcmDocEntry(DictEntry);
- if (!NewEntry)
- {
- dbg.Verbose(1, "gdcmDocument::NewDocEntryByNumber",
- "failed to allocate gdcmDocEntry");
- return (gdcmDocEntry*)0;
- }
- return NewEntry;
-}
-
-
-/**
- * \brief Build a new Element Value from all the low level arguments.
- * Check for existence of dictionary entry, and build
- * a default one when absent.
- * @param Group group number of the underlying DictEntry
- * @param Elem element number of the underlying DictEntry
- */
-gdcmValEntry *gdcmDocument::NewValEntryByNumber(guint16 Group, guint16 Elem)
-{
- // Find out if the tag we encountered is in the dictionaries:
- gdcmDictEntry *DictEntry = GetDictEntryByNumber(Group, Elem);
- if (!DictEntry)
- DictEntry = NewVirtualDictEntry(Group, Elem);
-
- gdcmValEntry *NewEntry = new gdcmValEntry(DictEntry);
- if (!NewEntry)
- {
- dbg.Verbose(1, "gdcmDocument::NewValEntryByNumber",
- "failed to allocate gdcmValEntry");
- return NULL;
- }
- return NewEntry;
-}
-
-
-/**
- * \brief Build a new Element Value from all the low level arguments.
- * Check for existence of dictionary entry, and build
- * a default one when absent.
- * @param Group group number of the underlying DictEntry
- * @param Elem element number of the underlying DictEntry
- */
-gdcmBinEntry *gdcmDocument::NewBinEntryByNumber(guint16 Group, guint16 Elem)
-{
- // Find out if the tag we encountered is in the dictionaries:
- gdcmDictEntry *DictEntry = GetDictEntryByNumber(Group, Elem);
- if (!DictEntry)
- DictEntry = NewVirtualDictEntry(Group, Elem);
-
- gdcmBinEntry *NewEntry = new gdcmBinEntry(DictEntry);
- if (!NewEntry)
- {
- dbg.Verbose(1, "gdcmDocument::NewBinEntryByNumber",
- "failed to allocate gdcmBinEntry");
- return NULL;
- }
- return NewEntry;
-}
/**
* \brief Generate a free TagKey i.e. a TagKey that is not present
}
-/**
- * \brief Searches both the public and the shadow dictionary (when they
- * exist) for the presence of the DictEntry with given name.
- * The public dictionary has precedence on the shadow one.
- * @param Name name of the searched DictEntry
- * @return Corresponding DictEntry when it exists, NULL otherwise.
- */
-gdcmDictEntry *gdcmDocument::GetDictEntryByName(std::string Name)
-{
- gdcmDictEntry *found = (gdcmDictEntry *)0;
- if (!RefPubDict && !RefShaDict)
- {
- dbg.Verbose(0, "gdcmDocument::GetDictEntry",
- "we SHOULD have a default dictionary");
- }
- if (RefPubDict)
- {
- found = RefPubDict->GetDictEntryByName(Name);
- if (found)
- return found;
- }
- if (RefShaDict)
- {
- found = RefShaDict->GetDictEntryByName(Name);
- if (found)
- return found;
- }
- return found;
-}
-
-/**
- * \brief Searches both the public and the shadow dictionary (when they
- * exist) for the presence of the DictEntry with given
- * group and element. The public dictionary has precedence on the
- * shadow one.
- * @param group group number of the searched DictEntry
- * @param element element number of the searched DictEntry
- * @return Corresponding DictEntry when it exists, NULL otherwise.
- */
-gdcmDictEntry *gdcmDocument::GetDictEntryByNumber(guint16 group,guint16 element)
-{
- gdcmDictEntry *found = (gdcmDictEntry *)0;
- if (!RefPubDict && !RefShaDict)
- {
- dbg.Verbose(0, "gdcmDocument::GetDictEntry",
- "we SHOULD have a default dictionary");
- }
- if (RefPubDict)
- {
- found = RefPubDict->GetDictEntryByNumber(group, element);
- if (found)
- return found;
- }
- if (RefShaDict)
- {
- found = RefShaDict->GetDictEntryByNumber(group, element);
- if (found)
- return found;
- }
- return found;
-}
-
/**
* \brief Assuming the internal file pointer \ref gdcmDocument::fp
* is placed at the beginning of a tag (TestGroup, TestElement),
}
/**
- * \brief Read the length of an exptected Sequence Delimiter tag i.e.
+ * \brief Read the length of an expected Sequence Delimiter tag i.e.
* (0xfffe, 0xe0dd).
* \sa \ref gdcmDocument::ReadTagLength
* \warning See warning of \ref gdcmDocument::ReadTagLength
* No other way so 'skip' the Data
*
*/
+
void gdcmDocument::Parse7FE0 (void)
{
gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010);
}
}
+
+
/**
* \brief Compares two documents, according to \ref gdcmDicomDir rules
* \warning Does NOT work with ACR-NEMA files
}
}
}
-
return false;
}
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2004/06/21 04:18:25 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.13 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
bool CloseFile(void);
// Write (used in gdcmFile, gdcmDicomDir)
- virtual bool Write(FILE *, FileType);
- virtual void WriteEntryTagVRLength(gdcmDocEntry *tag,
- FILE *_fp, FileType type);
- virtual void WriteEntryValue(gdcmDocEntry *tag,FILE *_fp,FileType type);
- virtual bool WriteEntry(gdcmDocEntry *tag,FILE *_fp,FileType type);
- virtual bool WriteEntries(FILE *_fp,FileType type);
+
+ virtual bool WriteF(FileType type); // New stuff, with recursive exploration
gdcmValEntry * ReplaceOrCreateByNumber(std::string Value,
guint16 Group, guint16 Elem);
-
+
gdcmBinEntry * ReplaceOrCreateByNumber(void *voidArea, int lgth,
- guint16 Group, guint16 Elem);
+ guint16 Group, guint16 Elem);
bool ReplaceIfExistByNumber (char *Value, guint16 Group, guint16 Elem);
virtual void *LoadEntryVoidArea (guint16 Group, guint16 Element);
// Entry
int CheckIfEntryExistByNumber(guint16 Group, guint16 Elem ); // int !
public:
- virtual std::string GetEntryByName (std::string tagName);
- virtual std::string GetEntryVRByName (std::string tagName);
+ virtual std::string GetEntryByName (TagName tagName);
+ virtual std::string GetEntryVRByName (TagName tagName);
virtual std::string GetEntryByNumber (guint16 group, guint16 element);
virtual std::string GetEntryVRByNumber(guint16 group, guint16 element);
virtual int GetEntryLengthByNumber(guint16 group, guint16 element);
virtual bool SetEntryByNumber(std::string content,
guint16 group, guint16 element);
virtual bool SetEntryByNumber(void *content, int lgth,
- guint16 group, guint16 element);
+ guint16 group, guint16 element);
virtual bool SetEntryLengthByNumber(guint32 length,
guint16 group, guint16 element);
// Header entry
gdcmDocEntry *GetDocEntryByNumber (guint16 group, guint16 element);
gdcmDocEntry *GetDocEntryByName (std::string Name);
-
+
gdcmValEntry *GetValEntryByNumber (guint16 group, guint16 element);
gdcmBinEntry *GetBinEntryByNumber (guint16 group, guint16 element);
void SetMaxSizeLoadEntry(long);
void SetMaxSizePrintEntry(long);
- // DictEntry related utilities
-
- gdcmDictEntry *GetDictEntryByName (std::string Name);
- gdcmDictEntry *GetDictEntryByNumber(guint16, guint16);
- gdcmDictEntry *NewVirtualDictEntry(guint16 group,
- guint16 element,
- std::string vr = "unkn",
- std::string fourth = "unkn",
- std::string name = "unkn");
+
// DocEntry related utilities
gdcmDocEntry *ReadNextDocEntry ();
- gdcmDocEntry *NewDocEntryByNumber(guint16 group,
- guint16 element);
- gdcmDocEntry *NewDocEntryByName (std::string Name);
-
- gdcmValEntry *NewValEntryByNumber(guint16 group,
- guint16 element);
- gdcmBinEntry *NewBinEntryByNumber(guint16 group,
- guint16 element);
+
+
guint32 GenerateFreeTagKeyInGroup(guint16 group);
public:
Program: gdcm
Module: $RCSfile: gdcmElementSet.cxx,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:47 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmElementSet.h"
#include "gdcmDebug.h"
+#include "gdcmValEntry.h"
+#include "gdcmBinEntry.h"
+#include "gdcmSeqEntry.h"
//-----------------------------------------------------------------------------
// Constructor / Destructor
{
EntryToDelete = cc->second;
if ( EntryToDelete )
- delete EntryToDelete; // TODO : a verifier
+ delete EntryToDelete;
}
tagHT.clear();
}
void gdcmElementSet::Print(std::ostream & os) {
for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i)
{
- //(*i)->second->SetPrintLevel(printLevel);
+ //(i)->second->SetPrintLevel(printLevel);
(i->second)->Print(os);
}
}
+/**
+ * \brief Writes the Header Entries (Dicom Elements)
+ * from the H Table
+ * @return
+ */
+void gdcmElementSet::Write(FILE *fp, FileType filetype) {
+
+// Troubles expected : BinEntries ARE ValEntries :-(
+// BinEntry is checked first, then ValEntry;
+ gdcmDocEntry *e;
+ for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i)
+ {
+ e=i->second;
+ e->WriteCommonPart(fp, filetype);
+ std::cout<<e->GetKey() << " " << hex << e->GetVR() << " "
+ << e->GetName()
+ << std::endl;
+
+// e->Write(fp,filetype); // This will be the right way to proceed !
+
+ if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(e) ) {
+ BinEntry->Write(fp,filetype);
+ continue;
+ }
+ if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(e) ) {
+ ValEntry->Write(fp,filetype);
+ continue;
+ }
+
+ if (gdcmSeqEntry* SeqEntry = dynamic_cast< gdcmSeqEntry* >(e) ) {
+ SeqEntry->Write(fp,filetype);
+ continue;
+ }
+ }
+}
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmElementSet.h,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:47 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmCommon.h"
#include "gdcmDocEntrySet.h"
+class gdcmValEntry;
+class gdcmBinEntry;
+class gdcmSeqEntry;
+
+
typedef std::map<TagKey, gdcmDocEntry *> TagDocEntryHT;
//-----------------------------------------------------------------------------
virtual bool RemoveEntry(gdcmDocEntry *EntryToRemove);
virtual void Print(std::ostream &os = std::cout);
+ virtual void Write(FILE *fp, FileType filetype);
+
protected:
// Variables
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2004/06/21 04:52:08 $
- Version: $Revision: 1.104 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.105 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
-/**
- * \ingroup gdcmFile
- * \brief returns the gdcmHeader *Header
- * @return
- */
-gdcmHeader *gdcmFile::GetHeader(void) {
- return(Header);
-}
/**
* \ingroup gdcmFile
Program: gdcm
Module: $RCSfile: gdcmFile.h,v $
Language: C++
- Date: $Date: 2004/06/21 04:52:08 $
- Version: $Revision: 1.31 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.32 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
virtual ~gdcmFile(void);
- gdcmHeader *GetHeader(void);
+ /// \brief returns the gdcmHeader *Header
+ inline gdcmHeader *GetHeader(void) {return(Header);};
- // For promotion (performs a deepcopy of pointed header object)
- // TODO Swig gdcmFile(gdcmHeader* header);
- // TODO Swig ~gdcmFile();
+ // For promotion (performs a deepcopy of pointed header object)
+ // TODO Swig gdcmFile(gdcmHeader* header);
+ // TODO Swig ~gdcmFile();
- // On writing purposes. When instance was created through
- // gdcmFile(std::string filename) then the filename argument MUST be
+ // On writing purposes. When instance was created through
+ // gdcmFile(std::string filename) then the filename argument MUST be
// different from the constructor's one (no overwriting allowed).
- // TODO Swig int SetFileName(std::string filename);
+ // TODO Swig int SetFileName(std::string filename);
void SetPixelDataSizeFromHeader(void);
size_t GetImageDataSize();
size_t GetImageDataIntoVector(void* destination, size_t MaxSize);
void * GetImageDataRaw();
size_t GetImageDataIntoVectorRaw(void* destination, size_t MaxSize);
-
+
// Allocates ExpectedSize bytes of memory at this->Data and copies the
// pointed data to it. Copying the image might look useless but
// the caller might destroy it's image (without knowing it: think
bool SetImageData (void * Data, size_t ExpectedSize);
// When the caller is aware we simply point to the data:
// TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
-
- // Push to disk.
- // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
- // incohérente avec l'ordre des octets en mémoire ?
- // TODO Swig int Write();
-
+
+ // Push to disk.
+ // TODO Swig int Write();
+
// Write pixels of ONE image on hard drive
// No test is made on processor "endianity"
// The user must call his reader correctly
/// \brief Header to use to load the file
gdcmHeader *Header;
-
- /// \brief Whether the underlying \ref gdcmHeader was loaded by
+
+ /// \brief Whether the underlying \ref gdcmHeader was loaded by
/// the constructor or passed to the constructor. When false
/// the destructor is in charge of deletion.
bool SelfHeader;
#define BITS_IN_JSAMPLE 8
+#define GDCM_jpr_DEBUG 0
+
/*
DICOM provides a mechanism for supporting the use of JPEG Image Compression
through the Encapsulated Format (see PS 3.3 of the DICOM Standard).
int row_stride; /* physical row width in output buffer */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* In this example we want to open the input file before doing anything else,
* so that the setjmp() error recovery below can assume the file is open.
*/
/* Step 1: allocate and initialize JPEG decompression object */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 1\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* We set up the normal JPEG error routines, then override error_exit. */
jpeg_create_decompress(&cinfo);
/* Step 2: specify data source (eg, a file) */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 2\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
jpeg_stdio_src(&cinfo, fp);
/* Step 3: read file parameters with jpeg_read_header() */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 3\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
(void) jpeg_read_header(&cinfo, TRUE);
* See libjpeg.doc for more info.
*/
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("--------------Header contents :----------------\n");
printf("image_width %d image_height %d\n",
cinfo.image_width , cinfo.image_height);
cinfo.output_components);
printf("nb of color components returned %d \n",
cinfo.data_precision);
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/*
*/
/* Step 4: set parameters for decompression */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 4\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* In this example, we don't need to change any of the defaults set by
* jpeg_read_header(), so we do nothing here.
*/
/* Step 5: Start decompressor */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 5\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
(void) jpeg_start_decompress(&cinfo);
/* We can ignore the return value since suspension is not possible
/* JSAMPLEs per row in output buffer */
row_stride = cinfo.output_width * cinfo.output_components;
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf ("cinfo.output_width %d cinfo.output_components %d row_stride %d\n",
cinfo.output_width, cinfo.output_components,row_stride);
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
/* Step 6: while (scan lines remain to be read) */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 6\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* jpeg_read_scanlines(...); */
/* Here we use the library's state variable cinfo.output_scanline as the
* loop counter, so that we don't have to keep track ourselves.
*/
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf ("cinfo.output_height %d cinfo.output_width %d\n",
cinfo.output_height,cinfo.output_width);
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
pimage=(char *)image_buffer;
while (cinfo.output_scanline < cinfo.output_height) {
}
/* Step 7: Finish decompression */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 7\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
(void) jpeg_finish_decompress(&cinfo);
/* Step 8: Release JPEG decompression object */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 8\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* This is an important step since it will release a good deal of memory. */
#define BITS_IN_JSAMPLE 12
+#define GDCM_jpr_DEBUG 0
// BITS_IN_JSAMPLE is a compile time defined options.
// We need both 8 an 12;
// To avoid renaming *all* the Jpeg functions,
// typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
int row_stride; /* physical row width in output buffer */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* In this example we want to open the input file before doing anything else,
* so that the setjmp() error recovery below can assume the file is open.
*/
/* Step 1: allocate and initialize JPEG decompression object */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 1\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* We set up the normal JPEG error routines, then override error_exit. */
jpeg_create_decompress(&cinfo);
/* Step 2: specify data source (eg, a file) */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 2\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
jpeg_stdio_src(&cinfo, fp);
/* Step 3: read file parameters with jpeg_read_header() */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 3\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
(void) jpeg_read_header(&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* See libjpeg.doc for more info.
*/
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("--------------Header contents :----------------\n");
printf("image_width %d image_height %d\n",
cinfo.image_width , cinfo.image_height);
cinfo.output_components);
printf("nb of color components returned %d \n",
cinfo.data_precision);
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/*
*/
/* Step 4: set parameters for decompression */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 4\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* In this example, we don't need to change any of the defaults set by
* jpeg_read_header(), so we do nothing here.
*/
/* Step 5: Start decompressor */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 5\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
(void) jpeg_start_decompress(&cinfo);
/* We can ignore the return value since suspension is not possible
/* JSAMPLEs per row in output buffer */
row_stride = cinfo.output_width * cinfo.output_components;
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf ("cinfo.output_width %d cinfo.output_components %d row_stride %d\n",
cinfo.output_width, cinfo.output_components,row_stride);
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
/* Step 6: while (scan lines remain to be read) */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 6\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* jpeg_read_scanlines(...); */
* loop counter, so that we don't have to keep track ourselves.
*/
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf ("cinfo.output_height %d cinfo.output_width %d\n",
cinfo.output_height,cinfo.output_width);
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
pimage=(char *)image_buffer;
}
/* Step 7: Finish decompression */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 7\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
(void) jpeg_finish_decompress(&cinfo);
/* We can ignore the return value since suspension is not possible
* with the stdio data source.
*/
/* Step 8: Release JPEG decompression object */
-#ifdef GDCM_DEBUG
+#ifdef GDCM_jpr_DEBUG
printf("Entree Step 8\n");
-#endif //GDCM_DEBUG
+#endif //GDCM_jpr_DEBUG
/* This is an important step since it will release a good deal of memory. */
jpeg_destroy_decompress(&cinfo);
Program: gdcm
Module: $RCSfile: gdcmParsePixels.cxx,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:48 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.7 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
nb = atoi(str_nb.c_str() );
if (nb == 12) nb =16;
}
- //int nBytes= nb/8; //FIXME
+ //int nBytes= nb/8; //FIXME
//int taille = Header->GetXSize() * Header->GetYSize() * Header->GetSamplesPerPixel();
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2004/06/19 23:51:04 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmBinEntry.h"
#include "gdcmGlobal.h"
#include "gdcmUtil.h"
+
#include "gdcmDebug.h"
+
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
for (int i=0;i<SQDepthLevel;i++)
s << " | " ;
}
- std::cout << s.str() << "SQItemNumber " << SQItemNumber << std::endl;
+ std::cout << s.str() << " --- SQItem number " << SQItemNumber << std::endl;
for (ListDocEntry::iterator i = docEntries.begin();
i != docEntries.end();
++i)
}
}
+
+/*
+ * \ingroup gdcmSQItem
+ * \brief canonical Writer
+ */
+ void gdcmSQItem::Write(FILE *fp,FileType filetype) {
+ gdcmDocEntry *Entry;
+ for (ListDocEntry::iterator i = docEntries.begin();
+ i != docEntries.end();
+ ++i)
+ {
+ Entry=*i;
+ (Entry)->WriteCommonPart(fp, filetype);
+
+ if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(Entry) ) {
+ BinEntry->Write(fp,filetype);
+ return;
+ }
+ if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(Entry) ) {
+ ValEntry->Write(fp,filetype);
+ return;
+ }
+ if (gdcmSeqEntry* SeqEntry = dynamic_cast< gdcmSeqEntry* >(Entry) ) {
+ SeqEntry->Write(fp,filetype);
+ return;
+ }
+ }
+}
+
+
//-----------------------------------------------------------------------------
// Public
/**
* \warning we suppose, right now, the element belongs to a Public Group
* (NOT a shadow one)
* @param val string value to set
- * @param group Group of the searched tag.
- * @param element Element of the searched tag.
+ * @param group Group number of the searched tag.
+ * @param element Element number of the searched tag.
* @return true if element was found or created successfully
*/
+
bool gdcmSQItem::SetEntryByNumber(std::string val,guint16 group,
guint16 element)
{
{
if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0xe000 )
continue;
+
if ( ( group < (*i)->GetGroup() )
||( group == (*i)->GetGroup() && element < (*i)->GetElement()) )
{
// that is a method of gdcmDocument :-(
gdcmValEntry* Entry = (gdcmValEntry*)0;
TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+
if ( ! ptagHT->count(key))
{
// we assume a Public Dictionnary *is* loaded
Entry->SetLength(val.length());
docEntries.insert(i,Entry);
return true;
- }
+ }
if (group == (*i)->GetGroup() && element == (*i)->GetElement() )
{
if ( gdcmValEntry* Entry = dynamic_cast<gdcmValEntry*>(*i) )
//-----------------------------------------------------------------------------
// Protected
-//-----------------------------------------------------------------------------
-// Private
-
-// end-user intended : the guy *wants* to create his own SeQuence ?!?
-
-/// \brief to be written if really usefull
-gdcmDocEntry *gdcmSQItem::NewDocEntryByNumber(guint16 group,
- guint16 element) {
-/// \todo TODO
- gdcmDocEntry *a;
- std::cout << " gdcmSQItem::NewDocEntryByNumber : TODO" <<std::endl;
- return a;
-}
-
-/// \brief to be written if really usefull
-gdcmDocEntry *gdcmSQItem::NewDocEntryByName (std::string Name) {
-/// \todo TODO
- gdcmDocEntry *a;
- std::cout << " gdcmSQItem::NewDocEntryByName : TODO" <<std::endl;
- return a;
-}
-
-/**
- * \brief Gets a Dicom Element inside a SQ Item Entry, by name
- * @return
- */
- gdcmDocEntry *gdcmSQItem::GetDocEntryByName(std::string name) {
- gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
- gdcmDictEntry *dictEntry = (*PubDict).GetDictEntryByName(name);
- if( dictEntry == NULL)
- return NULL;
- return GetDocEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement());
-}
/**
- * \ingroup gdcmSQItem
* \brief Gets a Dicom Element inside a SQ Item Entry, by number
* @return
*/
-gdcmDocEntry *gdcmSQItem::GetDocEntryByNumber(guint16 group, guint16 element) {
+gdcmDocEntry *gdcmSQItem::GetDocEntryByNumber(guint16 group, guint16 element) {
for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) {
if ( (*i)->GetGroup()==group && (*i)->GetElement()==element)
return (*i);
}
- return NULL;
+ return NULL;
}
/**
- * \ingroup gdcmSQItem
* \brief Get the value of a Dicom Element inside a SQ Item Entry, by number
* @return
*/
}
return GDCM_UNFOUND;
}
+//-----------------------------------------------------------------------------
+// Private
-/**
- * \ingroup gdcmSQItem
- * \brief Get the value of a Dicom Element inside a SQ Item Entry, by name
- * @param name : name of the searched element.
- * @return
- */
-
-std::string gdcmSQItem::GetEntryByName(TagName name) {
- gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
- gdcmDictEntry *dictEntry = (*PubDict).GetDictEntryByName(name);
-
- if( dictEntry == NULL)
- return GDCM_UNFOUND;
- return GetEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement());
-}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmSQItem.h,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:48 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmDocEntrySet.h"
#include "gdcmDocument.h"
+
+class gdcmBinEntry;
+
//-----------------------------------------------------------------------------
typedef std::list<gdcmDocEntry *> ListDocEntry;
//-----------------------------------------------------------------------------
~gdcmSQItem(void);
virtual void Print(std::ostream &os = std::cout);
+ virtual void Write(FILE *fp, FileType filetype);
/// \brief returns the DocEntry chained List for this SQ Item.
inline ListDocEntry &GetDocEntries() {return docEntries;};
bool SetEntryByNumber(std::string val,guint16 group, guint16 element);
- std::string GetEntryByNumber(guint16 group, guint16 element);
- std::string GetEntryByName(TagName name);
+ virtual std::string GetEntryByNumber(guint16 group, guint16 element);
+
+ inline int GetSQItemNumber()
+ {return SQItemNumber;};
- inline int GetSQItemNumber() { return SQItemNumber;};
+ inline void SetSQItemNumber(int itemNumber)
+ {SQItemNumber=itemNumber;};
- inline void SetSQItemNumber(int itemNumber) { SQItemNumber=itemNumber;};
protected:
// DocEntry related utilities
-
- virtual gdcmDocEntry *NewDocEntryByNumber(guint16 group,
- guint16 element); // TODO
- virtual gdcmDocEntry *NewDocEntryByName (std::string Name); //TODO
+
// Variables
/// \brief chained list of (Elementary) Doc Entries
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/21 04:43:02 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
{
delete *cc;
+ cout << "delete SQItem" << endl;
}
if (!seq_term)
delete seq_term;
std::ostringstream s,s2;
std::string vr;
- //unsigned short int g, e; //not used
- //long lgth; //not used
- //size_t o; //not used
- //char greltag[10]; //group element tag //not used
- //char st[20]; //not used
-
// First, Print the Dicom Element itself.
SetPrintLevel(2);
PrintCommonPart(os);
s << std::endl;
os << s.str();
-
+
+ if (GetReadLength() == 0)
+ return;
+
// Then, Print each SQ Item
for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
- {
+ {
(*cc)->Print(os);
}
- // at end, print the sequence terminator item, if any
+ // at end, print the sequence terminator item, if any
if (delimitor_mode) {
- if (SQDepthLevel>0) {
- for (int i=0;i<SQDepthLevel;i++)
- s2 << " | " ;
- }
+ for (int i=0;i<SQDepthLevel+1;i++)
+ s2 << " | " ;
os << s2.str();
if (seq_term != NULL) {
seq_term->Print(os);
}
}
+
+/*
+ * \brief canonical Writer
+ */
+void gdcmSeqEntry::Write(FILE *fp, FileType filetype) {
+ for(ListSQItem::iterator cc = GetSQItems().begin();
+ cc != GetSQItems().end();
+ ++cc) {
+ std::cout << "Et un SQItem !" << std::endl;
+ (*cc)->Write(fp, filetype);
+ }
+}
//-----------------------------------------------------------------------------
// Public
gdcmSQItem *gdcmSeqEntry::GetSQItemByOrdinalNumber(int nb) {
if (nb<0)
- return (*(items.begin()));
- int count = 0 ;
+ return (*(items.begin()));
+ int count = 0 ;
for(ListSQItem::iterator cc = items.begin();
- cc != items.end();
- count ++, ++cc){
+ cc != items.end();
+ count ++, ++cc){
if (count==nb)
- return (*cc);
+ return (*cc);
}
- return (*(items.end()));
+ return (*(items.end()));
}
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.h,v $
Language: C++
- Date: $Date: 2004/06/21 04:43:02 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.12 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
virtual ~gdcmSeqEntry();
virtual void Print(std::ostream &os = std::cout);
+ virtual void Write(FILE *fp,FileType filetype);
/// \brief returns the SQITEM chained List for this SeQuence.
inline ListSQItem &GetSQItems() { return items; }
/// \brief Sets the Sequence Delimitation Item
inline void SetSequenceDelimitationItem(gdcmDocEntry * e) { seq_term = e;}
-
+
void AddEntry(gdcmSQItem *it, int itemNumber);
gdcmSQItem *GetSQItemByOrdinalNumber(int itemNumber);
Program: gdcm
Module: $RCSfile: gdcmTS.cxx,v $
Language: C++
- Date: $Date: 2004/06/21 04:43:02 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.20 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
while (!from.eof()) {
from >> key;
+
eatwhite(from);
getline(from, name); /// MEMORY LEAK
Program: gdcm
Module: $RCSfile: gdcmValEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/21 12:38:29 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
s << " ==>\t[" << ts->GetValue(v) << "]";
} else {
if (g == 0x0004) {
- if ( (e == 0x1510) || (e == 0x1512) )
- s << " ==>\t[" << ts->GetValue(v) << "]";
- }
+ if ( (e == 0x1510) || (e == 0x1512) )
+ s << " ==>\t[" << ts->GetValue(v) << "]";
+ }
}
}
//if (e == 0x0000) { // elem 0x0000 --> group length
else {
if ( GetLength() !=0 )
sprintf(st," x(%x)", atoi(v.c_str()));//FIXME
- else
- sprintf(st," ");
+ else
+ sprintf(st," ");
}
s << st;
}
s << std::endl;
os << s.str();
}
-
+
+
+/*
+ * \brief canonical Writer
+ */
+void gdcmValEntry::Write(FILE *fp, FileType filetype) {
+ string vr=GetVR();
+ int lgr=GetLength();
+ if (vr == "US" || vr == "SS") {
+ // some 'Short integer' fields may be mulivaluated
+ // each single value is separated from the next one by '\'
+ // we split the string and write each value as a short int
+ std::vector<std::string> tokens;
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Tokenize (GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++) {
+ guint16 val_uint16 = atoi(tokens[i].c_str());
+ void *ptr = &val_uint16;
+ fwrite ( ptr,(size_t)2 ,(size_t)1 ,fp);
+ }
+ tokens.clear();
+ return;
+ }
+ if (vr == "UL" || vr == "SL") {
+ // Some 'Integer' fields may be multivaluated (multiple instances
+ // of integers). But each single integer value is separated from the
+ // next one by '\' (backslash character). Hence we split the string
+ // along the '\' and write each value as an int:
+ std::vector<std::string> tokens;
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Tokenize (GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++){
+ guint32 val_uint32 = atoi(tokens[i].c_str());
+ void *ptr = &val_uint32;
+ fwrite ( ptr,(size_t)4 ,(size_t)1 ,fp);
+ }
+ tokens.clear();
+ return;
+ }
+ fwrite (GetValue().c_str(),
+ (size_t)lgr ,(size_t)1, fp); // Elem value
+}
//-----------------------------------------------------------------------------
// Public
Program: gdcm
Module: $RCSfile: gdcmValEntry.h,v $
Language: C++
- Date: $Date: 2004/06/21 12:38:29 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2004/06/22 13:47:33 $
+ Version: $Revision: 1.13 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public:
gdcmValEntry(gdcmDictEntry* e);
+
gdcmValEntry(gdcmDocEntry* d);
virtual ~gdcmValEntry();
inline void SetValue(std::string val) { value = val; };
virtual void Print(std::ostream &os = std::cout);
-
+ virtual void gdcmValEntry::Write(FILE *fp, FileType filetype);
protected:
/// \brief for 'non string' values. Will be move to gdcmBinEntry, later