Flutter Engine
The Flutter Engine
EventQueueInterface.h
Go to the documentation of this file.
1// Copyright 2023 Google LLC
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
4#ifndef EventQueueInterface_DEFINED
5#define EventQueueInterface_DEFINED
6
9
10#include <set>
11
12// The EventQueueInterface and the SweepLineInterface allow the EventQueue and the SweepLine
13// to be tested independently of each other. This allows very specific scenarios to be setup and
14// tested in isolation.
15
16namespace bentleyottmann {
17// -- EventQueueInterface --------------------------------------------------------------------------
18// An EventQueueInterface implementation must be able to add crossing events into the event queue.
20public:
26 virtual ~EventQueueInterface() = default;
27
28 virtual void addCrossing(Point crossingPoint, const Segment& s0, const Segment& s1) = 0;
29};
30
31using DeletionSegmentSet = std::set<Segment>;
33 bool operator()(const Segment& s0, const Segment& s1) const;
34};
35// The set of insertion segments is ordered by slope. Since all the lines pass through the same
36// point, then the slope of each line must be ordered from smallest to largest to keep the
37// segment order correct in the sweep line.
38using InsertionSegmentSet = std::set<Segment, OrderBySlope>;
39
40// The EventQueue uses an object of SweepLineInterface to find new crossings when manipulating
41// the sweep line.
43public:
44 virtual ~SweepLineInterface() = default;
45
46 // These are the segments to remove from the sweep line.
47 virtual void handleDeletions(Point eventPoint, const DeletionSegmentSet& removing) = 0;
48
49 // Insert inserting into the sweep line. Check the inserting segments against the existing
50 // sweep line segments and report any crossings using the addCrossing from the
51 // EventQueueInterface.
53 Point eventPoint, const InsertionSegmentSet& inserting, EventQueueInterface* queue) = 0;
54};
55} // namespace bentleyottmann
56#endif // EventQueueInterface_DEFINED
virtual void addCrossing(Point crossingPoint, const Segment &s0, const Segment &s1)=0
virtual ~EventQueueInterface()=default
EventQueueInterface(const EventQueueInterface &)=default
EventQueueInterface & operator=(const EventQueueInterface &)=default
EventQueueInterface(EventQueueInterface &&)=default
EventQueueInterface & operator=(EventQueueInterface &&)=default
virtual ~SweepLineInterface()=default
virtual void handleInsertionsAndCheckForNewCrossings(Point eventPoint, const InsertionSegmentSet &inserting, EventQueueInterface *queue)=0
virtual void handleDeletions(Point eventPoint, const DeletionSegmentSet &removing)=0
VkQueue queue
Definition: main.cc:55
std::set< Segment, OrderBySlope > InsertionSegmentSet
std::set< Segment > DeletionSegmentSet
bool operator()(const Segment &s0, const Segment &s1) const
Definition: EventQueue.cpp:129