1*c8dee2aaSAndroid Build Coastguard Worker // Copyright 2023 Google LLC 2*c8dee2aaSAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3*c8dee2aaSAndroid Build Coastguard Worker 4*c8dee2aaSAndroid Build Coastguard Worker #include "modules/bentleyottmann/include/BentleyOttmann1.h" 5*c8dee2aaSAndroid Build Coastguard Worker 6*c8dee2aaSAndroid Build Coastguard Worker #include "modules/bentleyottmann/include/EventQueue.h" 7*c8dee2aaSAndroid Build Coastguard Worker #include "modules/bentleyottmann/include/Segment.h" 8*c8dee2aaSAndroid Build Coastguard Worker #include "modules/bentleyottmann/include/SweepLine.h" 9*c8dee2aaSAndroid Build Coastguard Worker 10*c8dee2aaSAndroid Build Coastguard Worker #include <optional> 11*c8dee2aaSAndroid Build Coastguard Worker #include <utility> 12*c8dee2aaSAndroid Build Coastguard Worker #include <vector> 13*c8dee2aaSAndroid Build Coastguard Worker 14*c8dee2aaSAndroid Build Coastguard Worker namespace bentleyottmann { 15*c8dee2aaSAndroid Build Coastguard Worker bentley_ottmann_1(SkSpan<const Segment> segments)16*c8dee2aaSAndroid Build Coastguard Workerstd::optional<std::vector<Crossing>> bentley_ottmann_1(SkSpan<const Segment> segments) { 17*c8dee2aaSAndroid Build Coastguard Worker if (auto possibleEQ = EventQueue::Make(segments)) { 18*c8dee2aaSAndroid Build Coastguard Worker EventQueue eventQueue = std::move(possibleEQ.value()); 19*c8dee2aaSAndroid Build Coastguard Worker SweepLine sweepLine; 20*c8dee2aaSAndroid Build Coastguard Worker while(eventQueue.hasMoreEvents()) { 21*c8dee2aaSAndroid Build Coastguard Worker eventQueue.handleNextEventPoint(&sweepLine); 22*c8dee2aaSAndroid Build Coastguard Worker } 23*c8dee2aaSAndroid Build Coastguard Worker return eventQueue.crossings(); 24*c8dee2aaSAndroid Build Coastguard Worker } 25*c8dee2aaSAndroid Build Coastguard Worker return std::nullopt; 26*c8dee2aaSAndroid Build Coastguard Worker } 27*c8dee2aaSAndroid Build Coastguard Worker } // namespace bentleyottmann 28