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);
void combine_seam(SEAM_QUEUE seam_queue, SEAM_PILE seam_pile, SEAM *seam)
ARRAY array_push(ARRAY array, void *value)
void HeapPush(HEAP *Heap, FLOAT32 Key, void *Data)
#define split_bounds_overlap(split, outline)
void split_outline(EDGEPT *join_point1, EDGEPT *join_point2)
PRIORITY full_split_priority(SPLIT *split, inT16 xmin, inT16 xmax)
#define pop_next_seam(seams, seam, priority)
void delete_seam_pile(SEAM_PILE seam_pile)
bool point_used_by_seam(SEAM *seam, EDGEPT *point)
void remove_edgept(EDGEPT *point)
inT16 constrained_split(SPLIT *split, TBLOB *blob)
SEAM * join_two_seams(SEAM *seam1, SEAM *seam2)
HEAP * MakeHeap(int Size)
int is_little_chunk(EDGEPT *point1, EDGEPT *point2)
void junk_worst_seam(SEAM_QUEUE seams, SEAM *new_seam, float new_priority)
void unsplit_outlines(EDGEPT *p1, EDGEPT *p2)
#define update_edge_window()
#define best_seam_priority(seam_queue)
int HeapPop(HEAP *Heap, FLOAT32 *Key, void *out_ptr)
#define create_seam_queue(seam_queue)
void prioritize_points(TESSLINE *outline, POINT_GROUP points)
#define delete_seam_queue(seam_queue)
int crosses_outline(EDGEPT *p0, EDGEPT *p1, EDGEPT *outline)
void delete_seam(void *arg)
#define add_seam_to_queue(seams, seam, priority)
#define clone_seam(dest, source)
void vertical_projection_point(EDGEPT *split_point, EDGEPT *target_point, EDGEPT **best_point, EDGEPT_CLIST *new_points)
TBOX bounding_box() const
#define is_exterior_point(edge, point)
#define partial_split_priority(split)
PRIORITY seam_priority(SEAM *seam, inT16 xmin, inT16 xmax)
#define create_seam_pile(seam_pile)
void try_vertical_splits(EDGEPT *points[MAX_NUM_POINTS], inT16 num_points, EDGEPT_CLIST *new_points, SEAM_QUEUE seam_queue, SEAM_PILE *seam_pile, SEAM **seam, TBLOB *blob)
bool wordrec_display_splits
#define edge_window_wait()
SEAM * new_seam(PRIORITY priority, const TPOINT &location, SPLIT *split1, SPLIT *split2, SPLIT *split3)
void try_point_pairs(EDGEPT *points[MAX_NUM_POINTS], inT16 num_points, SEAM_QUEUE seam_queue, SEAM_PILE *seam_pile, SEAM **seam, TBLOB *blob)
#define array_value(a, i)
SEAM * pick_good_seam(TBLOB *blob)
void mark_split(SPLIT *split)
SPLIT * new_split(EDGEPT *point1, EDGEPT *point2)
void draw_blob_edges(TBLOB *blob)
void print_seam(const char *label, SEAM *seam)
int HeapPopWorst(HEAP *Heap, FLOAT32 *Key, void *out_ptr)
void choose_best_seam(SEAM_QUEUE seam_queue, SEAM_PILE *seam_pile, SPLIT *split, PRIORITY priority, SEAM **seam_result, TBLOB *blob)
#define weighted_edgept_dist(p1, p2, chop_x_y_weight)