From: malaterre Date: Fri, 4 Jun 2004 01:42:03 +0000 (+0000) Subject: ENH: New support for cmake 2.0.1 X-Git-Tag: Version0.5.bp~156 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=5340d1e382a85926f050a0644d8c0d10d25586e2;p=gdcm.git ENH: New support for cmake 2.0.1 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7996eb79..5824e07e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.8) #----------------------------------------------------------------------------- # GDCM version number, usefull for packaging and doxygen doc: -SET(GDCM_VERSION_MAJOR 0) -SET(GDCM_VERSION_MINOR 4) -SET(GDCM_VERSION_PATCH 1) -SET(GDCM_VERSION "${GDCM_VERSION_MAJOR}.${GDCM_VERSION_MINOR}") -SET(GDCM_VERSION_FULL "${GDCM_VERSION}.${GDCM_VERSION_PATCH}") +SET(GDCM_MAJOR_VERSION 0) +SET(GDCM_MINOR_VERSION 4) +SET(GDCM_BUILD_VERSION 1) +SET(GDCM_VERSION + "${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}") #----------------------------------------------------------------------------- # datadir in CMake: diff --git a/Testing/CMakeLists.txt b/Testing/CMakeLists.txt index 0e013737..cfec4c30 100644 --- a/Testing/CMakeLists.txt +++ b/Testing/CMakeLists.txt @@ -88,13 +88,24 @@ ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9) "${GDCM_DATA_ROOT}/*.dcm" ) SET(GDCM_DATA_IMAGES_GLOB ${GDCM_DATA_IMAGES_GLOB_DCM} ${GDCM_DATA_IMAGES_GLOB_ACR}) + #SET(GDCM_DATA_IMAGES_GLOB ${GDCM_DATA_IMAGES_GLOB_ACR}) ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9) # Black list of images known to break lots of readers (efilm, xmedcon ...): SET(BLACK_LIST "gdcm-JPEG-LossLessThoravision.dcm" + "cr172241.dcm" #temporarily remove as it kills my gnome session (but not kde) + "emptyImage.dcm" #the png looks ugly... + "gdcm-MR-PHILIPS-16-Multi-Seq.fixed.dcm" weird looks exactly the same as gdcm-MR-PHILIPS-16-Multi-Seq.dcm + "gdcm-MR-PHILIPS-16.dcm" png looks ugly + "irmPhlipsNew1.dcm" png looks ugly + "mriThruVPRO.dcm" png looks ugly + "US.3405.1.dcm" looks exactly the same as US.1.2.dcm ) +# gdcm-ACR-LibIDO seems to be cut +# test.acr is very bright + # This is a GLOB expression, change it into a list separated with a comma and \n SET(GDCM_DATA_IMAGES) FOREACH(filename ${GDCM_DATA_IMAGES_GLOB}) diff --git a/Testing/TestBug.cxx b/Testing/TestBug.cxx index a8e55d47..6cc23404 100644 --- a/Testing/TestBug.cxx +++ b/Testing/TestBug.cxx @@ -15,7 +15,9 @@ int TestBug(int argc, char* argv[]) filename += "/test.acr"; e1 = new gdcmHeader( filename.c_str() ); } - e1->PrintPubDict(); + //e1->PrintPubDict(); + //e1->GetPubDict()->GetEntriesByKey(); + e1->GetPubDict()->PrintByKey(); return 0; } diff --git a/gdcmConfigure.h.in b/gdcmConfigure.h.in index 08856ac9..24294d6c 100644 --- a/gdcmConfigure.h.in +++ b/gdcmConfigure.h.in @@ -1,11 +1,46 @@ +#ifndef __gdcmConfigure_h +#define __gdcmConfigure_h + +/* This header is configured by GDCM's build process. */ + +/*--------------------------------------------------------------------------*/ +/* Platform Features */ + +/* Byte order. */ +//#cmakedefine VTK_WORDS_BIGENDIAN + +/* Allow access to UINT32_MAX , cf gdcmCommon.h */ #define __STDC_LIMIT_MACROS +/* Hard code the path to the public dictionary */ #define PUB_DICT_PATH "@GDCM_PUB_DICT_PATH@" +/* Hardcode the path to GDCM_DATA_ROOT */ #define GDCM_DATA_ROOT "@GDCM_DATA_ROOT@" +/* For older gcc / broken plateform */ #cmakedefine GDCM_NO_ANSI_STRING_STREAM +/* I guess something important */ #cmakedefine HAVE_NO_STDINT_H +/* This variable allows you to have helpful debug statement */ +/* That are in between #idfef / enif in the gdcm code */ #cmakedefine GDCM_DEBUG + +/* Whether we are building shared libraries. */ +/* This is important as long as GDCM is LGPL */ +#cmakedefine BUILD_SHARED_LIBS + + +/*--------------------------------------------------------------------------*/ +/* GDCM Versioning */ + +/* Version number. */ +#define GDCM_MAJOR_VERSION @GDCM_MAJOR_VERSION@ +#define GDCM_MINOR_VERSION @GDCM_MINOR_VERSION@ +#define GDCM_BUILD_VERSION @GDCM_BUILD_VERSION@ +#define GDCM_VERSION "@GDCM_VERSION@" + + +#endif diff --git a/gdcmPython/CMakeLists.txt b/gdcmPython/CMakeLists.txt index faeedec5..1b713bd0 100644 --- a/gdcmPython/CMakeLists.txt +++ b/gdcmPython/CMakeLists.txt @@ -18,14 +18,17 @@ IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9) INCLUDE(${SWIG_USE_FILE}) #INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - #SET(CMAKE_SWIG_FLAGS "") + #SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES PYTHON ON) SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES SWIG_FLAGS "-includeall") - SWIG_ADD_MODULE(gdcm python gdcm.i gdcm_wrap.cxx) - SWIG_LINK_LIBRARIES(gdcm ${PYTHON_LIBRARIES}) - TARGET_LINK_LIBRARIES(_gdcm gdcm) + SWIG_ADD_MODULE(gdcm python gdcm.i ) #gdcm_wrap.cxx + SWIG_LINK_LIBRARIES(gdcm gdcm ${PYTHON_LIBRARIES}) + + #SWIG_GET_EXTRA_OUTPUT_FILES(python foobar "/usr/" "gdcm" ) + #MESSAGE(FATAL_ERROR ${swig_generated_file_fullname}) + #MESSAGE(FATAL_ERROR ${swig_source_file_fullname}) ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9) @@ -161,9 +164,12 @@ IF(GDCM_VTK) # The C++ files must be made into a C++ library ADD_LIBRARY(vtkgdcmPython SHARED ${gdcmWrapSOURCES}) #MODULE on apple ? # set the libraries to link against + #SET_TARGET_PROPERTIES(${foobar} PROPERTIES PREFIX "") + + GET_TARGET_PROPERTY(swig_gdcm_fullpath "${SWIG_MODULE_gdcm_REAL_NAME}" LOCATION) TARGET_LINK_LIBRARIES (vtkgdcmPython - pygdcm - vtkgdcm + vtkgdcm # ??? + #`${swig_gdcm_fullpath}` #Does not work vtkCommonPython vtkIOPython) ENDIF (GDCM_WRAP_PYTHON) @@ -174,7 +180,7 @@ IF(GDCM_VTK) GET_FILENAME_COMPONENT(VTKPATH ${VTK_DIR}/../../ ABSOLUTE) CONFIGURE_FILE( ${GDCM_SOURCE_DIR}/gdcmPython/setup.py.in - ${GDCM_BINARY_DIR}/gdcmPython/setup.py + ${GDCM_BINARY_DIR}/setup.py ) ENDIF(GDCM_VTK) @@ -185,6 +191,15 @@ ENDIF(GDCM_VTK) # in /usr/lib/pythonx.x/site-package and not a a std /usr/lib # Thus generate a setup.py file using distutils +# Create a gdcm.pth file: + +FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/gdcm.pth + "gdcmPython" + ) + +FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/__init__.py + "import gdcm" + ) #----------------------------------------------------------------------------- # Add test from demo subdir: diff --git a/gdcmPython/setup.py.in b/gdcmPython/setup.py.in index fe7a51d3..525aa0c7 100644 --- a/gdcmPython/setup.py.in +++ b/gdcmPython/setup.py.in @@ -1,129 +1,104 @@ +#!/usr/bin/env python + +""" +setup.py for installing the gdcm-Python bindings using distutils. + +Created by Mathieu Malaterre, May 2004. +Heavily based on setup.py.in from VTK, Prabhu Ramachandran, June 2002. + +""" + +import glob, sys, os +from types import StringType from distutils.core import setup -import glob, os, sys, shutil -from distutilsWrapping import * -from WrapSwig import * -from WrapVTK import * - -ThisModule ="gdcmPython" -gdcmPythonSrcDir=ThisModule -gdcmSrcDir ="src" -gdcmJpeg8SrcDir =os.path.join('src', 'jpeg', 'libijg8') -gdcmJpeg12SrcDir=os.path.join('src', 'jpeg', 'libijg12') -gdcmJpgSrcDir =os.path.join('src', 'jpeg', 'ljpg') -gdcmvtkSrcDir ="vtk" -gdcmDictsDir ="Dicts" -gdcmTestDir ="Test" - -# Due to a distutils oddity on Unices : see -# http://aspn.activestate.com/ASPN/Mail/Message/distutils-sig/588325 -if(os.name=='posix'): - targetDir=os.path.join('lib','python'+sys.version[:3],'site-packages') - libraries=["stdc++"] - macros =[('__STDC_LIMIT_MACROS', '1')] - - VTKPATH="${VTKPATH}" - vtkWrapper="vtkWrapPython" -else: - targetDir=os.path.join('lib','site-packages') - libraries=["WSOCK32"] - macros =[] - - try: - VTKPATH=os.environ['VTKPATH'] - except KeyError,e: - err=str(e) - print "Environment variable",err[err.rfind(':')+1:],'not defined, '\ - 'please fix it!' - VTKPATH="${VTKPATH}" - vtkWrapper=os.path.join(VTKPATH,"bin","vtkWrapPython") - -targetDir=os.path.join(targetDir, ThisModule) - -### Sources section: determination of sources for the extensions: -# Sources 1a/ The kernel of gdcm itself (which wrapped with Swig) -# defines the first extension -Sources = [] -Sources.extend(glob.glob(os.path.join(gdcmSrcDir,"*.cxx"))) -Sources.append(os.path.join(gdcmPythonSrcDir,"gdcm.i")) -# Sources 1b/ The kernel of gdcm depends on a jpeg library whose sources are -# contained in subdir gdcmJpeg8SrcDir. But within this subdir -# some of the C files should not be compiled (refer to -# gdcmJpeg8SrcDir/Makefile.am) ! - -Jpeg8Sources = glob.glob(os.path.join(gdcmJpeg8SrcDir,"j*.c")) -Jpeg8SourcesToRemove = ['jmemansi.c', 'jmemname.c', 'jmemdos.c', 'jmemmac.c'] -for Remove in Jpeg8SourcesToRemove: - ### Because setup.py is a multiple pass process we need to trap - ### the case where the files were already wed out on a previous pass. - try: - Jpeg8Sources.remove(os.path.join(gdcmJpeg8SrcDir, Remove)) - except ValueError: - continue -Sources.extend(Jpeg8Sources) - -Jpeg12Sources = glob.glob(os.path.join(gdcmJpeg12SrcDir,"j*.c")) -Jpeg12SourcesToRemove = ['jmemansi12.c', 'jmemname12.c', 'jmemdos12.c', 'jmemmac12.c'] -for Remove in Jpeg12SourcesToRemove: - ### Because setup.py is a multiple pass process we need to trap - ### the case where the files were already wed out on a previous pass. - try: - Jpeg12Sources.remove(os.path.join(gdcmJpeg12SrcDir, Remove)) - except ValueError: - continue -Sources.extend(Jpeg12Sources) - -#For 'xmedcon' Jpeg Lossless -JpgSources =glob.glob(os.path.join(gdcmJpgSrcDir,"*.c")) -Sources.extend(JpgSources) - -# Sources 2/ The second extension contains the VTK classes (which we wrap -# with the vtk wrappers): -VTK_INCLUDE_DIR=os.path.join(VTKPATH,"include","vtk") -VTK_LIB_DIR=os.path.join(VTKPATH,"lib","vtk") -vtkSources = [] -vtkSources.extend(glob.glob(os.path.join(gdcmvtkSrcDir,'vtk*.cxx'))) -vtkSources.extend(glob.glob(os.path.join(gdcmSrcDir,'*.cxx'))) -vtkSources.extend(Jpeg8Sources) -vtkSources.extend(Jpeg12Sources) -vtkSources.extend(JpgSources) - -vtkLibraries=["vtkCommon","vtkCommonPython", - "vtkIO","vtkIOPython", - "vtkFiltering","vtkFilteringPython"] - -##### -setup(name=ThisModule, - version="${GDCM_VERSION_MAJOR}.${GDCM_VERSION_MINOR}", - description="...", - author="frog", - author_email="frog@creatis.insa-lyon.fr", - url="http://www.creatis.insa-lyon.fr/Public/Gdcm/", - packages=[ '.', - gdcmPythonSrcDir, - gdcmPythonSrcDir + '.demo' ], - cmdclass={'build_ext':build_extWrap}, # redirects default build_ext - ext_modules=[SwigExtension(name='_gdcm', - sources=Sources, - include_dirs=[gdcmSrcDir,gdcmJpeg8SrcDir, - gdcmJpeg12SrcDir,gdcmJpgSrcDir], - libraries=libraries, - define_macros=macros, - swig_cpp=1, - swig_include=[gdcmSrcDir] - ), - VTKExtension(name='gdcmPython.vtkgdcmPython', - sources=vtkSources, - include_dirs=[gdcmSrcDir,gdcmvtkSrcDir, - VTK_INCLUDE_DIR], - libraries=libraries+vtkLibraries, - define_macros=macros, - library_dirs=[VTK_LIB_DIR], - vtkWrapper=vtkWrapper, - ), - ], - data_files=[(os.path.join(targetDir,gdcmTestDir), - glob.glob(os.path.join(gdcmTestDir,"*.acr"))), - (os.path.join(targetDir,"Dicts"), - glob.glob(os.path.join(gdcmDictsDir,"*.*"))), - ] +from distutils.util import change_root, convert_path +from distutils.command.install_data import install_data +from distutils.sysconfig import get_config_var + +version = "${GDCM_VERSION}", + +build_lib_dir = "${LIBRARY_OUTPUT_PATH}" + +build_bin_dir = "${EXECUTABLE_OUTPUT_PATH}" + +gdcmDictsDir = "${GDCM_SOURCE_DIR}" +gdcmDictsDir = os.path.join( gdcmDictsDir, "Dicts" ) + +# You can change this to suit your needs. However you must make sure +# that under *nix the libvtk*Python*.so in the specified directory. +#install_lib_dir = "${CMAKE_INSTALL_PREFIX}/lib/vtk" + +def get_libs(): + """Returns a list of libraries to be installed. """ + libs = [] + if os.name == 'posix': + libs = glob.glob(os.path.abspath(os.path.join( + build_lib_dir, '_gdcm' + get_config_var('SO')))) + libs = libs + glob.glob(os.path.abspath(os.path.join( + build_lib_dir, 'libvtkgdcmPython' + get_config_var('SO')))) + else: + d = os.path.normpath(build_lib_dir) + if not os.path.isfile(os.path.join(d, 'libvtkgdcmPython.dll')): + d = os.path.normpath(os.path.join(build_lib_dir, 'release')) + + libs = glob.glob(os.path.join(d, 'vtk*Python.dll')) + + return libs + +def get_scripts(): + """Returns the appropriate gdcm.py python script + that is to be installed.""" + scripts = [] + if os.name == 'posix': + f = os.path.join(build_bin_dir, "gdcm.py") + if os.path.exists(f): + scripts.append(f) + else: + win32_bin_dir = build_bin_dir + for subdir in ('Debug', 'Release', 'MinSizeRel', + 'RelWithDebInfo'): + win32_bin_dir = os.path.join(build_bin_dir, subdir) + if os.path.exists(win32_bin_dir): + break + for i in ('vtkpython.exe', 'pvtkpython.exe'): + f = os.path.join(os.path.normpath(win32_bin_dir), i) + if os.path.exists(f): + scripts.append(f) + return scripts + + +print get_libs() +print get_scripts() +print gdcmDictsDir + +""" +setup(name="Distutils", + version="1.0", + description="Python Distribution Utilities", + author="Greg Ward", + author_email="gward@python.net", + url="http://www.python.org/sigs/distutils-sig/", + packages=['distutils', 'distutils.command'], ) + +""" +setup(name = "gdcmPython", + version = "${GDCM_VERSION}", + description = "GNU DiCoM", + author = "frog", + author_email = "frog@creatis.insa-lyon.fr", + maintainer = "GDCM Developers", + maintainer_email = "dcmlib@creatis.insa-lyon.fr", + license = "LGPL", + long_description = "Library dedicated to reading/parsing and writing Dicom files", + url = "http://www.creatis.insa-lyon.fr/Public/Gdcm/", + platforms = ['Any'], + packages = ['gdcmPython'], + #scripts = get_scripts(), + #package_dir = {'gdcmPython': '.'}, + #data_files = [ ('gdcmPython', 'gdcm.pth') ], + ) + + #data_files = [('gdcmPython', get_libs()), ('gdcmPython', ['gdcm.pth'])] + #data_files = [('Dicts', glob.glob(os.path.join(gdcmDictsDir,"Dicts/*"))) ] + diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index 3a3de007..7ef73566 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -529,7 +529,7 @@ int vtkGdcmReader::CheckFileCoherence() this->ImageType = type; this->PixelSize = GdcmHeader.GetPixelSize(); - if( GdcmHeader.HasLUT() ) + if( GdcmHeader.HasLUT() && false ) { this->NumComponents = GdcmHeader.GetNumberOfScalarComponentsRaw(); } @@ -624,7 +624,7 @@ size_t vtkGdcmReader::LoadImageInMemory( unsigned char * Source; - if( GdcmFile.GetHeader()->HasLUT() ) + if( GdcmFile.GetHeader()->HasLUT() && false ) { size = GdcmFile.GetImageDataSizeRaw(); Source = (unsigned char*) GdcmFile.GetImageDataRaw(); diff --git a/vtk/vtkgdcmViewer.cxx b/vtk/vtkgdcmViewer.cxx index ff1e6099..f1c1c32f 100644 --- a/vtk/vtkgdcmViewer.cxx +++ b/vtk/vtkgdcmViewer.cxx @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) vtkImageViewer2 *viewer = vtkImageViewer2::New(); - if( reader->GetLookupTable() ) +/* if( reader->GetLookupTable() ) { //convert to color: vtkImageMapToColors *map = vtkImageMapToColors::New (); @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) viewer->SetInput ( map->GetOutput() ); map->Delete(); } - else + else*/ { viewer->SetInput ( reader->GetOutput() ); @@ -86,8 +86,8 @@ int main(int argc, char *argv[]) viewer->SetupInteractor (iren); vtkFloatingPointType *range = reader->GetOutput()->GetScalarRange(); - viewer->SetColorWindow (range[1] - range[0]); - viewer->SetColorLevel (0.5 * (range[1] + range[0])); + //viewer->SetColorWindow (range[1] - range[0]); + //viewer->SetColorLevel (0.5 * (range[1] + range[0])); // Here is where we setup the observer, vtkgdcmObserver *obs = vtkgdcmObserver::New();