- gdcmDocEntry* a;
- gdcmBinEntry* b = 0;
- a = GetDocEntryByNumber( Group, Elem);
- if (a == NULL) {
- a =NewBinEntryByNumber(Group, Elem);
- if (a == NULL)
- return NULL;
-
- b = new gdcmBinEntry(a);
- AddEntry(b);
- }
- SetEntryByNumber(voidArea, lgth, Group, Elem);
- b->SetVoidArea(voidArea);
-
- return b;
-}
-
-
-
-/**
- * \brief Set a new value if the invoked element exists
- * Seems to be useless !!!
- * @param Value new element value
- * @param Group group number of the Entry
- * @param Elem element number of the Entry
- * \return boolean
- */
-bool gdcmDocument::ReplaceIfExistByNumber(char* Value, guint16 Group, guint16 Elem )
-{
- std::string v = Value;
- SetEntryByNumber(v, Group, Elem);
- return true;
-}
-
-//-----------------------------------------------------------------------------
-// Protected
-
-/**
- * \brief Checks if a given Dicom Element exists within the H table
- * @param group Group number of the searched Dicom Element
- * @param element Element number of the searched Dicom Element
- * @return number of occurences
- */
-int gdcmDocument::CheckIfEntryExistByNumber(guint16 group, guint16 element ) {
- std::string key = gdcmDictEntry::TranslateToKey(group, element );
- return tagHT.count(key);
-}
-
-/**
- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public and private dictionaries
- * for the element value of a given tag.
- * \warning Don't use any longer : use GetPubEntryByName
- * @param tagName name of the searched element.
- * @return Corresponding element value when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmDocument::GetEntryByName(std::string tagName) {
- gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName);
- if( dictEntry == NULL)
- return GDCM_UNFOUND;
-
- return GetEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement());
-}
-
-/**
- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public and private dictionaries
- * for the element value representation of a given tag.
- *
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param tagName name of the searched element.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmDocument::GetEntryVRByName(TagName tagName) {
- gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName);
- if( dictEntry == NULL)
- return GDCM_UNFOUND;
-
- gdcmDocEntry* elem = GetDocEntryByNumber(dictEntry->GetGroup(),
- dictEntry->GetElement());
- return elem->GetVR();
-}
-
-
-/**
- * \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 element Element number of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmDocument::GetEntryByNumber(guint16 group, guint16 element){
- TagKey key = gdcmDictEntry::TranslateToKey(group, element);
- if ( ! tagHT.count(key))
- return GDCM_UNFOUND;
- return ((gdcmValEntry *)tagHT.find(key)->second)->GetValue();
-}
-
-/**
- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public and private dictionaries
- * for the element value representation of a given tag..
- *
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param group Group number of the searched tag.
- * @param element Element number of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmDocument::GetEntryVRByNumber(guint16 group, guint16 element) {
- gdcmDocEntry* elem = GetDocEntryByNumber(group, element);
- if ( !elem )
- return GDCM_UNFOUND;
- return elem->GetVR();
-}
-
-/**
- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public and private dictionaries
- * for the value length of a given tag..
- * @param group Group number of the searched tag.
- * @param element Element number of the searched tag.
- * @return Corresponding element length; -2 if not found
- */
-int gdcmDocument::GetEntryLengthByNumber(guint16 group, guint16 element) {
- gdcmDocEntry* elem = GetDocEntryByNumber(group, element);
- if ( !elem )
- return -2;
- return elem->GetLength();
-}
-/**
- * \brief Sets the value (string) of the Header Entry (Dicom Element)
- * @param content string value of the Dicom Element
- * @param tagName name of the searched Dicom Element.
- * @return true when found
- */
-bool gdcmDocument::SetEntryByName(std::string content,std::string tagName) {
- gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName);
- if( dictEntry == NULL)
- return false;
-
- return SetEntryByNumber(content,dictEntry->GetGroup(),
- dictEntry->GetElement());
-}
-
-/**
- * \brief Accesses an existing gdcmDocEntry (i.e. a Dicom Element)
- * through it's (group, element) and modifies it's content with
- * the given value.
- * @param content new value (string) to substitute with
- * @param group group number of the Dicom Element to modify
- * @param element element number of the Dicom Element to modify
- */
-bool gdcmDocument::SetEntryByNumber(std::string content,
- guint16 group,
- guint16 element)
-{
- gdcmValEntry* ValEntry = GetValEntryByNumber(group, element);
- if (!ValEntry)
- {
- dbg.Verbose(0, "gdcmDocument::SetEntryByNumber: no corresponding",
- " ValEntry (try promotion first).");
- return false;
- }
-
- // Non even content must be padded with a space (020H).
- if((content.length())%2)
- content = content + '\0';
-
- ValEntry->SetValue(content);
-
- // Integers have a special treatement for their length:
- VRKey vr = ValEntry->GetVR();
- if( (vr == "US") || (vr == "SS") )
- ValEntry->SetLength(2);
- else if( (vr == "UL") || (vr == "SL") )
- ValEntry->SetLength(4);
- else
- ValEntry->SetLength(content.length());
-
- return true;
-}
-
-/**
- * \brief Accesses an existing gdcmDocEntry (i.e. a Dicom Element)
- * through it's (group, element) and modifies it's content with
- * the given value.
- * @param content new value (void *) to substitute with
- * @param group group number of the Dicom Element to modify
- * @param element element number of the Dicom Element to modify
- */
-bool gdcmDocument::SetEntryByNumber(void *content,
- int lgth,
- guint16 group,
- guint16 element)
-{
- (void)lgth; //not used
- TagKey key = gdcmDictEntry::TranslateToKey(group, element);
- if ( ! tagHT.count(key))
- return false;
-
-/* Hope Binray field length is never wrong
- if(lgth%2) // Non even length are padded with a space (020H).
- {
- lgth++;
- //content = content + '\0'; // fing a trick to enlarge a binary field?
- }
-*/
- gdcmBinEntry * a;
- a = (gdcmBinEntry *)tagHT[key];
- a->SetVoidArea(content);
- //a->SetLength(lgth); // ???
- return true;
-}
-
-/**
- * \brief Accesses an existing gdcmDocEntry (i.e. a Dicom Element)
- * in the PubDocEntrySet of this instance
- * through it's (group, element) and modifies it's length with
- * the given value.
- * \warning Use with extreme caution.
- * @param l new length to substitute with
- * @param group group number of the Entry to modify
- * @param element element number of the Entry to modify
- * @return true on success, false otherwise.
- */
-bool gdcmDocument::SetEntryLengthByNumber(guint32 l,
- guint16 group,
- guint16 element)
-{
- TagKey key = gdcmDictEntry::TranslateToKey(group, element);
- if ( ! tagHT.count(key))
- return false;
- if (l%2) l++; // length must be even
- ( ((tagHT.equal_range(key)).first)->second )->SetLength(l);
-
- return true ;
-}
-
-/**
- * \brief Gets (from Header) the offset of a 'non string' element value
- * (LoadElementValues has already be executed)
- * @param Group group number of the Entry
- * @param Elem element number of the Entry
- * @return File Offset of the Element Value
- */
-size_t gdcmDocument::GetEntryOffsetByNumber(guint16 Group, guint16 Elem)
-{
- gdcmDocEntry* Entry = GetDocEntryByNumber(Group, Elem);
- if (!Entry)