[vtkusers] Getting box coordinates
Ayman Habib
ahabib at stanford.edu
Wed Sep 8 13:51:53 EDT 2010
Hi Seb,
To follow up on this trail, I assume that this call requires the geometry to
be rendered already before you make the call (otherwise you get the
uninitialized box of -1,1 in each direction). Is there a way to compute
these bounds for a vtkAssembly before it is actually rendered? I need to
discover how big an assembly is before I add it to a scene (that already
contains other assemblies).
Thanks,
-Ayman
----- Original Message -----
From: "Sebastien Jourdain" <sebastien.jourdain at kitware.com>
To: "David Doria" <daviddoria+vtk at gmail.com>
Cc: <vtkusers at vtk.org>
Sent: Monday, September 06, 2010 4:49 AM
Subject: Re: [vtkusers] Getting box coordinates
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
>
_______________________________________________
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