FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/core.py
"import gdcm\n"
- "GDCM_DATA_ROOT =\"${GDCM_DATA_ROOT}\"\n"
+ "GDCM_DATA_ROOT = \"${GDCM_DATA_ROOT}\"\n"
)
IF(GDCM_VTK)
" from libvtkgdcmPython import *\n"
"else:\n"
" from vtkgdcmPython import *\n"
- "GDCM_DATA_ROOT =\"${GDCM_DATA_ROOT}\"\n"
+ "GDCM_DATA_ROOT = \"${GDCM_DATA_ROOT}\"\n"
)
ENDIF(GDCM_VTK)
#-----------------------------------------------------------------------------
# Copy all the demo directory content to the cmake bin
# Without it, tests can't be launched
+CONFIGURE_FILE(
+ ${GDCM_SOURCE_DIR}/gdcmPython/demo/gdcmConfigDemo.py.in
+ ${GDCM_BINARY_DIR}/gdcmPython/demo/gdcmConfigDemo.py
+)
+
CONFIGURE_FILE(
${GDCM_SOURCE_DIR}/gdcmPython/demo/PrintFile.py.in
${GDCM_BINARY_DIR}/gdcmPython/demo/PrintFile.py
-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 gdcmConfigDemo import *
from gdcmPython.core import *
+def PrintUse():
+ print ""
+ print "Use :"
+ print "-----"
+ print "%s <dicomDir>" % sys.argv[0]
+ print " dicomDir : path to the DICOMDIR to parse"
+ print ""
+ print ""
+
### Get filename from command line or default it
try:
fileName = sys.argv[1]
### Build the DicomDir element list
dicomdir = gdcm.DicomDir(fileName)
if not dicomdir.IsReadable():
- print
+ PrintUse()
raise RuntimeError,"The '%s' DicomDir is not readable with gdcm." % fileName
- #sys.exit()
+print "DICOMDIR -->",fileName
print "##############################################################"
print "## Display all the elements and their respective values"
print "## found in the ", fileName, " file."
-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 gdcmConfigDemo import *
from gdcmPython.core import *
print "#####################################################################"
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 gdcmConfigDemo import *
from gdcmPython.core import *
+def PrintUse():
+ print ""
+ print "Use :"
+ print "-----"
+ print "%s <fileName>" % sys.argv[0]
+ print " fileName : path to the DICOM file to parse"
+ print ""
+ print ""
+
### Get filename from command line or default it
try:
fileName = sys.argv[1]
printLevel = 1
### Build the file element list
-print fileName, type(fileName)
file = gdcm.File(fileName)
if not file.IsReadable():
+ PrintUse()
raise RuntimeError,"The '%s' file is not readable with gdcm." % fileName
+print "File -->",fileName
print "##############################################################"
print "### Display all the elements and their respective values"
print "## found in the ", fileName, " file."
--- /dev/null
+# gdcmPython Demo configurer
+
+if __name__!="main":
+ import sys
+ import os
+ import inspect
+ import os.path
+
+ def FindPath():
+ try:
+ path=inspect.getsourcefile(FindPath)
+ except:
+ pass
+ else:
+ if( path ):
+ path=os.path.split(path)[0]
+ file=os.path.join(path,"..","__init__.py")
+ if( os.path.isfile(file) ):
+ gdcmPath=os.path.join(path,"..","..")
+ sys.path.append(gdcmPath)
+ sys.path.append(os.path.join(gdcmPath,"bin"))
+ if( os.name != 'posix' ):
+ sys.path.append(os.path.join(gdcmPath,"bin","Release"))
+ sys.path.append(os.path.join(gdcmPath,"bin","Debug"))
+
+ def UseCMakePath():
+ sys.path.append('${GDCM_BINARY_DIR}')
+ sys.path.append('${GDCM_BINARY_DIR}/bin')
+ if( os.name != 'posix' ):
+ sys.path.append('${GDCM_BINARY_DIR}/bin/Release')
+ sys.path.append('${GDCM_BINARY_DIR}/bin/Debug')
+
+ try:
+ mod=__import__("gdcmPython")
+ except:
+ FindPath()
+ try:
+ mod=__import__("gdcmPython")
+ except:
+ UseCMakePath()
+
+else:
+ print "Only a system configurer for gdcm Demos."
+ print "Can't be executed"
+
-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 gdcmConfigDemo import *
from gdcmPython.vtk import *
from vtkpython import *
+def PrintUse():
+ print ""
+ print "Use :"
+ print "-----"
+ print "%s <fileName>" % sys.argv[0]
+ print " fileName : path to the DICOM file to see"
+ print ""
+ print ""
+
# Get the file names
try:
fileName = sys.argv[1]
except IndexError:
fileName = os.path.join(GDCM_DATA_ROOT, "test.acr")
+
+if( not os.path.isfile(fileName) ):
+ PrintUse()
+ sys.exit(1)
# read the image
reader = vtkGdcmReader()
-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 gdcmConfigDemo import *
from gdcmPython.vtk import *
from vtkpython import *
+def PrintUse():
+ print ""
+ print "Use :"
+ print "-----"
+ print "%s <fileName>" % sys.argv[0]
+ print " fileName : path to the DICOM file to see"
+ print ""
+ print ""
+
# Get the file names
try:
fileName = sys.argv[1]
except IndexError:
fileName = os.path.join(GDCM_DATA_ROOT, "test.acr")
+
+if( not os.path.isfile(fileName) ):
+ PrintUse()
+ sys.exit(1)
# read the image
reader = vtkGdcmReader()