imgproc: fix Subdiv2D::getTriangleList()

pull/12433/head
Alexander Alekhin 6 years ago
parent 9fae8070dc
commit e70526625f
  1. 28
      modules/imgproc/src/subdivision2d.cpp

@ -758,23 +758,29 @@ void Subdiv2D::getTriangleList(std::vector<Vec6f>& triangleList) const
triangleList.clear();
int i, total = (int)(qedges.size()*4);
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 )
{
if( edgemask[i] )
continue;
Point2f a, b, c;
int edge = i;
edgeOrg(edge, &a);
edgemask[edge] = true;
edge = getEdge(edge, NEXT_AROUND_LEFT);
edgeOrg(edge, &b);
edgemask[edge] = true;
edge = getEdge(edge, NEXT_AROUND_LEFT);
edgeOrg(edge, &c);
edgemask[edge] = true;
if( rect.contains(a) && rect.contains(b) && rect.contains(c) )
int edge_a = i;
edgeOrg(edge_a, &a);
if (filterPoints && !rect.contains(a))
continue;
int edge_b = getEdge(edge_a, NEXT_AROUND_LEFT);
edgeOrg(edge_b, &b);
if (filterPoints && !rect.contains(b))
continue;
int edge_c = getEdge(edge_b, NEXT_AROUND_LEFT);
edgeOrg(edge_c, &c);
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));
}
}

Loading…
Cancel
Save