fixed a bug in the construction visitor (tried to access an event that was freed)

This commit is contained in:
Baruch Zukerman 2006-06-27 13:50:59 +00:00
parent 0134eb0995
commit 35d98052ba
2 changed files with 20 additions and 14 deletions

View File

@ -485,9 +485,6 @@ public:
_init_endpoint(curve, MAX_END, m_subCurves+index); _init_endpoint(curve, MAX_END, m_subCurves+index);
_init_endpoint(curve, MIN_END, m_subCurves+index); _init_endpoint(curve, MIN_END, m_subCurves+index);
/*(m_subCurves+index)->set_left_event(left_event);
(m_subCurves+index)->set_right_event(right_event);*/
return; return;
} }
@ -901,7 +898,7 @@ protected:
// We have a new event // We have a new event
Point_2 pt = Point_2(); Point_2 pt = Point_2();
e = allocate_event(pt, type); e = allocate_event(pt, type);
_set_attributes_of_infinity(e, x_inf, y_inf, ind); _set_attributes_of_infinity(e, x_inf, y_inf);
if(sc != NULL) if(sc != NULL)
{ {
if(type == Base_event::LEFT_END) if(type == Base_event::LEFT_END)
@ -922,7 +919,7 @@ protected:
// The event already exsits // The event already exsits
e = *(pair_res.first); e = *(pair_res.first);
e->set_attribute(type); e->set_attribute(type);
_set_attributes_of_infinity(e, x_inf, y_inf, ind); _set_attributes_of_infinity(e, x_inf, y_inf);
if(sc != NULL) if(sc != NULL)
{ {
if(type == Base_event::LEFT_END) if(type == Base_event::LEFT_END)
@ -938,14 +935,12 @@ protected:
} }
} }
return (std::make_pair(e, !exist)); return (std::make_pair(e, !exist));
} }
void _set_attributes_of_infinity(Event* e, void _set_attributes_of_infinity(Event* e,
Infinity_type x_inf, Infinity_type x_inf,
Infinity_type y_inf, Infinity_type y_inf)
Curve_end ind)
{ {
if(x_inf == MINUS_INFINITY) if(x_inf == MINUS_INFINITY)
e->set_minus_infinite_x(); e->set_minus_infinite_x();

View File

@ -96,10 +96,6 @@ protected:
Event* m_prev_minus_inf_x_event; Event* m_prev_minus_inf_x_event;
Event* m_prev_plus_inf_y_event; Event* m_prev_plus_inf_y_event;
private: private:
Arr_construction_visitor (const Self& ); Arr_construction_visitor (const Self& );
@ -193,7 +189,10 @@ public:
} }
if(event->get_num_right_curves() == 0) if(event->get_num_right_curves() == 0)
{
set_prev_inf_event_to_null(event);
return true; return true;
}
event->get_is_curve_in_arr().resize(event->get_num_right_curves(),false); event->get_is_curve_in_arr().resize(event->get_num_right_curves(),false);
for(SubCurveIter itr = event->right_curves_begin(); for(SubCurveIter itr = event->right_curves_begin();
@ -244,6 +243,8 @@ public:
CGAL_assertion(prev->face() == hhandle->face()); CGAL_assertion(prev->face() == hhandle->face());
bool dummy; bool dummy;
res = this->insert_at_vertices(cv,hhandle,prev,sc, dummy); res = this->insert_at_vertices(cv,hhandle,prev,sc, dummy);
res = res->twin(); res = res->twin();
} }
@ -269,6 +270,7 @@ public:
if(lastEvent->dec_right_curves_counter() == 0) if(lastEvent->dec_right_curves_counter() == 0)
{ {
set_prev_inf_event_to_null(lastEvent);
(this ->deallocate_event(lastEvent)); (this ->deallocate_event(lastEvent));
} }
@ -479,7 +481,7 @@ public:
case MINUS_INFINITY: case MINUS_INFINITY:
m_arr_access.split_fictitious_edge(m_lh, v_at_inf); m_arr_access.split_fictitious_edge(m_lh, v_at_inf);
event->set_halfedge_handle(m_lh); event->set_halfedge_handle(m_lh);
if(m_prev_minus_inf_x_event != NULL) if(m_prev_minus_inf_x_event)
m_prev_minus_inf_x_event->set_halfedge_handle(m_lh->next()); m_prev_minus_inf_x_event->set_halfedge_handle(m_lh->next());
m_prev_minus_inf_x_event = event; m_prev_minus_inf_x_event = event;
return; return;
@ -564,6 +566,15 @@ private:
m_sc_he_table[i] = he; m_sc_he_table[i] = he;
} }
void set_prev_inf_event_to_null(Event* e)
{
if(e == m_prev_minus_inf_x_event)
m_prev_minus_inf_x_event = NULL;
else
if(e == m_prev_plus_inf_y_event)
m_prev_plus_inf_y_event = NULL;
}
}; };
CGAL_END_NAMESPACE CGAL_END_NAMESPACE