[vtk-developers] Problems with DICOM reader

Brad King brad.king at kitware.com
Wed Jun 11 11:10:58 EDT 2003


Hi Matt,

> Yes. I am willing to change the DICOMParser library to allow
> ansi/non-ansi if it's not too difficult. The DICOMParser is used outside
> of vtk, though, so I'll probably have to copy the vtk logic.

You'll have to create a DICOMConfigure.h.in that is configured by cmake to
DICOMConfigure.h.  It will define macros based on the result of
try-compiles:

In CMakeLists.txt:

INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
CHECK_INCLUDE_FILE_CXX("iosfwd" CMAKE_ANSI_IOSFWD_HEADER)
SET(DICOM_NO_ANSI_STREAMS ${CMAKE_ANSI_IOSFWD_HEADER})

CONFIGURE_FILE(${DICOM_SOURCE_DIR}/DICOMConfigure.h.in
               ${DICOM_BINARY_DIR}/DICOMConfigure.h @ONLY IMMEDIATE)

In DICOMConfigure.h.in:

#ifndef _DICOMConfigure_h
#define _DICOMConfigure_h

#cmakedefine DICOM_NO_ANSI_STREAMS

#endif

Then, in the top-level DICOM header, you'd #include the configured header
and write this to include iostreams:

#ifndef DICOM_NO_ANSI_STREAMS
# include <iostream>
#else
# include <iostream.h>
#endif

> Yes. The DICOMParser has templated classes in the API. This is still a
> problem for creating DLLs if I remember correctly. I'm open to
> suggestions here.

Are there any templates other than DICOMMemberCallback?  The way that
template is used should not be a problem for DLLs.

> I have changed this in vtkDICOMImageReader. I'm leaving DICOMParser as
> is, since it's used outside of vtk.

Not all of VTK's platforms support namespace std.  You'll want to
configure a macro into DICOMConfigure.h that is called something like
DICOM_std.  In CMake listfile code, use

INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)
SET(DICOM_NO_STD_NAMESPACE ${CMAKE_NO_STD_NAMESPACE})

Then in the configured header, use

#cmakedefine DICOM_NO_STD_NAMESPACE
#ifndef DICOM_NO_STD_NAMESPACE
# define DICOM_std std
#else
# define DICOM_std
#endif

Then use DICOM_std:: in your code.

I can provide more details if you need them.

-Brad




More information about the vtk-developers mailing list