vtkPolyData actor behaviour is changed in VTK >= 9.1

Hi all,

In my application I show slices of vtkImageData with orthogonal view, i.e. with the camera looking at slices on the XY, XZ or YZ plane along the normal to the slice plane).
On the scene I add other 3D actors from different types of sources such as vtkCubeSource or vtkSphereSource. Before displaying I slice the vtkPolyData with 2 planes just above and below the image slice.

Trying to upgrade from VTK 8 to VTK 9 I found an issue on how VTK renders the poly data. In particular in ortho view the actor disappears completely for vtkCubeSource.

I created a minimal example.

I installed VTK on windows with mamba with the command

mamba create -n vtkxy vtk=x.y -c conda-forge

The behaviour of the mapper (I should think) has changed between version <9.1 and >=9.1. In particular in version <=9.0.3 (including 8.2) I get lots of warnings of this sort

vtkOpenGLPolyDataMapper:329 WARN| vtkOpenGLPolyDataMapper::SetGeometryShaderCode was deprecated for VTK 9.0 and will be removed in a future version. Use vtkOpenGLShaderProperty::SetGeometryShaderCode instead.

These warnings disappear in version >9.1 and were not present in 8.1.2.

With VTK version <9.1 the clipped vtkCubeSource appears clearly in the rendered image, also with orthogonal view, while it disappears in VTK >=9.1.

By slightly tilting the position of the camera from orthogonal view, the polydata actor is now visible in both versions, though it’s rendered differently. In particular VTK>=9.1 doesn’t seem to respect the very large line width that I set to the actor.

Finally, I tried with a vtkSphereSource and the rendering different but in the ortho view the polydata is still visible.

How can I view the profile of the clipped poly data in VTK >=9.1?
Are there settings to the vtkPolyDataMapper/vtkLODActor (or vtkActor) that I can set to achieve this?

Thanks

Edo

I tried to use a number of vtkProperty and I managed to produce something reasonable by adding the following:

actor.GetProperty().SetRepresentationToWireframe()
actor.GetProperty().SetRenderLinesAsTubes(True)

Notice that in VTK < 9.1 the profile was visible with the default that is: representation to surface and render lines as tubes False.

Any other insight is welcome.

Edo

Cc @sankhesh

@Edoardo_Pasca Most likely you were seeing a side-effect of the issue fixed in https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10403 where surface with edges had a padding added to the edges to compensate for thick lines.

Thanks @sankhesh

Is this in master or in any stable release yet?

Thanks

Edo

No, it’s not in any VTK release. @sankhesh, does it make sense to backport to 9.3?

It would be a surprising change to see the behavior change in a patch release.

1 Like

I asked because it seems like it has been this way since 9.1 and it was described as a “fix”. But this is not my knowledge area of VTK, so will defer.

To clarify, I think that @Edoardo_Pasca’s reported issue is a non-issue and that the behavior he was seeing before was incorrect. When you clip a thin box and view it face down in an orthogonal projection, you should not expect to see anything rendered. My original comment meant that this incorrect behavior was fixed in the referenced merge request. Increasing line width and/or rendering lines as tubes seems right for your use case.

After all this discussion, I do not quite understand when was the bug.

Since this seems to be what I observed in VTK >=9.1, I deduce that VTK >=9.1 is correct.
The bugfix described above seems to have been merged onto master and is not even in VTK<=9.3.

So now I don’t understand the relationship of the issue above with this one.

For the record, in my test increasing the line width doesn’t seem to have any effect in orthogonal view and the only way to visualise the bounding box is to render the lines as tubes.

Thanks

Edo