[vtkusers] locate a vtkActor2D ???

Vladan Bato vbato at ieee.org
Mon Jul 19 04:05:54 EDT 2004


Cyril Giraudon wrote:
> I 'd like to draw a surface which represent Z.
> The problem is the following :
> if X and Y are contained in [0,1] all is OK,
> otherwise I can see only Z where X and Y are
> contained in [0,1].
> 
> Have I to normalize and translate X and Y ?
 >
 > [...]
> 
>     vtkCoordinate coo = new vtkCoordinate();
>     coo.SetCoordinateSystemToNormalizedViewport();
> 
>     vtkPolyDataMapper2D contMapper = new vtkPolyDataMapper2D();
>     contMapper.SetTransformCoordinate(coo);
>     contMapper.SetInput(polydata);
>     contMapper.ScalarVisibilityOn();
>     contMapper.SetScalarRange(ZMIN, ZMAX);
> 

The problem is that you are using a vtkPolyDataMapper2D. This maps your 
X/Y coordinates directly to screen coordinates without using a camera.
Since you are using normalized coordinates, this means that the X and Y 
range is [0,1].

If what you are trying to achieve is really a 2D visualization, then you 
have two options:

1) Normalize the X and Y coordinates (or otherwise transform tham to fit 
in that range). What you are doing here is basically drawing in 2D on 
the screen where the coordinates are normalized.

2) Use a 3D mapper, but set the camera to look at the surface from above 
  and use vtkInteractorStyleImage to constrain the interaction to 2D 
(you will be able to zoom, pan and rotate the view in 2D only).


-- 
Vladan Bato
vbato at ieee.org



More information about the vtkusers mailing list