void QTessellatorPrivate::processIntersections() { QDEBUG() << "PROCESS INTERSECTIONS"; // process intersections while (!intersections.isEmpty()) { Intersections::iterator it = intersections.begin(); if (it.key().y != y) break; // swap edges QDEBUG() << " swapping intersecting edges "; int min = scanline.size; int max = 0; Q27Dot5 xmin = INT_MAX; Q27Dot5 xmax = INT_MIN; int num = 0; while (1) { const Intersection &i = it.key(); int next = it->next; int edgePos = scanline.findEdge(i.edge); if (edgePos >= 0) { ++num; min = qMin(edgePos, min); max = qMax(edgePos, max); Edge *edge = scanline.edges[edgePos]; xmin = qMin(xmin, edge->positionAt(y)); xmax = qMax(xmax, edge->positionAt(y)); } Intersection key; key.y = y; key.edge = next; it = intersections.find(key); intersections.remove(i); if (it == intersections.end()) break; } if (num < 2) continue; Q_ASSERT(min != max); QDEBUG() << "sorting between" << min << "and" << max << "xpos=" << xmin << xmax; while (min > 0 && scanline.edges[min - 1]->positionAt(y) >= xmin) { QDEBUG() << " adding edge on left"; --min; } while (max + 1 < scanline.size && scanline.edges[max + 1]->positionAt(y) <= xmax) { QDEBUG() << " adding edge on right"; ++max; } qSort(scanline.edges + min, scanline.edges + max + 1, EdgeSorter(y)); #ifdef DEBUG for (int i = min; i <= max; ++i) QDEBUG() << " " << scanline.edges[i]->edge << "at pos" << i; #endif for (int i = min; i <= max; ++i) { Edge *edge = scanline.edges[i]; edge->intersect_left = true; edge->intersect_right = true; edge->mark = true; } } }