[vtkusers] vtkImageViewer2 image display

Oleksandr Dzyubak adzyubak at gmail.com
Mon Apr 14 12:56:16 EDT 2008


Hi Tobias,

I tried your suggestion and got compiler errors below.

myProject.cxx: In function ‘int main(int, char**)’:
myProject.cxx:56: error: invalid use of incomplete type ‘struct vtkRenderer’
/usr/bin/../include/vtk-5.0/vtkRenderWindowInteractor.h:46: error: 
forward declaration of ‘struct vtkRenderer’
make[2]: *** [CMakeFiles/myProject.dir/myProject.o] Error 1
make[1]: *** [CMakeFiles/myProject.dir/all] Error 2
make: *** [all] Error 2

What am I doing wrong?

Alex

tobse wrote:
> Hi Alex,
>
> you can setup the active camera via the renderer of the imageviewer.
> viewer->GetRenderer()->GetActiveCamera()->SetFocalPoint(x,y,z);
> Doesn't look nice but works...
>
> tobse
>
>
> Oleksandr Dzyubaka wrote:
>   
>> vtkusers-request at vtk.org wrote:
>>     
>>> Date: Fri, 4 Apr 2008 02:11:46 -0700 (PDT)
>>> From: tobse <tobias.meisel at phacon-leipzig.de>
>>> Subject: Re: [vtkusers] vtkImageViewer2 image display
>>> To: vtkusers at vtk.org
>>> Message-ID: <16489656.post at talk.nabble.com>
>>> Content-Type: text/plain; charset=us-ascii
>>>
>>>
>>> Hi,
>>>
>>> I calculated the FocalPoint and the Position of the camera with respect
>>> to
>>> the image size
>>>
>>> 1. determine the size of the image in x and y direction (using the extent
>>> and the spacing of the input image)
>>> 2. based on the larger axes, you can modify the view angle or the
>>> distance
>>> of the camera
>>>   
>>>             angle = Camera->GetViewAngle();
>>>             distance= SizeOfLargerAxes/2/tan(angle/2);
>>> 3. Determine the middle of the image
>>> 4. Focus the camera to the middle of the image 
>>>
>>>       
>>>             Camera->SetFocalPoint(xmax/2, ymax/2, 0);
>>>              Camera->SetPosition(xmax/2,ymax/2,distance);
>>>
>>> This will work as long as the image is in the xy-plane , with z=0.
>>>
>>> hope this will help
>>>
>>> tobse
>>>   
>>>       
>> Hi Tobias,
>>
>> Thanks for your answer.
>> I understand that the remedy against getting my image in a render window
>> so tiny is to preset the focal points and position before calling 
>> methods below.
>>
>> viewer->Render();
>> renderWindowInteractor->Start();
>>
>> I try to use vtkImageViewer2 class and as a starting point
>> I use the slightly modified code from GettingStarted-II attached below.
>> Searching the classes used in the code, I cannot find where I could
>> access the camera methods to preset the values.
>>
>> Where is it?
>>
>> Thanks,
>>
>> Alex
>>
>>
>> #include "itkImage.h"
>> #include "itkImageFileReader.h"
>> #include "itkImageToVTKImageFilter.h"
>> #include "vtkRenderWindowInteractor.h"
>> #include "vtkImageViewer2.h"
>>
>> int main( int argc, char **argv) {
>> typedef itk::Image <signed short, 3> ImageType;
>>
>> typedef itk::ImageFileReader <ImageType> ReaderType;
>> typedef itk::ImageToVTKImageFilter <ImageType> ConnectorType;
>>
>> ReaderType::Pointer reader= ReaderType::New();
>> ConnectorType::Pointer connector= ConnectorType::New();
>> reader->SetFileName( argv[1]);
>> connector->SetInput( reader->GetOutput() );
>> vtkImageViewer2* viewer= vtkImageViewer2::New();
>>
>> vtkRenderWindowInteractor* renderWindowInteractor =
>> vtkRenderWindowInteractor::New();
>>
>> viewer->SetupInteractor( renderWindowInteractor);
>> viewer->SetInput( connector->GetOutput() );
>>
>> viewer->SetSlice(3);
>> viewer->SetSize(300, 300);
>>
>> viewer->Render();
>> viewer->SetColorWindow( 255);
>> viewer->SetColorLevel( 128);
>>
>> renderWindowInteractor->Start();
>> return 0;
>> }
>>
>> _______________________________________________
>> This is the private VTK discussion list.
>> Please keep messages on-topic. Check the FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>>     
>
>   




More information about the vtkusers mailing list