Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:boostorg/geometry into ci_enable…
Browse files Browse the repository at this point in the history
…_c++17_testing
  • Loading branch information
vissarion committed Apr 30, 2024
2 parents 975cc5e + 1f8b6e0 commit 291a593
Show file tree
Hide file tree
Showing 12 changed files with 333 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .circleci/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ done

cd $BOOST_DIR

find "$BOOST_DIR" -type f -name "Jamfile" | while read -r file; do
find "$TEST_DIR" -type f -name "Jamfile" | while read -r file; do
# Replace "run" with "compile" using sed
sed -i 's/\brun\b/compile/g' "$file"
sed -i 's/: : :/:/g' "$file"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include <boost/geometry/algorithms/detail/sections/section_box_policies.hpp>

#include <boost/geometry/views/detail/closed_clockwise_view.hpp>
#include <boost/geometry/util/for_each_with_index.hpp>
#include <boost/geometry/views/enumerate_view.hpp>
#include <boost/geometry/util/range.hpp>


Expand Down Expand Up @@ -376,16 +376,18 @@ struct buffered_piece_collection

inline void update_turn_administration()
{
for_each_with_index(m_turns, [this](std::size_t index, auto& turn)
for (auto const& enumerated : util::enumerate(m_turns))
{
turn.turn_index = index;
// enumerated is const, but its value is a non-const reference
auto& turn = enumerated.value;
turn.turn_index = enumerated.index;

// Verify if a turn is a linear endpoint
if (! turn.is_linear_end_point)
{
this->check_linear_endpoints(turn);
}
});
}
}

// Calculate properties of piece borders which are not influenced
Expand Down Expand Up @@ -1091,30 +1093,32 @@ struct buffered_piece_collection
// Inner rings, for deflate, which do not have intersections, and
// which are outside originals, are skipped
// (other ones should be traversed)
for_each_with_index(offsetted_rings, [&](std::size_t index, auto const& ring)
for (auto const& enumerated : util::enumerate(offsetted_rings))
{
auto const& ring = enumerated.value;
if (! ring.has_intersections()
&& ! ring.is_untouched_outside_original)
{
if (! ring.has_intersections()
&& ! ring.is_untouched_outside_original)
properties const p = properties(ring, m_strategy);
if (p.valid)
{
properties p = properties(ring, m_strategy);
if (p.valid)
{
ring_identifier id(0, index, -1);
selected[id] = p;
}
ring_identifier id(0, enumerated.index, -1);
selected[id] = p;
}
});
}
}

// Select all created rings
for_each_with_index(traversed_rings, [&](std::size_t index, auto const& ring)
for (auto const& enumerated : util::enumerate(traversed_rings))
{
auto const& ring = enumerated.value;
properties p = properties(ring, m_strategy);
if (p.valid)
{
properties p = properties(ring, m_strategy);
if (p.valid)
{
ring_identifier id(2, index, -1);
selected[id] = p;
}
});
ring_identifier id(2, enumerated.index, -1);
selected[id] = p;
}
}

detail::overlay::assign_parents<overlay_buffer>(offsetted_rings, traversed_rings,
selected, m_strategy);
Expand Down
34 changes: 19 additions & 15 deletions include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#include <boost/geometry/algorithms/detail/partition.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
#include <boost/geometry/algorithms/detail/overlay/range_in_geometry.hpp>
#include <boost/geometry/views/enumerate_view.hpp>

#include <boost/geometry/geometries/box.hpp>

#include <boost/geometry/util/for_each_with_index.hpp>

