]> Creatis software - gdcm.git/commitdiff
* gdcmPython/demo : add python demos using VTK
authorregrain <regrain>
Mon, 17 Jan 2005 14:20:29 +0000 (14:20 +0000)
committerregrain <regrain>
Mon, 17 Jan 2005 14:20:29 +0000 (14:20 +0000)
   -- BeNours

ChangeLog
gdcmPython/CMakeLists.txt
gdcmPython/demo/CMakeLists.txt
gdcmPython/demo/vtkGdcmReader.py.in [new file with mode: 0644]
gdcmPython/demo/vtkGdcmWriter.py.in [new file with mode: 0644]
src/gdcmUtil.cxx

index 5d1bab0f105f86865c607cb1176f8e8fb91a1c31..a598438fe284805968cd25b053533347062afa24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2005-01-16 Jean-Pierre Roux <jpr@creatis.univ-lyon1.fr>                         
+2005-01-17 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * src/gdcmUtil.cxx : bug fix to find the Windows MAC address. Now, there
+     is no memory access violation
+   * gdcmPython/demo : add python demos using VTK
+
+2005-01-16 Jean-Pierre Roux <jpr@creatis.univ-lyon1.fr>
         * FIX 'Dictionnary' is now spelt 'Dictionary'
               'wether' is now spelt 'whether'
                         'archieve' is now spelt 'archive'   ;-)
@@ -7,7 +12,7 @@
     * ADD DicomDir, DicomDirPatient, DicomDirStudy, DicomDirSerie, DicomDirImage
               related methods, in order not to expose internal mechanisms
         InitTraversal();
-        GetNextEntry();                                 
+        GetNextEntry();
         * REM methods that exposed internal mechanisms :
         DicomDir::GetDicomDirPatients()
         DicomDirPatient::GetDicomDirStudies()
index ded39cb18359689a8afc2bcfdfe96d6b57f16edb..9e85703cd34402fdd914f2cf95106e2c75b92cc2 100644 (file)
@@ -150,6 +150,7 @@ IF(GDCM_VTK)
 
   SET(vtkgdcmPython_la_SOURCES
       ${GDCM_SOURCE_DIR}/vtk/vtkGdcmReader.cxx
+      ${GDCM_SOURCE_DIR}/vtk/vtkGdcmWriter.cxx
   )
   SET_SOURCE_FILES_PROPERTIES(vtkGdcmReaderPython.cxx GENERATED)
   
