28 fSweepLine.reserve(8);
29 fSweepLine.push_back(LeftSentinel);
30 fSweepLine.push_back(RightSentinel);
33void SweepLine::verify(int32_t
y)
const {
34 for(
auto cursor = fSweepLine.begin(); (cursor + 1) != fSweepLine.end(); ++cursor) {
35 [[maybe_unused]]
const Segment& left = *cursor;
36 [[maybe_unused]]
const Segment& right = *(cursor + 1);
42 std::vector<Segment>::iterator newEnd;
43 if (removing.empty()) {
45 auto toRemove = [eventPoint](
Segment s) {
46 return s.lower() == eventPoint;
48 newEnd = std::remove_if(fSweepLine.begin(), fSweepLine.end(), toRemove);
51 auto toRemove = [eventPoint, &removing](
Segment s) {
52 return s.lower() == eventPoint || removing.find(
s) != removing.end();
54 newEnd = std::remove_if(fSweepLine.begin(), fSweepLine.end(), toRemove);
56 fSweepLine.erase(newEnd, fSweepLine.end());
66 const auto rightOfInsertion = std::lower_bound(
67 fSweepLine.begin(), fSweepLine.end(), eventPoint, comp);
68 SkASSERT(rightOfInsertion != fSweepLine.begin());
69 const auto leftOfInsertion = rightOfInsertion - 1;
71 if (inserting.empty()) {
74 if (
auto crossingPoint =
intersect(*leftOfInsertion, *rightOfInsertion)) {
75 queue->addCrossing(crossingPoint.value(), *leftOfInsertion, *rightOfInsertion);
80 if (
auto crossingPoint =
intersect(*leftOfInsertion, *inserting.begin())) {
81 queue->addCrossing(crossingPoint.value(), *leftOfInsertion, *inserting.begin());
86 if (
auto crossingPoint =
intersect(*inserting.rbegin(), *rightOfInsertion)) {
87 queue->addCrossing(crossingPoint.value(), *inserting.rbegin(), *rightOfInsertion);
91 fSweepLine.insert(rightOfInsertion, inserting.begin(), inserting.end());
void handleDeletions(Point eventPoint, const DeletionSegmentSet &removing) override
void handleInsertionsAndCheckForNewCrossings(Point eventPoint, const InsertionSegmentSet &inserting, EventQueueInterface *queue) override
static float max(float r, float g, float b)
bool point_less_than_segment_in_x(Point p, const Segment &segment)
std::set< Segment, OrderBySlope > InsertionSegmentSet
std::optional< Point > intersect(const Segment &s0, const Segment &s1)
std::set< Segment > DeletionSegmentSet
bool less_than_at(const Segment &s0, const Segment &s1, int32_t y)