[Insight-users] Courseware FLTK example question...

Luis Ibanez luis.ibanez@kitware.com
Fri, 21 Mar 2003 14:28:44 -0500


Hi Bill,

1) You are right, the first line in my code
    was missing a 'typedef'.

2) You are missing to link with FLTK.
    the fltkImageViewer requires you to
    link with the fltk libraries.
    (e.g. fltk.a fltk_gl.a, fltk_forms.a, fltk_images.a)

    You may want to take advantage of the
    files

     FindFLTK.cmake
     FindFltkImageViewer.cmake

    modules in InsightApplications

    They will help you to set up all the
    libraries in the link line.


3) In your CMakeLists.txt file you should add

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

   This will look for FindFLTK.cmake




Regards,


    Luis



---------------------------------------------

Bill Oliver wrote:
> 
>>An easy fix is to replace the plain Fl_Window
>>with the more useful class : Image2DViewer
>>
>>
> 
> 
> Luis,
> 
> Thanks for the pointer.  Unfortunately, I'm getting
> more and more lost.
> 
> First, I assume that the code you provided should
> actually start with :
> 
> typedef fltk::Image2DViewer< PixelType > ViewerType;
> 
> rather than
> 
> fltk::Image2DViewer< PixelType > ViewerType;
> 
> 
> In any case, I'm having a hard time getting everything
> to link.  I tried manually including
> InsightApps/Auxiliary/FltkImageViewer/libITKFltkImageViewer.a
> in the Makefile (since I couldn't figure out how to do it in the
> CMakeLists.txt file).  InsightApps is the InsightApplications
> build directory.  However, I still get lots
> of undefined stuff such as:
> 
> /home/oliver/InsightApp/Auxiliary/FltkImageViewer/
> libITKFltkImageViewer.a(fltkImage2DViewerGUI.o)(.text+0x300):
> In function `fltkImage2DViewerGUI::fltkImage2DViewerGUI[not-in-charge]()':
> : undefined reference to `Fl_Value_Slider::Fl_Value_Slider[in-charge]
> (int, int, int, int, char const*)'
> 
> and
> 
> 
> /home/oliver/InsightApp/Auxiliary/FltkImageViewer/
> libITKFltkImageViewer.a(fltkGlWindow.o)(.text+0x2ed):
> In function `fltk::GlWindow::GlWindow[in-charge]
> (int, int, int, int, char const*)': : undefined reference to
> `Fl_Gl_Window::~Fl_Gl_Window [not-in-charge]()'
> 
> etc.
> 
> Clearly, I'm not including some stuff I should be including,
> but I don't know what to include, and I don't know where to
> look to find out.  I thought I had included the fl_gl etc.
> stuff which should cover it, but I guess not.
> 
> 
> Here's my CMakeLists.txt file.  I know there's excess
> vtk stuff, but that's because I was modifying it as I
> followed the coursware...
> 
> PROJECT( tst )
> 
> INCLUDE (${CMAKE_ROOT}/Modules/FindITK.cmake)
> IF ( USE_ITK_FILE )
> INCLUDE(${USE_ITK_FILE})
> ENDIF( USE_ITK_FILE )
> 
> INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
> IF (   USE_VTK_FILE   )
>          INCLUDE(  ${USE_VTK_FILE}  )
>          ENDIF(   USE_VTK_FILE   )
> 
> INCLUDE (${CMAKE_ROOT}/Modules/FindFLTK.cmake)
> 
> INCLUDE_DIRECTORIES( /home/oliver/InsightApplications-1.2.0/Auxiliary/vtk/
>         /usr/local/include/
>         /home/oliver/InsightApplications-1.2.0/Auxiliary/FltkImageViewer/
>         /home/oliver/InsightApp/Auxiliary/FltkImageViewer/
>                 )
> 
> ADD_EXECUTABLE( tst   tst.cxx )
> 
> TARGET_LINK_LIBRARIES ( tst
>          VXLNumerics   ITKCommon   ITKIO
>          ITKMetaIO   png   z
>          ITKBasicFilters
>          vtkRendering  vtkGraphics vtkHybrid vtkImaging
>          vtkIO vtkFiltering vtkCommon
>          ${FLTK_LIBRARY}
>          )
> 
> And here's the code:
> 
> nclude "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageToVTKImageFilter.h"
> #include "itkCurvatureFlowImageFilter.h"
> #include "vtkImageViewer.h"
> #include "vtkRenderWindowInteractor.h"
> #include "FL/Fl.H"
> #include "itkProcessObject.h"
> #include "itkCommand.h"
> #include "fltkImage2DViewer.h"
> #include "fltkImage2DViewerWindow.h"
> 
> 
> int main( int argc, char **argv ) {
> 
>   typedef float PixelType;
>   typedef itk::Image< float , 2 >            ImageType;
>   typedef itk::ImageFileReader<ImageType>            ReaderType;
>   typedef itk::CurvatureFlowImageFilter< ImageType, ImageType > SmoothingFilterType;
> 
>   typedef fltk::Image2DViewer< PixelType > ViewerType;
>   ViewerType::Pointer viewer = ViewerType::New();
>   ReaderType::Pointer reader = ReaderType::New();
>   SmoothingFilterType::Pointer smoother = SmoothingFilterType::New();
> 
>   reader->SetFileName( argv[1] );
> 
>   smoother->SetInput( reader->GetOutput() );
>   smoother->SetNumberOfIterations( 7 );
>   smoother->SetTimeStep( 0.5 );
> 
>    viewer -> SetImage (smoother->GetOutput() );
>    viewer -> SetLabel("output");
>    viewer -> Show();
> 
>    return 0;
> }
> 
> 
> 
> billo
> 
>