]> Creatis software - gdcm.git/commitdiff
* Fix bug while wrapping python. The DicomDir SetStart/Progress/EndMethod are...
authorregrain <regrain>
Mon, 29 Aug 2005 12:29:47 +0000 (12:29 +0000)
committerregrain <regrain>
Mon, 29 Aug 2005 12:29:47 +0000 (12:29 +0000)
   -- BeNours

Example/MakeDicomDir.cxx
Testing/TestMakeDicomDir.cxx
gdcmPython/demo/PrintDicomDir.py.in
gdcmPython/gdcm.i
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h

index 33e67afe61e3ff6716139478b615c150cfebe28b..b3465316bec24df647e59a827a90c48622910241 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: MakeDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/26 02:25:25 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2005/08/29 12:29:47 $
+  Version:   $Revision: 1.12 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
 
    dcmdir = new gdcm::DicomDir( );
 
-   dcmdir->SetStartMethod(StartMethod, (void *) NULL);
+   dcmdir->SetStartMethod(StartMethod);
    dcmdir->SetEndMethod(EndMethod);
 
    dcmdir->SetLoadMode(loadMode);
index 3d6b1bc325decba7eccaf9b5f8ba5bdec73b9ce5..81c9219cfbd86908f0341e46f93150d51a8c47ef 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestMakeDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/21 04:51:26 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/08/29 12:29:48 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -70,7 +70,7 @@ int TestMakeDicomDir(int argc, char *argv[])
    dcmdir->SetDirectoryName(dirName);
    dcmdir->Load( );
 
-   dcmdir->SetStartMethod(StartMethod, (void *) NULL);
+   dcmdir->SetStartMethod(StartMethod);
    dcmdir->SetEndMethod(EndMethod);
    
    if ( !dcmdir->GetFirstPatient() ) 
index a76944997823b599f47152b4df0362a7d975b601..341df43d0cfe802c12136b3ef423d52dabd9d16f 100644 (file)
@@ -12,6 +12,14 @@ def PrintUse():
    print ""
    print ""
 
+### Progress methods
+def startMethod():
+   print "Start"
+def progressMethod():
+   print "Progress",dicomdir.GetProgress()
+def endMethod():
+   print "End"
+
 ### Get filename from command line or default it
 try:
    fileName = sys.argv[1]
@@ -27,6 +35,11 @@ except IndexError:
 
 ### Build the DicomDir element list
 dicomdir = gdcm.DicomDir()
+
+dicomdir.SetStartMethod(startMethod)
+dicomdir.SetProgressMethod(progressMethod)
+dicomdir.SetEndMethod(endMethod)
+
 dicomdir.SetFileName(fileName)
 dicomdir.Load()
 if not dicomdir.IsReadable():
@@ -60,3 +73,17 @@ while(patient):
       study=patient.GetNextStudy()
    patient=dicomdir.GetNextPatient()
 
+dicomdir.SetDirectoryName(os.path.dirname(fileName))
+dicomdir.Load()
+if not dicomdir.IsReadable():
+   PrintUse()
+   raise RuntimeError,"The '%s' DicomDir is not readable with gdcm." % fileName
+
+print "DICOMDIR -->",fileName
+print "##############################################################"
+print "## Display all the elements and their respective values"
+print "## found in the ", fileName, " file."
+print "##############################################################"
+dicomdir.SetPrintLevel(-1)
+dicomdir.Print()
+
index ab1e48697bdd3762a7adccdf979e5ff1d8ec6a77..bb21af1be49a10ff9c3c23ef2ac41494eb30f819 100644 (file)
@@ -128,9 +128,7 @@ typedef unsigned long long uint64_t;
 // Note: Uses gdcmPythonVoidFunc and gdcmPythonVoidFuncArgDelete defined
 //       in the Swig verbatim section of this gdcm.i i.e. in the above section
 //       enclosed within the %{ ... %} scope operator ).
