From 9cb5f7b0a68069832c85b2e93448ffa2fd5fb219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ronald=20R=C3=B6mer?= Date: Wed, 30 Aug 2023 19:04:30 +0200 Subject: [PATCH] test invalid normals 2 --- Utilities.cxx | 4 +++ testing/test_filter.py | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/Utilities.cxx b/Utilities.cxx index d867bd8..2284d4c 100644 --- a/Utilities.cxx +++ b/Utilities.cxx @@ -63,6 +63,10 @@ void ComputeNormal (vtkPoints *pts, double *n, vtkIdType num, const vtkIdType *p } bool CheckNormal (vtkPoints *pts, vtkIdType num, const vtkIdType *poly, const double *n, double d) { + if (n[0] == 0 && n[1] == 0 && n[2] == 0) { + return false; + } + const double *pt; vtkIdType i; diff --git a/testing/test_filter.py b/testing/test_filter.py index 6b61b03..8e0c41d 100755 --- a/testing/test_filter.py +++ b/testing/test_filter.py @@ -808,3 +808,58 @@ def test_branched_6(tmp_path): write_result(bf, tmp_path) check_result(bf, [6, 5]) + +@pytest.mark.xfail +def test_bad_shaped(): + cube = vtkCubeSource() + cube.SetBounds(-2.5, 2.5, 0, 5, 0, 5) + + z = 4.999 + + pts = [ + [2.5, -2.5, 0], + [2.5, -2.5, 5], + [0, -2.5, z], + [-2.5, -2.5, 5], + [-2.5, -2.5, 0], + + [-2.5, 2.5, 0], + [-2.5, 2.5, 5], + [0, 2.5, z], + [2.5, 2.5, 5], + [2.5, 2.5, 0], + ] + + polys = [ + [0, 1, 2, 3, 4], + [5, 6, 7, 8, 9], + [9, 8, 1, 0], + [4, 3, 6, 5], + [9, 0, 4, 5], + [1, 8, 7, 6, 3, 2] + ] + + _pts = vtkPoints() + + for pt in pts: + _pts.InsertNextPoint(*pt) + + pd = vtkPolyData() + pd.Allocate(1) + pd.SetPoints(_pts) + + for poly in polys: + cell = vtkIdList() + [ cell.InsertNextId(i) for i in poly ] + pd.InsertNextCell(VTK_POLYGON, cell) + + prod = vtkTrivialProducer() + prod.SetOutput(pd) + + bf = vtkPolyDataBooleanFilter() + bf.SetInputConnection(0, cube.GetOutputPort()) + bf.SetInputConnection(1, prod.GetOutputPort()) + bf.SetOperModeToNone() + bf.Update() + + check_result(bf)