X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2Fgdcm.h;h=1b387098e06b74288cbe19773152e69dc3643c06;hb=81ed6935092ed908ca5c1af450f04c84baacf568;hp=20e754130838cf96c8a8a59dfcda04d60a356197;hpb=dc0c43e2f7912a4a0f70fc7f925c964823468f23;p=gdcm.git diff --git a/src/gdcm.h b/src/gdcm.h index 20e75413..1b387098 100644 --- a/src/gdcm.h +++ b/src/gdcm.h @@ -52,7 +52,6 @@ using namespace std; // string type lives in the std namespace on VC++ // exporter des images lisibles par les consoles cliniques // et pas seulement importables dans e-film. - #ifdef __GNUC__ #include #define guint16 uint16_t @@ -70,7 +69,6 @@ typedef unsigned int guint32; #define GDCM_EXPORT #endif - // // ---------------------------------------------------- gdcmDictEntry // @@ -119,7 +117,8 @@ public: // fabrique une ligne de Dictionnaire Dicom à partir des parametres en entrée - gdcmDictEntry(guint16 group, guint16 element, + gdcmDictEntry(guint16 group, + guint16 element, string vr = "Unknown", string fourth = "Unknown", string name = "Unknown"); @@ -128,14 +127,15 @@ public: static TagKey TranslateToKey(guint16 group, guint16 element); - guint16 GetGroup(void) { return group;}; + guint16 GetGroup(void) { return group; }; guint16 GetElement(void){return element;}; - string GetVR(void) {return vr; }; + string GetVR(void) {return vr; }; void SetVR(string); + void SetKey(string k){ key = k; } bool IsVrUnknown(void); string GetFourth(void) {return fourth;}; - string GetName(void) {return name;}; - string GetKey(void) {return key;}; + string GetName(void) {return name; }; + string GetKey(void) {return key; }; }; // @@ -151,9 +151,7 @@ public: // combined with all software versions... typedef map TagHT; - // Table de Hachage (group,Elem) --> pointeur vers une ligne du Dictionnaire Dicom - -typedef map TagHT; + // Table de Hachage : (group,Elem) --> pointeur vers une ligne du Dictionnaire Dicom class GDCM_EXPORT gdcmDict { string name; @@ -163,13 +161,14 @@ public: // rempli le Dictionnaire Dicom à partir d'un fichier texte gdcmDict(const char* FileName); // Read Dict from disk - // QUESTION : - // Ca doit ajouter une nouvelle entrée 'a la fin', ou 'a sa place' ? - // - // TODO Swig int AppendEntry(gdcmDictEntry* NewEntry); + int AddNewEntry (gdcmDictEntry* NewEntry); + int ReplaceEntry(gdcmDictEntry* NewEntry); + int RemoveEntry (TagKey k); + int RemoveEntry (guint16 group, guint16 element); // renvoie une ligne de Dictionnaire Dicom à partir de (numGroup, numElement) gdcmDictEntry * GetTag(guint32 group, guint32 element); + void Print(ostream&); TagHT & GetEntries(void) { return entries; } }; @@ -212,6 +211,7 @@ public: // // Question : ne faudra-t-il pas mettre LE dictionnaire DICOM dans un Directory // et les eventuels 'dictionnaires prives' dans un autre? + // (pour eviter a un utilisateur mal dégourdi de tout saccager ?) // int LoadDicomV3Dict(void); void Print(ostream&); @@ -251,24 +251,35 @@ private: public: string value; // used to be char * valeurElem size_t Offset; // Offset from the begining of file for direct user access + ElValue(gdcmDictEntry*); void SetDictEntry(gdcmDictEntry *NewEntry) { entry = NewEntry; }; - 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; }; - void SetVR(string); - string GetVR(void); - string GetValue(void) { return value; }; - guint32 GetLength(void) { return LgrElem; }; - size_t GetOffset(void) { return Offset; }; - guint16 GetGroup(void) { return entry->GetGroup(); }; + + guint16 GetGroup(void) { return entry->GetGroup(); }; guint16 GetElement(void) { return entry->GetElement(); }; string GetKey(void) { return entry->GetKey(); }; string GetName(void) { return entry->GetName(); }; + + string GetVR(void) { return entry->GetVR(); }; + void SetVR(string v) { entry->SetVR(v); }; + + // Question : + // Un champ privé, accessible en consultation et en modif (sans restriction) + // interet par rapport à un champ public ? + // --> pouvoir en changer la définition sans toucher à l'API + + void SetLength(guint32 l){ LgrElem = l; }; + guint32 GetLength(void) { return LgrElem; }; + + void SetValue(string val){ value = val; }; + string GetValue(void) { return value; }; + + void SetOffset(size_t of){ Offset = of; }; + size_t GetOffset(void) { return Offset; }; + }; @@ -292,11 +303,13 @@ public: void Add(ElValue*); void Print(ostream &); void PrintByName(ostream &); + int Write(FILE *fp); ElValue* GetElementByNumber(guint32 group, guint32 element); ElValue* GetElementByName (string); string GetElValueByNumber(guint32 group, guint32 element); string GetElValueByName (string); - TagElValueHT & GetTagHt(void); + + TagElValueHT & GetTagHt(void); int SetElValueByNumber(string content, guint32 group, guint32 element); int SetElValueByName(string content, string TagName); @@ -324,24 +337,17 @@ public: // (Swig limitations for as Has_a dependency between gdcmFile and gdcmHeader) -typedef string VRKey; // Ne devrait-elle pas etre utilisee dans la definition de VRHT ? +typedef string VRKey; typedef string VRAtr; -typedef map VRHT; // Value Representation Hash Table - // Cette Table de Hachage ne devrait servir qu'a determiner - // si deux caractères correspondent à une VR existante ? +typedef map VRHT; // Value Representation Hash Table + class GDCM_EXPORT gdcmHeader { void SkipBytes(guint32); private: static VRHT *dicom_vr; // Dictionaries of data elements: - - // Question : - // Pourquoi mettre un pointeur statique vers le container des dictionnaires - // (qui est une H-table de pointeurs vers des dictionnaires) - // en plus des pointeurs vers chacun des dictionnaires ? - // Ces derniers n'auraient-ils pas suffit ? - // + static gdcmDictSet* Dicts; // global dictionary container gdcmDict* RefPubDict; // public dictionary gdcmDict* RefShaDict; // shadow dictionary (optional) @@ -350,9 +356,9 @@ private: ElValSet ShaElVals; // parsed with Shadow Dictionary string filename; // refering underlying file FILE * fp; - // The tag Image Location ((0028,0200) containing the address of - // the pixels) is not allways present. Then we store this information - + // The tag Image Location (0028,0200) - containing the address of + // the pixels - is not allways present. Then we store this information + // il etait facultatif en ACR-NEMA, il n'existe plus en DICOM 3 // FIXME // Question : @@ -441,7 +447,7 @@ public: // TODO Swig int SetShaDict(string filename); // Retrieve all potentially available tag [tag = (group, element)] names - // from the standard (or public) dictionary. Typical usage: enable the + // from the standard (or public) dictionary. Typical usage : enable the // user of a GUI based interface to select his favorite fields for sorting // or selecting. list * GetPubTagNames(void); @@ -479,24 +485,25 @@ public: int SetPubElValByName(string content, string TagName); int SetPubElValByNumber(string content, guint16 group, guint16 element); - // TODO Swig int SetShaElValByName(string content, string ShadowTagName); - // TODO Swig int SetShaElValByNumber(string content, guint16 group, guint16 element); + int SetShaElValByName(string content, string ShadowTagName); + int SetShaElValByNumber(string content, guint16 group, guint16 element); + ElValSet GetPubElVals() { return(PubElVals); } }; // // ---------------------------------------------------- gdcmFile // // un fichier EST_UNE entete, ou A_UNE entete ? -// -// +// +// On dit 'EST_UNE' ... //////////////////////////////////////////////////////////////////////////// // In addition to Dicom header exploration, this class is designed // for accessing the image/volume content. One can also use it to // write Dicom files. -////// QUESTION: this looks still like an open question wether the +////// QUESTION: this looks still like an open question whether the ////// relationship between a gdcmFile and gdcmHeader is of ////// type IS_A or HAS_A ! @@ -555,9 +562,21 @@ public: int PutImageDataHere(void* destination, size_t MaxSize ); + // Question : + // + // GetImageData et PutImageDataHere + // Get et Put pour 2 fonctions qui font presque la meme chose :-( + // + // Allocates ExpectedSize bytes of memory at this->Data and copies the // pointed data to it. + + // Question : + // Pourquoi dupliquer les pixels, alors qu'on les a deja en mémoire, + // et que Data (dans le gdcmHeader) est un pointeur ? + // TODO Swig int SetImageData(void * Data, size_t ExpectedSize); + // Push to disk. // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete) // incohérente avec l'ordre des octets en mémoire @@ -565,9 +584,10 @@ public: // Ecrit sur disque les pixels d'UNE image // Aucun test n'est fait sur l'"Endiannerie" du processeur. - // C'est à l'utilisateur d'appeler son Reader correctement + // Ca sera à l'utilisateur d'appeler son Reader correctement int WriteRawData (string nomFichier); + int WriteDcm (string nomFichier); }; //