Debian Codegraph @

modules/bentleyottmann/src/BruteForceCrossings.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/BruteForceCrossings.h"
5
6 #include "modules/bentleyottmann/include/Segment.h"
7
8 #include <optional>
9 #include <vector>
10
11 namespace bentleyottmann {
12 std::optional<std::vector<Crossing>> brute_force_crossings(SkSpan<const Segment> segments) {
13 std::vector<Crossing> answer;
14 if (segments.size() >= 2) {
15 for (auto i0 = segments.begin(); i0 != segments.end() - 1; ++i0) {
16 for (auto i1 = i0 + 1; i1 != segments.end(); ++i1) {
17 if (auto possiblePoint = intersect(*i0, *i1)) {
18 answer.push_back({*i0, *i1, possiblePoint.value()});
19 }
20 }
21 }
22 }
23 return answer;
24 }
25 } // namespace bentleyottmann