Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/09/17 13:11:16 $
- Version: $Revision: 1.81 $
+ Date: $Date: 2004/09/22 10:34:53 $
+ 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
void gdcmDocument::Write(FILE* fp,FileType filetype)
{
/// \todo move the following lines (and a lot of others, to be written)
- /// to a future function CheckAndCorrectHeader
-
- /// WARNING : Si on veut ecrire du DICOM V3 a partir d'un DcmHeader ACR-NEMA
- /// 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 (?)
-
+ /// to a future function CheckAndCorrectHeader
+ /// (necessary if user wants to write a DICOM V3 file
+ /// starting from an ACR-NEMA (V2) gdcmHeader
+
if (filetype == gdcmImplicitVR)
{
std::string implicitVRTransfertSyntax = UI1_2_840_10008_1_2;
}
-/**
- * \brief Modifies the value of a given Header Entry (Dicom Element)
- * when it exists. Create it with the given value when unexistant.
- * @param value (string) Value to be set
- * @param group Group number of the Entry
- * @param elem Element number of the Entry
- * \return pointer to the modified/created Header Entry (NULL when creation
- * failed).
- */
-
-/*
-gdcmValEntry * gdcmDocument::ReplaceOrCreateByNumber(
- std::string const & value,
- uint16_t group,
- uint16_t elem )
-{
- gdcmValEntry* valEntry = 0;
- gdcmDocEntry* currentEntry = GetDocEntryByNumber( group, elem);
-
- if (!currentEntry)
- {
- // The entry wasn't present and we simply create the required ValEntry:
- currentEntry = NewDocEntryByNumber(group, elem);
- if (!currentEntry)
- {
- dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: call to"
- " NewDocEntryByNumber failed.");
- return NULL;
- }
- valEntry = new gdcmValEntry(currentEntry);
- if ( !AddEntry(valEntry))
- {
- dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: AddEntry"
- " failed allthough this is a creation.");
- }
- }
- else
- {
- valEntry = dynamic_cast< gdcmValEntry* >(currentEntry);
- if ( !valEntry ) // Euuuuh? It wasn't a ValEntry
- // then we change it to a ValEntry ?
- // Shouldn't it be considered as an error ?
- {
- // We need to promote the gdcmDocEntry to a gdcmValEntry:
- valEntry = new gdcmValEntry(currentEntry);
- if (!RemoveEntry(currentEntry))
- {
- dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: removal"
- " of previous DocEntry failed.");
- return NULL;
- }
- if ( !AddEntry(valEntry))
- {
- dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: adding"
- " promoted ValEntry failed.");
- return NULL;
- }
- }
- }
-
- SetEntryByNumber(value, group, elem);
-
- return valEntry;
-}
-*/
-
/**
* \brief Modifies the value of a given Header Entry (Dicom Element)
* when it exists. Create it with the given value when unexistant.
* @param VR V(alue) R(epresentation) of the Entry -if private Entry-
* \return pointer to the modified/created Header Entry (NULL when creation
* failed).
- */
-
- // TODO : write something clever, using default value for VR
- // to avoid code duplication
- // (I don't know how to tell NewDocEntryByNumber
- // that ReplaceOrCreateByNumber was called with a default value)
-
+ */
gdcmValEntry * gdcmDocument::ReplaceOrCreateByNumber(
std::string const & value,
uint16_t group,
if (!dictEntry)
{
- currentEntry = NewDocEntryByNumber(group, elem,VR);
+ currentEntry = NewDocEntryByNumber(group, elem, VR);
}
else
{
return elem->GetVR();
}
-
/**
* \brief Searches within Header Entries (Dicom Elements) parsed with
* the public and private dictionaries
gdcmBinEntry* a = (gdcmBinEntry *)TagHT[key];
a->SetVoidArea(content);
a->SetLength(lgth);
+ a->SetValue(GDCM_BINLOADED);
return true;
}
{
dbg.Verbose(0, "gdcmDocument::LoadEntryVoidArea setting failed.");
}
-
return a;
}
/**
// hierarchy and the Key is simply of the form ( group, elem )...
if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) )
{
+ (void)dummy;
newValEntry->SetKey( newValEntry->GetKey() );
}
// ...but when "set" is a gdcmSQItem, we are inserting this new
// form ( group, elem )...
if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) )
{
+ (void)dummy;
newBinEntry->SetKey( newBinEntry->GetKey() );
}
// but when "this" is a SQItem, we are inserting this new
// level of one:
if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) )
{
+ (void)dummy;
newSeqEntry->SetDepthLevel( 1 );
newSeqEntry->SetKey( newSeqEntry->GetKey() );
}
// When we find a BinEntry not very much can be done :
if (gdcmBinEntry* binEntryPtr = dynamic_cast< gdcmBinEntry* >(entry) )
{
- s << "gdcm::Loaded (BinEntry)";
+ s << GDCM_BINLOADED;
binEntryPtr->SetValue(s.str());
LoadEntryVoidArea(binEntryPtr); // last one, not to erase length !
return;
* a Dicom header will need to dig in the gdcm internals (which
* implies exposing all the internal data structures to the API).
* In order to avoid this burden to the user, \ref BuildFlatHashTable
- * recursively builds a temporary hash table, which olds all the
+ * recursively builds a temporary hash table, which holds all the
* Dicom entries in a flat structure (a \ref TagDocEntryHT i.e. a
* std::map<>).
* \warning Of course there is NO integrity constrain between the
- * returned \ref TagDocEntryHT and the \ref gdcmElemenSet used
- * to build it. Hence if the underlying \ref gdcmElemenSet is
+ * returned \ref TagDocEntryHT and the \ref gdcmElementSet used
+ * to build it. Hence if the underlying \ref gdcmElementSet is
* altered, then it is the caller responsability to invoke
* \ref BuildFlatHashTable again...
* @return The flat std::map<> we juste build.