namespace boost { namespace geometry
{
Expand Down Expand Up @@ -271,25 +271,28 @@ inline void assign_parents(Geometry1 const& geometry1,
std::size_t index_positive = 0; // only used if count_positive>0

// Copy to vector (this might be obsolete, using the map directly)
// The index in the map is also the index in the vector.
using helper = ring_info_helper<point_type, area_result_type>;
std::vector<helper> vector(count_total);

for_each_with_index(ring_map, [&](std::size_t index, auto const& pair)
for (auto const& enumerated : util::enumerate(ring_map))
{
vector[index] = helper(pair.first, pair.second.get_area());
helper& item = vector[index];
switch(pair.first.source_index)
auto const& ring_id = enumerated.value.first;
auto const& info = enumerated.value.second;
vector[enumerated.index] = helper(ring_id, info.get_area());
helper& item = vector[enumerated.index];
switch(ring_id.source_index)
{
case 0 :
geometry::envelope(get_ring<tag1>::apply(pair.first, geometry1),
geometry::envelope(get_ring<tag1>::apply(ring_id, geometry1),
item.envelope, strategy);
break;
case 1 :
geometry::envelope(get_ring<tag2>::apply(pair.first, geometry2),
geometry::envelope(get_ring<tag2>::apply(ring_id, geometry2),
item.envelope, strategy);
break;
case 2 :
geometry::envelope(get_ring<void>::apply(pair.first, collection),
geometry::envelope(get_ring<void>::apply(ring_id, collection),
item.envelope, strategy);
break;
}
Expand All @@ -300,9 +303,9 @@ inline void assign_parents(Geometry1 const& geometry1,
if (item.real_area > 0)
{
count_positive++;
index_positive = index;
index_positive = enumerated.index;
}
});
}

if (! check_for_orientation)
{
Expand All @@ -323,15 +326,16 @@ inline void assign_parents(Geometry1 const& geometry1,
// located outside the outer ring, this cannot be done
ring_identifier id_of_positive = vector[index_positive].id;
ring_info_type& outer = ring_map[id_of_positive];
for_each_with_index(vector, [&](std::size_t index, auto const& item)
for (auto const& item : util::enumerate(vector))
{
if (index != index_positive)
if (item.index != index_positive)
{
ring_info_type& inner = ring_map[item.id];
auto const id = item.value.id;
ring_info_type& inner = ring_map[id];
inner.parent = id_of_positive;
outer.children.push_back(item.id);
outer.children.push_back(id);
}
});
}
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <boost/range/value_type.hpp>

#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
#include <boost/geometry/views/enumerate_view.hpp>


namespace boost { namespace geometry
Expand Down Expand Up @@ -122,17 +123,17 @@ inline void check_detailed(MetaTurns& meta_turns, MetaTurn const& meta_turn,


template <typename TurnPoints>
inline bool check_graph(TurnPoints& turn_points, operation_type for_operation)
inline bool check_graph(TurnPoints const& turn_points, operation_type for_operation)
{
typedef typename boost::range_value<TurnPoints>::type turn_point_type;
using turn_point_type = typename boost::range_value<TurnPoints>::type;

bool error = false;

std::vector<meta_turn<turn_point_type> > meta_turns;
for_each_with_index(turn_points, [&](std::size_t index, auto const& point)
for (auto const& item : util::enumerate(turn_points))
{
meta_turns.push_back(meta_turn<turn_point_type>(index, point));
});
meta_turns.push_back(meta_turn<turn_point_type>(item.index, item.value));
}

int cycle = 0;
for (auto& meta_turn : meta_turns)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <boost/range/value_type.hpp>

#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
#include <boost/geometry/algorithms/detail/overlay/check_enrich.hpp>
#include <boost/geometry/algorithms/detail/overlay/discard_duplicate_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/handle_colocations.hpp>
#include <boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp>
Expand All @@ -42,11 +43,8 @@
#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
#include <boost/geometry/policies/robustness/robust_type.hpp>
#include <boost/geometry/util/constexpr.hpp>
#include <boost/geometry/util/for_each_with_index.hpp>
#include <boost/geometry/views/enumerate_view.hpp>

#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
# include <boost/geometry/algorithms/detail/overlay/check_enrich.hpp>
#endif


namespace boost { namespace geometry
Expand Down Expand Up @@ -112,8 +110,10 @@ template <typename Operations, typename Turns>
inline void enrich_assign(Operations& operations, Turns& turns,
bool check_consecutive_turns)
{
for_each_with_index(operations, [&](std::size_t index, auto const& indexed)
for (auto const& item : util::enumerate(operations))
{
auto const& index = item.index;
auto const& indexed = item.value;
auto& turn = turns[indexed.turn_index];
auto& op = turn.operations[indexed.operation_index];

Expand Down Expand Up @@ -185,7 +185,7 @@ inline void enrich_assign(Operations& operations, Turns& turns,
// Next turn is located further on same segment: assign next_ip_index
op.enriched.next_ip_index = static_cast<signed_size_type>(operations[next_index].turn_index);
}
});
}

#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
for (auto const& indexed_op : operations)
Expand Down Expand Up @@ -223,8 +223,10 @@ inline void enrich_adapt(Operations& operations, Turns& turns)
bool next_phase = false;
std::size_t previous_index = operations.size() - 1;

for_each_with_index(operations, [&](std::size_t index, auto const& indexed)
for (auto const& item : util::enumerate(operations))
{
auto const& index = item.index;
auto const& indexed = item.value;
auto& turn = turns[indexed.turn_index];
auto& op = turn.operations[indexed.operation_index];

Expand All @@ -243,7 +245,7 @@ inline void enrich_adapt(Operations& operations, Turns& turns)
}
}
previous_index = index;
});
}

if (! next_phase)
{
Expand Down Expand Up @@ -290,12 +292,16 @@ template <typename Turns, typename MappedVector, typename IncludePolicy>
inline void create_map(Turns const& turns, MappedVector& mapped_vector,
IncludePolicy const& include_policy)
{
for_each_with_index(turns, [&](std::size_t index, auto const& turn)
for (auto const& turn_item : util::enumerate(turns))
{
auto const& index = turn_item.index;
auto const& turn = turn_item.value;
if (! turn.discarded)
{
for_each_with_index(turn.operations, [&](std::size_t op_index, auto const& op)
for (auto const& op_item : util::enumerate(turn.operations))
{
auto const& op_index = op_item.index;
auto const& op = op_item.value;
if (include_policy.include(op.operation))
{
ring_identifier const ring_id
Expand All @@ -309,9 +315,9 @@ inline void create_map(Turns const& turns, MappedVector& mapped_vector,
index, op_index, op, turn.operations[1 - op_index].seg_id
);
}
});
}
}
});
}
}

template <typename Point1, typename Point2>
Expand Down Expand Up @@ -534,9 +540,15 @@ inline void enrich_intersection_points(Turns& turns,
}

#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
//detail::overlay::check_graph(turns, for_operation);
constexpr bool do_check_graph = true;
#else
constexpr bool do_check_graph = false;
#endif

if BOOST_GEOMETRY_CONSTEXPR (do_check_graph)
{
detail::overlay::check_graph(turns, target_operation);
}
}

}} // namespace boost::geometry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#if defined(BOOST_GEOMETRY_DEBUG_FOLLOW)
#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/util/for_each_with_index.hpp>
#include <boost/geometry/views/enumerate_view.hpp>
#endif

namespace boost { namespace geometry
Expand Down Expand Up @@ -379,10 +379,11 @@ struct intersection_of_linestring_with_areal
}

#if defined(BOOST_GEOMETRY_DEBUG_FOLLOW)
for_each_with_index(turns, [](auto index, auto const& turn)
for (auto const& item : util::enumerate(turns))
{
debug_follow(turn, turn.operations[0], index);
});
auto const& turn = item.value;
debug_follow(turn, turn.operations[0], item.index);
}
#endif

return follower::apply
Expand Down
49 changes: 0 additions & 49 deletions include/boost/geometry/util/for_each_with_index.hpp

This file was deleted.

Loading

0 comments on commit 291a593

Please sign in to comment.