[Insight-users] Re: 答复: VtkFltk in InsightApplications

Luis Ibanez luis . ibanez at kitware . com
Tue, 10 Jun 2003 21:14:37 -0400


Hi Zhao,


1) If the image is not displayed until your
   first mouse interaction, you probably want
   to invoke "Render()" on the vtkRenderWindow
   before you invoke "Start()" on the render
   window interactor.

2) vtkFlRenderWindowInteractor is an adaptor
   class that allows you to manage an VTK
   window inside an FLTK GUI. There may be
   some refreshing issue when you use the
   FLTK one.

   How are you comparing the speeds ?
   are you moving the image with the mouse
   and waiting for the refresh ?
   if this is the case, it may be that FLTK
   is caching all your mouse interactions
   and triggering a redraw for every intermediate
   mouse movement. You could easily test this
   hypotesis by overloading the "handle()"
   method of the FLTK window and printing out
   the number of times that mouse interactions
   are logged in.

   In practice, you will not get interactive
   redraw rates unles you use some sort of
   level-of-detail policy in the renderer.
   This class (the one in Insight/Auxiliary)
   may be too primitive for doing so.  It is
   providing only as a generic example of
   ITK,FLTK,VTK integration.

   I would suggest you to avoid redrawing under
   mouse interaction and rather have some FLTK
   button for refreshing the volume render.



Regards,


  Luis



