Repository: pyvista/pyvista

Issue #2124: Crash when `compute_normals`
Created: 2022-02-02T15:38:37Z
Describe the bug, what's wrong, and what you expect:
When calculating normals, the interpreter silently crashes.. No error's or output, not even with the VTKErrorCatcher. can anyone please enlighten me what happens in this minimal example?

To Reproduce
Please include a code snippet to reproduce the bug in the block below:
import pyvista
import numpy as np

xyz = np.random.random(102*3).reshape(-1,3)
faces = np.arange(102*3)
np.random.shuffle(faces)
faces = faces.reshape(-1,3)
faces = np.column_stack((np.ones(len(faces),) * 3, faces)).astype(int)

mesh = pyvista.PolyData()
mesh.points = xyz
mesh.faces = faces
print(mesh.compute_normals(inplace=False))

System Information:
Please run the following code wherever you are experiencing the bug and paste the output below. This report helps us track down bugs and it is critical to addressing your bug:
# Get system info
import pyvista as pv
print(pv.Report())
--------------------------------------------------------------------------------
  Date: Wed Feb 02 16:36:41 2022 W. Europe Standard Time

                OS : Windows
            CPU(s) : 8
           Machine : AMD64
      Architecture : 64bit
               RAM : 31.9 GiB
       Environment : Python
       File system : unknown
        GPU Vendor : NVIDIA Corporation
      GPU Renderer : Quadro M1000M/PCIe/SSE2
       GPU Version : 4.5.0 NVIDIA 441.66

  Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit
  (AMD64)]

           pyvista : 0.33.2
               vtk : 9.1.0
             numpy : 1.22.1
           imageio : 2.14.1
           appdirs : 1.4.4
            scooby : 0.5.11
        matplotlib : 3.5.1
         pyvistaqt : 0.7.0
             PyQt5 : 5.15.6
             scipy : 1.7.3
--------------------------------------------------------------------------------

Duplicate issue #4735: Plotting `PolyData` with invalid faces/cells causes a crash
Created: 2023-08-03T17:54:33Z
Describe the bug, what's wrong, and what you expected.
Plotting PolyData with invalid faces/cells causes a crash. See code below.
Not sure if it would be a good idea to do a check for invalid cells when calling plot() and raise a ValueError as needed, similar to how pyvista.PolyData(None).plot() raises:
ValueError: Empty meshes cannot be plotted. Input mesh has zero points.

Steps to reproduce the bug.
import faulthandler 
faulthandler.enable()

 import pyvista
mesh = pyvista.PolyData([0.,0.,0.], faces=[1]) 
mesh.plot() 

faulthandler.dump_traceback()
This will output:
Windows fatal exception: access violation

Current thread 0x00005110 (most recent call first):
  File "pyvista\pyvista\plotting\renderer.py", line 427 in bounds
  File "pyvista\pyvista\plotting\renderer.py", line 459 in center
  File "pyvista\pyvista\plotting\renderer.py", line 2446 in get_default_cam_pos
  File "pyvista\pyvista\plotting\plotter.py", line 1476 in get_default_cam_pos
  File "pyvista\pyvista\_plot.py", line 278 in plot
  File "test.py", line 5 in <module>

Here's a link to line 427 in renderer.py where the crash happens.
System Information
OS : Windows
            CPU(s) : 12
           Machine : AMD64
      Architecture : 64bit
               RAM : 31.8 GiB
       Environment : IPython
        GPU Vendor : Intel
      GPU Renderer : Intel(R) UHD Graphics 630
       GPU Version : 4.5.0 - Build 30.0.100.9864
  MathText Support : False
  Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64
  bit (AMD64)]
           pyvista : 0.42.dev0
               vtk : 9.2.20230323
             numpy : 1.24.2
        matplotlib : 3.7.1
            scooby : 0.7.1
             pooch : v1.7.0
           imageio : 2.26.1
           IPython : 8.12.0
        ipywidgets : 8.0.6
             scipy : 1.10.1
              tqdm : 4.65.0
            meshio : 5.3.4
      nest_asyncio : 1.5.6
Screenshots
No response

Closing comment (2025-01-02T20:29:22Z): This seems related to #2124 as well.