Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
BruteForceCrossings.cpp
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
5
7
8#include <optional>
9#include <vector>
10
11namespace bentleyottmann {
12std::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
constexpr T * begin() const
Definition SkSpan_impl.h:90
constexpr T * end() const
Definition SkSpan_impl.h:91
constexpr size_t size() const
Definition SkSpan_impl.h:95
std::optional< std::vector< Crossing > > brute_force_crossings(SkSpan< const Segment > segments)
std::optional< Point > intersect(const Segment &s0, const Segment &s1)
Definition Segment.cpp:97