X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=gdcmPython%2Fgdcm.i;h=9929125a975201a4732e5ede1a4f96757b3fb8ad;hb=98ab91206c2a0e603d6d9b11951860e5c78e315a;hp=a5f9001599b4ce4e41567236dfaeec528f505a4b;hpb=09f5bc8993ebabc6af98370630d2ea64649d5a39;p=gdcm.git diff --git a/gdcmPython/gdcm.i b/gdcmPython/gdcm.i index a5f90015..9929125a 100644 --- a/gdcmPython/gdcm.i +++ b/gdcmPython/gdcm.i @@ -4,8 +4,10 @@ #include "gdcmDictEntry.h" #include "gdcmDict.h" #include "gdcmDictSet.h" -#include "gdcmParser.h" -#include "gdcmHeaderEntry.h" +#include "gdcmDocEntrySet.h" +#include "gdcmSQItem.h" +#include "gdcmDocument.h" +#include "gdcmElementSet.h" #include "gdcmHeader.h" #include "gdcmHeaderHelper.h" #include "gdcmFile.h" @@ -19,6 +21,7 @@ #include "gdcmDicomDirStudy.h" #include "gdcmDicomDirSerie.h" #include "gdcmDicomDirImage.h" +#include "gdcmValEntry.h" //////////////////////////////////////////////////////////////////////////// // Utility functions on strings for removing leading and trailing spaces @@ -67,12 +70,6 @@ void gdcmPythonVoidFuncArgDelete(void *arg) typedef unsigned short guint16; typedef unsigned int guint32; -//////////////////////////////////////////////////////////////////////////// -// Global variables get exported to cvar in Python -%immutable; -extern gdcmGlobal gdcmGlob; -%mutable; - //////////////////////////////////////////////////////////////////////////// %typemap(out) std::list * { PyObject* NewItem = (PyObject*)0; @@ -112,14 +109,14 @@ extern gdcmGlobal gdcmGlob; //////////////////////////////////////////////////////////////////////////// // Convert a c++ hash table in a python native dictionary -%typemap(out) TagHeaderEntryHT & { +%typemap(out) TagDocEntryHT & { PyObject* NewDict = PyDict_New(); // The result of this typemap std::string RawName; // Element name as gotten from gdcm PyObject* NewKey = (PyObject*)0; // Associated name as python object std::string RawValue; // Element value as gotten from gdcm PyObject* NewVal = (PyObject*)0; // Associated value as python object - for (TagHeaderEntryHT::iterator tag = $1->begin(); tag != $1->end(); ++tag) { + for (TagDocEntryHT::iterator tag = $1->begin(); tag != $1->end(); ++tag) { // The element name shall be the key: RawName = tag->second->GetName(); @@ -130,24 +127,33 @@ extern gdcmGlobal gdcmGlob; RawName = tag->second->GetKey(); NewKey = PyString_FromString(RawName.c_str()); - // Element values are striped from leading/trailing spaces - RawValue = tag->second->GetValue(); - EatLeadingAndTrailingSpaces(RawValue); - NewVal = PyString_FromString(RawValue.c_str()); - - PyDict_SetItem( NewDict, NewKey, NewVal); - } - $result = NewDict; + // Element values are striped from leading/trailing spaces + // Element values are striped from leading/trailing spaces + if (gdcmValEntry* ValEntryPtr = + dynamic_cast< gdcmValEntry* >(tag->second) ) + { + RawValue = ValEntryPtr->GetValue(); + } + else + continue; + EatLeadingAndTrailingSpaces(RawValue); + NewVal = PyString_FromString(RawValue.c_str()); + + PyDict_SetItem( NewDict, NewKey, NewVal); + } + $result = NewDict; } -%typemap(out) TagHeaderEntryHT { +/* +CLEAN ME FIXME CLEANME TODO +%typemap(out) TagDocEntryHT { PyObject* NewDict = PyDict_New(); // The result of this typemap - std::string RawName; // Element name as gotten from gdcm + std::string RawName; // Element name as gotten from gdcm PyObject* NewKey = (PyObject*)0; // Associated name as python object - std::string RawValue; // Element value as gotten from gdcm + std::string RawValue; // Element value as gotten from gdcm PyObject* NewVal = (PyObject*)0; // Associated value as python object - for (TagHeaderEntryHT::iterator tag = $1.begin(); tag != $1.end(); ++tag) { + for (TagDocEntryHT::iterator tag = $1.begin(); tag != $1.end(); ++tag) { // The element name shall be the key: RawName = tag->second->GetName(); @@ -158,8 +164,14 @@ extern gdcmGlobal gdcmGlob; RawName = tag->second->GetKey(); NewKey = PyString_FromString(RawName.c_str()); - // Element values are striped from leading/trailing spaces - RawValue = tag->second->GetValue(); + // Element values are striped from leading/trailing spaces + if (gdcmValEntry* ValEntryPtr = + dynamic_cast< gdcmValEntry* >(tag->second) ) + { + RawValue = ValEntryPtr->GetValue(); + } + else + continue; EatLeadingAndTrailingSpaces(RawValue); NewVal = PyString_FromString(RawValue.c_str()); @@ -167,6 +179,7 @@ extern gdcmGlobal gdcmGlob; } $result = NewDict; } +*/ //////////////////////////////////////////////////////////////////////////// %typemap(out) ListDicomDirPatient & { @@ -244,12 +257,15 @@ extern gdcmGlobal gdcmGlob; } //////////////////////////////////////////////////////////////////////////// +// Warning: Order matters ! %include "gdcmCommon.h" %include "gdcmDictEntry.h" %include "gdcmDict.h" %include "gdcmDictSet.h" -%include "gdcmParser.h" -%include "gdcmHeaderEntry.h" +%include "gdcmDocEntrySet.h" +%include "gdcmElementSet.h" +%include "gdcmDocument.h" +%include "gdcmSQItem.h" %include "gdcmHeader.h" %include "gdcmHeaderHelper.h" %include "gdcmFile.h"