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

Bill Oliver billo@Radix.Net
Fri, 21 Mar 2003 13:49:52 -0500 (EST)


>
> 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