--------------------------
zhao yong qiang wrote:
> HI Luis,
> Thanks for your help, after I read a MHD file, it works now.
>  But the display result is not good. 
>   1. 3d object is not displayed in the box(fltkRenderWindowInteractor),
> unless use mouse to drug .
>   2. the speed is slow, I use class vtkRenderwindowinteractor to display
> the same 3d object. It is fast and sensitive, I was confused as
> vtkFlRenderWindowInteractor is the subclass of
> vtkRenderWindowInteractor, and I read the source files ,but I cannot
> find the reason.
> 
> Thanks!!!
> 
> -----邮件原件-----
> 发件人: Luis Ibanez [mailto:luis . ibanez at kitware . com] 
> 发送时间: 2003年6月10日 8:31
> 收件人: zhao yong qiang
> 抄送: insight-users at www . itk . org
> 主题: Re: VtkFltk in InsightApplications
> 
> HI Zhao,
> 
> Thanks for pointing this out.
> 
> There was actually an error in lines 19-20
> of fltkVTKImageViewer.h
> 
> The SmartPointer<> declarations were missing
> their itk:: namespace.
> 
> A fix has been commited in CVS.
> http://www . itk . org/cgi-bin/cvsweb . cgi/InsightApplications/Auxiliary/VtkF
> ltk/fltkVTKImageViewer.h.diff?r1=1.4&r2=1.5&cvsroot=Insight&sortby=date
> 
> ---
> 
> On the other hand, please not that this
> class is assuming that your input image
> will be 3D.  The fltkVTKImageViewer is
> a simple skeleton for setting up volume
> rendering for segmented data.
> 
> Loading a single DICOM 2D slice will not
> match the expected input image. Please
> try loading a full volume.  You may
> want to create a MetaImage header for your
> data, or use MRIConvert for generating
> a full MetaImage from your DICOM slices.
> 
> 
> 
> Regards,
> 
> 
>     Luis
> 
> 
> 
> ---------------------------------------
> zhao yong qiang wrote:
> 
>>Hi,
>>
>>    I write the following code to use fltkVTKImageViewer 
>>(InsightApplications/Auxiliary/vtkFltk)to show image:
>>
>> 
>>
>>#include "itkImage.h"
>>
>>#include "itkDICOMImageIO2.h"
>>
>>#include "itkImageFileReader.h"
>>
>>#include "itkDICOMImageIO2Factory.h"
>>
>> 
>>
>>#include "fltkVTKImageViewer.h"
>>
>> 
>>
>>#include <config.h>
>>
>>#include <FL/Fl.H>
>>
>> 
>>
>>int main(int argc, char **argv)
>>
>>{
>>
>>         typedef float InputPixelType;
>>
>>         const unsigned int Dimension = 2;
>>
>>         typedef itk::Image< InputPixelType, Dimension >
> 
> InputImageType;
> 
>> 
>>
>>         
>>
> 
> itk::ObjectFactoryBase::RegisterFactory(itk::DICOMImageIO2Factory::New()
> ); 
> 
>>       itk::DICOMImageIO2::Pointer DICOMImage =
>>
>>                     itk::DICOMImageIO2::New();
>>
>> 
>>
>>         itk::ImageFileReader<InputImageType>::Pointer fileReader  =
>>
>>                     itk::ImageFileReader<InputImageType>::New();
>>
>> 
>>
>>            fileReader->SetImageIO(DICOMImage);
>>
>>            fileReader->SetFileName("f:\\test\\t1.dcm");
>>
>>            fileReader->UpdateLargestPossibleRegion();
>>
>> 
>>
>>         typedef fltk::VTKImageViewer<InputImageType::PixelType>
> 
> ImageViewer;
> 
>>         ImageViewer::Pointer viewer = ImageViewer::New();           
>>
>>          viewer->SetImage(fileReader->GetOutput());
>>
>>          viewer->Show();
>>
>> 
>>
>>         Fl::run();
>>
>>         return 0;
>>
>>}
>>
>> 
>>
>>it showed such mistake:
>>
>>E:\P609\fltkVTKImageViewer.h(49) : error C2143: syntax error : missing
> 
> 
>>';' before '<'
>>
>>        E:\P609\fltkVTKImageViewer.h(89) : see reference to class 
>>template instantiation 'fltk::VTKImageViewer<ImagePixelType>' being
> 
> compiled
> 
>>E:\P609\fltkVTKImageViewer.h(49) : error C2059: syntax error : '<'
>>
>>        E:\P609\fltkVTKImageViewer.h(89) : see reference to class 
>>template instantiation 'fltk::VTKImageViewer<ImagePixelType>' being
> 
> compiled
> 
>>E:\P609\fltkVTKImageViewer.h(49) : error C2238: unexpected token(s) 
>>preceding ';'
>>
>>        E:\P609\fltkVTKImageViewer.h(89) : see reference to class 
>>template instantiation 'fltk::VTKImageViewer<ImagePixelType>' being
> 
> compiled
> 
>>E:\P609\fltkVTKImageViewer.h(50) : error C2059: syntax error : '<'
>>
>>        E:\P609\fltkVTKImageViewer.h(89) : see reference to class 
>>template instantiation 'fltk::VTKImageViewer<ImagePixelType>' being
> 
> compiled
> 
>>E:\P609\fltkVTKImageViewer.h(50) : error C2238: unexpected token(s) 
>>preceding ';'
>>
>>        E:\P609\fltkVTKImageViewer.h(89) : see reference to class 
>>template instantiation 'fltk::VTKImageViewer<ImagePixelType>' being
> 
> compiled
> 
>>E:\P609\fltkVTKImageViewer.h(49) : error C2143: syntax error : missing
> 
> 
>>';' before '<'
>>
>>        E:\P609\main\main.cxx(45) : see reference to class template 
>>instantiation 'fltk::VTKImageViewer<float>' being compiled
>>
>>E:\P609\fltkVTKImageViewer.h(49) : error C2059: syntax error : '<'
>>
>>        E:\P609\main\main.cxx(45) : see reference to class template 
>>instantiation 'fltk::VTKImageViewer<float>' being compiled
>>
>>E:\P609\fltkVTKImageViewer.h(49) : error C2238: unexpected token(s) 
>>preceding ';'
>>
>>        E:\P609\main\main.cxx(45) : see reference to class template 
>>instantiation 'fltk::VTKImageViewer<float>' being compiled
>>
>>E:\P609\fltkVTKImageViewer.h(50) : error C2059: syntax error : '<'
>>
>>        E:\P609\main\main.cxx(45) : see reference to class template 
>>instantiation 'fltk::VTKImageViewer<float>' being compiled
>>
>>E:\P609\fltkVTKImageViewer.h(50) : error C2238: unexpected token(s) 
>>preceding ';'
>>
>>        E:\P609\main\main.cxx(45) : see reference to class template 
>>instantiation 'fltk::VTKImageViewer<float>' being compiled
>>
>>E:\P609\main\main.cxx(46) : error C2039: 'SetImage' : is not a member
> 
> of 
> 
>>'VTKImageViewerBase'
>>
>>        E:\P609\fltkVTKImageViewerBase.h(26) : see declaration of 
>>'VTKImageViewerBase'
>>
>>E:\P609\main\main.cxx(47) : error C2039: 'Show' : is not a member of 
>>'VTKImageViewerBase'
>>
>>        E:\P609\fltkVTKImageViewerBase.h(26) : see declaration of 
>>'VTKImageViewerBase'
>>
>>Error executing cl.exe.
>>
>> 
>>
>>It made me confused. In class fltkVTKImageViewer, it defines the
> 
> member 
> 
>>of SetImage() and Show(). Why it found them in its parent class?
>>
>>Thanks a lot !!
>>
>>Sincerely,
>>                          Zhao Yongqiang
>>                          Dept. of Computer Science & Engineering
>>                          Shanghai JiaoTong University
>>                          Shanghai, China
>>                          zhao-yq at cs . sjtu . edu . cn 
>><mailto:zhao-yq at cs . sjtu . edu . cn>
> 
> 
> 
>