[vtkusers] Cannot disable vtkPolyDataMapper2D scalar visibility using VTK OpenGL2 backend

Andras Lasso lasso at queensu.ca
Tue Jul 10 00:10:11 EDT 2018


Thanks a lot Ken for the quick response. The change that you described below fixed the issue!

Andras

From: Ken Martin <ken.martin at kitware.com>
Sent: Monday, July 9, 2018 3:53 PM
To: Andras Lasso <lasso at queensu.ca>
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Cannot disable vtkPolyDataMapper2D scalar visibility using VTK OpenGL2 backend

Sounds like a bug. Andras if you move line 568 from vtkOpenGLPolyDataMapper2D.cxx out of the if statement to line 563 does that solve the problem? Looking at the code I believe that is the correct fix.

e.g. it should look like this

  this->MapScalars(act->GetProperty()->GetOpacity());
  this->HaveCellScalars = false;
  if (this->ScalarVisibility)
  {
    // We must figure out how the scalars should be mapped to the polydata.
    if ( (this->ScalarMode == VTK_SCALAR_MODE_USE_CELL_DATA ||
          this->ScalarMode == VTK_SCALAR_MODE_USE_CELL_FIELD_DATA ||



On Mon, Jul 9, 2018 at 12:33 PM, Andras Lasso <lasso at queensu.ca<mailto:lasso at queensu.ca>> wrote:
Hi all,

I try to render a polydata with a plain solid color using a 2D actor. However, it seems that with OpenGL2 rendering backend, if a polydata has scalars and rendered once with scalar visibility enabled, ScalarVisibility cannot be disabled anymore. The actor will always appear as colored. In some cases, the colors randomly flicker. See a very simple code snippet below to reproduce it.

The same code works well (scalar visibility can be enabled/disabled) using VTK OpenGL1 backend. If I use 3D mapper and actor (vtkPolyDataMapper and vtk.vtkActor) then it works well using both VTK OpenGL1 and OpenGL2 backends.

Is this a known issue? Could somebody have a look?

Thank you,
Andras


reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName("scalartest.vtp")
mapper = vtk.vtkPolyDataMapper2D()
mapper.SetInputConnection(reader.GetOutputPort())
actor = vtk.vtkActor2D()
actor.SetMapper(mapper)
actor.SetPosition(150,150)
ren = vtk.vtkRenderer()
ren.AddActor(actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.Render()
# actor appears in color here => OK
mapper.SetScalarVisibility(False)
renWin.Render()
# actor appears in color here => ERROR (it should be white)


Download link for scalartest.vtp sample data set (any other polydata with scalars should work):
https://1drv.ms/u/s!Arm_AFxB9yqHtK1gHCIsGt0U62OTQg<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2F1drv.ms%2Fu%2Fs!Arm_AFxB9yqHtK1gHCIsGt0U62OTQg&data=02%7C01%7Classo%40queensu.ca%7Ce06fabd733c540fd9c4a08d5e5d59008%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636667627766232634&sdata=qosMAzacqE779GLw69Pogi1Rayk%2B%2F%2FTX5tJ2SGm8VWs%3D&reserved=0>


_______________________________________________
Powered by www.kitware.com<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com&data=02%7C01%7Classo%40queensu.ca%7Ce06fabd733c540fd9c4a08d5e5d59008%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636667627766232634&sdata=Q5elxCkAVlQA861ll43jK29n1Shhq616iKUHSv%2FaB88%3D&reserved=0>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=02%7C01%7Classo%40queensu.ca%7Ce06fabd733c540fd9c4a08d5e5d59008%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636667627766232634&sdata=9u1SGTHnY%2FTwxPLLYkNbGKgSUxLPoT1kLETaE5iYpWA%3D&reserved=0>

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.vtk.org%2FWiki%2FVTK_FAQ&data=02%7C01%7Classo%40queensu.ca%7Ce06fabd733c540fd9c4a08d5e5d59008%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636667627766232634&sdata=tk3W1q3O64ZNy8BaH%2FHmFJkT9pKBqnaH24TkNNG92D4%3D&reserved=0>

Search the list archives at: http://markmail.org/search/?q=vtkusers<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3Dvtkusers&data=02%7C01%7Classo%40queensu.ca%7Ce06fabd733c540fd9c4a08d5e5d59008%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636667627766232634&sdata=G%2FLjb5W%2Fa7LAb5RSS6oqjTHklNT0wpPi6b2Tb21I9Z4%3D&reserved=0>

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Fvtkusers&data=02%7C01%7Classo%40queensu.ca%7Ce06fabd733c540fd9c4a08d5e5d59008%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636667627766232634&sdata=urx%2BU7azPuK2Sg9bBJN%2BWb6dVxafyGrYRvHEAQST4%2Bw%3D&reserved=0>



--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
101 East Weaver Street
Carrboro, North Carolina
27510 USA
This communication, including all attachments, contains confidential and legally privileged information, and it is intended only for the use of the addressee.  Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. If you received this communication in error please notify us immediately and destroy the original message.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180710/46d9d21b/attachment.html>


More information about the vtkusers mailing list