Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • VTK VTK
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 830
    • Issues 830
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 234
    • Merge requests 234
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • VTKVTK
  • VTKVTK
  • Issues
  • #17910
Closed
Open
Issue created May 26, 2020 by Lina Muryanto@muryanto1

[vtk 9.0.0.rc3][Python]GetMultiSamples() returns different value after doing Render()

Running vtk-example.py (see script below) shows that in an environment with vtk 9.0.0.rc3 with mesalib, calling GetMultiSamples() after calling Render() returns 0, which is different from what GetMultiSamples() returns before Render(). Platform: MacOS - 10.14.6

Running the following script in a conda environment with vtk 9.0.0.rc3 and mesalib shows that 2nd call to GetMultiSamples() return 0.

Run: python vtk-example.py [mesalib|no_mesalib]

import random
import vtk

print(vtk.VTK_VERSION)

mesa_or_no_mesa = sys.argv[2]
print(mesa_or_no_mesa)

r = random.Random(1234)

poly = vtk.vtkPolyData()
pts = vtk.vtkPoints()

w, h = 640, 480
step = 10
for x, y in zip(range(0, w+step, step), [r.randint(0, h) for _ in range(0, w+step, step)]):
    pts.InsertNextPoint((x, y, 0.0))

poly.SetPoints(pts)

lines = vtk.vtkCellArray()

for x in range(0, int((w+step)/step)-1):
    line = vtk.vtkLine()
    line.GetPointIds().SetId(0, x)
    line.GetPointIds().SetId(1, x+1)

    lines.InsertNextCell(line)

poly.SetLines(lines)

colors = vtk.vtkNamedColors()

mapper = vtk.vtkPolyDataMapper2D()
mapper.SetInputData(poly)

actor = vtk.vtkActor2D()
actor.SetMapper(mapper)
actor.GetProperty().SetLineWidth(1)
actor.GetProperty().SetColor(colors.GetColor3d('black'))

renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(colors.GetColor3d('white'))

win = vtk.vtkRenderWindow()
win.SetMultiSamples(int(sys.argv[1]))
win.SetSize(w, h)
win.AddRenderer(renderer)

print(win.GetClassName())

interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(win)

print('Before Render', win.GetMultiSamples())
print("Doing..Render()")
win.Render()
print("\n".join(re.findall("^OpenGL.*$", win.ReportCapabilities(), re.MULTILINE)))

interactor.Start()

print('After Render', win.GetMultiSamples())

filter = vtk.vtkWindowToImageFilter()
filter.SetInput(win)
 
writer = vtk.vtkPNGWriter()
#writer.SetFileName(f'vtk-{vtk.VTK_VERSION}.png')
writer.SetFileName(f'vtk-{vtk.VTK_VERSION}.{sys.argv[2]}.png')
writer.SetInputConnection(filter.GetOutputPort())
writer.Write()

NOTE: for some reason with vtk 8.2.0, the png written out is a blank black screen

Results of running vtk-example.py:

[1] With vtk 9.0.0.rc3 - no mesalib

conda create -n vtk_9.0.0 -c conda-forge/label/vtk_dev -c conda-forge vtk=9.0.0.rc3 "python>=3.7,<3.8"
conda list | grep -E "^(vtk|mesalib)"
vtk                       9.0.0.rc3       no_osmesa_py37h3fd7587_100    conda-forge/label/vtk_dev

Running 'python vtk-example.py 8' returns:
vtkCocoaRenderWindow
Before Render 8
Doing..Render()
OpenGL vendor string:  ATI Technologies Inc.
OpenGL renderer string:  AMD Radeon Pro 560 OpenGL Engine
OpenGL version string:  4.1 ATI-2.11.21
OpenGL extensions:  
After Render 8

vtk-9.0.0.no_mesalib

[2] With vtk 9.0.0.rc3 and mesalib

conda create -n vtk_9.0.0_mesalib -c conda-forge/label/vtk_dev -c conda-forge vtk=9.0.0.rc3 mesalib=17.3.9 "python>=3.7,<3.8"
conda list | grep -E "^(vtk|mesalib)"
mesalib                   17.3.9               hdd5ec5b_0    conda-forge
vtk                       9.0.0.rc3       with_osmesa_py37hb208ac8_0  [mesalib]  conda-forge/label/vtk_dev

Running 'python vtk-example.py 8' returns:
vtkOSOpenGLRenderWindow
Before Render 8
Doing..Render()
Segmentation fault: 11

If I comment out the ReportCapabilities() call, then it returns:
After Render 0

vtk-9.0.0.mesalib

[3] With vtk 8.2.0 - no mesalib

conda create -n vtk_8.2.0 -c conda-forge vtk=8.2.0 "python>=3.7,<3.8"
conda list | grep -E "^(vtk|mesalib)"
vtk                       8.2.0           py37hd5eadda_217    conda-forge
Running 'python vtk-example.py 8' returns:
vtkCocoaRenderWindow
Before Render 8
Doing..Render()
OpenGL vendor string:  ATI Technologies Inc.
OpenGL renderer string:  AMD Radeon Pro 560 OpenGL Engine
OpenGL version string:  4.1 ATI-2.11.21
OpenGL extensions:  
After Render 8

vtk-8.2.0.no_mesalib.screenshot

[4] With vtk 8.2.0 and mesalib

conda create -n vtk_8.2.0_mesalib -c conda-forge vtk=8.2.0 mesalib=17.3.9 "python>=3.7,<3.8"
conda list | grep -E "^(vtk|mesalib)"
mesalib                   17.3.9               hdd5ec5b_0    conda-forge
vtk                       8.2.0           py37hd5eadda_217    conda-forge
Running 'python vtk-example.py 8' returns:
vtkCocoaRenderWindow
Before Render 8
Doing..Render()
OpenGL vendor string:  ATI Technologies Inc.
OpenGL renderer string:  AMD Radeon Pro 560 OpenGL Engine
OpenGL version string:  4.1 ATI-2.11.21
OpenGL extensions:  
After Render 8

vtk-8.2.0.mesalib.screenshot

You can see the images generated with [1] matches [3] and [4], but not [2]. The lines in [1], [3] and [4] are smoother than [2]. (In other words, the lines in [2] are more jagged than in [1], [3] and [4])

Edited May 27, 2020 by Lina Muryanto
Assignee
Assign to
Time tracking