Program: gdcm
Module: $RCSfile: gdcmBinEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/23 15:01:57 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2004/06/24 18:03:14 $
+ 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
{
gdcmDocEntry::Print(os);
std::ostringstream s;
+ void *voidArea = GetVoidArea();
if (voidArea != NULL)
{
s << " [gdcm::Binary data loaded with length is "
}
else
{
- s << " [gdcm::Binary data NOT loaded]";
+ if ( GetLength() == 0 )
+ s << " []";
+ else
+ {
+ s << " [gdcm::Binary data NOT loaded]";
+ }
+
}
os << s.str();
}
Program: gdcm
Module: $RCSfile: gdcmDocEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/23 13:02:36 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2004/06/24 18:03:14 $
+ 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
*/
void gdcmDocEntry::Write(FILE *fp, FileType filetype) {
+ guint32 FFFF = 0xffffffff;
guint16 group = GetGroup();
VRKey vr = GetVR();
guint16 el = GetElement();
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);
+ if (vr == "SQ") {
+ // we set SQ length to ffffffff
+ // and we shall write a Sequence Delimitor Item
+ // at the end of the Sequence!
+ fwrite ( &FFFF,(size_t)4 ,(size_t)1 ,fp);
+ } else {
+ 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);
+ if (vr == "SQ") {
+ fwrite ( &FFFF,(size_t)4 ,(size_t)1 ,fp);
+ } else {
+ fwrite ( &lgr,(size_t)4 ,(size_t)1 ,fp);
+ }
}
}
/**
* \ingroup gdcmDocEntry
- * \brief tells us if entry is the first one of a Sequence Item (fffe,e00d)
+ * \brief tells us if entry is the last one of a 'no length' SequenceItem
+ * (fffe,e00d)
*/
bool gdcmDocEntry::isItemDelimitor() {
if ( (GetGroup() == 0xfffe) && (GetElement() == 0xe00d) )
}
/**
* \ingroup gdcmDocEntry
- * \brief tells us if entry is the last one of a 'no length' Sequence fffe,e0dd)
+ * \brief tells us if entry is the last one of a 'no length' Sequence
+ * (fffe,e0dd)
*/
bool gdcmDocEntry::isSequenceDelimitor() {
if (GetGroup() == 0xfffe && GetElement() == 0xe0dd)
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/06/23 16:34:36 $
- Version: $Revision: 1.31 $
+ Date: $Date: 2004/06/24 18:03:14 $
+ 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
const unsigned int gdcmDocument::HEADER_LENGTH_TO_READ = 256;
// Refer to gdcmDocument::SetMaxSizeLoadEntry()
-const unsigned int gdcmDocument::MAX_SIZE_LOAD_ELEMENT_VALUE = 4096;
+const unsigned int gdcmDocument::MAX_SIZE_LOAD_ELEMENT_VALUE = 0x7fffffff;// 4096;
-const unsigned int gdcmDocument::MAX_SIZE_PRINT_ELEMENT_VALUE = 64;
+const unsigned int gdcmDocument::MAX_SIZE_PRINT_ELEMENT_VALUE = 0x7fffffff;//64;
//-----------------------------------------------------------------------------
// Constructor / Destructor
long l=ParseDES( this, beg, lgt, false); // le Load sera fait a la volee
(void)l; //is l used anywhere ?
-
- rewind(fp);
+
+ rewind(fp);
// Load 'non string' values
}
//FIXME later : how to use it?
LoadEntryVoidArea(0x0028,0x3006); //LUT Data (CTX dependent)
-
+
CloseFile();
// --------------------------------------------------------------
* if ( filetype == ACR)
* UpdateGroupLength(true,ACR);
*/
-
- gdcmElementSet::Write(fp,filetype);
+
+ gdcmElementSet::Write(fp,filetype);
- /// WriteEntries(fp,type); // old stuff
return true;
}
delete[] a;
return NULL;
}
-
+ return a;
+}
+/**
+ * \brief Loads (from disk) the element content
+ * when a string is not suitable
+ * @param Element Entry whose voidArea is going to be loaded
+ */
+void *gdcmDocument::LoadEntryVoidArea(gdcmBinEntry *Element)
+{
+ size_t o =(size_t)Element->GetOffset();
+ fseek(fp, o, SEEK_SET);
+ size_t l = Element->GetLength();
+ char* a = new char[l];
+ if(!a) {
+ dbg.Verbose(0, "gdcmDocument::LoadEntryVoidArea cannot allocate a");
+ return NULL;
+ }
+ Element->SetVoidArea((void *)a);
+ /// \todo check the result
+ size_t l2 = fread(a, 1, l ,fp);
+ if(l != l2)
+ {
+ delete[] a;
+ return NULL;
+ }
return a;
}
*/
gdcmDocEntry* gdcmDocument::GetDocEntryByNumber(guint16 group, guint16 element)
{
- TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+ TagKey key = gdcmDictEntry::TranslateToKey(group, element);
if ( ! tagHT.count(key))
return NULL;
return tagHT.find(key)->second;
// The elements whose length is bigger than the specified upper bound
// are not loaded. Instead we leave a short notice of the offset of
// the element content and it's length.
-
+
+ std::ostringstream s;
if (length > MaxSizeLoadEntry) {
if (gdcmBinEntry* BinEntryPtr = dynamic_cast< gdcmBinEntry* >(Entry) )
- {
- std::ostringstream s;
+ {
s << "gdcm::NotLoaded (BinEntry)";
s << " Address:" << (long)Entry->GetOffset();
s << " Length:" << Entry->GetLength();
}
// to be sure we are at the end of the value ...
fseek(fp,(long)Entry->GetOffset()+(long)Entry->GetLength(),SEEK_SET);
- return;
- // Be carefull : a BinEntry IS_A ValEntry ...
+ return;
+ // Be carefull : a BinEntry IS_A ValEntry ...
if (gdcmValEntry* ValEntryPtr = dynamic_cast< gdcmValEntry* >(Entry) )
{
- std::ostringstream s;
s << "gdcm::NotLoaded. (ValEntry)";
s << " Address:" << (long)Entry->GetOffset();
s << " Length:" << Entry->GetLength();
s << " x(" << std::hex << Entry->GetLength() << ")";
ValEntryPtr->SetValue(s.str());
- }
+ }
// to be sure we are at the end of the value ...
fseek(fp,(long)Entry->GetOffset()+(long)Entry->GetLength(),SEEK_SET);
return;
// When we find a BinEntry not very much can be done :
if (gdcmBinEntry* BinEntryPtr = dynamic_cast< gdcmBinEntry* >(Entry) ) {
- LoadEntryVoidArea (BinEntryPtr->GetGroup(),BinEntryPtr->GetElement());
- return;
- }
+
+ LoadEntryVoidArea(BinEntryPtr);
+ s << "gdcm::Loaded (BinEntry)";
+ BinEntryPtr->SetValue(s.str());
+ return;
+ }
// Any compacter code suggested (?)
// We need an additional byte for storing \0 that is not on disk
std::string NewValue(length,0);
item_read = fread(&(NewValue[0]), (size_t)length, (size_t)1, fp);
- if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(Entry) ) {
+ if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(Entry) ) {
if ( item_read != 1 ) {
dbg.Verbose(1, "gdcmDocument::LoadElementValue","unread element value");
ValEntry->SetValue("gdcm::UnRead");
else
ValEntry->SetValue(NewValue);
} else {
- // fusible
- std::cout << "Should have a ValEntry, here !" << std::endl;
- }
+ // fusible
+ std::cout << "Should have a ValEntry, here !" << std::endl;
+ }
}
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2004/06/22 14:57:11 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2004/06/24 18:03:14 $
+ 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
bool ReplaceIfExistByNumber (char *Value, guint16 Group, guint16 Elem);
virtual void *LoadEntryVoidArea (guint16 Group, guint16 Element);
+ virtual void *LoadEntryVoidArea (gdcmBinEntry*);
// System access
guint16 SwapShort(guint16); // needed by gdcmFile
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2004/06/23 13:02:36 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2004/06/24 18:03:14 $
+ 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
i != docEntries.end();
++i)
{
+ // Item Delimitor Item IS the last one of a 'no length' SQItem
+ // (when it exists) we don't write it right now
+ // It will be written outside, because ALL the SQItems are written
+ // as 'no length'
+ if ( (*i)->isItemDelimitor() )
+ break;
+ if ( ((*i)->GetGroup() == 0xfffe) && ((*i)->GetElement() == 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;
+ // It's up to the gdcmDocEntry Writter to write the SQItem begin element
+ // (fffe|e000) as a 'no length' one
(*i)->Write(fp, filetype);
}
}
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/23 15:01:57 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2004/06/24 18:03:14 $
+ 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
for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
{
delete *cc;
- std::cout << "delete SQItem" <<std:: endl;
}
if (!seq_term)
delete seq_term;
os << std::endl;
}
else
+ // fusible
os << " -------------- should have a sequence terminator item";
}
}
*/
void gdcmSeqEntry::Write(FILE *fp, FileType filetype)
{
+ guint16 seq_term_gr = 0xfffe;
+ guint16 seq_term_el = 0xe0dd;
+ guint32 seq_term_lg = 0x00000000;
+
+ guint16 item_term_gr = 0xfffe;
+ guint16 item_term_el = 0xe00d;
+
gdcmDocEntry::Write(fp, filetype);
for(ListSQItem::iterator cc = GetSQItems().begin();
cc != GetSQItems().end();
++cc)
{
- (*cc)->Write(fp, filetype);
- }
+ (*cc)->Write(fp, filetype);
+
+ fwrite ( &item_term_gr,(size_t)2 ,(size_t)1 ,fp);
+ fwrite ( &item_term_el,(size_t)2 ,(size_t)1 ,fp);
+ fwrite ( &seq_term_lg,(size_t)4 ,(size_t)1 ,fp);
+ }
+ //we force the writting of a Sequence Delimitaion item
+ // because we wrote the Sequence as a 'no Length' sequence
+ fwrite ( &seq_term_gr,(size_t)2 ,(size_t)1 ,fp);
+ fwrite ( &seq_term_el,(size_t)2 ,(size_t)1 ,fp);
+ fwrite ( &seq_term_lg,(size_t)4 ,(size_t)1 ,fp);
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmValEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/23 13:02:36 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2004/06/24 18:03:14 $
+ 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
{
gdcmDocEntry::Write(fp, filetype);
std::string vr=GetVR();
- int lgr=GetLength();
+ int lgr=GetReadLength();
if (vr == "US" || vr == "SS")
{
// some 'Short integer' fields may be mulivaluated
Program: gdcm
Module: $RCSfile: gdcmValEntry.h,v $
Language: C++
- Date: $Date: 2004/06/23 13:02:36 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2004/06/24 18:03:14 $
+ 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
/// Sets the value (string) of the current Dicom Document Entry
inline void SetValue(std::string val) { value = val; };
-
+
+ /// Sets the value (void *) of the current Dicom Document Entry
+ inline void SetVoidArea(void * val) { voidArea = val; };
+
virtual void Print(std::ostream &os = std::cout);
virtual void Write(FILE *fp, FileType filetype);
protected:
// Members :
/// \brief Document Entry value, internaly represented as a std::string
- /// The Value Representation (\ref gdcmVR) is indenpendently used
+ /// The Value Representation (\ref gdcmVR) is independently used
/// in order to interpret (decode) this field.
std::string value;
};