Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/01/20 11:07:07 $
- Version: $Revision: 1.201 $
+ Date: $Date: 2005/01/23 10:12:33 $
+ Version: $Revision: 1.204 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/**
* \brief constructor
- * @param filename file to be opened for parsing
+ * @param filename 'Document' (File or DicomDir) to be opened for parsing
*/
Document::Document( std::string const &filename ) : ElementSet(-1)
{
return false;
}
- if( TagHT.empty() )
+ //if( TagHT.empty() )
+ if ( IsEmpty() )
{
gdcmVerboseMacro( "No tag in internal hash table.");
return false;
return GetDocEntry(0x0002, 0x0010) != NULL;
}
+/**
+ * \brief Predicate for Papyrus file
+ * Dedicated to whomsoever it may concern
+ * @return True when the file is a Papyrus file.
+ */
+bool Document::IsPapyrus()
+{
+ // check for Papyrus private Sequence
+ DocEntry *e = GetDocEntry(0x0041, 0x1050);
+ if ( !e )
+ return false;
+ // check if it's actually a Sequence
+ if ( !dynamic_cast<SeqEntry*>(e) )
+ return false;
+ return true;
+}
+
/**
* \brief returns the File Type
* (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
//-----------------------------------------------------------------------------
// Protected
-/**
- * \brief Checks if a given Dicom Element exists within the H table
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return true is found
- */
-bool Document::CheckIfEntryExist(uint16_t group, uint16_t elem )
-{
- const std::string &key = DictEntry::TranslateToKey(group, elem );
- return TagHT.count(key) != 0;
-}
-
-
-/**
- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public and private dictionaries
- * for the element value representation of a given tag.
- * @param group Group number of the searched tag.
- * @param elem Element number of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string Document::GetEntry(uint16_t group, uint16_t elem)
-{
- TagKey key = DictEntry::TranslateToKey(group, elem);
- if ( !TagHT.count(key))
- {
- return GDCM_UNFOUND;
- }
-
- return ((ValEntry *)TagHT.find(key)->second)->GetValue();
-}
-
/**
* \brief Searches within Header Entries (Dicom Elements) parsed with
* the public and private dictionaries
return false;
}*/
-/**
- * \brief retrieves a Dicom Element using (group, element)
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return
- */
-DocEntry *Document::GetDocEntry(uint16_t group, uint16_t elem)
-{
- TagKey key = DictEntry::TranslateToKey(group, elem);
- if ( !TagHT.count(key))
- {
- return NULL;
- }
- return TagHT.find(key)->second;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * ValEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding ValEntry.
- */
-ValEntry *Document::GetValEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( ValEntry *entry = dynamic_cast<ValEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound ValEntry.");
-
- return 0;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * BinEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding BinEntry.
- */
-BinEntry *Document::GetBinEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( BinEntry *entry = dynamic_cast<BinEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound BinEntry.");
-
- return 0;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * SeqEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding SeqEntry.
- */
-SeqEntry *Document::GetSeqEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( SeqEntry *entry = dynamic_cast<SeqEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound SeqEntry.");
-
- return 0;
-}
-
/**
* \brief Loads the element while preserving the current
{
if ( newDocEntry->IsSequenceDelimitor() )
{
- seqEntry->SetSequenceDelimitationItem( newDocEntry );
+ seqEntry->SetDelimitationItem( newDocEntry );
break;
}
}
offsetStartCurrentSQItem = Fp->tellg();
// end try -----------------
- seqEntry->AddEntry( itemSQ, SQItemNumber );
+ seqEntry->AddSQItem( itemSQ, SQItemNumber );
SQItemNumber++;
if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max )
{
return newEntry;
}
-
+//GenerateFreeTagKeyInGroup? What was it designed for ?!?
/**
* \brief Generate a free TagKey i.e. a TagKey that is not present
* in the TagHt dictionary.
* @param group The generated tag must belong to this group.
* @return The element of tag with given group which is fee.
*/
-uint32_t Document::GenerateFreeTagKeyInGroup(uint16_t group)
-{
- for (uint32_t elem = 0; elem < UINT32_MAX; elem++)
- {
- TagKey key = DictEntry::TranslateToKey(group, elem);
- if (TagHT.count(key) == 0)
- {
- return elem;
- }
- }
- return UINT32_MAX;
-}
+//uint32_t Document::GenerateFreeTagKeyInGroup(uint16_t group)
+//{
+// for (uint32_t elem = 0; elem < UINT32_MAX; elem++)
+// {
+// TagKey key = DictEntry::TranslateToKey(group, elem);
+// if (TagHT.count(key) == 0)
+// {
+// return elem;
+// }
+// }
+// return UINT32_MAX;
+//}
/**
* \brief Assuming the internal file pointer \ref Document::Fp
}
}
-/**
+/*
* \brief Walk recursively the given \ref DocEntrySet, and feed
* the given hash table (\ref TagDocEntryHT) with all the
* \ref DocEntry (Dicom entries) encountered.
}
}*/
-/**
+/*
* \brief Build a \ref TagDocEntryHT (i.e. a std::map<>) from the current
* Document.
*