mirror of https://github.com/CGAL/cgal
Handle "right" folds
The following configurations of collinear points: x-2 x x-1 AND x+2 x x+1 cannot be handled with the typical left swap because the interval has range n-1. Instead, just manually swap like it is done when the fold is on the left (which can and is immediately detected at the beginning of the insertion event)
This commit is contained in:
parent
f650c2f467
commit
bea5995756
|
|
@ -179,6 +179,52 @@ less_than_in_tree(Vertex_index new_edge, Vertex_index tree_edge) const
|
||||||
m_vertex_data->point(mid),
|
m_vertex_data->point(mid),
|
||||||
m_vertex_data->point(right)));
|
m_vertex_data->point(right)));
|
||||||
m_vertex_data->is_simple_result = false;
|
m_vertex_data->is_simple_result = false;
|
||||||
|
|
||||||
|
// need to handle the specific combinations:
|
||||||
|
// as the standard x;x+k swap (see below) will not work
|
||||||
|
if (m_vertex_data->edges[tree_edge.as_int()].is_left_to_right)
|
||||||
|
{
|
||||||
|
// x+1 x x+2
|
||||||
|
// This is actually already handled in the insertion event, when the orientation returns "COPLANAR"
|
||||||
|
// but leaving the code below for completion.
|
||||||
|
if (m_vertex_data->next(mid) == left || m_vertex_data->next(mid) == right)
|
||||||
|
{
|
||||||
|
// swap mid & left
|
||||||
|
m_vertex_data->conflict1 = m_vertex_data->prev(mid);
|
||||||
|
m_vertex_data->conflict2 = left;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// x-2 x x-1
|
||||||
|
else if (m_vertex_data->prev(mid) == left || m_vertex_data->prev(mid) == right)
|
||||||
|
{
|
||||||
|
// swap mid & right
|
||||||
|
m_vertex_data->conflict1 = left;
|
||||||
|
m_vertex_data->conflict2 = mid;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // right to left
|
||||||
|
{
|
||||||
|
// x+2 x x+1
|
||||||
|
if (m_vertex_data->next(mid) == left || m_vertex_data->next(mid) == right)
|
||||||
|
{
|
||||||
|
// swap mid & right
|
||||||
|
m_vertex_data->conflict1 = m_vertex_data->prev(mid);
|
||||||
|
m_vertex_data->conflict2 = right;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// x-1 x x-2
|
||||||
|
// This is actually already handled in the insertion event, when the orientation returns "COPLANAR"
|
||||||
|
// but leaving the code below for completion.
|
||||||
|
else if (m_vertex_data->prev(mid) == left || m_vertex_data->prev(mid) == right)
|
||||||
|
{
|
||||||
|
// swap mid & left
|
||||||
|
m_vertex_data->conflict1 = right;
|
||||||
|
m_vertex_data->conflict2 = mid;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vertex_index mid_succ = m_vertex_data->next(mid);
|
Vertex_index mid_succ = m_vertex_data->next(mid);
|
||||||
if (mid_succ.as_int() <= (std::min)(left.as_int(), right.as_int()))
|
if (mid_succ.as_int() <= (std::min)(left.as_int(), right.as_int()))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,8 @@ struct Vertex_index {
|
||||||
explicit Vertex_index(Index_t i): m_i(i) {}
|
explicit Vertex_index(Index_t i): m_i(i) {}
|
||||||
Index_t as_int() const {return m_i;}
|
Index_t as_int() const {return m_i;}
|
||||||
Vertex_index operator++() {++m_i; return *this; }
|
Vertex_index operator++() {++m_i; return *this; }
|
||||||
|
bool operator==(const Vertex_index& other) const = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Index_t m_i;
|
Index_t m_i;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue