[vtkusers] Getting box coordinates

David Doria daviddoria+vtk at gmail.com
Mon Sep 6 06:38:15 EDT 2010


On Mon, Sep 6, 2010 at 4:27 AM, Mario Rodriguez <biomates at telefonica.net> wrote:
> Hello,
>
> I have a scene formed by several objects (some of them obtained from
> translation and/or rotations) bounded by a box (vtkAppendPolyData +
> vtkOutlineFilter). Then I draw the axes with the corresponding x-y-z
> tics (vtkCamera + vtkCubeAxesActor2D). Everything works fine.
>
> What I need is to set the camera parameters automatically from the
> dimensions of the bounding box. Instead of writing explicitly something
> as
>
> vtkCamera camera
>    camera SetFocalPoint 2 3 3
>    camera SetPosition 15 15 15
>    camera SetViewUp 0 0 1
>
> I need to set the focal point to the geometric center of the box and the
> position coordinates at a certain distance from the scene. And the
> question is: is it possible to get the x-y-z ranges of the complete
> scene, and after some simple calculations pass the necessary values to
> SetFocalPoint and SetPosition?
>
> I haven't found any example solving this particular problem.
>
> Sorry if this question is very basic, but I've started to make my first
> steps into vtk some days ago and I am not very familiar with this
> software.
>
> --
> Mario

This isn't particularly elegant, but you could loop over all of the
actors and call GetBounds
http://www.vtk.org/doc/nightly/html/classvtkActor.html#a65b0a469a62bb01862777a47784c3dbc
on each of them and keep track of the min/max in all directions.

David



More information about the vtkusers mailing list