Eliminate infinite loop AssemblePolygon

This commit is contained in:
phkahler 2020-05-06 17:24:10 -04:00
parent 7366a6c53d
commit 88a0e55f35

View File

@ -269,31 +269,25 @@ bool SEdgeList::AssemblePolygon(SPolygon *dest, SEdge *errorAt, bool keepDir) co
dest->Clear(); dest->Clear();
bool allClosed = true; bool allClosed = true;
for(;;) { Vector first = Vector::From(0, 0, 0);
Vector first = Vector::From(0, 0, 0); Vector last = Vector::From(0, 0, 0);
Vector last = Vector::From(0, 0, 0); int i;
int i; for(i = 0; i < l.n; i++) {
for(i = 0; i < l.n; i++) { if(!l[i].tag) {
if(!l[i].tag) { first = l[i].a;
first = l[i].a; last = l[i].b;
last = l[i].b; /// @todo fix const!
/// @todo fix const! const_cast<SEdge*>(&(l[i]))->tag = 1;
const_cast<SEdge*>(&(l[i]))->tag = 1; // Create a new empty contour in our polygon, and finish assembling
break; // into that contour.
dest->AddEmptyContour();
if(!AssembleContour(first, last, dest->l.Last(), errorAt, keepDir)) {
allClosed = false;
} }
// But continue assembling, even if some of the contours are open
} }
if(i >= l.n) {
return allClosed;
}
// Create a new empty contour in our polygon, and finish assembling
// into that contour.
dest->AddEmptyContour();
if(!AssembleContour(first, last, dest->l.Last(), errorAt, keepDir)) {
allClosed = false;
}
// But continue assembling, even if some of the contours are open
} }
return allClosed;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------