-%typemap(python, in) ( gdcm::DicomDir::Method *, 
-                       void * = NULL, 
-                       gdcm::DicomDir::Method * = NULL )
+%typemap(python, in) (void(*method)(void *),void *arg,void(*argDelete)(void *))
 {
        if($input!=Py_None)
        {
@@ -205,8 +203,9 @@ typedef unsigned long long uint64_t;
 %ignore gdcm::binary_write(std::ostream &,uint32_t const &);
 %ignore gdcm::binary_write(std::ostream &,uint16_t const &);
 
-//%ignore gdcm::File::File();
-//%ignore gdcm::DicomDir::DicomDir();
+%ignore gdcm::DicomDir::SetStartMethod(DicomDir::Method *method,void *arg = NULL);
+%ignore gdcm::DicomDir::SetProgressMethod(DicomDir::Method *method,void *arg = NULL);
+%ignore gdcm::DicomDir::SetEndMethod(DicomDir::Method *method,void *arg = NULL);
 
 // Ignore all placed in gdcmCommon.h
 %ignore GDCM_UNKNOWN;
index 6ffb4fdd5b4a6d9cd973e08459422904df40549c..8be64395a19f80c26c9804367ad21425ab1a6aaf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/29 09:41:22 $
-  Version:   $Revision: 1.154 $
+  Date:      $Date: 2005/08/29 12:29:50 $
+  Version:   $Revision: 1.155 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -159,9 +159,9 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
  */
 DicomDir::~DicomDir() 
 {
-   SetStartMethod(NULL);
-   SetProgressMethod(NULL);
-   SetEndMethod(NULL);
+   SetStartMethod(NULL,NULL,NULL);
+   SetProgressMethod(NULL,NULL,NULL);
+   SetEndMethod(NULL,NULL,NULL);
 
    ClearPatient();
    if ( MetaElems )
@@ -404,6 +404,21 @@ void DicomDir::ParseDirectory()
    CreateDicomDir();
 }
 
+void DicomDir::SetStartMethod( DicomDir::Method *method, void *arg )
+{
+   SetStartMethod(method,arg,NULL);
+}
+
+void DicomDir::SetProgressMethod( DicomDir::Method *method, void *arg )
+{
+   SetProgressMethod(method,arg,NULL);
+}
+
+void DicomDir::SetEndMethod( DicomDir::Method *method, void *arg )
+{
+   SetEndMethod(method,arg,NULL);
+}
+
 /**
  * \brief   Set the start method to call when the parsing of the
  *          directory starts.
@@ -621,10 +636,10 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
          break;
       }
 
-   f = new File( );
-   f->SetLoadMode(LoadMode); // we allow user not to load Sequences, or Shadow
-                             //             groups, or ......
-   f->SetFileName( it->c_str() );
+      f = new File( );
+      f->SetLoadMode(LoadMode); // we allow user not to load Sequences, or Shadow
+                              //             groups, or ......
+      f->SetFileName( it->c_str() );
    /*int res = */f->Load( );
 
 //     if ( !f )
index f51c9f4cd0a8b4d8e3a1e5c73fe659d7241673b1..22ced06db8dfde4bbeb416385556b5c010b25ffb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2005/07/21 05:02:11 $
-  Version:   $Revision: 1.66 $
+  Date:      $Date: 2005/08/29 12:29:50 $
+  Version:   $Revision: 1.67 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -95,17 +95,25 @@ public:
    //       following method declarations. Refer to gdcmPython/gdcm.i
    //       for the reasons of this unnecessary notation at C++ level.
    void SetStartMethod(    DicomDir::Method *method,
-                           void *arg = NULL,
-                           DicomDir::Method *argDelete = NULL );
-   void SetProgressMethod( DicomDir::Method *method, 
-                           void *arg = NULL,
-                           DicomDir::Method *argDelete = NULL );
+                           void *arg = NULL );
+   void SetProgressMethod( DicomDir::Method *method,
+                           void *arg = NULL );
    void SetEndMethod(      DicomDir::Method *method,
-                           void *arg = NULL, 
-                           DicomDir::Method *argDelete = NULL );
-   void SetStartMethodArgDelete   ( DicomDir::Method *m );
-   void SetProgressMethodArgDelete( DicomDir::Method *m );
-   void SetEndMethodArgDelete     ( DicomDir::Method *m );
+                           void *arg = NULL );
+   // Note: replace DicomDir::Method *method to void(*method)(void *) to
+   //       avoid wrapping problems with the typemap conversions
+   void SetStartMethod(    void(*method)(void *), // DicomDir::Method *method
+                           void *arg,
+                           void(*argDelete)(void *));
+   void SetProgressMethod( void(*method)(void *), // DicomDir::Method *method
+                           void *arg,
+                           void(*argDelete)(void *));
+   void SetEndMethod(      void(*method)(void *), // DicomDir::Method *method
+                           void *arg, 
+                           void(*argDelete)(void *));
+   void SetStartMethodArgDelete   ( DicomDir::Method *method );
+   void SetProgressMethodArgDelete( DicomDir::Method *method );
+   void SetEndMethodArgDelete     ( DicomDir::Method *method );
 
    /// GetProgress GetProgress
    float GetProgress()   { return Progress; }