#include <sstream>
#include "gdcmUtil.h"
-#define HEADER_LENGTH_TO_READ 256 // on ne lit plus que le debut
-
-#define DEBUG 1
+#define HEADER_LENGTH_TO_READ 256 // on ne lit plus que le debut
+#define _MaxSizeLoadElementValue_ 1024 // longueur au dela de laquelle on ne charge plus les valeurs
namespace Error {
struct FileReadError {
}
//FIXME: this looks dirty to me...
+
#define str2num(str, typeNum) *((typeNum *)(str))
+// str est un pointeur dans un tableau de caractères, qui doit contenir,
+// à cet endroit la, la représentation binaire d'un entier (16 ou 32 bits)
+// je veux récupérer ça ... dans un entier.
+// s'il y a une autre solution, évitant des cast et les indirections,
+// je suis preneur
+
VRHT * gdcmHeader::dicom_vr = (VRHT*)0;
gdcmDictSet* gdcmHeader::Dicts = new gdcmDictSet();
}
gdcmHeader::gdcmHeader (const char* InFilename) {
- SetMaxSizeLoadElementValue(1024);
+ SetMaxSizeLoadElementValue(_MaxSizeLoadElementValue_);
filename = InFilename;
Initialise();
fp=fopen(InFilename,"rw");
net2host = false;
// The easiest case is the one of a DICOM header, since it possesses a
- // file preamble where it suffice to look for the sting "DICM".
+ // file preamble where it suffice to look for the string "DICM".
lgrLue = fread(deb, 1, HEADER_LENGTH_TO_READ, fp);
entCur = deb + 128;
sw = 3412;
}
-void gdcmHeader::GetPixels(size_t lgrTotale, void* Pixels) {
+void gdcmHeader::GetPixels(size_t lgrTotale, void* _Pixels) {
size_t pixelsOffset;
pixelsOffset = GetPixelOffset();
fseek(fp, pixelsOffset, SEEK_SET);
- fread(Pixels, 1, lgrTotale, fp);
+ fread(_Pixels, 1, lgrTotale, fp);
}
// Il y en a encore DIX-SEPT, comme ça.
// Il faudrait trouver qq chose + rusé ...
//
+// --> probablement TOUS les supprimer (Eric dixit)
+//
void gdcmHeader::FixFoundLength(ElValue * ElVal, guint32 FoundLength) {
// in little endian, and big endian coding only starts at the next
// group. The corresponding code can be hard to analyse and adds
// many additional unnecessary tests for regular tags.
- // * the second strategy consist in waiting for trouble, that shall appear
+ // * the second strategy consists in waiting for trouble, that shall appear
// when we find the first group with big endian encoding. This is
// easy to detect since the length of a "Group Length" tag (the
// ones with zero as element number) has to be of 4 (0x0004). When we
// 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;
+ //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
guint16 grPixel;
guint16 numPixel;
string ImageLocation = GetPubElValByName("Image Location");
- if ( ImageLocation == "UNFOUND" ) {
+ if ( ImageLocation == "gdcm::Unfound" ) {
grPixel = 0x7fe0;
} else {
grPixel = (guint16) atoi( ImageLocation.c_str() );
return GetShaElValRepByName(TagName);
}
+/**
+ * \ingroup gdcmHeader
+ * \brief Modifie la valeur d'un ElValue déja existant
+ * \ dans le PubElVals du gdcmHeader,
+ * \ accédé par ses numero de groupe et d'element.
+ */
+int gdcmHeader::SetPubElValByNumber(string content, guint16 group, guint16 element) {
+ //TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+ //PubElVals.tagHt[key]->SetValue(content);
+
+ return ( PubElVals.SetElValueByNumber (content, group, element) );
+}
+
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Modifie la valeur d'un ElValue déja existant
+ * \ dans le PubElVals du gdcmHeader,
+ * \ accédé par son nom
+ */
+int gdcmHeader::SetPubElValByName(string content, string TagName) {
+ //TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+ //PubElVals.tagHt[key]->SetValue(content);
+
+ return ( PubElVals.SetElValueByName (content, TagName) );
+}
+
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Modifie la valeur d'un ElValue déja existant
+ * \ dans le ShaElVals du gdcmHeader,
+ * \ accédé par ses numero de groupe et d'element.
+ */
+int gdcmHeader::SetShaElValByNumber(string content, guint16 group, guint16 element) {
+
+ return ( ShaElVals.SetElValueByNumber (content, group, element) );
+}
+
+
+/**
+ * \ingroup gdcmHeader
+ * \brief Modifie la valeur d'un ElValue déja existant
+ * \ dans le ShaElVals du gdcmHeader,
+ * \ accédé par son nom
+ */
+int gdcmHeader::SetShaElValByName(string content, string TagName) {
+
+ return ( ShaElVals.SetElValueByName (content, TagName) );
+}
/**
* \ingroup gdcmHeader
* \brief Parses the header of the file but does NOT load element values.
*/
void gdcmHeader::LoadElements(void) {
- if (DEBUG) printf("LoadElements : Entree\n");
-
rewind(fp);
- if (DEBUG) printf("LoadElements : rewind\n");
TagElValueHT ht = PubElVals.GetTagHt();
- if (DEBUG) printf("LoadElements : GetTagHt\n");
-
for (TagElValueHT::iterator tag = ht.begin(); tag != ht.end(); ++tag) {
LoadElementValue(tag->second);
}