[vtkusers] Getting box coordinates

Sebastien Jourdain sebastien.jourdain at kitware.com
Mon Sep 6 07:49:41 EDT 2010


On the vtkRenderer, you do have a method that do exactly that.

void 	ComputeVisiblePropBounds  (double bounds[6])
double * 	ComputeVisiblePropBounds ()

Moreover, if you call ResetCamera() on the camera, you migh get the
result that you try to achieve.

Seb

On Mon, Sep 6, 2010 at 6:38 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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