17 #ifndef GCALC_TOOLS_INCLUDED
18 #define GCALC_TOOLS_INCLUDED
20 #include "gcalc_slicescan.h"
44 static const uint32 function_buffer_item_size= 4;
45 static const uint32 shape_buffer_item_size= 4;
69 op_intersection= 0x20000000,
70 op_symdifference= 0x30000000,
71 op_difference= 0x40000000,
72 op_backdifference= 0x50000000,
83 gcalc_shape_info add_new_shape(uint32 shape_id, shape_type shape_kind);
88 int single_shape_op(shape_type shape_kind, gcalc_shape_info *si);
89 void add_operation(op_type operation, uint32 n_operands);
90 void add_not_operation(op_type operation, uint32 n_operands);
91 uint32 get_next_operation_pos() {
return function_buffer.length(); }
100 void set_cur_obj(uint32 cur_obj) { cur_object_id= cur_obj; }
101 int reserve_shape_buffer(uint n_shapes);
102 int reserve_op_buffer(uint n_ops);
103 uint get_nshapes()
const {
return n_shapes; }
104 shape_type get_shape_kind(gcalc_shape_info si)
const
106 return (shape_type) uint4korr(shapes_buffer.ptr() + (si*4));
109 void set_states(
int *shape_states) { i_states= shape_states; }
111 void invert_state(gcalc_shape_info shape) { i_states[shape]^= 1; }
112 int get_state(gcalc_shape_info shape) {
return i_states[shape]; }
115 cur_func= function_buffer.ptr();
116 return count_internal();
118 void clear_state() { memset(i_states, 0, n_shapes *
sizeof(
int)); }
146 gcalc_shape_info m_si;
179 Gcalc_function::shape_type common_shapetype;
180 bool collection_result;
184 Gcalc_function::shape_type cur_shape;
186 double first_x, first_y, prev_x, prev_y;
199 inline void dbug_print()
const;
205 int start_shape(Gcalc_function::shape_type shape);
206 int add_point(
double x,
double y);
207 int complete_shape();
208 int single_point(
double x,
double y);
212 const char *result() {
return buffer.ptr(); }
213 uint length() {
return buffer.length(); }
214 int get_nshapes() {
return n_shapes; }
215 int get_nholes() {
return n_holes; }
216 int get_result_typeid();
217 uint32 position() {
return buffer.length(); }
218 int reorder_chunks(chunk_info *chunks,
int nchunks);
236 prefer_big_with_holes= 1,
237 polygon_selfintersections_allowed= 2,
238 line_selfintersections_allowed= 4
244 size_t blk_size=8192);
254 bool intersection_point;
269 DBUG_PRINT(
"info", (
"setting outer_poly of #%u to #%u",
271 m_outer_poly ? m_outer_poly->item_id() : 0));
273 res_point *get_outer_poly() {
return m_outer_poly; }
284 rp= m_thread_start= NULL;
286 DBUG_PRINT(
"info", (
"setting m_thread_start of #%u to NULL (reset)",
292 DBUG_PRINT(
"info", (
"setting m_thread_start of #%u to #%u",
293 item_id(), p ? p->item_id() : 0));
296 res_point *thread_start()
const {
return m_thread_start; }
313 DBUG_PRINT(
"info", (
"add_res_point #%u: pi=(%g,%g,#%u)",
314 rp->item_id(), pi->x, pi->y, pi->shape));
320 res_point *rp= new_res_point(pi,
true);
323 DBUG_PRINT(
"info", (
"add_res_i_point #%u: pi=(%g,%g,#%u) xy=(%g,%g)",
324 rp->item_id(), pi->x, pi->y, pi->shape, x, y));
332 res_point *rp= new_res_point(pi,
false);
335 DBUG_PRINT(
"info", (
"add_res_single_point #%u: pi=(%g,%g,#%u)",
336 rp->item_id(), pi->x, pi->y, pi->shape));
342 active_thread *new_active_thread()
344 active_thread *tmp= (active_thread *) new_item();
353 bool intersection_point)
355 res_point *result= (res_point *) new_item();
357 result->prev_hook= m_res_hook;
358 m_res_hook= &result->next;
360 result->intersection_point= intersection_point;
373 int start_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p,
374 const active_thread *prev_range);
375 int start_i_couple(active_thread *t0, active_thread *t1,
379 const active_thread *prev_range);
380 int end_couple(active_thread *t0, active_thread *t1,
const Gcalc_heap::Info *p);
381 int end_i_couple(active_thread *t0, active_thread *t1,
388 int handle_lines_intersection(active_thread *t0, active_thread *t1,
392 int handle_polygons_intersection(active_thread *t0, active_thread *t1,
396 int prev_state,
double x,
double y,
397 const active_thread *prev_range);
398 int handle_line_polygon_intersection(active_thread *l,
400 int line_state,
int poly_state,
409 void free_result(res_point *res);