/// ==0 if GetImageData was used
/// ==-1 if ImageData never read
int PixelRead;
- .
+
/// weather already parsed
int Parsed;
private:
// FIXME: In fact we should be more specific and use :
// friend gdcmHeaderEntry * gdcmHeader::ReadNextElement(void);
+
friend class gdcmHeader;
// Variables
/// *for internal* use only
guint32 ReadLength;
- /// Even when reading explicit vr files, some
- /// elements happen to be implicit. Flag them here
- /// since we can't use the entry->vr without breaking
- /// the underlying dictionary.
+ /// Even when reading explicit vr files, some
+ /// elements happen to be implicit. Flag them here
+ /// since we can't use the entry->vr without breaking
+ /// the underlying dictionary.
bool ImplicitVR;
std::string value;
- /// unsecure memory area to hold 'non string' values
- /// (ie : Lookup Tables, overlays)
+ /// unsecure memory area to hold 'non string' values
+ /// (ie : Lookup Tables, overlays)
void *voidArea;
- /// Offset from the begining of file for direct user access
+ /// Offset from the begining of file for direct user access
size_t Offset;
int printLevel;
* \ingroup gdcmParser
* \brief Sets Entry (Dicom Element) value of an element,
* specified by it's tag (Group, Number)
- * and the length, too ...
+ * and the length, too ...
+ * If the Element is not found, it's just created !
+ * \warning we suppose, right now, the element belongs to a Public Group
+ * (NOT a shadow one)
* @param val string value to set
* @param group Group of the searched tag.
* @param element Element of the searched tag.
- * @return true if element was found, else false
+ * @return true if element was found or created successfully
*/
bool gdcmObject::SetEntryByNumber(std::string val,guint16 group,
- guint16 element) {
-
- //for(ListTag::iterator i=beginObj;i!=endObj;++i) // JPR
- for(ListTag::iterator i=beginObj;;++i) {
- if ( (*i)->GetGroup()==group && (*i)->GetElement()==element) {
+ guint16 element) {
+
+ gdcmHeaderEntry *a;
+ for(ListTag::iterator i=beginObj;;++i) {
+ if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0xe000 )
+ continue;
+ if ( group < (*i)->GetGroup() ||
+ (group == (*i)->GetGroup() && element < (*i)->GetElement()) ){
+ // instead of ReplaceOrCreateByNumber
+ // that is a method of gdcmParser :-(
+ gdcmHeaderEntry *Entry;
+ TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+ if ( ! ptagHT->count(key)) {
+ // we assume the element is a belongs to a Public Group (not a shadow one)
+ // we assume a Public Dictionnary *is* loaded
+ gdcmDict *PubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict();
+ // we assume the invoqued (group,elem) exists
+ // inside the Public Dictionary
+ gdcmDictEntry *DictEntry = PubDict->GetDictEntryByNumber(group, element);
+ // we assume the constuctor didn't fail
+ Entry = new gdcmHeaderEntry(DictEntry);
+ // ----
+ // TODO
+ // ----
+ // better we don't assume too much !
+ // in the next release, gdcmObject will be used
+ // to describe any Header Entry ...
+ } else {
+ Entry = ptagHT->find(key)->second;
+ }
+ Entry->SetValue(val);
+ Entry->SetLength(val.length());
+ plistEntries->insert(i,Entry);
+ return true;
+ }
+ if (group == (*i)->GetGroup() && element == (*i)->GetElement() ) {
(*i)->SetValue(val);
- (*i)->SetLength(val.length()+1);
- return true;
- }
- if (i == endObj) break;
- }
- return false;
+ (*i)->SetLength(val.length());
+ return true;
+ }
+ }
}
/**
* \ingroup gdcmObject
* \ingroup gdcmParser
* \brief Modifies the value of a given Header Entry (Dicom Element)
* if it exists; Creates it with the given value if it doesn't
+ * \warning : adds the Header Entry to the HTable, NOT to the chained List
* @param Value passed as a std::string
- * @param Group
- * @param Elem
- * \return false only if new element creation fails
+ * @param Group group of the Entry
+ * @param Elem element of the Entry
+ * \return pointer to the created Header Entry
+ * NULL if creation failed
*/
-bool gdcmParser::ReplaceOrCreateByNumber(std::string Value,
+gdcmHeaderEntry * gdcmParser::ReplaceOrCreateByNumber(
+ std::string Value,
guint16 Group,
- guint16 Elem ){
- if (CheckIfEntryExistByNumber(Group, Elem) == 0) {
+ guint16 Elem ){
+ gdcmHeaderEntry* a;
+ a = GetHeaderEntryByNumber( Group, Elem);
+ if (a == NULL) {
gdcmHeaderEntry *a =NewHeaderEntryByNumber(Group, Elem);
if (a == NULL)
- return false;
+ return NULL;
AddHeaderEntry(a);
}
- SetEntryByNumber(Value, Group, Elem);
- return(true);
+ //SetEntryByNumber(Value, Group, Elem);
+ a->SetValue(Value);
+ return(a);
}
/**
* @param Value passed as a char*
* @param Group group of the Entry
* @param Elem element of the Entry
- * \return boolean
+ * \return pointer to the created Header Entry
+ * NULL if creation failed
*
*/
-bool gdcmParser::ReplaceOrCreateByNumber(char* Value, guint16 Group, guint16 Elem ) {
+gdcmHeaderEntry * gdcmParser::ReplaceOrCreateByNumber(
+ char* Value,
+ guint16 Group,
+ guint16 Elem ) {
gdcmHeaderEntry* nvHeaderEntry=NewHeaderEntryByNumber(Group, Elem);
if(!nvHeaderEntry)
- return(false);
+ return(NULL);
AddHeaderEntry(nvHeaderEntry);
std::string v = Value;
SetEntryByNumber(v, Group, Elem);
- return(true);
+ return(nvHeaderEntry);
}
/**
// Write (used in gdcmFile, gdcmDicomDir)
virtual bool Write(FILE *, FileType);
- bool ReplaceOrCreateByNumber(std::string Value, guint16 Group, guint16 Elem);
- bool ReplaceOrCreateByNumber( char *Value, guint16 Group, guint16 Elem);
+ gdcmHeaderEntry * ReplaceOrCreateByNumber(std::string Value, guint16 Group, guint16 Elem);
+ gdcmHeaderEntry * ReplaceOrCreateByNumber( char *Value, guint16 Group, guint16 Elem);
bool ReplaceIfExistByNumber ( char *Value, guint16 Group, guint16 Elem);
// System access
gdcmHeaderEntry *NewHeaderEntryByNumber(guint16 group,
guint16 element);
gdcmHeaderEntry *NewHeaderEntryByName (std::string Name);
-
-
+
// Deprecated (Not used) --> commented out
//gdcmHeaderEntry *NewManualHeaderEntryToPubDict(std::string NewTagName,
// std::string VR);
*/
int sw;
/**
- * \brief Size treshold above which an element value will NOT be loaded in
+ * \brief Size threshold above which an element value will NOT be loaded in
* memory (to avoid loading the image/volume itself). By default,
* this upper bound is fixed to 1024 bytes (which might look reasonable
- * when one considers the definition of the various VR contents).
+ * when one considers the definition of the various VR contents).
*/
guint32 MaxSizeLoadEntry;
/**
- * \brief Size treshold above which an element value will NOT be *printed* in
+ * \brief Size threshold above which an element value will NOT be *printed* in
* order no to polute the screen output.
* By default, this upper bound is fixed to 64 bytes.
*/