YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
int Gcalc_function::check_function(Gcalc_scan_iterator &scan_it)
{ const Gcalc_scan_iterator::point *eq_start, *cur_eq; const Gcalc_scan_iterator::event_point *events; int result;
GCALC_DBUG_ENTER("Gcalc_function::check_function");
while (scan_it.more_points())
{ if (scan_it.step())
GCALC_DBUG_RETURN(-1);
events= scan_it.get_events();
/* these kinds of events don't change the function */
Gcalc_point_iterator pit(&scan_it);
clear_b_states();
clear_i_states(); /* Walk to the event, marking polygons we met */ for (; pit.point() != scan_it.get_event_position(); ++pit)
{
gcalc_shape_info si= pit.point()->get_shape(); if ((get_shape_kind(si) == Gcalc_function::shape_polygon))
invert_i_state(si);
} if (events->simple_event())
{ if (events->event == scev_end)
set_b_state(events->get_shape());
if ((result= count()) != result_unknown)
GCALC_DBUG_RETURN(result);
clear_b_states(); continue;
}
/* Check the status of the event point */ for (; events; events= events->get_next())
{
gcalc_shape_info si= events->get_shape(); if (events->event == scev_thread ||
events->event == scev_end ||
(get_shape_kind(si) == Gcalc_function::shape_polygon))
set_b_state(si); elseif (events->event == scev_single_point ||
get_shape_kind(si) == Gcalc_function::shape_line)
set_i_state(si);
}
if ((result= count()) != result_unknown)
GCALC_DBUG_RETURN(result);
/* Set back states changed in the loop above. */ for (events= scan_it.get_events(); events; events= events->get_next())
{
gcalc_shape_info si= events->get_shape(); if (events->event == scev_thread ||
events->event == scev_end ||
get_shape_kind(si) == Gcalc_function::shape_polygon)
clear_b_state(si); elseif (events->event == scev_single_point ||
get_shape_kind(si) == Gcalc_function::shape_line)
clear_i_state(si);
}
if (scan_it.get_event_position() == scan_it.get_event_end()) continue;
/* Check the status after the event */
eq_start= pit.point(); do
{
++pit; if (pit.point() != scan_it.get_event_end() &&
eq_start->cmp_dx_dy(pit.point()) == 0) continue; for (cur_eq= eq_start; cur_eq != pit.point();
cur_eq= cur_eq->get_next())
{
gcalc_shape_info si= cur_eq->get_shape(); if (get_shape_kind(si) == Gcalc_function::shape_polygon)
set_b_state(si); else
invert_i_state(si);
} if ((result= count()) != result_unknown)
GCALC_DBUG_RETURN(result);
for (cur_eq= eq_start; cur_eq != pit.point(); cur_eq= cur_eq->get_next())
{
gcalc_shape_info si= cur_eq->get_shape(); if ((get_shape_kind(si) == Gcalc_function::shape_polygon))
{
clear_b_state(si);
invert_i_state(si);
} else
invert_i_state(cur_eq->get_shape());
} if ((result= count()) != result_unknown)
GCALC_DBUG_RETURN(result);
eq_start= pit.point();
} while (pit.point() != scan_it.get_event_end());
}
GCALC_DBUG_RETURN(count_last());
}
int Gcalc_result_receiver::add_point(double x, double y)
{
GCALC_DBUG_ENTER("Gcalc_result_receiver::add_point"); if (n_points && x == prev_x && y == prev_y)
GCALC_DBUG_RETURN(0);
/* Walk through the event, collecting all the 'incoming' threads */ for (; events; events= events->get_next())
{
active_thread *cur_t= *cur_t_hook;
if (events->event == scev_single_point) continue;
if (events->event == scev_thread ||
events->event == scev_two_threads)
{
active_thread *new_t= new_active_thread(); if (!new_t)
GCALC_DBUG_RETURN(1);
new_t->rp= NULL; /* Insert into the main thread list before the current */
new_t->next= cur_t;
*cur_t_hook= new_t;
cur_t_hook= (active_thread **) &new_t->next;
} else
{ if (events->is_bottom())
{ /* Move thread from the main list to the bottom_threads. */
*cur_t_hook= cur_t->get_next();
cur_t->next= bottom_threads;
bottom_threads= cur_t;
} if (cur_t->enabled())
{ if (cur_t->rp->type == Gcalc_function::shape_line)
{
GCALC_DBUG_ASSERT(!prev_state);
add_line(1, cur_t, events);
} else
{
add_poly_border(1, cur_t, prev_state, events);
prev_state^= 1;
prev_range= prev_state ? cur_t : 0;
} if (!events->is_bottom())
{
active_thread *new_t= new_active_thread(); if (!new_t)
GCALC_DBUG_RETURN(1);
new_t->rp= NULL; /* Replace the current thread with the new. */
new_t->next= cur_t->next;
*cur_t_hook= new_t;
cur_t_hook= (active_thread **) &new_t->next; /* And move old to the bottom list */
cur_t->next= bottom_threads;
bottom_threads= cur_t;
}
} elseif (!events->is_bottom())
cur_t_hook= (active_thread **) &cur_t->next;
}
}
prev_state= sav_prev_state;
cur_t_hook= starting_t_hook;
eq_start= pi.point();
eq_thread= point_thread= *starting_t_hook;
m_fn->clear_b_states(); while (eq_start != si->get_event_end())
{ const Gcalc_scan_iterator::point *cur_eq; int in_state, after_state;
++pi;
point_thread= point_thread->get_next();
if (pi.point() != si->get_event_end() &&
eq_start->cmp_dx_dy(pi.point()) == 0) continue;
if (!sav_prev_state && !m_poly_borders && !m_lines)
{ /* Check if we need to add the event point itself */
m_fn->clear_i_states(); /* b_states supposed to be clean already */ for (pi.restart(si); pi.point() != si->get_event_position(); ++pi)
{ if (m_fn->get_shape_kind(pi.get_shape()) == Gcalc_function::shape_polygon)
m_fn->invert_i_state(pi.get_shape());
} for (events= si->get_events(); events; events= events->get_next())
m_fn->set_b_state(events->get_shape());
if (m_lines)
{
*m_lines_hook= NULL; if (m_lines->get_next() &&
!m_lines->get_next()->get_next())
{ if (connect_threads(m_lines->incoming, m_lines->get_next()->incoming,
m_lines->t, m_lines->get_next()->t,
m_lines->p, m_lines->get_next()->p,
NULL, si, Gcalc_function::shape_line))
GCALC_DBUG_RETURN(1);
} else
{ for (line *cur_line= m_lines; cur_line; cur_line= cur_line->get_next())
{ if (cur_line->incoming)
{ if (end_line(cur_line->t, si))
GCALC_DBUG_RETURN(1);
} else
start_line(cur_line->t, cur_line->p, si);
}
}
free_list(m_lines);
m_lines= NULL;
m_lines_hook= (Gcalc_dyn_list::Item **) &m_lines;
}
if (bottom_threads)
free_list(bottom_threads);
GCALC_DBUG_RETURN(0);
}
int Gcalc_operation_reducer::add_single_point(const Gcalc_scan_iterator *si)
{
res_point *rp= add_res_point(Gcalc_function::shape_point);
GCALC_DBUG_ENTER("Gcalc_operation_reducer::add_single_point"); if (!rp)
GCALC_DBUG_RETURN(1);
rp->glue= rp->up= rp->down= NULL;
rp->set(si);
GCALC_DBUG_RETURN(0);
}
Gcalc_operation_reducer::poly_border
*Gcalc_operation_reducer::get_pair_border(poly_border *b1)
{
poly_border *prev_b= b1;
poly_border *result= b1->get_next();
GCALC_DBUG_ENTER("Gcalc_operation_reducer::get_pair_border"); if (b1->prev_state)
{ if (b1->incoming)
{ /* Find the first outgoing, otherwise the last one. */ while (result->incoming && result->get_next())
{
prev_b= result;
result= result->get_next();
}
} else
{ /* Get the last one */ while (result->get_next())
{
prev_b= result;
result= result->get_next();
}
}
} else/* !b1->prev_state */
{ if (b1->incoming)
{ /* Get the next incoming, otherwise the last one. */ while (!result->incoming && result->get_next())
{
prev_b= result;
result= result->get_next();
}
} else
{ /* Just pick the next one */
}
} /* Delete the result from the list. */
prev_b->next= result->next;
GCALC_DBUG_RETURN(result);
}
int Gcalc_operation_reducer::get_line_result(res_point *cur,
Gcalc_result_receiver *storage)
{
res_point *next;
res_point *cur_orig= cur; int move_upward= 1;
GCALC_DBUG_ENTER("Gcalc_operation_reducer::get_line_result"); if (cur->glue)
{ /* Here we have to find the beginning of the line */
next= cur->up;
move_upward= 1; while (next)
{
cur= next;
next= move_upward ? next->up : next->down; if (!next)
{
next= cur->glue; if (next == cur_orig)
{ /* It's the line loop */
cur= cur_orig;
cur->glue->glue= NULL;
move_upward= 1; break;
}
move_upward^= 1;
}
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.95Bemerkung:
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.