mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 21:44:04 +00:00
[overlay] now we can/need to remove functionality to discard turns
colocated with uu and the same ring. This breaks one case (# case_recursive_boxes_23) but repairs many (about 50% of the wrong cases in robustness test)
This commit is contained in:
parent
31e7dd8f2f
commit
d256e57487
@ -199,77 +199,6 @@ inline signed_size_type add_turn_to_cluster(Turn const& turn,
|
||||
return cid0;
|
||||
}
|
||||
|
||||
/// Discards turn colocated with a uu turn, where both turns are on the same
|
||||
/// rings and one is (most probably) invalid
|
||||
template
|
||||
<
|
||||
bool Reverse1, bool Reverse2,
|
||||
typename Turns,
|
||||
typename Geometry1,
|
||||
typename Geometry2
|
||||
>
|
||||
inline bool discard_colocated_uu(signed_size_type cluster_id,
|
||||
Turns const& turns,
|
||||
turn_operation_index const& ref_toi,
|
||||
turn_operation_index const& toi,
|
||||
Geometry1 const& geometry1, Geometry2 const& geometry2)
|
||||
{
|
||||
typedef typename boost::range_value<Turns>::type turn_type;
|
||||
typedef typename geometry::point_type<Geometry1>::type point_type;
|
||||
|
||||
// Order counter clockwise to get the most right turn
|
||||
typedef sort_by_side::side_sorter
|
||||
<
|
||||
Reverse1, Reverse2, point_type, std::less<int>
|
||||
> sbs_type;
|
||||
|
||||
sbs_type sbs;
|
||||
|
||||
turn_type const& ref_turn = turns[ref_toi.turn_index];
|
||||
turn_type const& turn = turns[toi.turn_index];
|
||||
|
||||
// Add operations, the first is the "subject" (so sorting done from there)
|
||||
BOOST_ASSERT(ref_turn.both(operation_union));
|
||||
sbs.add(ref_turn.operations[ref_toi.op_index],
|
||||
ref_toi.turn_index, ref_toi.op_index,
|
||||
geometry1, geometry2, true);
|
||||
sbs.add(ref_turn.operations[1 - ref_toi.op_index],
|
||||
ref_toi.turn_index, 1 - ref_toi.op_index,
|
||||
geometry1, geometry2, false);
|
||||
|
||||
// Skip toi.op_index because ref_toi and toi have the same operation
|
||||
BOOST_ASSERT(ref_turn.operations[ref_toi.op_index].seg_id
|
||||
== turn.operations[toi.op_index].seg_id);
|
||||
|
||||
sbs.add(turn.operations[1 - toi.op_index],
|
||||
toi.turn_index, 1 - toi.op_index,
|
||||
geometry1, geometry2, false);
|
||||
|
||||
sbs.apply(ref_turn.point);
|
||||
|
||||
// Inspect points, the first right turn has main_rank==1
|
||||
// If this is still from the same source, with no others in between, it
|
||||
// should be discarded
|
||||
signed_size_type const source_index
|
||||
= ref_turn.operations[ref_toi.op_index].seg_id.source_index;
|
||||
for (std::size_t i = 0; i < sbs.m_ranked_points.size(); i++)
|
||||
{
|
||||
const typename sbs_type::rp& ranked_point = sbs.m_ranked_points[i];
|
||||
if (ranked_point.main_rank > 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (ranked_point.seg_id.source_index != source_index)
|
||||
{
|
||||
// Other sources in between or collinear with it, don't discard
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Discard this turn
|
||||
return true;
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
bool Reverse1, bool Reverse2,
|
||||
@ -308,8 +237,6 @@ inline void handle_colocation_cluster(Turns& turns,
|
||||
|
||||
if (ref_op.fraction == op.fraction)
|
||||
{
|
||||
turn_operation_type const& ref_other_op
|
||||
= ref_turn.operations[1 - ref_toi.op_index];
|
||||
turn_operation_type const& other_op = turn.operations[1 - toi.op_index];
|
||||
|
||||
if (ref_id == -1)
|
||||
@ -340,19 +267,6 @@ inline void handle_colocation_cluster(Turns& turns,
|
||||
turn.discarded = true;
|
||||
// We can either set or not set colocated because it is not effective on blocked turns
|
||||
}
|
||||
|
||||
if (ref_turn.both(operation_union)
|
||||
&& ! turn.both(operation_union))
|
||||
{
|
||||
if (other_op.seg_id.multi_index == ref_other_op.seg_id.multi_index
|
||||
&& other_op.seg_id.ring_index == ref_other_op.seg_id.ring_index
|
||||
&& discard_colocated_uu<Reverse1, Reverse2>(id,
|
||||
turns, ref_toi, toi, geometry1, geometry2))
|
||||
{
|
||||
turn.discarded = true;
|
||||
turn.colocated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -601,10 +601,18 @@ static std::string case_recursive_boxes_28[2] =
|
||||
|
||||
static std::string case_recursive_boxes_29[2] =
|
||||
{
|
||||
// Requires not discarding colocated cc turns
|
||||
"MULTIPOLYGON(((2 3,2 4,1 4,2 5,4 5,4 4,3 4,3 3,2 3)),((3 3,4 3,4 1,5 1,5 0,3 0,3 2,2 2,3 3)),((1 2,0 2,0 3,1 3,1 2)),((1 1,0 1,1 2,2 2,2 1,1 1)),((2 1,2 0,1 0,2 1)))",
|
||||
"MULTIPOLYGON(((0 4,0 5,1 4,0 4)),((2 3,2 4,4 4,4 3,2 3)),((2 2,1 2,1 3,2 3,2 2)),((1 2,0 2,0 3,1 3,0.5 2.5,1 2)),((1 0,0 0,1 1,4 1,4 0,1 0)),((4 0,5 1,5 0,4 0)))"
|
||||
};
|
||||
|
||||
static std::string case_recursive_boxes_30[2] =
|
||||
{
|
||||
// Requires not discarding turns colocated with uu/invalid polygons (now not necessary anymore because of startable)
|
||||
"MULTIPOLYGON(((2 2,2 3,4 3,4 4,4.5 3.5,5 4,5 0,3 0,3 1,4 1,4 2,2 2)),((1 5,3 5,4 4,0 4,0 5,1 5)))",
|
||||
"MULTIPOLYGON(((2 1,2 3,1 3,1 4,2 5,2 4,3 4,3 5,5 5,5 4,4 4,3.5 3.5,4 3,4 4,5 3,4.5 2.5,5 2,5 0,4 0,4 2,3 2,3 3,2.5 2.5,4 1,3 1,3 0,1 0,2 1)))"
|
||||
};
|
||||
|
||||
static std::string pie_21_7_21_0_3[2] =
|
||||
{
|
||||
"MULTIPOLYGON(((2500 2500,2500 3875,2855 3828,3187 3690,3472 3472,3690 3187,3828 2855,3875 2500,3828 2144,3690 1812,3472 1527,3187 1309,2855 1171,2499 1125,2144 1171,1812 1309,1527 1527,1309 1812,1171 2144,1125 2499,1171 2855,1309 3187,2500 2500)))",
|
||||
|
@ -213,6 +213,9 @@ void test_areal()
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_29",
|
||||
case_recursive_boxes_29[0], case_recursive_boxes_29[1],
|
||||
5, 0, 3.75);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_30",
|
||||
case_recursive_boxes_30[0], case_recursive_boxes_30[1],
|
||||
4, 0, 6.0);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
|
||||
ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
|
||||
|
@ -204,6 +204,9 @@ void test_areal()
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_29",
|
||||
case_recursive_boxes_29[0], case_recursive_boxes_29[1],
|
||||
2, 0, -1, 15.5);
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_30",
|
||||
case_recursive_boxes_30[0], case_recursive_boxes_30[1],
|
||||
1, 1, -1, 17.5);
|
||||
|
||||
test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
|
||||
ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
|
||||
|
Loading…
x
Reference in New Issue
Block a user