23 auto [l, t, r,
b] =
s.bounds();
50 this->add({crossingPoint,
Cross{s0, s1}});
51 fCrossings.push_back({s0, s1, crossingPoint});
55 return !fQueue.empty();
59struct Visitor : Ts... {
using Ts::operator()...; };
68 fInsertionSet.clear();
71 bool hasLower =
false;
74 auto handleLower = [&hasLower](
const Lower& l) {
79 auto handleCross = [
this](
const Cross& c) {
80 fDeletionSet.insert({c.s0, c.s1});
81 fInsertionSet.insert({c.s0, c.s1});
85 auto handleUpper = [
this](
const Upper& u) {
86 fInsertionSet.insert(u.s);
89 SkASSERT(u.s.lower() != u.s.upper());
93 Visitor visitor{handleLower, handleCross, handleUpper};
95 const Point eventPoint = fQueue.begin()->where;
98 SkASSERT(fLastEventPoint < eventPoint);
99 fLastEventPoint = eventPoint;
102 auto cursor = fQueue.begin();
103 const auto queueEnd = fQueue.end();
104 for (; cursor != queueEnd && cursor->where == eventPoint;
106 const Event&
event = *cursor;
107 std::visit(visitor,
event.type);
111 fQueue.erase(fQueue.begin(), cursor);
113 if (hasLower || !fDeletionSet.empty()) {
118 if (hasLower || !fDeletionSet.empty() || !fInsertionSet.empty()) {
126 return std::vector<Crossing>{fCrossings.begin(), fCrossings.end()};
std::vector< Crossing > crossings()
bool hasMoreEvents() const
void addCrossing(Point crossingPoint, const Segment &s0, const Segment &s1) override
void handleNextEventPoint(SweepLineInterface *handler)
static std::optional< EventQueue > Make(SkSpan< const Segment > segments)
virtual void handleInsertionsAndCheckForNewCrossings(Point eventPoint, const InsertionSegmentSet &inserting, EventQueueInterface *queue)=0
virtual void handleDeletions(Point eventPoint, const DeletionSegmentSet &removing)=0
static float max(float r, float g, float b)
static float min(float r, float g, float b)
Visitor(Ts...) -> Visitor< Ts... >
int compare_slopes(const Segment &s0, const Segment &s1)
bool operator()(const Segment &s0, const Segment &s1) const
static bool DifferenceTooBig(Point p0, Point p1)