[vtkusers] Display Error under Ubuntu 16.04
Andrea Borsic
aborsic at ne-scientific.com
Wed Nov 16 10:38:25 EST 2016
Hi All,
Apologies for the long hiatus, but I would like to understand why the
crash I and Elvis are experiencing is occurring. I am half convinced it
could be a bug in the numpy support functions, and wanted to share my
knowledge so far in order to hear any possible feedback.
I am attaching a new Python script, which is simpler and self contained
now. The script builds a vtkUnstructuredGrid with a single tetrahedra
and displays it. The script does not crash under Windows, but crashes
under Ubuntu 16.04 / VTK 7.1RC2 / OpenGL2
The dataset has only 4 points and the only cell of the dataset (a
tetrahedra) is described by the list of nodes [0,1,2,3] to which is
pre-pended a "4" to indicate that 4 points describe the cell, the cell
data is therefore [4,0,1,2,3]. The cell data is automatically converted
from numpy to vtk using the vtk numpy support functions.
Printing the VTK converted cell_data (line 47) shows the output attached
below:
In the output the MaxId is 4, but the number of tuples is 1, shouldn't
the MaxId therefore be 0 (the shape of the array is (1,5) )? Can this be
the source of the problem ?
Similarly if a (2x5) numpy array is converted to vtk with
vtk_np.numpy_to_vtkIdTypeArray, the resulting array has a MaxId of 9,
which in my opininion should be 1. I will dig some more into the
vtk_np.numpy_to_vtkIdTypeArray function ...
Thanks for any comment,
Best Regards,
Andrea
Printing cell data
vtkIdTypeArray (000002C3420E7BE0)
Debug: Off
Modified Time: 54
Reference Count: 1
Registered Events: (none)
Name: (none)
Data type: idtype
Size: 5
MaxId: 4
NumberOfComponents: 5
Information: 0000000000000000
Name: (none)
Number Of Components: 5
Number Of Tuples: 1
Size: 5
MaxId: 4
LookupTable: (none)
Array: 000002C342B0EA50
On 10/28/2016 4:39 PM, Andrea Borsic wrote:
> Hi Elvis,
>
> Thanks for testing this. Actually I started out on Ubuntu with your
> Jumbo VTK package, and is it was throwing this error, I switched to
> compiling from source - with the same result.
>
> Cheers,
>
> Andrea
>
>
>
>> I tested your example with the 7.1.0.rc1 build we use at work (also
>> Ubuntu 16.04), and I also get an X error, though a slightly different
>> one:
>>
>> X Error of failed request: BadMatch (invalid parameter attributes)
>> Major opcode of failed request: 154 (GLX)
>> Minor opcode of failed request: 11 (X_GLXSwapBuffers)
>> Serial number of failed request: 2141
>> Current serial number in output stream: 2143
>>
>> I can confirm that commenting the interactor initialization/start, it
>> terminates OK.
>>
>> Haven't looked closer at what's happening, but just thought I should
>> share.
>>
>> For brevity, these are the flags we use when configuring our build:
>>
>> -DCMAKE_INSTALL_PREFIX=/opt/VTK7 \
>> -DVTK_Group_Qt=ON \
>> -DVTK_QT_VERSION=5 \
>> -DVTK_Group_Imaging=ON \
>> -DVTK_Group_Views=ON \
>> -DModule_vtkRenderingFreeTypeFontConfig=ON \
>> -DVTK_WRAP_PYTHON=ON \
>> -DVTK_PYTHON_VERSION=3 \
>> -DPYTHON_EXECUTABLE=/usr/bin/python3 \
>> -DPYTHON_INCLUDE_DIR=/usr/include/python3.5 \
>> -DPYTHON_LIBRARY=/usr/lib/$(DEB_HOST_MULTIARCH)/libpython3.5m.so \
>> -DBUILD_TESTING=OFF \
>> -DVTK_USE_SYSTEM_LIBRARIES=ON \
>> -DVTK_USE_SYSTEM_LIBPROJ4=OFF \
>> -DVTK_USE_SYSTEM_GL2PS=OFF \
>> -DCMAKE_BUILD_TYPE=Release
>>
>> Elvis
>>
>>> Best Regards,
>>>
>>> Andrea
>>>
>>>
>>>
>>> On 27/10/2016 23:25, Ken Martin wrote:
>>>
>>> Hmm, well that means VTK's rendering engine is initializing OK and
>>> running.
>>> So it could be something specific to the python app. If you run some
>>> of the
>>> python tests do they work? ala
>>>
>>> ctest -R Python -I ,,23
>>>
>>> thats runs 1/23rd of the python tests
>>>
>>> if those all pass then it must be something specific to your script
>>>
>>>
>>>
>>> On Thu, Oct 27, 2016 at 5:16 PM, Andrea Borsic
>>> <aborsic at ne-scientific.com>
>>> wrote:
>>>> Hi Ken,
>>>>
>>>> The test seems to run fine, I am attaching below the output.
>>>>
>>>> Best Regards,
>>>>
>>>> Andrea
>>>>
>>>>
>>>> -----------------------
>>>>
>>>> andrea at i7-Desktop:/opt/VTK-7.1.0.rc1-bin$ sudo ctest -R VBOPLY -VV
>>>> UpdateCTestConfiguration from
>>>> :/opt/VTK-7.1.0.rc1-bin/DartConfiguration.tcl
>>>> Parse Config file:/opt/VTK-7.1.0.rc1-bin/DartConfiguration.tcl
>>>> Add coverage exclude regular expressions.
>>>> Add coverage exclude: vtk.*TCLInit.cxx
>>>> Add coverage exclude: vtk[^\.]+(Java|Python|Tcl).cxx
>>>> Add coverage exclude: .*vtkOpenGLState.*
>>>> Add coverage exclude: .*Testing.Cxx.*cxx
>>>> Add coverage exclude: .*Testing.Cxx.*h
>>>> Add coverage exclude: .*moc_.*cxx
>>>> Add coverage exclude: .*/Rendering/OpenGL/vtkgl.*
>>>> Add coverage exclude: .*/Utilities/.*
>>>> Add coverage exclude: .*/ThirdParty/.*
>>>> Add coverage exclude: .*vtkOpenGLPolyDataMapper.*
>>>> SetCTestConfiguration:CMakeCommand:/usr/bin/cmake
>>>> UpdateCTestConfiguration from
>>>> :/opt/VTK-7.1.0.rc1-bin/DartConfiguration.tcl
>>>> Parse Config file:/opt/VTK-7.1.0.rc1-bin/DartConfiguration.tcl
>>>> Test project /opt/VTK-7.1.0.rc1-bin
>>>> Constructing a list of tests
>>>> Done constructing a list of tests
>>>> Checking test dependency graph...
>>>> Checking test dependency graph end
>>>> test 1551
>>>> Start 1551: vtkRenderingOpenGL2Cxx-TestVBOPLYMapper
>>>>
>>>> 1551: Test command:
>>>> /opt/VTK-7.1.0.rc1-bin/bin/vtkRenderingOpenGL2CxxTests
>>>> "TestVBOPLYMapper" "-D"
>>>> "/opt/VTK-7.1.0.rc1-bin/ExternalData//Testing" "-T"
>>>> "/opt/VTK-7.1.0.rc1-bin/Testing/Temporary" "-V"
>>>> "/opt/VTK-7.1.0.rc1-bin/ExternalData/Rendering/OpenGL2/Testing/Data/Baseline/TestVBOPLYMapper.png"
>>>>
>>>> 1551: Test timeout computed to be: 3600
>>>> 1551: first render time: 0.132993
>>>> 1551: opengl version 4.5
>>>> 1551: interactive render time: 0.0166377
>>>> 1551: number of triangles: 871414
>>>> 1551: triangles per second: 5.2376e+07
>>>> 1551: <DartMeasurement name="ImageError"
>>>> type="numeric/double">0</DartMeasurement><DartMeasurement
>>>> name="BaselineImage"
>>>> type="text/string">Standard</DartMeasurement><DartMeasurement
>>>> name="WallTime" type="numeric/double">0.059715</DartMeasurement>
>>>> 1551: <DartMeasurement name="CPUTime"
>>>> type="numeric/double">0.037073</DartMeasurement>
>>>> 1/1 Test #1551: vtkRenderingOpenGL2Cxx-TestVBOPLYMapper ... Passed
>>>> 0.91 sec
>>>>
>>>> The following tests passed:
>>>> vtkRenderingOpenGL2Cxx-TestVBOPLYMapper
>>>>
>>>> 100% tests passed, 0 tests failed out of 1
>>>>
>>>> Label Time Summary:
>>>> vtkRenderingOpenGL2 = 0.91 sec (1 test)
>>>>
>>>> Total Test time (real) = 0.97 sec
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On 27/10/2016 18:56, Ken Martin wrote:
>>>>
>>>> Can you try running ctest -R VBOPLY -VV and let us know the output?
>>>>
>>>> On Thu, Oct 27, 2016 at 12:46 PM, Andrea Borsic
>>>> <aborsic at ne-scientific.com> wrote:
>>>>> Dear All,
>>>>>
>>>>> I have successfully compiled VTK 7.0.0 under Ubuntu 16.04.1 LTS on a
>>>>> computer with the following hw configuration:
>>>>>
>>>>> Processor: Intel Core i7
>>>>>
>>>>> GPU: NVIDIA GTX Titan Black
>>>>>
>>>>> ---
>>>>>
>>>>> VTK has been configured for:
>>>>>
>>>>> OpenGL 2 back-end
>>>>>
>>>>> Use Qt 5.7
>>>>>
>>>>> Use OpenMP for SMP
>>>>>
>>>>> Wrap Python 3 (ver 3.5.2 on the system)
>>>>>
>>>>> ---
>>>>>
>>>>> A simple python script which displays an unstructured grid and which
>>>>> works fine under Windows, opens (under Ubuntu) a rendering window and
>>>>> crashes with the message below:
>>>>>
>>>>> X Error of failed request: GLXBadDrawable
>>>>> Major opcode of failed request: 154 (GLX)
>>>>> Minor opcode of failed request: 11 (X_GLXSwapBuffers)
>>>>> Serial number of failed request: 111
>>>>> Current serial number in output stream: 111
>>>>>
>>>>>
>>>>> Do you have any hint about this? Should I try the RC 7.1 or switch
>>>>> to the
>>>>> plain OpenGL back-end ?
>>>>>
>>>>> Thanks in advance for any suggestion,
>>>>>
>>>>> Best Regards,
>>>>>
>>>>> Andrea
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>
>>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>>
>>>>
>>>>
>>>> --
>>>> Ken Martin PhD
>>>> Chairman & CFO
>>>> Kitware Inc.
>>>> 28 Corporate Drive
>>>> Clifton Park NY 12065
>>>> 518 371 3971
>>>>
>>>> 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.
>>>>
>>>>
>>>
>>>
>>> --
>>> Ken Martin PhD
>>> Chairman & CFO
>>> Kitware Inc.
>>> 28 Corporate Drive
>>> Clifton Park NY 12065
>>> 518 371 3971
>>>
>>> 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.
>>>
>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
-------------- next part --------------
import pickle
import numpy as np
import time
import vtk
from vtk.util import numpy_support as vtk_np
# manually generate a single tetrahedra using numpy and then convert it to a vtkUstructuredMesh
nodes = np.zeros((4,3),dtype=np.float32)
nodes[0,:] = (0,0,0)
nodes[1,:] = (0,0,1)
nodes[2,:] = (0,1,0)
nodes[3,:] = (1,0,0)
elems = np.zeros((2,4),dtype=np.int32)
elems[0,:] = (0,1,2,3)
scalars = np.zeros((4),dtype=np.float32)
scalars[0] = 10
scalars[1] = 20
scalars[2] = 30
scalars[3] = 40
# embed now the nodes (coordinates of nodes of a FEM mesh) and elements (indices to nodes defining the tetrahedra of a FEM mesh) into a vtkUnstructuredGrid
# copy nodes to dataset (unstructured grid)
num_nodes = nodes.shape[0]
pts = vtk.vtkPoints()
pts_data = vtk_np.numpy_to_vtk(nodes, deep=True)
pts.SetData(pts_data)
# copy tetrahedral elements to cell data
# for the cell array data we need to prepend a column of "4" indicating that each cell has 4 nodes
num_elems = elems.shape[0]
num_ids = np.ones((num_elems,1), dtype=np.int64)*4
cells_data = np.concatenate((num_ids, elems), axis=1)
cells_data = vtk_np.numpy_to_vtkIdTypeArray(cells_data, deep=True)
print("Printing cell data")
print(cells_data)
cells = vtk.vtkCellArray()
cells.SetCells(num_elems, cells_data)
# create the vtkUnstructuredGrid
dataset = vtk.vtkUnstructuredGrid()
dataset.SetPoints(pts)
dataset.SetCells(vtk.VTK_TETRA, cells)
# prepare now the scalars
# generate vtk scalars from input data and associate it with the unstructured grid
vtkscalars = vtk_np.numpy_to_vtk(scalars, deep=True)
dataset.GetPointData().SetScalars(vtkscalars)
# display now the dataset
# use a mapper
mapper = vtk.vtkDataSetMapper()
mapper.SetInputData(dataset)
# create a default color lookup table
vtkLut = vtk.vtkLookupTable()
vtkLut.SetTableRange (0, 1)
vtkLut.SetHueRange (0.66, 0)
vtkLut.SetSaturationRange (1, 1)
vtkLut.SetValueRange (1, 1)
vtkLut.Build()
mapper.SetLookupTable(vtkLut)
mapper.SetScalarRange(np.min(scalars), np.max(scalars))
# actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetRepresentationToSurface()
# generate a colorbar
scalarBar = vtk.vtkScalarBarActor()
scalarBar.SetOrientationToVertical()
scalarBar.SetTitle("Potential")
# position the colorbar in the window
pos = scalarBar.GetPositionCoordinate()
pos.SetCoordinateSystemToNormalizedViewport()
pos.SetValue(0.85,0.05)
scalarBar.SetWidth(.1)
scalarBar.SetHeight(.95)
# set lookup table
scalarBar.SetLookupTable(vtkLut)
# renderer
ren = vtk.vtkRenderer()
ren.AddActor(actor)
ren.AddActor(scalarBar)
# render window
renWin = vtk.vtkRenderWindow() # save ref, so that we can start an interactor at a later time
renWin.AddRenderer(ren)
renWin.SetSize(600,600)
renWin.SetPosition(600,250)
renWin.Render()
# setup the interactor
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renWin)
istyle = vtk.vtkInteractorStyleSwitch()
istyle.SetCurrentStyleToTrackballCamera()
interactor.SetInteractorStyle(istyle)
# DISPLAY THE DATASET FOR 5sec BEFORE STARTING THE INTERACTOR (WHICH WILL CRASH THE SCRIPT)
time.sleep(5)
####################### NOTE ###############################
# IF BOTH NEXT LINES ARE COMMENTED THE SCRIPT WILL NOT CRASH
interactor.Initialize()
interactor.Start()
print("Terminated OK")
More information about the vtkusers
mailing list