Skip to content

Commit

Permalink
a test for invalid capt points 4
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy84 committed Sep 17, 2023
1 parent 5936ed6 commit c345be6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 43 deletions.
8 changes: 2 additions & 6 deletions testing/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,19 +959,15 @@ def test_invalid_capt_pts_2(tmp_path):
reader = vtkPolyDataReader()
reader.SetFileName('data/cross.vtk')

cyl = vtkCylinderSource()
cyl.SetHeight(2.5)
cyl.SetResolution(12)

z = .0000025
z = .000001

tra = vtkTransform()
tra.RotateZ(45)
tra.Translate(0, 0, z)

tf = vtkTransformPolyDataFilter()
tf.SetTransform(tra)
tf.SetInputConnection(cyl.GetOutputPort())
tf.SetInputConnection(reader.GetOutputPort())

bf = vtkPolyDataBooleanFilter()
bf.SetInputConnection(0, reader.GetOutputPort())
Expand Down
89 changes: 52 additions & 37 deletions vtkPolyDataBooleanFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,58 @@ bool vtkPolyDataBooleanFilter::GetPolyStrips (vtkPolyData *pd, vtkIdTypeArray *c

}

// sucht nach gleichen captPts

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

PolyStripsType::iterator itr;
StripPtsType::iterator itr2;

for (itr = polyStrips.begin(); itr != polyStrips.end(); ++itr) {
PStrips &pStrips = itr->second;

StripPtsType &pts = pStrips.pts;

for (itr2 = pts.begin(); itr2 != pts.end(); ++itr2) {
StripPt &sp = itr2->second;

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

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

// for (auto &[ind, pts] : map) {
// for (auto &p : pts) {
// std::cout << p << std::endl;
// }
// }

// if (map.size() == 2 && std::all_of(map.begin(), map.end(), [](const auto &m) { return m.second.size() == 1 && m.second.back().get().capt == Capt::EDGE; })) {

// for (auto &[ind, pts] : map) {
// StripPt &sp = pts.back();

// sp.capt = Capt::NOT;
// sp.edge[0] = sp.edge[1] = NOTSET;
// Cpy(sp.cutPt, sp.pt, 3);
// }

// } else {
// return true;
// }

return true;

}
}
}

for (itr = polyLines.begin(); itr != polyLines.end(); ++itr) {
PStrips &pStrips = polyStrips.at(itr->first);

Expand Down Expand Up @@ -779,43 +831,6 @@ bool vtkPolyDataBooleanFilter::GetPolyStrips (vtkPolyData *pd, vtkIdTypeArray *c

}

// sucht nach gleichen captPts

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

PolyStripsType::const_iterator itr;
StripPtsType::const_iterator itr2;

for (itr = polyStrips.begin(); itr != polyStrips.end(); ++itr) {
const PStrips &pStrips = itr->second;

const StripPtsType &pts = pStrips.pts;

for (itr2 = pts.begin(); itr2 != pts.end(); ++itr2) {
const StripPt &sp = itr2->second;

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

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

// for (auto &[ind, pts] : map) {
// for (auto &p : pts) {
// std::cout << p << std::endl;
// }
// }

return true;
}
}
}

return false;

}
Expand Down

0 comments on commit c345be6

Please sign in to comment.