From dc78a7e599ec9f2fcd946c4d740f74da24be6f06 Mon Sep 17 00:00:00 2001 From: regrain Date: Thu, 5 Feb 2004 14:34:38 +0000 Subject: [PATCH] * FIX : wrapping python for ListPatient, ListStudy, ListSerie, ListImage -- BeNours --- ChangeLog | 1 + gdcmPython/gdcm.i | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/ChangeLog b/ChangeLog index cfad4d3f..a72d3a28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2004-02-05 Benoit Regrain * ENH : add methods in gdcmObject to get the hash table or the list of header entries + * FIX : wrapping python for ListPatient, ListStudy, ListSerie, ListImage 2004-02-04 Benoit Regrain * FIX : even length for some strings when writting the dicom dir diff --git a/gdcmPython/gdcm.i b/gdcmPython/gdcm.i index 998702e8..82436e9e 100644 --- a/gdcmPython/gdcm.i +++ b/gdcmPython/gdcm.i @@ -104,6 +104,53 @@ extern gdcmGlobal gdcmGlob; $result = NewDict; } +//////////////////////////////////////////////////////////////////////////// +%typemap(out) ListPatient & { + PyObject* NewItem = (PyObject*)0; + $result = PyList_New(0); // The result of this typemap + + for (list::iterator New = ($1)->begin(); + New != ($1)->end(); ++New) { + NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_gdcmPatient,1); + PyList_Append($result, NewItem); + } +} + +%typemap(out) ListStudy & { + PyObject* NewItem = (PyObject*)0; + $result = PyList_New(0); // The result of this typemap + + for (list::iterator New = ($1)->begin(); + New != ($1)->end(); ++New) { + NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_gdcmStudy,1); + PyList_Append($result, NewItem); + } +} + +%typemap(out) ListSerie & { + PyObject* NewItem = (PyObject*)0; + $result = PyList_New(0); // The result of this typemap + + for (list::iterator New = ($1)->begin(); + New != ($1)->end(); ++New) { + NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_gdcmSerie,1); + PyList_Append($result, NewItem); + } +} + +%typemap(out) ListImage & { + PyObject* NewItem = (PyObject*)0; + $result = PyList_New(0); // The result of this typemap + + for (list::iterator New = ($1)->begin(); + New != ($1)->end(); ++New) { + NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_gdcmImage,1); + PyList_Append($result, NewItem); + } +} + +//////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// // Deals with function returning a C++ string. %typemap(out) string, std::string { -- 2.48.1