From bd1e1aea88a95e4d14cd59088a7e5280703402ea Mon Sep 17 00:00:00 2001 From: regrain Date: Wed, 19 Oct 2005 12:01:47 +0000 Subject: [PATCH] * Fix compilation errors for the Python part * Fix errors in the Python tests -- BeNours --- gdcmPython/demo/PrintDicomDir.py.in | 2 +- gdcmPython/gdcm.i | 53 ++------------------------ src/gdcmCommon.h | 19 ++++++++-- src/gdcmDefaultDicts.cxx.in | 6 +-- src/gdcmDicomDirElement.cxx | 13 ++++--- src/gdcmDicomDirElement.h | 58 ++++++++++++++--------------- src/gdcmDocument.cxx | 6 +-- src/gdcmDocument.h | 6 +-- src/gdcmFile.cxx | 6 +-- src/gdcmSystem.h | 14 +------ 10 files changed, 71 insertions(+), 112 deletions(-) diff --git a/gdcmPython/demo/PrintDicomDir.py.in b/gdcmPython/demo/PrintDicomDir.py.in index c8916503..c988a4e6 100644 --- a/gdcmPython/demo/PrintDicomDir.py.in +++ b/gdcmPython/demo/PrintDicomDir.py.in @@ -67,7 +67,7 @@ while(patient): image=serie.GetFirstImage() while(image): print " Image" - print " ---",image.GetDataEntry(0x0004,0x1500).GetValue() + print " ---",image.GetDataEntry(0x0004,0x1500).GetString() image=serie.GetNextImage() serie=study.GetNextSerie() study=patient.GetNextStudy() diff --git a/gdcmPython/gdcm.i b/gdcmPython/gdcm.i index 3a6dcfd3..84dede02 100644 --- a/gdcmPython/gdcm.i +++ b/gdcmPython/gdcm.i @@ -101,10 +101,10 @@ typedef unsigned long long uint64_t; { if(dynamic_cast($1)) // SeqEntry * newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__SeqEntry,0); - else if(dynamic_cast($1)) // BinEntry * - newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__BinEntry,0); - else // ValEntry * - newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__ValEntry,0); + else if(dynamic_cast($1)) // DataEntry * + newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__DataEntry,0); + else + newEntry = NULL; } else { @@ -255,48 +255,3 @@ typedef unsigned long long uint64_t; %include "gdcmVR.h" %include "gdcmTS.h" %include "gdcmDictGroupName.h" - -//////////////////////////////////////////////////////////////////////////// -// Notes on swig and this file gdcm.i: -// -///////////////////////////////////// -// Note 1: swig collision of method overloading and %typemap -// Consider the following junk.i file: -// %module junk -// %{ -// #include -// #include -// void Junk(std::string const & bozo) { std::cout << bozo << std::endl; } -// void Junk() { std::cout << "Renamed Junk()" << std::endl; } -// %} -// -// %typemap(python, in) std::string const & -// { -// $1 = new std::string( PyString_AsString( $input ) ); -// } -// void Junk(); -// void Junk(std::string const & bozo); -// -// that we compile on linux with: -// swig -c++ -python junk.i -// g++ -g -I/usr/include/python2.3/ -o junk_wrap.o -c junk_wrap.cxx -// g++ junk_wrap.o -shared -g -o _junk.so -L/usr/lib/python2.3/config \ -// -lpython2.3 -// and invoque with: -// python -c 'from junk import *; Junk("aaa") ' -// then we get the following unexpected (for novice) python TypeError: -// TypeError: No matching function for overloaded 'Junk' -// -// This happens because the swig generated code (at least for python) does -// the following two stage process: -// 1/ first do a dynamic dispatch ON THE NUMBER OF ARGUMENTS of the overloaded -// Junk function (the same happens with method of course). [Note that the -// dispatch is NOT done on the type of the arguments]. -// 2/ second apply the typemap. -// When the first dynamic dispatch is executed, the swig generated code -// has no knowledge of the typemap, and thus expects a pointer to a std::string -// type i.e. an argument to Junk of the form _p_std__int
. But this -// is not what python handles to Junk ! An invocation of the form 'Junk("aaa")' -// will make Python pass a PyString to swig (and this is precisely why we -// wrote the typemap). And this will fail.... -///////////////////////////////////// diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index 5d909742..85c63a55 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmCommon.h,v $ Language: C++ - Date: $Date: 2005/10/19 08:06:45 $ - Version: $Revision: 1.97 $ + Date: $Date: 2005/10/19 12:01:50 $ + Version: $Revision: 1.98 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,6 +24,8 @@ #include +//----------------------------------------------------------------------------- +// TagKey definition #define FASTTAGKEY 0 // FIXME: Should rewrite this: @@ -36,6 +38,17 @@ #include #endif +//----------------------------------------------------------------------------- +#if defined(_WIN32) && defined(BUILD_SHARED_LIBS) + #ifdef gdcm_EXPORTS + #define GDCM_EXPORT __declspec( dllexport ) + #else + #define GDCM_EXPORT __declspec( dllimport ) + #endif +#else + #define GDCM_EXPORT +#endif + //----------------------------------------------------------------------------- /// \brief namespace for Grass root DiCoM namespace gdcm @@ -158,7 +171,7 @@ enum LodModeType /** * \brief structure, for internal use only */ -struct Element +struct DicomElement { /// DicomGroup number unsigned short int Group; diff --git a/src/gdcmDefaultDicts.cxx.in b/src/gdcmDefaultDicts.cxx.in index 2622cc23..6418c31e 100644 --- a/src/gdcmDefaultDicts.cxx.in +++ b/src/gdcmDefaultDicts.cxx.in @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDefaultDicts.cxx.in,v $ Language: C++ - Date: $Date: 2005/04/05 10:56:25 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/10/19 12:01:50 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -85,7 +85,7 @@ void FillDefaultDIRDict(DicomDirElement *dde) { unsigned int i = 0; ELEMENT e = dataElement[i]; - Element elem; + DicomElement elem; DicomDirType type; std::string strType; diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index 1757284f..4af127cd 100644 --- a/src/gdcmDicomDirElement.cxx +++ b/src/gdcmDicomDirElement.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirElement.cxx,v $ Language: C++ - Date: $Date: 2005/07/11 14:40:40 $ - Version: $Revision: 1.39 $ + Date: $Date: 2005/10/19 12:01:50 $ + Version: $Revision: 1.40 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -51,7 +51,7 @@ DicomDirElement::DicomDirElement() { char buff[1024]; std::string strType; - Element elem; + DicomElement elem; DicomDirType type; while (!from.eof()) @@ -115,7 +115,7 @@ DicomDirElement::~DicomDirElement() * @param type Element type (DD_PATIENT, DD_STUDY, DD_SERIE, DD_IMAGE) * @param elem elem */ -bool DicomDirElement::AddEntry(DicomDirType type, Element const &elem) +bool DicomDirElement::AddEntry(DicomDirType type, DicomElement const &elem) { switch( type ) { @@ -150,12 +150,13 @@ bool DicomDirElement::AddEntry(DicomDirType type, Element const &elem) void DicomDirElement::AddDicomDirElement(DicomDirType type, uint16_t group, uint16_t elem) { - Element el; + DicomElement el; el.Group = group; el.Elem = elem; el.Value = ""; AddEntry(type, el); } + //----------------------------------------------------------------------------- // Protected @@ -171,7 +172,7 @@ void DicomDirElement::AddDicomDirElement(DicomDirType type, void DicomDirElement::Print(std::ostream &os) { std::ostringstream s; - std::list::iterator it; + std::list::iterator it; //char greltag[10]; //group element tag TagKey greltag; diff --git a/src/gdcmDicomDirElement.h b/src/gdcmDicomDirElement.h index ffb8ba0d..74b18e03 100644 --- a/src/gdcmDicomDirElement.h +++ b/src/gdcmDicomDirElement.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirElement.h,v $ Language: C++ - Date: $Date: 2005/09/02 07:10:03 $ - Version: $Revision: 1.31 $ + Date: $Date: 2005/10/19 12:01:50 $ + Version: $Revision: 1.32 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -28,36 +28,36 @@ namespace gdcm //----------------------------------------------------------------------------- -typedef std::list ListDicomDirElem; -typedef std::list ListDicomDirMetaElem; -typedef std::list ListDicomDirPatientElem; -typedef std::list ListDicomDirStudyElem; -typedef std::list ListDicomDirVisitElem; -typedef std::list ListDicomDirSerieElem; -typedef std::list ListDicomDirImageElem; +typedef std::list ListDicomDirElem; +typedef std::list ListDicomDirMetaElem; +typedef std::list ListDicomDirPatientElem; +typedef std::list ListDicomDirStudyElem; +typedef std::list ListDicomDirVisitElem; +typedef std::list ListDicomDirSerieElem; +typedef std::list ListDicomDirImageElem; // For future use (Full DICOMDIR) /* -typedef std::list ListDicomDirResultElem; -typedef std::list ListDicomDirStudyComponentElem; - -typedef std::list ListDicomDirOverlayElem; -typedef std::list ListDicomDirModalityLutElem; -typedef std::list ListDicomDirModalityLutElem; -typedef std::list ListDicomDirCurveElem; -typedef std::list ListDicomDirStoredPrintElem; -typedef std::list ListDicomDirRtDoseElem; -typedef std::list ListDicomDirRtStructureSetElem; -typedef std::list ListDicomDirRtPlanElem; -typedef std::list ListDicomDirRtTreatRecordElem; -typedef std::list ListDicomDirPresentationElem; -typedef std::list ListDicomDirSrDocumentElem; -typedef std::list ListDicomDirKeyObjectDocElem; -typedef std::list ListDicomDirSpectroscopyElem; -typedef std::list ListDicomDirRawDataElem; -typedef std::list ListDicomDirRegistrationElem; -typedef std::list ListDicomDirFiducialElem; +typedef std::list ListDicomDirResultElem; +typedef std::list ListDicomDirStudyComponentElem; + +typedef std::list ListDicomDirOverlayElem; +typedef std::list ListDicomDirModalityLutElem; +typedef std::list ListDicomDirModalityLutElem; +typedef std::list ListDicomDirCurveElem; +typedef std::list ListDicomDirStoredPrintElem; +typedef std::list ListDicomDirRtDoseElem; +typedef std::list ListDicomDirRtStructureSetElem; +typedef std::list ListDicomDirRtPlanElem; +typedef std::list ListDicomDirRtTreatRecordElem; +typedef std::list ListDicomDirPresentationElem; +typedef std::list ListDicomDirSrDocumentElem; +typedef std::list ListDicomDirKeyObjectDocElem; +typedef std::list ListDicomDirSpectroscopyElem; +typedef std::list ListDicomDirRawDataElem; +typedef std::list ListDicomDirRegistrationElem; +typedef std::list ListDicomDirFiducialElem; */ //----------------------------------------------------------------------------- @@ -118,7 +118,7 @@ public: { return DicomDirImageList; } // Public method to add an element - bool AddEntry(DicomDirType type, Element const &elem); + bool AddEntry(DicomDirType type, DicomElement const &elem); // Only one instance of ddElem void AddDicomDirElement(DicomDirType type, diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 82142ef0..15680d25 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 21:19:57 $ - Version: $Revision: 1.297 $ + Date: $Date: 2005/10/19 12:01:50 $ + Version: $Revision: 1.298 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -277,7 +277,7 @@ bool Document::DoTheLoadingDocumentJob( ) */ void Document::AddForceLoadElement (uint16_t group, uint16_t elem) { - Element el; + DicomElement el; el.Group = group; el.Elem = elem; UserForceLoadList.push_back(el); diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 764160ab..1d8ce95c 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.h,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:28 $ - Version: $Revision: 1.125 $ + Date: $Date: 2005/10/19 12:01:51 $ + Version: $Revision: 1.126 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,7 +41,7 @@ class GDCM_EXPORT Document : public ElementSet { public: -typedef std::list ListElements; +typedef std::list ListElements; // Loading //Deprecated : use SetFileName() + Load() diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index c5321671..0a4339b2 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/10/19 09:43:13 $ - Version: $Revision: 1.281 $ + Date: $Date: 2005/10/19 12:01:51 $ + Version: $Revision: 1.282 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1570,7 +1570,7 @@ size_t File::GetPixelAreaLength() void File::AddAnonymizeElement (uint16_t group, uint16_t elem, std::string const &value) { - Element el; + DicomElement el; el.Group = group; el.Elem = elem; el.Value = value; diff --git a/src/gdcmSystem.h b/src/gdcmSystem.h index c2afd26c..5e392027 100644 --- a/src/gdcmSystem.h +++ b/src/gdcmSystem.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSystem.h,v $ Language: C++ - Date: $Date: 2005/10/19 08:16:59 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/10/19 12:01:51 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -75,15 +75,5 @@ typedef unsigned int uint32_t; #define UINT32_MAX (4294967295U) #endif -#if defined(_WIN32) && defined(BUILD_SHARED_LIBS) - #ifdef gdcm_EXPORTS - #define GDCM_EXPORT __declspec( dllexport ) - #else - #define GDCM_EXPORT __declspec( dllimport ) - #endif -#else - #define GDCM_EXPORT -#endif - //----------------------------------------------------------------------------- #endif -- 2.45.1