17 #ifndef GCALC_SLICESCAN_INCLUDED
18 #define GCALC_SLICESCAN_INCLUDED
42 uint item_id()
const {
return m_item_id; }
43 void set_item_id(uint
id) { m_item_id=
id; }
54 if (!m_free && alloc_new_blk())
62 result->set_item_id(++m_last_item_id);
67 inline void free_item(
Item *item)
72 inline void free_list(
Item *list,
Item **hook)
78 void free_list(
Item *list)
83 free_list(list, hook);
92 unsigned int m_points_per_blk;
99 void format_blk(
void*
block);
100 inline Item *ptr_add(
Item *ptr,
int n_items)
102 return (
Item *)(((
char*)ptr) + n_items * m_sizeof_item);
106 typedef uint gcalc_shape_info;
125 gcalc_shape_info shape;
130 inline bool is_bottom()
const {
return !left; }
131 inline Info *get_next() {
return (
Info *)next; }
132 inline const Info *get_next()
const {
return (
const Info *)next; }
134 inline void dbug_print()
const;
140 Info *new_point_info(
double x,
double y, gcalc_shape_info shape)
142 Info *result= (Info *)new_item();
146 m_hook= &result->next;
150 result->shape= shape;
153 void prepare_operation();
154 inline bool ready()
const {
return m_hook == NULL; }
155 Info *get_first() {
return (Info *)m_first; }
156 const Info *get_first()
const {
return (
const Info *)m_first; }
175 int m_last_shape_pos;
208 int int_single_point(gcalc_shape_info Info,
double x,
double y);
209 int int_add_point(gcalc_shape_info Info,
double x,
double y);
210 void int_start_line()
212 DBUG_ASSERT(!m_shape_started);
214 m_first= m_prev= NULL;
216 void int_complete_line()
218 DBUG_ASSERT(m_shape_started== 1);
222 void int_start_ring()
224 DBUG_ASSERT(m_shape_started== 2);
226 m_first= m_prev= NULL;
228 void int_complete_ring()
230 DBUG_ASSERT(m_shape_started== 3);
234 void int_start_poly()
236 DBUG_ASSERT(!m_shape_started);
239 void int_complete_poly()
241 DBUG_ASSERT(m_shape_started== 2);
244 bool line_started() {
return m_shape_started == 1; };
247 m_shape_started(0), m_heap(heap) {}
264 return start_poly(st) || start_ring(st);
268 return complete_ring(st) || complete_poly(st);
278 virtual bool skip_point()
const {
return false; }
279 virtual bool skip_line_string()
const {
return false; }
280 virtual bool skip_poly()
const {
return false; }
286 enum Gcalc_scan_events
291 scev_intersection= 8,
294 scev_single_point= 64
298 const char *Gcalc_scan_event_name(
enum Gcalc_scan_events
event);
301 typedef int sc_thread_id;
324 const point *precursor;
326 inline const point *c_get_next()
const
327 {
return (
const point *)next; }
328 inline bool is_bottom()
const {
return pi->is_bottom(); }
329 gcalc_shape_info get_shape()
const {
return pi->shape; }
330 inline point *get_next() {
return (
point *)next; }
331 inline const point *get_next()
const {
return (
const point *)next; }
334 void copy_core(
const point *from)
337 horiz_dir= from->horiz_dir;
339 next_pi= from->next_pi;
340 thread= from->thread;
343 inline void dbug_print_slice(
double y,
enum Gcalc_scan_events
event)
const;
350 sc_thread_id thread_a;
351 sc_thread_id thread_b;
364 DBUG_ASSERT(more_points());
365 return m_cur_intersection ? intersection_scan() : normal_scan();
369 inline bool more_trapezoids()
370 {
return m_cur_pi && m_cur_pi->next; }
372 inline Gcalc_scan_events get_event()
const {
return m_event0; }
373 inline const point *get_event_position()
const
374 {
return m_event_position0; }
375 inline const point *get_b_slice()
const {
return m_slice0; }
376 inline const point *get_t_slice()
const {
return m_slice1; }
377 inline double get_h()
const {
return m_h; }
378 inline double get_y()
const {
return m_y0; }
385 intersection *m_intersections;
386 int m_n_intersections;
387 intersection *m_cur_intersection;
388 point **m_pre_intersection_hook;
393 bool m_next_is_top_point;
394 unsigned int m_bottom_points_count;
395 sc_thread_id m_cur_thread;
396 Gcalc_scan_events m_event0, m_event1;
397 point *m_event_position0;
398 point *m_event_position1;
401 int intersection_scan();
402 void sort_intersections();
403 int handle_intersections();
404 int insert_top_point();
405 int add_intersection(
const point *a,
const point *b,
407 int find_intersections();
408 void pop_suitable_intersection();
410 intersection *new_intersection()
412 return (intersection *)new_item();
414 point *new_slice_point()
416 return (point *)new_item();
418 point *new_slice(point *example);
436 sp0(scan_i->get_b_slice()),
437 sp1(scan_i->get_t_slice())
440 inline bool more()
const {
return sp1 && sp1->next; }
447 while ((result= result->c_get_next())->is_bottom())
452 {
return sp1->c_get_next(); }
474 sp(scan_i->get_b_slice())
477 inline bool more()
const {
return sp != NULL; }
478 inline void operator++() { sp= sp->c_get_next(); }
481 inline gcalc_shape_info get_shape()
const {
return sp->get_shape(); }
482 inline double get_x()
const {
return sp->x; }