]> Creatis software - gdcm.git/commitdiff
ENH: New support for cmake 2.0.1
authormalaterre <malaterre>
Fri, 4 Jun 2004 01:42:03 +0000 (01:42 +0000)
committermalaterre <malaterre>
Fri, 4 Jun 2004 01:42:03 +0000 (01:42 +0000)
CMakeLists.txt
Testing/CMakeLists.txt
Testing/TestBug.cxx
gdcmConfigure.h.in
gdcmPython/CMakeLists.txt
gdcmPython/setup.py.in
vtk/vtkGdcmReader.cxx
vtk/vtkgdcmViewer.cxx

index 7996eb79f89f9d31960491303e7e7a32e8da2287..5824e07ede56d578cc67cd32110460995beb6a74 100644 (file)
@@ -3,11 +3,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.8)
 \r
 #-----------------------------------------------------------------------------\r
 # GDCM version number, usefull for packaging and doxygen doc:\r
-SET(GDCM_VERSION_MAJOR 0)\r
-SET(GDCM_VERSION_MINOR 4)\r
-SET(GDCM_VERSION_PATCH 1)\r
-SET(GDCM_VERSION "${GDCM_VERSION_MAJOR}.${GDCM_VERSION_MINOR}")\r
-SET(GDCM_VERSION_FULL "${GDCM_VERSION}.${GDCM_VERSION_PATCH}")\r
+SET(GDCM_MAJOR_VERSION 0)\r
+SET(GDCM_MINOR_VERSION 4)\r
+SET(GDCM_BUILD_VERSION 1)\r
+SET(GDCM_VERSION \r
+    "${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")\r
 \r
 #-----------------------------------------------------------------------------\r
 # datadir in CMake:\r
index 0e013737b1bc8ae5ba273fe2c3f5a9f321a496e0..cfec4c304bf5d330802923b9e63b1c390ef0b6f4 100644 (file)
@@ -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})
index a8e55d475f0947fc7f02fb64ccf80268618f9f0b..6cc2340444039232375bd350571d1152efb69120 100644 (file)
@@ -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;
 }
index 08856ac9cd87d092643ef0879f74c24c27bf2723..24294d6c5ba16038f7fa506d04a4ecd43c5b25aa 100644 (file)
@@ -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
index faeedec531da338b04cf3f08d23994f4d8112dd7..1b713bd019d63a03c465dfe4633e049d988224fe 100644 (file)
@@ -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:
index fe7a51d356060cfde71bca6d83d5a01946a54f4a..525aa0c75633f81dff5b0157aaf123d23b8bd422 100644 (file)
+#!/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/*"))) ]
+
index 3a3de007a9d5b7eb1568a6123dd94f45767463f0..7ef73566e8963d9ac0596a019626c99af7e9961e 100644 (file)
@@ -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();
index ff1e6099b46f63a0a0b4b3b1dc0e1447ad4c7367..f1c1c32f5d8ca558a56df9f704ea0e153127699c 100644 (file)
@@ -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();