Debian Codegraph @

modules/bentleyottmann/src/BentleyOttmann1.cpp

raw
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 #include "modules/bentleyottmann/include/BentleyOttmann1.h"
5
6 #include "modules/bentleyottmann/include/EventQueue.h"
7 #include "modules/bentleyottmann/include/Segment.h"
8 #include "modules/bentleyottmann/include/SweepLine.h"
9
10 #include <optional>
11 #include <utility>
12 #include <vector>
13
14 namespace bentleyottmann {
15
16 std::optional<std::vector<Crossing>> bentley_ottmann_1(SkSpan<const Segment> segments) {
17 if (auto possibleEQ = EventQueue::Make(segments)) {
18 EventQueue eventQueue = std::move(possibleEQ.value());
19 SweepLine sweepLine;
20 while(eventQueue.hasMoreEvents()) {
21 eventQueue.handleNextEventPoint(&sweepLine);
22 }
23 return eventQueue.crossings();
24 }
25 return std::nullopt;
26 }
27 } // namespace bentleyottmann