Skip to content

Commit

Permalink
test invalid normals 2
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy84 committed Aug 30, 2023
1 parent 9c34bdf commit 9cb5f7b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Utilities.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
55 changes: 55 additions & 0 deletions testing/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 9cb5f7b

Please sign in to comment.