2D pointcloud plot using vtkActor

In my application, I am displaying a 3D pointcloud view alongside a 2D overhead view of the same thing. For the 3D pointcloud, I am using a vtkActor and vtkPolyDataMapper with vtkTableToPolyData as input (I opted not to use vtkChartXYZ as I don’t want axes or a bounding box).

What would be the best way to display a 2D overhead view of the same pointcloud (ignoring the Z values)? I previously tried using vtkActor2D, but it seems to expect pixel coordinates from vtkPolyDataMapper2D. The best I’ve managed so far is to do a 3D view with vtkActor and disable all interaction, though that seems kind of hackish…

Your current approach is good. There is nothing hackish about it. It is a 3D data set that you want to show from a specific viewing angle. No need to disable all interactions, just disable rotation.

You can project all the points using transform polydata filter by setting a projection transform (e.g., set third column to zeros to project all points to z=0 plane). However, this is completely unnecessary and may make display worse, since you lose z ordering.

  1. DeepCopy the vrkPoints from the 3D polydata.
  2. Loop through the new points and set the z component to a fixed value e.g. 0.0
  3. Create a new polydata and display it.

@lassoan: Is there a way to simply disable the rotation? I’ve tried using the vtkInteractorStyleImage but it doesn’t let me pan around (I’m trying to zoom into the top right corner):

com-video-to-gif

You can override actions by adding observers to GUI events. You can also implement your own interactor style class, derived from any existing style.

1 Like

That does seem unnecessary, though I figured there may be some kind of 2D plot mechanism using simple actors that would use less resources than a 3D plot. I had previously tried vtkChartXY for this and the plot looked fine, though I don’t really want/need the axes and other special features of that (and would prefersomething with an API similar to using a vtkActor for 3D plotting, just in 2D).

2D plots still use 3D rendering under the hood because you still need 3D for example to manage z order of overlapping objects, be able to show widgets and handles with smooth 3D shaded surface, etc.

It still seems a bit wasteful to basically create a pair of renderers and actors that do the exact same thing, with the only difference being that one has a smaller window size and has interaction disabled. Is there something I’m missing?

I’m not sure what pair of renderers you are referring to. Normally you create a renderer for each view. Usually you cannot share mappers and actors between views, but they may share processing pipeline and data objects.

I’m talking about the renderer, actors, and mappers I’m creating for each view.

You need to duplicate renderer, actor, mapper for each view, regardless of 2D or 3D.

Given that, what would be the best way to implement multiple views of the same data that are updated in sync with the least duplication of resources?

Hi @thully, I am actually trying to do exactly what you did about disabling Pan Zoom and Tilt of a vtkActor.
can you please share how you did that?
Thanks!