From: frog Date: Thu, 31 Oct 2002 15:15:49 +0000 (+0000) Subject: * Straightforward temporary fixes for swig to build the python wrappers. X-Git-Tag: April2003~89 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=51b61705e90b352de08519835fa1c63b81bca616;p=gdcm.git * Straightforward temporary fixes for swig to build the python wrappers. src/Makefile now has a python working entry [by working we mean that we can import de shadow classes without errors]. --- Frog --- diff --git a/ChangeLog b/ChangeLog index 9820dfc8..4aea47dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-10-31 Eric Boix + * Straightforward temporary fixes for swig to build the python wrappers. + src/Makefile now has a python working entry [by working we mean + that we can import de shadow classes without errors]. + 2002-10-29 Eric Boix * hashtest.cxx removed (since allready in Test) * src/gdcmlib.h renamed to src/gdcm.h diff --git a/src/Makefile b/src/Makefile index f929fc2d..e28a8765 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ ###CC = gcc ###LINK = gcc -shared -o ptinpoly.so -SWIG = ~/Local/bin/swig +SWIG = swig SWIGFLAGS= -python -c++ PYTHON=python @@ -13,10 +13,12 @@ CXXFLAGS=`glib-config --cflags` CPPFLAGS=-g -Wall -Wunused-variable LDFLAGS=`glib-config --libs` -g -%.o : %.cxx - $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ +%_wrap.o : %_wrap.cxx + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(PYTHON_INCLUDES) $< -o $@ %_wrap.cxx : %.i $(SWIG) $(SWIGFLAGS) $(PYTHON_INCLUDES) -o $@ $< +%.o : %.cxx + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ all: gdcmlib.so @@ -27,13 +29,14 @@ gdcmlib.so: gdcmUtil.o \ gdcmDict.o \ gdcmDictSet.o \ gdcmElValSet.o \ - gdcmHeaderIdo.o + gdcmHeaderIdo.o \ + gdcmFile.o g++ -shared -o gdcmlib.so $^ $(LDFLAGS) -python: gdcmlib.so dcm_wrap.o - g++ -shared $^ -o gdcmc.so +python: gdcmlib.so gdcm_wrap.o + g++ -shared $^ -o _gdcm.so clean: - rm -f *_wrap* *.so *.o *.pyc + rm -f *_wrap* *.so *.o *.pyc gdcm.py .SECONDARY: dcm_wrap.cxx diff --git a/src/gdcm.h b/src/gdcm.h index 512c86e4..80e98048 100644 --- a/src/gdcm.h +++ b/src/gdcm.h @@ -7,6 +7,13 @@ // * Formats: this lib should be able to read ACR-NEMA v1 and v2, Dicom v3 (as // stated in part10). [cf dcmtk/dcmdata/docs/datadict.txt] // * Targeted plateforms: Un*xes and Win32/VC++6.0 +// +// +// TODO +// The declarations commented out and starting with "TODO Swig" needed +// to be temporarily removed for swig to proceed correctly (in fact +// problems appears at loading of _gdcm.[so/dll]). So, simply uncomment +// the declaration once you provided the definition of the method... #include #include // For size_t @@ -85,9 +92,8 @@ class gdcmDict { string filename; TagHT entries; public: - gdcmDict(); gdcmDict(char *FileName); // Read Dict from disk - int AppendEntry(gdcmDictEntry* NewEntry); + // TODO Swig int AppendEntry(gdcmDictEntry* NewEntry); gdcmDictEntry * GetTag(guint32 group, guint32 element); void Print(ostream&); }; @@ -104,17 +110,17 @@ class gdcmDictSet { private: DictSetHT dicts; int AppendDict(gdcmDict* NewDict); + int LoadDictFromFile(char* filename, DictKey); public: gdcmDictSet(void); // loads THE DICOM v3 dictionary - int LoadDictFromFile(string filename); + // TODO Swig int LoadDictFromFile(string filename); ///// QUESTION: the following function might not be thread safe !? Maybe ///// we need some mutex here, to avoid concurent creation of ///// the same dictionary !?!?! - int LoadDictFromName(string filename); - int LoadDictFromFile(char*, DictKey); - int LoadAllDictFromDirectory(string DirectoryName); + // TODO Swig int LoadDictFromName(string filename); + // TODO Swig int LoadAllDictFromDirectory(string DirectoryName); + // TODO Swig string* GetAllDictNames(); int LoadDicomV3Dict(void); - string* GetAllDictNames(); void Print(ostream&); gdcmDict* GetDict(DictKey DictName); gdcmDict* GetDefaultPublicDict(void); @@ -235,50 +241,50 @@ protected: public: void LoadElements(void); virtual void ParseHeader(void); - gdcmHeader(char* filename); + gdcmHeader(const char* filename); virtual ~gdcmHeader(); - int SetPubDict(string filename); + // TODO Swig int SetPubDict(string filename); // When some proprietary shadow groups are disclosed, whe can set // up an additional specific dictionary to access extra information. - int SetShaDict(string filename); + // TODO Swig int SetShaDict(string filename); // Retrieve all potentially available tag [tag = (group, element)] names // from the standard (or public) dictionary (hence static). Typical usage: // enable the user of a GUI based interface to select his favorite fields // for sorting or selection. - string* GetPubTagNames(); + // TODO Swig string* GetPubTagNames(); // Get the element values themselves: string GetPubElValByName(string TagName); string GetPubElValByNumber(guint16 group, guint16 element); // Get the element value representation: (VR) might be needed by caller // to convert the string typed content to caller's native type (think // of C/C++ vs Python). - string GetPubElValRepByName(string TagName); - string GetPubElValRepByNumber(guint16 group, guint16 element); + // TODO Swig string GetPubElValRepByName(string TagName); + // TODO Swig string GetPubElValRepByNumber(guint16 group, guint16 element); void PrintPubElVal(ostream &); void PrintPubDict(ostream &); // Same thing with the shadow : - string* GetShaTagNames(); - string GetShaElValByName(string TagName); - string GetShaElValByNumber(guint16 group, guint16 element); - string GetShaElValRepByName(string TagName); - string GetShaElValRepByNumber(guint16 group, guint16 element); + // TODO Swig string* GetShaTagNames(); + // TODO Swig string GetShaElValByName(string TagName); + // TODO Swig string GetShaElValByNumber(guint16 group, guint16 element); + // TODO Swig string GetShaElValRepByName(string TagName); + // TODO Swig string GetShaElValRepByNumber(guint16 group, guint16 element); // Wrappers of the above (both public and shadow) to avoid bugging the // caller with knowing if ElVal is from the public or shadow dictionary. - string GetElValByName(string TagName); - string GetElValByNumber(guint16 group, guint16 element); - string GetElValRepByName(string TagName); - string GetElValRepByNumber(guint16 group, guint16 element); + // TODO Swig string GetElValByName(string TagName); + // TODO Swig string GetElValByNumber(guint16 group, guint16 element); + // TODO Swig string GetElValRepByName(string TagName); + // TODO Swig string GetElValRepByNumber(guint16 group, guint16 element); - int SetPubElValByName(string content, string TagName); - int SetPubElValByNumber(string content, guint16 group, guint16 element); - int SetShaElValByName(string content, string ShadowTagName); - int SetShaElValByNumber(string content, guint16 group, guint16 element); + // TODO Swig int SetPubElValByName(string content, string TagName); + // TODO Swig 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 GetSwapCode(); + // TODO Swig int GetSwapCode(); }; // In addition to Dicom header exploration, this class is designed @@ -296,7 +302,7 @@ private: public: // Constructor dedicated to writing a new DICOMV3 part10 compliant // file (see SetFileName, SetDcmTag and Write) - gdcmFile(); + // TODO Swig gdcmFile(); // Opens (in read only and when possible) an existing file and checks // for DICOM compliance. Returns NULL on failure. // Note: the in-memory representation of all available tags found in @@ -306,28 +312,28 @@ public: // seen a a side effect). gdcmFile(string & filename); // For promotion (performs a deepcopy of pointed header object) - gdcmFile(gdcmHeader* header); - ~gdcmFile(); + // TODO Swig gdcmFile(gdcmHeader* header); + // TODO Swig ~gdcmFile(); // On writing purposes. When instance was created through // gdcmFile(string filename) then the filename argument MUST be different // from the constructor's one (no overwriting aloud). - int SetFileName(string filename); + // TODO Swig int SetFileName(string filename); // Allocates necessary memory, copies the data (image[s]/volume[s]) to // newly allocated zone and return a pointer to it: - void * GetImageData(); + // TODO Swig void * GetImageData(); // Returns size (in bytes) of required memory to contain data // represented in this file. - size_t GetImageDataSize(); + // TODO Swig size_t GetImageDataSize(); // Copies (at most MaxSize bytes) of data to caller's memory space. // Returns an error code on failure (if MaxSize is not big enough) - int PutImageDataHere(void* destination, size_t MaxSize ); + // TODO Swig int PutImageDataHere(void* destination, size_t MaxSize ); // Allocates ExpectedSize bytes of memory at this->Data and copies the // pointed data to it. - int SetImageData(void * Data, size_t ExpectedSize); + // TODO Swig int SetImageData(void * Data, size_t ExpectedSize); // Push to disk. - int Write(); + // TODO Swig int Write(); }; //class gdcmSerie : gdcmFile; diff --git a/src/gdcm.i b/src/gdcm.i index c2b404a4..4ec46001 100644 --- a/src/gdcm.i +++ b/src/gdcm.i @@ -1,7 +1,7 @@ -%module dcm +%module gdcm %{ -#include "dcmlib.h" +#include "gdcm.h" %} %rename(new_dcmHeader_c) dcmHeader::dcmHeader(char*); -%include dcmlib.h +%include gdcm.h diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index 8b42624d..271a2346 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -1,5 +1,5 @@ #include -#include "gdcmlib.h" +#include "gdcm.h" #include "gdcmUtil.h" gdcmDict::gdcmDict(char * FileName) { diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index 5bcacb34..ddfd3e00 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -1,4 +1,4 @@ -#include "gdcmlib.h" +#include "gdcm.h" gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement, string InVr, string InFourth, string InName) diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 5352bcae..ed4bdf9b 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -1,5 +1,5 @@ #include -#include "gdcmlib.h" +#include "gdcm.h" #include "gdcmUtil.h" diff --git a/src/gdcmElValSet.cxx b/src/gdcmElValSet.cxx index 85ea5fc5..2b5656fe 100644 --- a/src/gdcmElValSet.cxx +++ b/src/gdcmElValSet.cxx @@ -1,4 +1,4 @@ -#include "gdcmlib.h" +#include "gdcm.h" #include "gdcmUtil.h" TagElValueHT & ElValSet::GetTagHt(void) { diff --git a/src/gdcmElValue.cxx b/src/gdcmElValue.cxx index 3a353cf8..5194a799 100644 --- a/src/gdcmElValue.cxx +++ b/src/gdcmElValue.cxx @@ -1,4 +1,4 @@ -#include "gdcmlib.h" +#include "gdcm.h" void ElValue::SetVR(string ValRep) { entry->SetVR(ValRep); } string ElValue::GetVR(void) { return entry->GetVR(); } diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 37672ec0..cb693875 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -1,5 +1,7 @@ -#include "gdcmlib.h" +#include "gdcm.h" -gdcmFile::gdcmFile(string & filename) { +gdcmFile::gdcmFile(string & filename) + :gdcmHeader(filename.c_str()) +{ } diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 49a4945f..cd5785b1 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -1,4 +1,4 @@ -#include "gdcmlib.h" +#include "gdcm.h" extern "C" { #include "glib.h" } @@ -39,7 +39,7 @@ void gdcmHeader::Initialise(void) { RefShaDict = (gdcmDict*)0; } -gdcmHeader::gdcmHeader (char* InFilename) { +gdcmHeader::gdcmHeader (const char* InFilename) { filename = InFilename; Initialise(); fp=fopen(InFilename,"rw"); diff --git a/src/gdcmIdo.h b/src/gdcmIdo.h index d22cf355..af006f76 100644 --- a/src/gdcmIdo.h +++ b/src/gdcmIdo.h @@ -1,4 +1,4 @@ -#include "gdcmlib.h" +#include "gdcm.h" class gdcmHeaderIdo: protected gdcmHeader { private: