Skip to content

Commit

Permalink
Merge pull request #1172 from jkunimune/patch-1
Browse files Browse the repository at this point in the history
raise an error when calling cell_normals before compute_normals()
  • Loading branch information
marcomusy authored Aug 16, 2024
2 parents b53ce12 + 76c0413 commit dba7ead
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vedo/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ def cell_normals(self):
Check out also `compute_normals(cells=True)` and `compute_normals_with_pca()`.
"""
vtknormals = self.dataset.GetCellData().GetNormals()
return vtk2numpy(vtknormals)
numpy_normals = vtk2numpy(vtknormals)
if len(numpy_normals) == 0 and len(self.cells) != 0:
raise ValueError("VTK failed to return any normal vectors. You may need to call `Mesh.compute_normals()` before accessing `Mesh.cell_normals`.")
return numpy_normals

def compute_normals(self, points=True, cells=True, feature_angle=None, consistency=True) -> Self:
"""
Expand Down

0 comments on commit dba7ead

Please sign in to comment.