else
dbg.Error(!fp, "gdcmHeader::gdcmHeader cannot open file", InFilename);
ParseHeader();
+ LoadElements();
AddAndDefaultElements();
}
if( group == 0xfffe )
SkipLoad = true;
- // The group length doesn't represent data to be loaded in memory, since
- // each element of the group shall be loaded individualy.
- if( elem == 0 )
- //SkipLoad = true; // modif sauvage JPR
- // On charge la longueur du groupe
- // quand l'element 0x0000 est présent !
-
if ( SkipLoad ) {
- // FIXME the following skip is not necessary
- SkipElementValue(ElVal);
ElVal->SetLength(0);
ElVal->SetValue("gdcm::Skipped");
return;
// pour les elements de Value Multiplicity > 1
// on aura en fait une serie d'entiers
- // code original
-
- //if ( IsAnInteger(ElVal) ) {
- // guint32 NewInt;
- // if( length == 2 ) {
- // NewInt = ReadInt16();
- // } else if( length == 4 ) {
- //
- // NewInt = ReadInt32();
- // } else
- // dbg.Error(true, "LoadElementValue: Inconsistency when reading Int.");
- //
- // //FIXME: make the following an util fonction
- // ostringstream s;
- // s << NewInt;
- // ElVal->SetValue(s.str());
- // return;
- //}
-
- // modif proposee. JPR
// on devrait pouvoir faire + compact (?)
if ( IsAnInteger(ElVal) ) {
return;
}
-
-
// FIXME The exact size should be length if we move to strings or whatever
char* NewValue = (char*)malloc(length+1);
if( !NewValue) {
* the ones of the official DICOM fields Rows, Columns and Planes.
*/
void gdcmHeader::AddAndDefaultElements(void) {
- gdcmElValue* NewEntry = (gdcmElValue*)0;
+ gdcmElValue* NewElVal = (gdcmElValue*)0;
+ string NewVal;
+
+ NewElVal = NewManualElValToPubDict("gdcmXSize", "US");
+ if (!NewElVal) return;
+ NewVal = GetElValByName("Rows");
+ if (NewVal != "gdcm::Unfound")
+ NewElVal->SetValue(NewVal);
+ else
+ NewElVal->SetValue("0");
+
+
+ NewElVal = NewManualElValToPubDict("gdcmYSize", "US");
+ if (!NewElVal) return;
+ NewVal = GetElValByName("Columns");
+ if (NewVal != "gdcm::Unfound")
+ NewElVal->SetValue(NewVal);
+ else
+ NewElVal->SetValue("0");
- NewEntry = NewElValueByName("gdcmXSize");
- NewEntry->SetValue(GetElValByName("Rows"));
- PubElVals.Add(NewEntry);
- NewEntry = NewElValueByName("gdcmYSize");
- NewEntry->SetValue(GetElValByName("Columns"));
- PubElVals.Add(NewEntry);
+ NewElVal = NewManualElValToPubDict("gdcmZSize", "US");
+ if (!NewElVal) return;
+ NewVal = GetElValByName("Planes");
+ if (NewVal != "gdcm::Unfound")
+ NewElVal->SetValue(NewVal);
+ else
+ NewElVal->SetValue("0");
+}
- NewEntry = NewElValueByName("gdcmZSize");
- NewEntry->SetValue(GetElValByName("Planes"));
- PubElVals.Add(NewEntry);
+/**
+ * \ingroup gdcmHeader
+ * \brief Small utility function that creates a new manually crafted
+ * (as opposed as read from the file) gdcmElValue with user
+ * specified name and adds it to the public tag hash table.
+ * Refer to gdcmHeader::AddAndDefaultElements for a typical usage.
+ * \note A fake TagKey is generated so the PubDict can keep it's coherence.
+ * @param NewTagName The name to be given to this new tag.
+ * @param VR The Value Representation to be given to this new tag.
+ * @ return The newly hand crafted Element Value.
+ */
+gdcmElValue* gdcmHeader::NewManualElValToPubDict(string NewTagName, string VR) {
+ gdcmElValue* NewElVal = (gdcmElValue*)0;
+ guint32 StuffGroup = 0xffff; // Group to be stuffed with additional info
+ guint32 FreeElem = 0;
+ gdcmDictEntry* NewEntry = (gdcmDictEntry*)0;
+
+ FreeElem = PubElVals.GenerateFreeTagKeyInGroup(StuffGroup);
+ if (FreeElem == UINT32_MAX) {
+ dbg.Verbose(1, "gdcmHeader::NewManualElValToPubDict",
+ "Group 0xffff in Public Dict is full");
+ return (gdcmElValue*)0;
+ }
+ NewEntry = new gdcmDictEntry(StuffGroup, FreeElem,
+ VR, "GDCM", NewTagName);
+ NewElVal = new gdcmElValue(NewEntry);
+ PubElVals.Add(NewElVal);
+ return NewElVal;
}
/**