-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[experimental] update test-demo with version with lambdas
- Loading branch information
1 parent
a8bd9a0
commit 33e1218
Showing
3 changed files
with
175 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Boost.Geometry (aka GGL, Generic Geometry Library) | ||
# Robustness Test - convex_hull | ||
# | ||
# Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. | ||
|
||
# Use, modification and distribution is subject to the Boost Software License, | ||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | ||
# http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
|
||
project partition_within | ||
: requirements | ||
<include>. | ||
<link>static | ||
; | ||
|
||
exe partition_within : partition_within.cpp ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Boost.Geometry (aka GGL, Generic Geometry Library) | ||
|
||
// Copyright (c) 2023 Barend Gehrels, Amsterdam, the Netherlands. | ||
// Use, modification and distribution is subject to the Boost Software License, | ||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#ifndef BOOST_GEOMETRY_EXPERIMENTAL_QUADTREE_PARTITION_HPP | ||
#define BOOST_GEOMETRY_EXPERIMENTAL_QUADTREE_PARTITION_HPP | ||
|
||
#include <boost/range.hpp> | ||
#include <boost/geometry/algorithms/detail/partition.hpp> | ||
|
||
#include <functional> | ||
|
||
namespace boost { namespace geometry | ||
{ | ||
|
||
namespace experimental | ||
{ | ||
|
||
template <typename F> | ||
struct adapt_partition_visitor | ||
{ | ||
F m_f; | ||
|
||
explicit adapt_partition_visitor(F&& f) | ||
: m_f(std::move(f)) | ||
{} | ||
|
||
template <typename ...Ts> | ||
decltype(auto) apply(Ts&& ...is) const | ||
{ | ||
return m_f(std::forward<Ts>(is)...); | ||
} | ||
}; | ||
|
||
template | ||
< | ||
typename BoxType, | ||
typename ForwardRange1, | ||
typename ForwardRange2 | ||
> | ||
bool quadtree_partition(ForwardRange1 const& forward_range1, | ||
ForwardRange2 const& forward_range2, | ||
const std::function | ||
< | ||
void(BoxType&, | ||
typename boost::range_value<ForwardRange1>::type const&) | ||
>& expand_policy1, | ||
const std::function | ||
< | ||
bool(BoxType const&, | ||
typename boost::range_value<ForwardRange1>::type const&) | ||
>& overlaps_policy1, | ||
const std::function | ||
< | ||
void(BoxType&, | ||
typename boost::range_value<ForwardRange2>::type const&) | ||
>& expand_policy2, | ||
const std::function | ||
< | ||
bool(BoxType const&, | ||
typename boost::range_value<ForwardRange2>::type const&) | ||
>& overlaps_policy2, | ||
const std::function | ||
< | ||
bool(typename boost::range_value<ForwardRange1>::type const&, | ||
typename boost::range_value<ForwardRange2>::type const&) | ||
>& visitor, | ||
const std::function | ||
< | ||
void(BoxType const&, int level) | ||
>& box_visitor = [](auto const&, int) {}) | ||
{ | ||
adapt_partition_visitor<decltype(visitor)> av(visitor); | ||
adapt_partition_visitor<decltype(expand_policy1)> aev1(expand_policy1); | ||
adapt_partition_visitor<decltype(expand_policy2)> aev2(expand_policy2); | ||
adapt_partition_visitor<decltype(overlaps_policy1)> aov1(overlaps_policy1); | ||
adapt_partition_visitor<decltype(overlaps_policy2)> aov2(overlaps_policy2); | ||
adapt_partition_visitor<decltype(box_visitor)> apbv(box_visitor); | ||
|
||
// TODO: the "16" could be part of an optional options structure | ||
// The all_policies (it is never run in a different way) could be | ||
// a compiletime part of that options structure as well. | ||
return partition | ||
< | ||
BoxType, | ||
detail::partition::include_all_policy, | ||
detail::partition::include_all_policy | ||
>::apply(forward_range1, forward_range2, av, | ||
aev1, aov1, | ||
aev2, aov2, 16, apbv); | ||
} | ||
|
||
}}} // namespace boost::geometry::experimental | ||
|
||
#endif // BOOST_GEOMETRY_EXPERIMENTAL_QUADTREE_PARTITION_HPP |