You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In particular configurations the generated triangles use the SweepContext::head_ and SweepContext::tail_ points in the final triangles list.
These points are out of bound.
Here is the smallest test case I have found.
#include<iostream>
#include"poly2tri/poly2tri.h"intmain() {
// Fill contour
std::vector < p2t::Point * > contourPoints;
contourPoints.push_back(newp2t::Point(0, -1200));
contourPoints.push_back(newp2t::Point(0, -2600));
contourPoints.push_back(newp2t::Point(-2280, -2600));
p2t::CDT myCDT(contourPoints);
// Add steiner points
std::vector < p2t::Point * > steinerPoints;
steinerPoints.push_back(newp2t::Point(0, -2560));
myCDT.AddPoint(steinerPoints.back());
// Launch triangulate
myCDT.Triangulate();
// Check the resultauto Triangles = myCDT.GetTriangles();
autotriangleIt(Triangles.cbegin());
autoendIt(Triangles.cend());
autoxMin(-2280), xMax(0);
autoyMin(-2600), yMax(-1200);
size_ttriangleIndex(0), triangleCount(Triangles.size());
std::cout << "Triangles count: " << triangleCount << "\n";
auto CheckValidity = [ & ](p2t::Point * pPoint) {
if (pPoint -> x < xMin || pPoint -> x > xMax || pPoint -> y < yMin || pPoint -> y > yMax) {
std::cout << "!!! Point out of bound x " << pPoint -> x;
std::cout << " y " << pPoint -> y << "\n";
} else {
std::cout << "Point in bound x " << pPoint -> x;
std::cout << " y " << pPoint -> y << "\n";
}
};
for (triangleIndex = 0; triangleIndex < triangleCount; ++triangleIndex) {
std::cout << "Triangle index " << triangleIndex << "\n";
autopTriangle(Triangles[triangleIndex]);
CheckValidity(pTriangle->GetPoint(0));
CheckValidity(pTriangle->GetPoint(1));
CheckValidity(pTriangle->GetPoint(2));
}
}
Did I miss something?
The text was updated successfully, but these errors were encountered:
I also encountered this issue, managed to narrow it down: this issue only happens if there is a steiner point on a boundary edge, and the point is sorted in a specific way internally so that in the Sweep::EdgeEvent function, the if (o1 == COLLINEAR) { ... branch is entered. If the other branch, if (o2 == COLLINEAR) { ... is entered, then it works fine.
In particular configurations the generated triangles use the SweepContext::head_ and SweepContext::tail_ points in the final triangles list.
These points are out of bound.
Here is the smallest test case I have found.
Did I miss something?
The text was updated successfully, but these errors were encountered: