Commit 107660c7 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #12433 from alalek:fix_contrib_1746

parents 8a328e39 e7052662
...@@ -758,24 +758,30 @@ void Subdiv2D::getTriangleList(std::vector<Vec6f>& triangleList) const ...@@ -758,24 +758,30 @@ void Subdiv2D::getTriangleList(std::vector<Vec6f>& triangleList) const
triangleList.clear(); triangleList.clear();
int i, total = (int)(qedges.size()*4); int i, total = (int)(qedges.size()*4);
std::vector<bool> edgemask(total, false); std::vector<bool> edgemask(total, false);
Rect2f rect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); const bool filterPoints = true;
Rect2f rect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
for( i = 4; i < total; i += 2 ) for( i = 4; i < total; i += 2 )
{ {
if( edgemask[i] ) if( edgemask[i] )
continue; continue;
Point2f a, b, c; Point2f a, b, c;
int edge = i; int edge_a = i;
edgeOrg(edge, &a); edgeOrg(edge_a, &a);
edgemask[edge] = true; if (filterPoints && !rect.contains(a))
edge = getEdge(edge, NEXT_AROUND_LEFT); continue;
edgeOrg(edge, &b); int edge_b = getEdge(edge_a, NEXT_AROUND_LEFT);
edgemask[edge] = true; edgeOrg(edge_b, &b);
edge = getEdge(edge, NEXT_AROUND_LEFT); if (filterPoints && !rect.contains(b))
edgeOrg(edge, &c); continue;
edgemask[edge] = true; int edge_c = getEdge(edge_b, NEXT_AROUND_LEFT);
if( rect.contains(a) && rect.contains(b) && rect.contains(c) ) edgeOrg(edge_c, &c);
triangleList.push_back(Vec6f(a.x, a.y, b.x, b.y, c.x, c.y)); if (filterPoints && !rect.contains(c))
continue;
edgemask[edge_a] = true;
edgemask[edge_b] = true;
edgemask[edge_c] = true;
triangleList.push_back(Vec6f(a.x, a.y, b.x, b.y, c.x, c.y));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment