Skip to content

Commit

Permalink
a test for invalid capt points 3
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy84 committed Sep 14, 2023
1 parent e989c94 commit 5936ed6
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 9 deletions.
65 changes: 65 additions & 0 deletions testing/data/cross.vtk
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# vtk DataFile Version 5.1
vtk output
ASCII
DATASET POLYDATA
POINTS 70 double
0.5 1 0 0.43301269412 1 -0.25 0.25 1 -0.43301269412
3.0616171315e-17 1 -0.5 -0.25 1 -0.43301269412 -0.43301269412 1 -0.25
-0.5 1 -6.1232342629e-17 -0.43301269412 1 0.25 -0.25 1 0.43301269412
-9.1848507326e-17 1 0.5 0.25 1 0.43301269412 0.43301269412 1 0.25
0.43301269412 -1 0.25 0.25 -1 0.43301269412 -9.1848507326e-17 -1 0.5
-0.25 -1 0.43301269412 -0.43301269412 -1 0.25 -0.5 -1 -6.1232342629e-17
-0.43301269412 -1 -0.25 -0.25 -1 -0.43301269412 3.0616171315e-17 -1 -0.5
0.25 -1 -0.43301269412 0.43301269412 -1 -0.25 0.5 -1 0
0.43301269412 -0.43301269412 -0.25 0.5 -0.5 0 0.5 0.5 0
0.43301269412 0.43301269412 -0.25 0.25 -0.25 -0.43301269412 0.25 0.25 -0.43301269412
4.4290609559e-16 -1.1830696364e-18 -0.5 -0.25 -0.25 -0.43301269412 -0.25 0.25 -0.43301269412
-0.43301269412 -0.43301269412 -0.25 -0.43301269412 0.43301269412 -0.25 -0.5 -0.5 -5.7130552552e-17
-0.5 0.5 0 -0.43301269412 -0.43301269412 0.25 -0.43301269412 0.43301269412 0.25
-0.25 -0.25 0.43301269412 -0.25 0.25 0.43301269412 -8.5695822653e-17 1.3634875996e-16 0.5
0.25 -0.25 0.43301269412 0.25 0.25 0.43301269412 0.43301269412 -0.43301269412 0.25
0.43301269412 0.43301269412 0.25 -1 0.5 0 -1 0.43301269412 -0.25
-1 0.25 -0.43301269412 -1 2.5266076962e-16 -0.5 -1 -0.25 -0.43301269412
-1 -0.43301269412 -0.25 -1 -0.5 -6.1232342629e-17 -1 -0.43301269412 0.25
-1 -0.25 0.43301269412 -1 1.301960976e-16 0.5 -1 0.25 0.43301269412
-1 0.43301269412 0.25 1 0.43301269412 0.25 1 0.25 0.43301269412
1 -3.1389309902e-16 0.5 1 -0.25 0.43301269412 1 -0.43301269412 0.25
1 -0.5 -6.1232342629e-17 1 -0.43301269412 -0.25 1 -0.25 -0.43301269412
1 -1.9142844023e-16 -0.5 1 0.25 -0.43301269412 1 0.43301269412 -0.25
1 0.5 0
POLYGONS 53 240
OFFSETS vtktypeint64
0 12 24 28 32 36 40 44 48
52 56 60 64 68 72 76 80 84
88 92 96 100 104 108 112 116 120
132 144 148 152 156 160 164 168 172
176 180 184 188 192 196 200 204 208
212 216 220 224 228 232 236 240
CONNECTIVITY vtktypeint64
0 1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 23 22 24
25 0 26 27 1 22 21 28 24
1 27 29 2 21 20 30 28 2
29 30 3 20 19 31 30 3 30
32 4 19 18 33 31 4 32 34
5 18 17 35 33 5 34 36 6
17 16 37 35 6 36 38 7 16
15 39 37 7 38 40 8 15 14
41 39 8 40 41 9 14 13 42
41 9 41 43 10 13 12 44 42
10 43 45 11 12 23 25 44 11
45 26 0 46 47 48 49 50 51
52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69
46 36 34 47 69 68 27 26 47
34 32 48 68 67 29 27 48 32
30 49 67 66 30 29 49 30 31
50 66 65 28 30 50 31 33 51
65 64 24 28 51 33 35 52 64
63 25 24 52 35 37 53 63 62
44 25 53 37 39 54 62 61 42
44 54 39 41 55 61 60 41 42
55 41 40 56 60 59 43 41 56
40 38 57 59 58 45 43 57 38
36 46 58 69 26 45
6 changes: 4 additions & 2 deletions testing/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ def test_self_intersecting_polys():
check_result(bf)

@pytest.mark.xfail
def test_invalid_capt_pts():
def test_invalid_capt_pts(tmp_path):
cyl = vtkCylinderSource()
cyl.SetHeight(2)
cyl.SetResolution(12)
Expand All @@ -951,10 +951,11 @@ def test_invalid_capt_pts():
bf.SetOperModeToNone()
bf.Update()

# write_result(bf, tmp_path)
check_result(bf)

@pytest.mark.xfail
def test_invalid_capt_pts_2():
def test_invalid_capt_pts_2(tmp_path):
reader = vtkPolyDataReader()
reader.SetFileName('data/cross.vtk')

Expand All @@ -978,4 +979,5 @@ def test_invalid_capt_pts_2():
bf.SetOperModeToNone()
bf.Update()

# write_result(bf, tmp_path)
check_result(bf)
22 changes: 15 additions & 7 deletions vtkPolyDataBooleanFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ bool vtkPolyDataBooleanFilter::GetPolyStrips (vtkPolyData *pd, vtkIdTypeArray *c
// sucht nach gleichen captPts

{
std::map<Point3d, _IdsType> collapsed;
std::map<Point3d, std::map<vtkIdType, std::vector<std::reference_wrapper<const StripPt>>>> collapsed;

PolyStripsType::const_iterator itr;
StripPtsType::const_iterator itr2;
Expand All @@ -796,14 +796,22 @@ bool vtkPolyDataBooleanFilter::GetPolyStrips (vtkPolyData *pd, vtkIdTypeArray *c
const StripPt &sp = itr2->second;

if (sp.capt & Capt::BOUNDARY) {
auto &inds = collapsed[{sp.cutPt[0], sp.cutPt[1], sp.cutPt[2]}];
collapsed[{sp.cutPt[0], sp.cutPt[1], sp.cutPt[2]}][sp.ind].push_back(sp);
}
}
}

inds.emplace(sp.ind);
for (auto &[pt, map] : collapsed) {
if (map.size() > 1) {
// std::cout << pt << std::endl;

if (inds.size() > 1) {
return true;
}
}
// for (auto &[ind, pts] : map) {
// for (auto &p : pts) {
// std::cout << p << std::endl;
// }
// }

return true;
}
}
}
Expand Down

0 comments on commit 5936ed6

Please sign in to comment.