BUGFIX: in Make_x_monotone_2 corrected a problem

Previously if the polyline went vertically up->down->up (again) then
it wouldn't be split. This was now corrected.
This commit is contained in:
Dror Atariah 2013-04-19 16:17:52 +02:00
parent 799df6c8b7
commit 59ebc5d5f2
1 changed files with 18 additions and 32 deletions

View File

@ -561,40 +561,26 @@ public:
for (/*it_next was advanced earlier*/; it_next != end_seg; ++it_next)
{
if ( is_start_vertical )
// TODO: Improve this test. Avoid double tests
// of geometrical elements.
// Without having the tag HAS_SOURCE_TARGET it seems that
// these tests cannot be simplified!
if (
// Polyline changes direction (zig-zag)
((comp_xy(get_max_v(*it_curr), get_min_v(*it_next)) != EQUAL) &&
(comp_xy(get_min_v(*it_curr), get_max_v(*it_next)) != EQUAL)
) ||
// or, polyline changes it vertical-ness
(is_vertical(*it_curr) != is_vertical(*it_next)) )
{
if ( !is_vertical(*it_next) )
{
*oi++ =
make_object(construct_x_monotone_curve(it_start, it_next));
it_start = it_next;
is_start_vertical = is_vertical(*it_start);
}
it_curr = it_next;
}
else
{
// TODO: Improve this test. Avoid double tests
// of geometrical elements.
// Without having the tag HAS_SOURCE_TARGET it seems that
// these tests cannot be simplified!
if (
((comp_xy(get_max_v(*it_curr), get_min_v(*it_next)) != EQUAL) &&
(comp_xy(get_min_v(*it_curr), get_max_v(*it_next)) != EQUAL)
) ||
// Polyline has to be cut when starting vertical part
is_vertical(*it_next) )
{
// Construct an x-monotone curve from the sub-range which
// was found
*oi++ =
make_object(construct_x_monotone_curve(it_start, it_next));
it_start = it_next;
is_start_vertical = is_vertical(*it_start);
}
it_curr = it_next;
// Construct an x-monotone curve from the sub-range which
// was found
*oi++ =
make_object(construct_x_monotone_curve(it_start, it_next));
it_start = it_next;
is_start_vertical = is_vertical(*it_start);
}
it_curr = it_next;
}
*oi++ = make_object(construct_x_monotone_curve(it_start, it_next));
return oi;