* Data/* dcm and acr files for the test suite.
* glib dependance removed from un*x version. We now use ISO C99
7.18 Integer types (see stdint.h)
- python/Makefile, src/Makefile src/gdcm.h
* src/ when an explicit vr (like dicom files) suddenly poped an
implicit element we use to mark the underlying DictEntry of the
concerned ElValue with "Implicit". This strategy was damageable
too the public or provite dictionaries, since some of their vr
would be changed. Since Header::FindLength heavily relies on the
detection by Header::FindVR of falsely explicit elements, I
added an extra ImplicitVr member to ElValue (boolean).
The rest of the changes we the necessary adaptations. --- Frog
+2002-11-14 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+ * python/testSuite.py unittest test suite added (uses Data)
+ * Data/* dcm and acr files for the test suite.
+ * glib dependance removed from un*x version. We now use ISO C99
+ 7.18 Integer types (see stdint.h)
+ - python/Makefile, src/Makefile src/gdcm.h
+ * src/ when an explicit vr (like dicom files) suddenly poped an
+ implicit element we use to mark the underlying DictEntry of the
+ concerned ElValue with "Implicit". This strategy was damageable
+ too the public or provite dictionaries, since some of their vr
+ would be changed. Since Header::FindLength heavily relies on the
+ detection by Header::FindVR of falsely explicit elements, I
+ added an extra ImplicitVr member to ElValue (boolean).
+ The rest of the changes we the necessary adaptations.
+
2002-11-12 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
* src/gdcmHeader::FindLength bug fix when trapping falsely explicit
VR files.
+* Group length is not a unique tag in a file. Hence avoid putting it
+ in the element values dictionary without doing something smarter
+ (say, instead of storing the length store the group and the length
+ so we can related a length to a group).
+
GetPubElValByNumber doit faire la difference entre chaine vide
et chaine pas touve''. Eventuellement raiser une exception ?
* fournir une method qui ne fait que lire les elements passes en arguments
sous forme d'une liste.
-grep str2num *.c: c'est une macro sans doute proprifiable
+grep str2num *.cxx: c'est une macro sans doute proprifiable
gdcmHeader::CheckSwap() dans le cas ACR pas propre, degager tout de suite
si on a deduit que c'en est pas...
-CXXFLAGS=`glib-config --cflags`
CPPFLAGS=-g -Wall -Wunused-variable
-LDFLAGS=`glib-config --libs` -g
+LDFLAGS=-g
OBJECTS=gdcmUtil.o \
gdcmHeader.o \
#include <string>
#include <iostream>
#include <stddef.h> // For size_t
-#include <glib.h>
#include <stdio.h> // FIXME For FILE on GCC only
#include <map> // The requirement for the hash table (or map) that
// we shall use:
// 3/ Make sure we can setup some default size value,
// which should be around 4500 entries which is the
// average dictionary size (said JPR)
+#ifdef __GNUC__
+#include <stdint.h>
+#define guint16 uint16_t
+#define guint32 uint32_t
+#define g_malloc malloc
+#define g_free free
+#endif
+#ifdef _MSC_VER
+#include <glib.h>
+#endif
#ifdef _MSC_VER
using namespace std; // string type lives in the std namespace on VC++
public:
//CLEANME gdcmDictEntry();
gdcmDictEntry(guint16 group, guint16 element,
- string vr, string fourth, string name);
+ string vr = "Unknown",
+ string fourth = "Unknown",
+ string name = "Unknown");
static TagKey TranslateToKey(guint16 group, guint16 element);
guint16 GetGroup(void) { return group;};
guint16 GetElement(void){return element;};
string GetVR(void) {return vr; };
- void SetVR(string in){vr = in; };
+ void SetVR(string);
+ bool IsVrUnknown(void);
string GetFourth(void) {return fourth;};
string GetName(void) {return name;};
string GetKey(void) {return key;};
private:
gdcmDictEntry *entry;
guint32 LgrElem;
+ bool ImplicitVr; // 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.
// Might prove of some interest (see _ID_DCM_ELEM)
// int Swap;
public:
ElValue(gdcmDictEntry*);
void SetVR(string);
string GetVR(void);
+ bool IsVrUnknown(void) { return entry->IsVrUnknown(); };
void SetLength(guint32 l){LgrElem = l; };
void SetValue(string val){ value = val; };
void SetOffset(size_t of){ Offset = of; };
+ void SetImplicitVr(void) { ImplicitVr = true; };
+ bool IsImplicitVr(void) { return ImplicitVr; };
string GetValue(void) { return value; };
- guint32 GetLength(void) { return LgrElem; };
+ guint32 GetLength(void) { return LgrElem; };
size_t GetOffset(void) { return Offset; };
guint16 GetGroup(void) { return entry->GetGroup(); };
guint16 GetElement(void) { return entry->GetElement(); };
#include "gdcm.h"
+#include "gdcmUtil.h"
gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement,
string InVr, string InFourth, string InName)
key = trash; // Convertion through assignement
return key;
}
+
+/**
+ * \ingroup gdcmDictEntry
+ * \brief If-and only if-the vr is unset then overwrite it.
+ * @param NewVr New vr to be set.
+ */
+void gdcmDictEntry::SetVR(string NewVr) {
+ if ( IsVrUnknown() )
+ vr = NewVr;
+ else {
+ dbg.Error(true, "gdcmDictEntry::SetVR",
+ "Overwriting vr might compromise a dictionary");
+ }
+}
+
+bool gdcmDictEntry::IsVrUnknown() {
+ if ( vr == "Unknown" )
+ return true;
+ return false;
+}
void ElValue::SetVR(string ValRep) { entry->SetVR(ValRep); }
string ElValue::GetVR(void) { return entry->GetVR(); }
-ElValue::ElValue(gdcmDictEntry* in) { entry = in; }
+ElValue::ElValue(gdcmDictEntry* in) {
+ ImplicitVr = false;
+ entry = in;
+}
#include "gdcm.h"
-extern "C" {
-#include "glib.h"
-}
#include <stdio.h>
// For nthos:
#ifdef _MSC_VER
entCur = deb + 136;
if(memcmp(entCur, "UL", (size_t)2) == 0) {
filetype = ExplicitVR;
- dbg.Verbose(0, "gdcmHeader::CheckSwap:",
+ dbg.Verbose(1, "gdcmHeader::CheckSwap:",
"explicit Value Representation");
} else {
filetype = ImplicitVR;
- dbg.Verbose(0, "gdcmHeader::CheckSwap:",
+ dbg.Verbose(1, "gdcmHeader::CheckSwap:",
"not an explicit Value Representation");
}
if (net2host) {
sw = 4321;
- dbg.Verbose(0, "gdcmHeader::CheckSwap:",
+ dbg.Verbose(1, "gdcmHeader::CheckSwap:",
"HostByteOrder != NetworkByteOrder");
} else {
sw = 0;
- dbg.Verbose(0, "gdcmHeader::CheckSwap:",
+ dbg.Verbose(1, "gdcmHeader::CheckSwap:",
"HostByteOrder = NetworkByteOrder");
}
RealExplicit = false;
if ( RealExplicit ) {
- ElVal->SetVR(vr);
+ if ( ElVal->IsVrUnknown() )
+ ElVal->SetVR(vr);
return;
}
// We thought this was explicit VR, but we end up with an
// implicit VR tag. Let's backtrack.
- dbg.Verbose(1, "gdcmHeader::FindVR:",
- "Falsely explicit vr file");
- ElVal->SetVR("Implicit");
+ dbg.Verbose(1, "gdcmHeader::FindVR:", "Falsely explicit vr file");
fseek(fp, PositionOnEntry, SEEK_SET);
+ // When this element is known in the dictionary we shall use, e.g. for
+ // the semantics (see the usage of IsAnInteger), the vr proposed by the
+ // dictionary entry. Still we have to flag the element as implicit since
+ // we know now our assumption on expliciteness is not furfilled.
+ // avoid .
+ if ( ElVal->IsVrUnknown() )
+ ElVal->SetVR("Implicit");
+ ElVal->SetImplicitVr();
}
void gdcmHeader::FindLength( ElValue * ElVal) {
guint16 length16;
string vr = ElVal->GetVR();
- if ( (filetype == ExplicitVR) && (vr != "Implicit") ) {
+ if ( (filetype == ExplicitVR) && ! ElVal->IsImplicitVr() ) {
if ( (vr=="OB") || (vr=="OW") || (vr=="SQ") || (vr=="UN") ) {
// The following two bytes are reserved, so we skip them,
guint16 elem = ElVal->GetElement();
string vr = ElVal->GetVR();
guint32 length = ElVal->GetLength();
+
fseek(fp, (long)ElVal->GetOffset(), SEEK_SET);
// Sequences not treated yet !
// Find out if the tag we encountered is in the dictionaries:
gdcmDictEntry * NewTag = IsInDicts(g, n);
if (!NewTag)
- NewTag = new gdcmDictEntry(g, n, "Unknown", "Unknown", "Unknown");
+ NewTag = new gdcmDictEntry(g, n);
NewElVal = new ElValue(NewTag);
if (!NewElVal) {
bool gdcmHeader::IsAnInteger(guint16 group, guint16 element,
string vr, guint32 length ) {
- // When we have some semantics on the element we just read, and we
- // a priori now we are dealing with an integer, then we can swap it's
- // element value properly.
+ // When we have some semantics on the element we just read, and if we
+ // a priori know we are dealing with an integer, then we shall be
+ // able to swap it's element value properly.
if ( element == 0 ) { // This is the group length of the group
if (length != 4)
dbg.Error("gdcmHeader::ShouldBeSwaped", "should be four");
-#include <ctype.h>
+#include <ctype.h> // For isspace
#include "gdcmUtil.h"
gdcmDebug::gdcmDebug(int level) {