39 #include "config_auto.h"
45 #define SPLIT_CLOSENESS 20
47 #define MAX_NUM_SEAMS 150
49 #define MAX_OLD_SEAMS 150
50 #define NO_FULL_PRIORITY -1
52 #define BAD_PRIORITY 9999.0
64 #define add_seam_to_queue(seams,seam,priority) \
68 junk_worst_seam(seams,seam,priority);\
70 HeapPush (seams, priority, (char*) seam);\
79 #define best_seam_priority(seam_queue) \
80 (HeapEmpty (seam_queue) ? \
82 ((SEAM*) seam_queue_element(seam_queue, 0))->priority)
90 #define create_seam_queue(seam_queue) \
91 (seam_queue = MakeHeap (MAX_NUM_SEAMS))
99 #define create_seam_pile(seam_pile) \
100 (seam_pile = array_new (MAX_OLD_SEAMS))
109 #define delete_seam_queue(seam_queue) \
110 (FreeHeapData (seam_queue, delete_seam), \
122 #define pop_next_seam(seams,seam,priority) \
123 (HeapPop (seams,&priority,&seam) == TESS_HEAP_OK) \
132 #define seam_queue_element(seam_queue,index) \
133 ((index < SizeOfHeap (seam_queue)) ? \
134 HeapDataFor (seam_queue, index) : \
149 float new_priority) {
154 if (priority > new_priority) {
156 HeapPush (seams, new_priority, (
char *) new_seam);
160 HeapPush (seams, priority, (
char *) seam);
188 my_priority = priority;
208 sprintf (str,
"Full my_priority %0.0f, ", my_priority);
212 if ((*seam_result ==
NULL ||
213 (*seam_result)->priority > my_priority) && my_priority <
chop_ok_split) {
218 (*seam_result)->priority = my_priority;
297 inT16 split2_point1_y = 0;
298 inT16 split2_point2_y = 0;
308 ((split1_point1_y >= top1 && split1_point2_y >= top1) ||
309 (split1_point1_y <= bottom1 && split1_point2_y <= bottom1))
311 ((split1_point1_y >= top2 && split1_point2_y >= top2) ||
312 (split1_point1_y <= bottom2 && split1_point2_y <= bottom2))
319 ((split2_point1_y >= top1 && split2_point2_y >= top1) ||
320 (split2_point1_y <= bottom1 && split2_point2_y <= bottom1))
322 ((split2_point1_y >= top2 && split2_point2_y >= top2) ||
323 (split2_point1_y <= bottom2 && split2_point2_y <= bottom2))
349 for (outline = blob->
outlines; outline; outline = outline->
next) {
387 EDGEPT_CLIST new_points;
390 inT16 num_points = 0;
392 #ifndef GRAPHICS_DISABLED
400 for (outline = blob->
outlines; outline; outline = outline->
next)
405 points[num_points++] = (
EDGEPT *) edge;
413 try_point_pairs(points, num_points, seam_queue, &seam_pile, &seam, blob);
415 seam_queue, &seam_pile, &seam, blob);
425 EDGEPT_C_IT it(&new_points);
426 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
427 EDGEPT *inserted_point = it.data();
429 for (outline = blob->
outlines; outline; outline = outline->
next) {
430 if (outline->
loop == inserted_point) {
446 #ifndef GRAPHICS_DISABLED
523 for (x = 0; x < num_points; x++) {
524 for (y = x + 1; y < num_points; y++) {
529 points[x] != points[y]->next &&
530 points[y] != points[x]->next &&
533 split =
new_split (points[x], points[y]);
556 EDGEPT_CLIST *new_points,
567 for (x = 0; x < num_points; x++) {
568 vertical_point =
NULL;
569 for (outline = blob->
outlines; outline; outline = outline->
next) {
571 &vertical_point, new_points);
574 if (vertical_point &&
575 points[x] != vertical_point->
next &&
576 vertical_point != points[x]->
next &&
580 split =
new_split (points[x], vertical_point);