Umgang mit schnellen Einschränkungen der CGAL -eingeschränkten Delaunay -Triangulation
Posted: 01 Mar 2025, 12:23
Ich verwende cGAL eingeschränkte Delaunay -Triangulation , um eine automatisch erzeugte Polylinie zu triangulieren, die aus dem Contourfinder von OpenCV erhalten wurde. Wenn die Form jedoch leicht komplex wird, wirft CGAL die ** intersection_of_constraints_exception ();*aus, wodurch das Programm aufhört. Trotzdem stoße ich immer noch auf die gleiche Ausnahme. Die gefilterte Polylinie zu CGAL zur Triangulation. Das erwartet CGAL?
Code: Select all
//find contour
contourFinder.findContours(grayscaleImage, *minimumArea, *maximumArea, *considered, false, true);
//find outlines
polylines.clear();
meshes.clear();
for (int i = 0; i < contourFinder.nBlobs; i++) {
ofPolyline polyline;
polyline.clear();
vector contour;
for (const auto& p : contourFinder.blobs.at(i).pts) {
contour.push_back(cv::Point(p.x, p.y));
}
if (contour.size() > 0) {
//reduce points
vector approx;
cv::approxPolyDP(contour, approx, *polygonApproximation, true);
//store end coordinate to check first segment
cv::Point previousPoint = approx.at(approx.size() - 1);
//go through all segments, add only if not causing an intersection
for (int i = 0; i < approx.size(); i++) {
bool wouldIntersect = false;
for (int j = 0; j < polyline.size(); j++) {
if (
doIntersect(
ofPoint(
previousPoint.x,
previousPoint.y
),
ofPoint(
approx.at(i).x,
approx.at(i).y
),
ofPoint(
polyline.getVertices().at((j + 1) % polyline.getVertices().size()).x,
polyline.getVertices().at((j + 1) % polyline.getVertices().size()).y
),
ofPoint(
polyline.getVertices().at(j).x,
polyline.getVertices().at(j).y
)
)
) {
wouldIntersect = true;
}
}
if (wouldIntersect == false) {
cout