located inside a Sequence, when we ReWrite as Implicit VR.
Thx to Mathieu for reporting the pb.
Program: gdcm
Module: $RCSfile: gdcmDataEntry.cxx,v $
Language: C++
- Date: $Date: 2007/06/04 13:40:01 $
- Version: $Revision: 1.43 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.44 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
/**
- * \brief Writes the 'value' area of a DataEntry
+ * \brief Writes the 'common part' + the 'value' area of a DataEntry
* @param fp already open ofstream pointer
* @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
*/
-void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
+void DataEntry::WriteContent(std::ofstream *fp, FileType filetype,
+ bool insideMetaElements)
{
- DocEntry::WriteContent(fp, filetype);
+ // writes the 'common part'
+ DocEntry::WriteContent(fp, filetype, insideMetaElements);
if ( GetGroup() == 0xfffe )
{
Program: gdcm
Module: $RCSfile: gdcmDataEntry.h,v $
Language: C++
- Date: $Date: 2007/07/04 10:40:56 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ 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
void Print(std::ostream &os = std::cout, std::string const &indent = "");
// Write
- virtual void WriteContent(std::ofstream *fp, FileType filetype);
+ virtual void WriteContent(std::ofstream *fp, FileType filetype,
+ bool insideMetaElements );
uint32_t ComputeFullLength();
// Set/Get data
Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:08 $
- Version: $Revision: 1.193 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.194 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
binary_write( *fp, "DICM");
DicomDirMeta *ptrMeta = GetMeta();
- ptrMeta->WriteContent(fp, ExplicitVR);
+ ptrMeta->WriteContent(fp, ExplicitVR, true);
// force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
for(i=0;i<6;++i)
cc != Patients.end();
++cc )
{
- (*cc)->WriteContent( fp, ExplicitVR );
+ (*cc)->WriteContent( fp, ExplicitVR, false );
}
// force writing Sequence Delimitation Item
Program: gdcm
Module: $RCSfile: gdcmDicomDirMeta.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:08 $
- Version: $Revision: 1.37 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.38 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param filetype type of the file (ImplicitVR, ExplicitVR, ...)
* @return
*/
-void DicomDirMeta::WriteContent(std::ofstream *fp, FileType filetype)
+void DicomDirMeta::WriteContent(std::ofstream *fp, FileType filetype,
+ bool insideMetaElements)
{
// 'File Meta Information Version'
i!= DocEntries.end();
++i)
{
- (*i)->WriteContent(fp, filetype);
+ // true : we are in MetaElements
+ (*i)->WriteContent(fp, filetype, true);
}
}
Program: gdcm
Module: $RCSfile: gdcmDicomDirMeta.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:08 $
- Version: $Revision: 1.22 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.23 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
static DicomDirMeta *New(bool empty=false) {return new DicomDirMeta(empty);}
virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" );
- virtual void WriteContent(std::ofstream *fp, FileType t);
+ virtual void WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements);
int ComputeGroup0002Length( );
protected:
Program: gdcm
Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:08 $
- Version: $Revision: 1.41 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.42 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param fp ofstream to write to
* @param t Type of the File (explicit VR, implicitVR, ...)
*/
-void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
+void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements)
{
- DicomDirObject::WriteContent(fp, t);
+ DicomDirObject::WriteContent(fp, t, false);
for(ListDicomDirStudy::iterator cc = Studies.begin();
cc!= Studies.end();
++cc )
{
- (*cc)->WriteContent( fp, t );
+ (*cc)->WriteContent( fp, t, false );
}
}
Program: gdcm
Module: $RCSfile: gdcmDicomDirPatient.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:08 $
- Version: $Revision: 1.31 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ 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
static DicomDirPatient *New(bool empty=false) {return new DicomDirPatient(empty);}
void Print(std::ostream &os = std::cout, std::string const &indent = "" );
- void WriteContent(std::ofstream *fp, FileType t);
+ void WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements);
// Patient methods
/// \brief Adds a new gdcmDicomDirStudy to the Patient
Program: gdcm
Module: $RCSfile: gdcmDicomDirSerie.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:08 $
- Version: $Revision: 1.43 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.44 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param fp ofstream to write to
* @param t Type of the File (explicit VR, implicitVR, ...)
*/
-void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t)
+void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements)
{
- DicomDirObject::WriteContent(fp, t);
+ DicomDirObject::WriteContent(fp, t, false);
for(ListDicomDirImage::iterator cc = Images.begin();
cc!= Images.end();
++cc )
{
- (*cc)->WriteContent( fp, t );
+ (*cc)->WriteContent( fp, t, false );
}
for(ListDicomDirPrivate::iterator cc2 = Privates.begin();
cc2!= Privates.end();
++cc2 )
{
- (*cc2)->WriteContent( fp, t );
+ (*cc2)->WriteContent( fp, t, false);
}
}
Program: gdcm
Module: $RCSfile: gdcmDicomDirSerie.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:08 $
- Version: $Revision: 1.34 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.35 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
static DicomDirSerie *New(bool empty=false) {return new DicomDirSerie(empty);}
void Print( std::ostream &os = std::cout, std::string const &indent = "" );
- void WriteContent( std::ofstream *fp, FileType t );
+ void WriteContent( std::ofstream *fp, FileType t, bool insideMetaElements );
// 'Image' methods
DicomDirImage *NewImage();
Program: gdcm
Module: $RCSfile: gdcmDicomDirStudy.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:08 $
- Version: $Revision: 1.43 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.44 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param t Type of the File (explicit VR, implicitVR, ...)
* @return
*/
-void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t)
+void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements)
{
- DicomDirObject::WriteContent(fp, t);
+ DicomDirObject::WriteContent(fp, t, false);
for(ListDicomDirSerie::iterator cc = Series.begin();
cc!= Series.end();
++cc )
{
- (*cc)->WriteContent( fp, t );
+ (*cc)->WriteContent( fp, t, false );
}
for(ListDicomDirVisit::iterator icc = Visits.begin();
icc!= Visits.end();
++icc )
{
- (*icc)->WriteContent( fp, t );
+ (*icc)->WriteContent( fp, t, false );
}
}
Program: gdcm
Module: $RCSfile: gdcmDicomDirStudy.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:09 $
- Version: $Revision: 1.33 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.34 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
static DicomDirStudy *New(bool empty=false) {return new DicomDirStudy(empty);}
void Print(std::ostream &os = std::cout, std::string const &indent = "" );
- void WriteContent(std::ofstream *fp, FileType t);
+ void WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements);
// 'Serie' methods
DicomDirSerie *NewSerie();
Program: gdcm
Module: $RCSfile: gdcmDicomDirVisit.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:09 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
static DicomDirVisit *New(bool empty=false) {return new DicomDirVisit(empty);}
void Print( std::ostream &os = std::cout, std::string const &indent = "" );
- // void WriteContent( std::ofstream *fp, FileType t );
protected:
DicomDirVisit(bool empty=false);
Program: gdcm
Module: $RCSfile: gdcmDocEntry.cxx,v $
Language: C++
- Date: $Date: 2007/07/24 16:17:04 $
- Version: $Revision: 1.89 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.90 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param fp already open ofstream pointer
* @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
*/
-void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
+void DocEntry::WriteContent(std::ofstream *fp, FileType filetype, bool insideMetaElements)
{
uint32_t ffff = 0xffffffff;
uint16_t group = GetGroup();
binary_write( *fp, elem); //element number
// Dicom V3 group 0x0002 is *always* Explicit VR !
- if ( filetype == ExplicitVR || filetype == JPEG || filetype == JPEG2000 || group == 0x0002 )
+ if ( filetype == ExplicitVR || filetype == JPEG || filetype == JPEG2000 || (group == 0x0002 && insideMetaElements) )
{
// ----------- Writes the common part : the VR + the length
s << "[" << vr << "] ";
std::string name;
- if ( GetElement() == 0x0000 )
+ uint16_t e = GetElement();
+ if ( e == 0x0000 )
name = "Group Length";
+ else if ( GetGroup()%2 == 1 && ( e >= 0x0010 && e <= 0x00ff ) )
+ name = "Private Creator";
else
{
name = GetName();
Program: gdcm
Module: $RCSfile: gdcmDocEntry.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:09 $
- Version: $Revision: 1.67 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.68 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public:
virtual void Print (std::ostream &os = std::cout, std::string const &indent = "");
- virtual void WriteContent(std::ofstream *fp, FileType filetype);
+ virtual void WriteContent(std::ofstream *fp, FileType filetype,
+ bool insideMetaElements);
/// \brief Gets the DicEntry of the current Dicom entry
/// @return The DicEntry of the current Dicom entry
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:09 $
- Version: $Revision: 1.69 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.70 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
/**
* \brief
- * \ref DocEntrySet is an abstract base class for \ref ElementSet
- * and \ref SQItem which are both containers for DocEntries.
+ * \ref DocEntrySet is an abstract base class for \ref ElementSet, \ref SQItem
+ * which are both containers for DocEntries.
* - \ref ElementSet is based on the STL map<> container
* (see \ref ElementSet::TagHT)
* - \ref SQItem is based on an STL list container (see \ref ListDocEntry).
public:
/// \brief write any type of entry to the entry set
- virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0;
+ virtual void WriteContent (std::ofstream *fp, FileType filetype,
+ bool insideMetaElements) = 0;
/// \brief Remove all Entry of the current set
virtual void ClearEntry() = 0;
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2007/07/11 12:21:01 $
- Version: $Revision: 1.363 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.364 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* --> We don't write the element 0x0000 (group length)
*/
- ElementSet::WriteContent(fp, filetype); // This one is recursive
+ ElementSet::WriteContent(fp, filetype, false); // This one is recursive
}
// -----------------------------------------
changeFromUN = false;
CurrentGroup = GetInt16();
CurrentElem = GetInt16();
-
+
// In 'true DICOM' files Group 0002 is always little endian
if ( HasDCMPreamble )
{
realVR = "UL";
}
- // Commented out in order not to generate 'Shadow Groups' where some
+ // Was commented out in order not to generate 'Shadow Groups' where some
// Data Elements are Explicit VR and some other ones Implicit VR
- // (Stupid MatLab DICOM Reader couldn't read gdcm-written images)
- /*
+ // -> Better we fix the problem at Write time
+
else if (CurrentGroup%2 == 1 &&
(CurrentElem >= 0x0010 && CurrentElem <=0x00ff ))
{
// (gggg-0010->00FF where gggg is odd) attributes have to be LO
realVR = "LO";
}
- */
+
else
{
DictEntry *dictEntry = GetDictEntry(CurrentGroup,CurrentElem);//only when ImplicitVR
Program: gdcm
Module: $RCSfile: gdcmElementSet.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:10 $
- Version: $Revision: 1.76 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.77 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param fp ofstream to write to
* @param filetype ExplicitVR/ImplicitVR/ACR/ACR_LIBIDO/JPEG/JPEG2000/...
*/
-void ElementSet::WriteContent(std::ofstream *fp, FileType filetype)
+void ElementSet::WriteContent(std::ofstream *fp, FileType filetype, bool dummy)
{
+ bool insideMetaElements = false;
+ bool yetOutsideMetaElements = false;
+
for (TagDocEntryHT::const_iterator i = TagHT.begin();
i != TagHT.end();
++i)
- {
+ {
+ int group = (i->second)->GetGroup();
+
+ if (yetOutsideMetaElements==false && group == 0x0002)
+ insideMetaElements = true;
+
+ if (insideMetaElements == true && group != 0x0002)
+ {
+ yetOutsideMetaElements = true;
+ insideMetaElements = false;
+ }
+
// depending on the gdcm::Document type
// (gdcm::File; gdcm::DicomDir, (more to come ?)
// some groups *cannot* be present.
// We hereby protect gdcm for writting stupid things
// if they were found in the original document.
- if ( !MayIWrite( (i->second)->GetGroup() ) )
+ if ( !MayIWrite( group ) )
continue;
// Skip 'Group Length' element, since it may be wrong.
||( (filetype == ACR || filetype == ACR_LIBIDO ) && (i->second)->GetGroup() == 0x0008 ) )
)
{
- i->second->WriteContent(fp, filetype);
+ // There are DocEntries, written recursively
+ i->second->WriteContent(fp, filetype, insideMetaElements );
}
}
}
Program: gdcm
Module: $RCSfile: gdcmElementSet.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:10 $
- Version: $Revision: 1.55 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.56 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
virtual void Print(std::ostream &os = std::cout,
std::string const &indent = "" );
- void WriteContent(std::ofstream *fp, FileType filetype);
+ void WriteContent(std::ofstream *fp, FileType filetype,
+ bool insideMetaElements);
bool AddEntry(DocEntry *Entry);
bool RemoveEntry(DocEntry *EntryToRemove);
Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2007/07/24 16:17:04 $
- Version: $Revision: 1.118 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.119 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
/**
- * \brief Prints the common part of DataEntry, SeqEntry
+ * \brief Prints the FileInternal + info on PixelReadConvertor
* @param os ostream we want to print in
* @param indent (unused)
*/
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:11 $
- Version: $Revision: 1.85 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.86 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param fp file pointer to an already open file.
* @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
*/
-void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
+void SQItem::WriteContent(std::ofstream *fp, FileType filetype,
+ bool insideMetaElements)
{
int j;
uint16_t item[4] = { 0xfffe, 0xe000, 0xffff, 0xffff };
// --> makes no difference since the only bugged file we have
// contains 'impossible tag' fffe|0000 in last position !
}
-
- (*it)->WriteContent(fp, filetype);
+ // false : we are not in MetaElements
+ (*it)->WriteContent(fp, filetype, false);
}
//we force the writting of an 'Item Delimitation' item
Program: gdcm
Module: $RCSfile: gdcmSQItem.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:11 $
- Version: $Revision: 1.52 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.53 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
virtual void Print(std::ostream &os = std::cout,
std::string const &indent = "" );
- void WriteContent(std::ofstream *fp, FileType filetype);
+ void WriteContent(std::ofstream *fp, FileType filetype, bool insideMetaElements);
uint32_t ComputeFullLength();
bool AddEntry(DocEntry *Entry); // add to the List
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.cxx,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:11 $
- Version: $Revision: 1.68 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.69 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param fp pointer to an already open file
* @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
*/
-void SeqEntry::WriteContent(std::ofstream *fp, FileType filetype)
+void SeqEntry::WriteContent(std::ofstream *fp, FileType filetype, bool dummy)
{
uint16_t seq_term_gr = 0xfffe;
uint16_t seq_term_el = 0xe0dd;
// ignore 'Zero length' Sequences
if ( GetReadLength() == 0 )
return;
-
- DocEntry::WriteContent(fp, filetype);
+ // false : we are not in MetaElements
+ DocEntry::WriteContent(fp, filetype, false);
for(ListSQItem::iterator cc = Items.begin();
cc != Items.end();
++cc)
- {
- (*cc)->WriteContent(fp, filetype);
+ {
+ (*cc)->WriteContent(fp, filetype, false);
}
// we force the writting of a Sequence Delimitation item
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.h,v $
Language: C++
- Date: $Date: 2007/05/23 14:18:11 $
- Version: $Revision: 1.43 $
+ Date: $Date: 2007/07/26 08:36:49 $
+ Version: $Revision: 1.44 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{return new SeqEntry(group,elem);}
void Print(std::ostream &os = std::cout, std::string const &indent = "" );
- void WriteContent(std::ofstream *fp, FileType filetype);
+ void WriteContent(std::ofstream *fp, FileType filetype, bool insideMetaElements);
uint32_t ComputeFullLength();
void AddSQItem(SQItem *it, int itemNumber);