[vtkusers] how to make data always fit into the rendering window ?

Oliver Kania ptw.freiburg at googlemail.com
Mon Nov 17 08:10:15 EST 2008


hello all,
I really need your help on the following issue:
I have a certain set of data that I want to ALWAYS fit into
the rendering window no matter how the window is resized.

VTKs default seems to be the following:
if width > height, then the data is zoomed such that
it fits the window.
If only the width changes and width < height, the data
is not zoomed in / out to fit into the window.
At least this is the behavior of the program of which
the code is shown below.

Does anybody know how to force the camera to
zoom in / out such that the data always fits into the window,
no matter how its proportions are ?
On a note,I am using parallel projection in my project.

Here is the code:
----------------------------------------------------------------
vtkRenderer * renderer = vtkRenderer::New();
    vtkRenderWindow * renWin = vtkRenderWindow::New();
    vtkTIFFReader* l_reader = vtkTIFFReader::New();
    vtkImageActor* l_actor  = vtkImageActor::New();
    vtkImageMapToColors* l_mapper = vtkImageMapToColors::New();
    vtkImageCast* l_cast = vtkImageCast::New();

    renderer->SetInteractive(1);
    renWin->SetSize(500, 500);
    //vtkPolyData* l_dat = vtkPolyData::New();
    renWin->AddRenderer(renderer);
    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);
    vtkInteractorStyleImage* style = vtkInteractorStyleImage::New();
    iren->SetInteractorStyle( style );
    renderer->AddActor(l_actor);

    l_reader->SetFileName("D:\\data\\imgs\\plan.tif");
    l_cast->SetInput(l_reader->GetOutput());
    l_cast->SetOutputScalarTypeToUnsignedChar();
    l_mapper->SetInput(l_cast->GetOutput());
    l_actor->SetInput(l_mapper->GetOutput());
    renWin->Render();
    iren->Initialize();
    iren->Start();
------------------------------------------------------------------------------

best regards, Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081117/20b5d9d1/attachment.htm>


More information about the vtkusers mailing list