Skip to content

Commit

Permalink
fuzzy test ok, TODO handle vertical segments
Browse files Browse the repository at this point in the history
  • Loading branch information
fhamonic committed Sep 25, 2024
1 parent b03de54 commit 3a5425a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/bentley_ottmann_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#undef NDEBUG
#include <gtest/gtest.h>

#include <random>
#include <ranges>

#include "melon/experimental/bentley_ottmann.hpp"
Expand Down Expand Up @@ -97,11 +98,23 @@ GTEST_TEST(bentley_ottmann, fuzzy_test) {
std::declval<segment>(), std::declval<segment>()))::value_type;

std::vector<segment> segments;
const std::size_t & num_segments = 100;

std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<int64_t> dist(-15, 15);

for(std::size_t i = 0; i < num_segments; ++i) {
segments.emplace_back(std::make_pair(dist(rng), dist(rng)),
std::make_pair(dist(rng), dist(rng)));
if(segments.back().first.first == segments.back().second.first)
segments.pop_back();
}

std::vector<std::pair<intersection, std::vector<std::size_t>>>
intersections_vec;
for(const auto & [i, intersecting_segments] :
bentley_ottmann(std::views::iota(0ul, segments.size()), segments)) {
bentley_ottmann(std::views::iota(0ul, num_segments), segments)) {
intersections_vec.emplace_back(std::make_pair(
i, std::vector<std::size_t>(intersecting_segments.begin(),
intersecting_segments.end())));
Expand Down

0 comments on commit 3a5425a

Please sign in to comment.