[Insight-users] Problem with fltkImageViewer

Laurent Paul Laurent.Paul at orto.ucl.ac.be
Fri Oct 28 03:31:52 EDT 2005


Hi users,

I'm building a software using FLTK, ITK and VTK.
I've got a problem with 2D images. I manage to display these with
vtkImageViewer and interact with vtkFlRenderWindowInteractor. But I just
can modify level window. Nothing about pan, zoom, pick...
So I tried with other viewers, fltkImageViewer and fltkImage2DViewer.

The first one compile but at run time, there is only a black screen
instead of image. The value_slider is "0" and it's impossible to move it
(as if there was any image) and when I interact with the image, the
program crashes.

The second one doesn't compile, linking error:
Linking...
ITKFltkImageViewer.lib(fltkGlWindow.obj) : error LNK2005: "public: virtual
int __thiscall itk::LightObject::GetReferenceCount(void)const "
(?GetReferenceCount at LightObject@itk@@UBEHXZ) already defined in
ITKCommon.lib(ITKCommon.dll)
ITKFltkImageViewer.lib(fltkGlWindow.obj) : warning LNK4006: "public:
virtual int __thiscall itk::LightObject::GetReferenceCount(void)const "
(?GetReferenceCount at LightObject@itk@@UBEHXZ) already defined in
ITKCommon.lib(ITKCommon.dll); second definition ignored

   Creating library Release/essai_viewer.lib and object
Release/essai_viewer.exp
ITKFltkImageViewer.lib(fltkImage2DViewerWindow.obj) : error
LNK2001:unresolved external symbol _gluOrtho2D at 32
Release/essai_viewer.exe : fatal error LNK1120: 1 unresolved externals

I put the Cmakelist.txt and a part of my code:
Cmakelist.txt:
PROJECT(essai_viewer)

# first we have to find VTK
FIND_PACKAGE(VTK)
IF(VTK_FOUND)
  INCLUDE(${VTK_USE_FILE})
ENDIF(VTK_FOUND)

# first we have to find ITK
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
  INCLUDE(${ITK_USE_FILE})
ENDIF(ITK_FOUND)

# then FLTK
FIND_PACKAGE(FLTK)
IF(FLTK_FOUND)
 INCLUDE_DIRECTORIES(${FLTK_INCLUDE_DIR})
ENDIF(FLTK_FOUND)

# then vtkFlRenderWindowInteractor.h and .cxx
FIND_PATH(VTK_FL_RWI_H_PATH vtkFlRenderWindowInteractor.h)
FIND_PATH(VTK_FL_RWI_CXX_PATH vtkFLRenderWindowInteractor.cxx)

IF(NOT VTK_FL_RWI_H_PATH)
   MESSAGE(FATAL_ERROR "Please enter the path of
vtkFlRenderWindowInteractor.h")
ENDIF(NOT VTK_FL_RWI_H_PATH)

IF(NOT VTK_FL_RWI_CXX_PATH)
   MESSAGE(FATAL_ERROR "Please enter the path of
vtkFlRenderWindowInteractor.cxx")
ENDIF(NOT VTK_FL_RWI_CXX_PATH)

SET(InsightApplications_SOURCE_DIR C:/lib/InsightApplications/sources)
SET(InsightApplications_BINARY_DIR C:/lib/InsightApplications/bin)

# add the VtkFltk path to the include directories
INCLUDE_DIRECTORIES(${VTK_FL_RWI_H_PATH}
                        ${InsightApplications_SOURCE_DIR}/Auxiliary/FltkImageViewer
                        ${InsightApplications_BINARY_DIR}/Auxiliary/FltkImageViewer)

# remember to actually build and link with vtkFlRenderWindowInteractor.cxx
ADD_EXECUTABLE(essai_viewer essai_viewer.cxx FltkVTKViewerUI.cxx main.cxx
${VTK_FL_RWI_CXX_PATH}/vtkFlRenderWindowInteractor.cxx)

TARGET_LINK_LIBRARIES(essai_viewer ITKCommon vtkCommon ITKFltkImageViewer

ITKBasicFilters ITKIO ITKNumerics vtkVolumeRendering vtkImaging vtkIO
vtkRendering vtkGraphics ${FLTK_LIBRARIES} )


Part of code in myprogram.h :
        typedef unsigned short InputPixelType;
        typedef itk::Image< InputPixelType, 3 >  ImageType;
        typedef itk::ImageFileReader< ImageType >  ReaderType;
        typedef ReaderType::Pointer ReaderPointer;
        ReaderPointer ItkReader;

        //viewer1
        typedef unsigned char OverlayPixelType;
        typedef fltk::ImageViewer< InputPixelType, OverlayPixelType >
InternalImageViewerType;
        InternalImageViewerType *ITKviewer;

        //Viewer2
           typedef fltk::Image2DViewer< InputPixelType > ImageViewerType;
        ImageViewerType::Pointer ITKviewer2;

        //convert 3D to 2D
        typedef itk::Image< InputPixelType, 2 >  Image2DType;
        typedef itk::CastImageFilter< ImageType, Image2DType >
CastImageFilterType;
        CastImageFilterType::Pointer m_CastImageFilter;


Part of code in myprogram.cxx :
void essai_viewer::Load_hdr_Volume(const char *directory)
{
        ItkReader = ReaderType::New();
        ItkReader->SetFileName(directory);

        ITKviewer = new InternalImageViewerType;
        ITKviewer->SetLabel( "test" );
            ITKviewer->SetImage( ItkReader->GetOutput() );

        m_CastImageFilter->CastImageFilterType::New();
        m_CastImageFilter->SetInput( ItkReader->GetOutput() );
        ITKviewer2 = ImageViewerType::New();
        ITKviewer2->SetLabel( "test" );
        ITKviewer2->SetImage(m_CastImageFilter->GetOutput());
        ITKviewer2->Show();
...
}

Whats wrong with these two viewers?

Great thanks for any help!

Laurent.



More information about the Insight-users mailing list