InsightSoftwareConsortium / InsightSoftwareConsortium/itkwidgets

PlotterITK in Jupyter notebook fails to show plot after adding cell arrays and running various filters

Open
#431 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
624
Forks
83
PR merge metrics
No merged PRs in 30d

Description

So I raised a bug issue with Pyvista's PlotterITK() and was told to forward it here. The link to the issue thread is provided bellow, but I'll provide a copy of the description of the issue here too.
https://github.com/pyvista/pyvista/issues/1624

**Bug Description**

After adding various cell arrays to a PolyData mesh, and then running various filters, PlotterITK in a jupyter notebook environment fails to display the plot. There is no crash report, but the plotting window simply does not show.

Reducing the number of cell arrays in the code bellow seems to prevent the bug, and so does removing at least one of the *add_mesh()* calls.

After running the code once in a new jupyter notebook seems to work fine, but running the same cell again will produce the bug. After running the same code in the same cell at least 7 times, PlotterITK() will fail to display anything in any other cell.

-----

**To Reproduce**

Running the following code at least **twice** in the same jupyter cell will recreate the bug.

```py
import pyvista as pv
import numpy as np

sphere = pv.Sphere()

#Add a bunch of cell arrays to the sphere
numberOfCellArrays = 5
for i in range(numberOfCellArrays):
sphere['randomArray'+str(i)] = np.random.random(sphere.cell_normals.shape[0])

#Run the particular filters that are causing the issue
randomIndex = np.random.random(sphere.faces.shape[0]) > 0.5
randomCells = sphere.extract_cells(np.argwhere(randomIndex))
randomEdges = randomCells.extract_feature_edges(non_manifold_edges=False, feature_edges=False, manifold_edges=False)
randomCellsSubdivided = pv.PolyData(randomCells.points, randomCells.cells).subdivide(3)

#Attempt to plot results
plotter = pv.PlotterITK()
plotter.add_mesh(sphere)
plotter.add_mesh(randomCells, color='b')
plotter.add_mesh(randomEdges, color='r')
plotter.add_mesh(randomCellsSubdivided.points, color='cyan')
plotter.show()
```

After running the above code at least 7 times in a jupyter notebook cell, the following PlotterITK() window will also fail to show.

```py
plotter = pv.PlotterITK()
plotter.add_mesh(pv.Plane())
plotter.show()
```

-----

**System Information:**

I am running pyvista in the following docker container:

``` txt
docker pull suoarski/earthinit
```

```txt
--------------------------------------------------------------------------------
Date: Wed Sep 01 04:17:45 2021 UTC

OS : Linux
CPU(s) : 12
Machine : x86_64
Architecture : 64bit
Environment : Jupyter
GPU Vendor : VMware, Inc.
GPU Renderer : llvmpipe (LLVM 10.0.0, 256 bits)
GPU Version : 3.3 (Core Profile) Mesa 20.0.8

Python 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]

pyvista : 0.31.3
vtk : 8.1.2
numpy : 1.19.5
imageio : 2.9.0
appdirs : 1.4.4
scooby : 0.5.7
meshio : 4.4.3
matplotlib : 3.3.4
IPython : 7.16.1
colorcet : 1.0.0
ipyvtklink : 0.2.1
scipy : 1.5.4
itkwidgets : 0.32.0
tqdm : 4.60.0
--------------------------------------------------------------------------------
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.