index 6cc554568017ff9bbddefab43c5d9a3248925bc8..66da5850535758bfe3297ece52a6a01bcab87334 100644 (file)
@@ -3,7 +3,7 @@
 #-----------------------------------------------------------------------------
 # DOH! python is not found by default
 FIND_PROGRAM(PYTHON_EXECUTABLE
-    NAMES python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python
+    NAMES python python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5
     PATHS
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
@@ -47,3 +47,26 @@ CONFIGURE_FILE(
     ${GDCM_SOURCE_DIR}/gdcmPython/demo/PrintDict.py.in
     ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintDict.py
 )
+
+#-----------------------------------------------------------------------------
+# Same but for VTK
+IF(GDCM_VTK)
+  IF(PYTHON_EXECUTABLE)
+    ADD_TEST(Python-VTK-Reader ${PYTHON_EXECUTABLE}
+        ${GDCM_BINARY_DIR}/gdcmPython/demo/vtkGdcmReader.py
+    )
+    ADD_TEST(Python-VTK-Writer ${PYTHON_EXECUTABLE}
+        ${GDCM_BINARY_DIR}/gdcmPython/demo/vtkGdcmWriter.py
+    )
+  ENDIF(PYTHON_EXECUTABLE)
+
+  CONFIGURE_FILE(
+      ${GDCM_SOURCE_DIR}/gdcmPython/demo/vtkGdcmReader.py.in
+      ${GDCM_BINARY_DIR}/gdcmPython/demo/vtkGdcmReader.py
+  )
+
+  CONFIGURE_FILE(
+      ${GDCM_SOURCE_DIR}/gdcmPython/demo/vtkGdcmWriter.py.in
+      ${GDCM_BINARY_DIR}/gdcmPython/demo/vtkGdcmWriter.py
+  )
+ENDIF(GDCM_VTK)
diff --git a/gdcmPython/demo/vtkGdcmReader.py.in b/gdcmPython/demo/vtkGdcmReader.py.in
new file mode 100644 (file)
index 0000000..70670b2
--- /dev/null
@@ -0,0 +1,43 @@
+import sys
+import os
+
+# All paths must be added without system tests, because of ctest...
+sys.path.append('${GDCM_BINARY_DIR}')
+if os.name == 'posix':
+   sys.path.append('${GDCM_BINARY_DIR}/bin')
+else:
+   sys.path.append('${GDCM_BINARY_DIR}/bin/Release')
+   sys.path.append('${GDCM_BINARY_DIR}/bin/Debug')
+
+from gdcmPython.vtk import *
+from vtkpython import *
+
+# Get the file names
+try:
+   fileName = sys.argv[1]
+except IndexError:
+   fileName = os.path.join(GDCM_DATA_PATH, "test.acr")
+
+# read the image
+reader = vtkGdcmReader()
+reader.SetFileName(fileName)
+reader.Update()
+
+# show the image
+viewer = vtkImageViewer()
+viewer.SetInput(reader.GetOutput())
+rng = reader.GetOutput().GetScalarRange()
+viewer.SetColorWindow(rng[1] - rng[0])
+viewer.SetColorLevel(0.5 * (rng[1] + rng[0]))
+
+dim = reader.GetOutput().GetDimensions()
+viewer.SetSize(dim[0],dim[1])
+if(dim[2] != 1):
+   # For multifame dicom, take a snapshot of the center slice (+/- 1)
+   viewer.SetZSlice(dim[2] / 2)
+else:
+   viewer.SetZSlice(0)
+viewer.Render()
+
+# sys.stdin.read(1)
+
diff --git a/gdcmPython/demo/vtkGdcmWriter.py.in b/gdcmPython/demo/vtkGdcmWriter.py.in
new file mode 100644 (file)
index 0000000..845243f
--- /dev/null
@@ -0,0 +1,52 @@
+import sys
+import os
+
+sys.path.append('${GDCM_BINARY_DIR}')
+if os.name == 'posix':
+   sys.path.append('${GDCM_BINARY_DIR}/bin')
+else:
+   sys.path.append('${GDCM_BINARY_DIR}/bin/Release')
+   sys.path.append('${GDCM_BINARY_DIR}/bin/Debug')
+
+from gdcmPython.vtk import *
+from vtkpython import *
+
+# Get the file names
+try:
+   fileName = sys.argv[1]
+except IndexError:
+   fileName = os.path.join(GDCM_DATA_PATH, "test.acr")
+
+# read the image
+reader = vtkGdcmReader()
+reader.SetFileName(fileName)
+
+# write the image
+writer = vtkGdcmWriter()
+writer.SetInput(reader.GetOutput())
+writer.SetFileName("outputPy.dcm")
+writer.Write()
+
+# re-read the image
+reader2 = vtkGdcmReader()
+reader2.SetFileName("outputPy.dcm")
+reader2.Update()
+
+# show the image
+viewer = vtkImageViewer()
+viewer.SetInput(reader2.GetOutput())
+rng = reader.GetOutput().GetScalarRange()
+viewer.SetColorWindow(rng[1] - rng[0])
+viewer.SetColorLevel(0.5 * (rng[1] + rng[0]))
+
+dim = reader.GetOutput().GetDimensions()
+viewer.SetSize(dim[0],dim[1])
+if(dim[2] != 1):
+   # For multifame dicom, take a snapshot of the center slice (+/- 1)
+   viewer.SetZSlice(dim[2] / 2)
+else:
+   viewer.SetZSlice(0)
+viewer.Render()
+
+# sys.stdin.read(1)
+
index dee613e57bf53ca2684c370ace1c49586e2944f7..b8a06b66f2c108e592be4d20e0686a50d7d04036 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/17 13:55:26 $
-  Version:   $Revision: 1.100 $
+  Date:      $Date: 2005/01/17 14:20:30 $
+  Version:   $Revision: 1.101 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 // For GetMACAddress
 #ifdef _WIN32
-#include <snmp.h>
-#include <conio.h>
+   #include <snmp.h>
+   #include <conio.h>
 #else
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+   #include <unistd.h>
+   #include <stdlib.h>
+   #include <string.h>
+   #include <sys/types.h>
 #endif
 
 // How do I do that in CMake ?
 #ifdef __APPLE__
-#define HAVE_SA_LEN
-#define CMAKE_HAVE_NET_IF_DL_H
-#define CMAKE_HAVE_NETINET_IN_H
-#define CMAKE_HAVE_NET_IF_H
+   #define HAVE_SA_LEN
+   #define CMAKE_HAVE_NET_IF_DL_H
+   #define CMAKE_HAVE_NETINET_IN_H
+   #define CMAKE_HAVE_NET_IF_H
 #endif //APPLE
 
 #ifdef CMAKE_HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>  // For SIOCGIFCONF on Linux
+   #include <sys/ioctl.h>  // For SIOCGIFCONF on Linux
 #endif
 #ifdef CMAKE_HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
+   #include <sys/socket.h>
 #endif
 #ifdef CMAKE_HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h>  // For SIOCGIFCONF on SunOS
+   #include <sys/sockio.h>  // For SIOCGIFCONF on SunOS
 #endif
 #ifdef CMAKE_HAVE_NET_IF_H
-#include <net/if.h>
+   #include <net/if.h>
 #endif
 #ifdef CMAKE_HAVE_NETINET_IN_H
-#include <netinet/in.h>   //For IPPROTO_IP
+   #include <netinet/in.h>   //For IPPROTO_IP
 #endif
 #ifdef CMAKE_HAVE_NET_IF_DL_H
-#include <net/if_dl.h>
+   #include <net/if_dl.h>
 #endif
 #ifdef __sun
-//#if defined(CMAKE_HAVE_NET_IF_ARP_H) && defined(__sun)
-// This is absolutely necesseray on SunOS
-#include <net/if_arp.h>
+   //#if defined(CMAKE_HAVE_NET_IF_ARP_H) && defined(__sun)
+   // This is absolutely necesseray on SunOS
+   #include <net/if_arp.h>
 #endif
 
 namespace gdcm 
@@ -516,6 +516,24 @@ int GetMacAddrSys ( unsigned char *addr )
    // Free the bindings
    SNMP_FreeVarBind(&varBind[0]);
    SNMP_FreeVarBind(&varBind[1]);
+
+
+
+/*   IP_ADAPTER_INFO AdapterInfo[2]; 
+    DWORD dwBufSize = sizeof(AdapterInfo); 
+
+    DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwBufSize); 
+
+    PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; 
+    do 
+    { 
+         unsigned char *MAC=pAdapterInfo->Address;
+         printf("Your MAC Address Is: %02X-%02X-%02X-%02X-%02X-%02X", MAC[0], MAC[1], MAC[2], MAC[3], MAC[4], MAC[5]);
+        pAdapterInfo = pAdapterInfo->Next; 
+    } 
+    while(pAdapterInfo); */
+
+
    return 0;
 #endif //Win32 version