mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-09 23:22:10 +00:00
[partition] support heterogenous collections
This commit is contained in:
@@ -106,10 +106,15 @@ static inline void handle_one(InputCollection const& collection,
|
||||
}
|
||||
|
||||
// Match collection 1 with collection 2
|
||||
template <typename InputCollection, typename Policy>
|
||||
static inline void handle_two(
|
||||
InputCollection const& collection1, index_vector_type const& input1,
|
||||
InputCollection const& collection2, index_vector_type const& input2,
|
||||
template
|
||||
<
|
||||
typename InputCollection1,
|
||||
typename InputCollection2,
|
||||
typename Policy
|
||||
>
|
||||
inline void handle_two(
|
||||
InputCollection1 const& collection1, index_vector_type const& input1,
|
||||
InputCollection2 const& collection2, index_vector_type const& input2,
|
||||
Policy& policy)
|
||||
{
|
||||
typedef boost::range_iterator
|
||||
@@ -209,7 +214,8 @@ template
|
||||
<
|
||||
int Dimension,
|
||||
typename Box,
|
||||
typename OverlapsPolicy,
|
||||
typename OverlapsPolicy1,
|
||||
typename OverlapsPolicy2,
|
||||
typename VisitBoxPolicy
|
||||
>
|
||||
class partition_two_collections
|
||||
@@ -220,15 +226,21 @@ class partition_two_collections
|
||||
<
|
||||
1 - Dimension,
|
||||
Box,
|
||||
OverlapsPolicy,
|
||||
OverlapsPolicy1,
|
||||
OverlapsPolicy2,
|
||||
VisitBoxPolicy
|
||||
> sub_divide;
|
||||
|
||||
template <typename InputCollection, typename Policy>
|
||||
template
|
||||
<
|
||||
typename InputCollection1,
|
||||
typename InputCollection2,
|
||||
typename Policy
|
||||
>
|
||||
static inline void next_level(Box const& box,
|
||||
InputCollection const& collection1,
|
||||
InputCollection1 const& collection1,
|
||||
index_vector_type const& input1,
|
||||
InputCollection const& collection2,
|
||||
InputCollection2 const& collection2,
|
||||
index_vector_type const& input2,
|
||||
int level, std::size_t min_elements,
|
||||
Policy& policy, VisitBoxPolicy& box_policy)
|
||||
@@ -252,10 +264,15 @@ class partition_two_collections
|
||||
}
|
||||
|
||||
public :
|
||||
template <typename InputCollection, typename Policy>
|
||||
template
|
||||
<
|
||||
typename InputCollection1,
|
||||
typename InputCollection2,
|
||||
typename Policy
|
||||
>
|
||||
static inline void apply(Box const& box,
|
||||
InputCollection const& collection1, index_vector_type const& input1,
|
||||
InputCollection const& collection2, index_vector_type const& input2,
|
||||
InputCollection1 const& collection1, index_vector_type const& input1,
|
||||
InputCollection2 const& collection2, index_vector_type const& input2,
|
||||
int level,
|
||||
std::size_t min_elements,
|
||||
Policy& policy, VisitBoxPolicy& box_policy)
|
||||
@@ -267,9 +284,9 @@ public :
|
||||
|
||||
index_vector_type lower1, upper1, exceeding1;
|
||||
index_vector_type lower2, upper2, exceeding2;
|
||||
divide_into_subsets<OverlapsPolicy>(lower_box, upper_box, collection1,
|
||||
divide_into_subsets<OverlapsPolicy1>(lower_box, upper_box, collection1,
|
||||
input1, lower1, upper1, exceeding1);
|
||||
divide_into_subsets<OverlapsPolicy>(lower_box, upper_box, collection2,
|
||||
divide_into_subsets<OverlapsPolicy2>(lower_box, upper_box, collection2,
|
||||
input2, lower2, upper2, exceeding2);
|
||||
|
||||
if (boost::size(exceeding1) > 0)
|
||||
@@ -308,15 +325,17 @@ struct visit_no_policy
|
||||
template
|
||||
<
|
||||
typename Box,
|
||||
typename ExpandPolicy,
|
||||
typename OverlapsPolicy,
|
||||
typename ExpandPolicy1,
|
||||
typename OverlapsPolicy1,
|
||||
typename ExpandPolicy2 = ExpandPolicy1,
|
||||
typename OverlapsPolicy2 = OverlapsPolicy1,
|
||||
typename VisitBoxPolicy = visit_no_policy
|
||||
>
|
||||
class partition
|
||||
{
|
||||
typedef std::vector<std::size_t> index_vector_type;
|
||||
|
||||
template <typename InputCollection>
|
||||
template <typename ExpandPolicy, typename InputCollection>
|
||||
static inline void expand_to_collection(InputCollection const& collection,
|
||||
Box& total, index_vector_type& index_vector)
|
||||
{
|
||||
@@ -344,12 +363,12 @@ public :
|
||||
index_vector_type index_vector;
|
||||
Box total;
|
||||
assign_inverse(total);
|
||||
expand_to_collection(collection, total, index_vector);
|
||||
expand_to_collection<ExpandPolicy1>(collection, total, index_vector);
|
||||
|
||||
detail::partition::partition_one_collection
|
||||
<
|
||||
0, Box,
|
||||
OverlapsPolicy,
|
||||
OverlapsPolicy1,
|
||||
VisitBoxPolicy
|
||||
>::apply(total, collection, index_vector, 0, min_elements,
|
||||
visitor, box_visitor);
|
||||
@@ -373,9 +392,14 @@ public :
|
||||
}
|
||||
}
|
||||
|
||||
template <typename InputCollection, typename VisitPolicy>
|
||||
static inline void apply(InputCollection const& collection1,
|
||||
InputCollection const& collection2,
|
||||
template
|
||||
<
|
||||
typename InputCollection1,
|
||||
typename InputCollection2,
|
||||
typename VisitPolicy
|
||||
>
|
||||
static inline void apply(InputCollection1 const& collection1,
|
||||
InputCollection2 const& collection2,
|
||||
VisitPolicy& visitor,
|
||||
std::size_t min_elements = 16,
|
||||
VisitBoxPolicy box_visitor = visit_no_policy()
|
||||
@@ -387,12 +411,12 @@ public :
|
||||
index_vector_type index_vector1, index_vector2;
|
||||
Box total;
|
||||
assign_inverse(total);
|
||||
expand_to_collection(collection1, total, index_vector1);
|
||||
expand_to_collection(collection2, total, index_vector2);
|
||||
expand_to_collection<ExpandPolicy1>(collection1, total, index_vector1);
|
||||
expand_to_collection<ExpandPolicy2>(collection2, total, index_vector2);
|
||||
|
||||
detail::partition::partition_two_collections
|
||||
<
|
||||
0, Box, OverlapsPolicy, VisitBoxPolicy
|
||||
0, Box, OverlapsPolicy1, OverlapsPolicy2, VisitBoxPolicy
|
||||
>::apply(total,
|
||||
collection1, index_vector1,
|
||||
collection2, index_vector2,
|
||||
@@ -402,13 +426,17 @@ public :
|
||||
{
|
||||
typedef typename boost::range_iterator
|
||||
<
|
||||
InputCollection const
|
||||
>::type iterator_type;
|
||||
for(iterator_type it1 = boost::begin(collection1);
|
||||
InputCollection1 const
|
||||
>::type iterator_type1;
|
||||
typedef typename boost::range_iterator
|
||||
<
|
||||
InputCollection2 const
|
||||
>::type iterator_type2;
|
||||
for(iterator_type1 it1 = boost::begin(collection1);
|
||||
it1 != boost::end(collection1);
|
||||
++it1)
|
||||
{
|
||||
for(iterator_type it2 = boost::begin(collection2);
|
||||
for(iterator_type2 it2 = boost::begin(collection2);
|
||||
it2 != boost::end(collection2);
|
||||
++it2)
|
||||
{
|
||||
@@ -417,9 +445,9 @@ public :
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_PARTITION_HPP
|
||||
|
||||
Reference in New Issue
Block a user