30 #include "config_auto.h"
41 #define partial_split_priority(split) \
42 (grade_split_length(split) + grade_sharpness(split))
47 #define SPLIT_CLOSENESS 20
49 #define MAX_NUM_SEAMS 150
51 #define NO_FULL_PRIORITY -1
53 #define BAD_PRIORITY 9999.0
68 if (new_seam ==
nullptr)
return;
70 tprintf(
"Pushing new seam with priority %g :", new_priority);
71 new_seam->
Print(
"seam: ");
75 if (seams->
PopWorst(&old_pair) && old_pair.
key() <= new_priority) {
77 tprintf(
"Old seam staying with priority %g\n", old_pair.
key());
80 seams->
Push(&old_pair);
83 tprintf(
"New seam with priority %g beats old worst seam with %g\n",
84 new_priority, old_pair.
key());
87 SeamPair new_pair(new_priority, new_seam);
88 seams->
Push(&new_pair);
112 my_priority = priority;
113 if (split !=
nullptr) {
117 seam =
new SEAM(my_priority, split_point, *split);
127 while (!seam_queue->
empty()) {
129 seam_queue->
Pop(&seam_pair);
136 sprintf (str,
"Full my_priority %0.0f, ", my_priority);
140 if ((*seam_result ==
nullptr || (*seam_result)->
priority() > my_priority) &&
146 *seam_result =
new SEAM(*seam);
147 (*seam_result)->set_priority(my_priority);
165 seam_pile->
Push(&pair);
168 seam_pile->
PeekTop().key() > seam_pair.
key()) {
171 seam_pile->
Pop(&pair);
176 seam_pile->
Push(&pair);
200 for (
int x = 0; x < seam_pile.
size(); ++x) {
201 const SEAM *this_one = seam_pile.
get(x).data();
220 EDGEPT_CLIST new_points;
221 SEAM *seam =
nullptr;
223 int16_t num_points = 0;
225 #ifndef GRAPHICS_DISABLED
233 for (outline = blob->
outlines; outline; outline = outline->
next)
237 points[num_points++] = point_heap.
PeekTop().data;
238 point_heap.
Pop(
nullptr);
244 try_point_pairs(points, num_points, &seam_queue, &seam_pile, &seam, blob);
246 &seam_queue, &seam_pile, &seam, blob);
248 if (seam ==
nullptr) {
255 EDGEPT_C_IT it(&new_points);
256 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
257 EDGEPT *inserted_point = it.data();
258 if (seam ==
nullptr || !seam->
UsesPoint(inserted_point)) {
259 for (outline = blob->
outlines; outline; outline = outline->
next) {
260 if (outline->
loop == inserted_point) {
273 #ifndef GRAPHICS_DISABLED
308 for (x = 0; x < num_points; x++) {
309 for (y = x + 1; y < num_points; y++) {
313 points[x] != points[y]->next && points[y] != points[x]->next &&
316 SPLIT split(points[x], points[y]);
338 EDGEPT_CLIST *new_points,
343 EDGEPT *vertical_point =
nullptr;
348 for (x = 0; x < num_points; x++) {
349 vertical_point =
nullptr;
350 for (outline = blob->
outlines; outline; outline = outline->
next) {
352 &vertical_point, new_points);
355 if (vertical_point && points[x] != vertical_point->
next &&
356 vertical_point != points[x]->
next &&
359 SPLIT split(points[x], vertical_point);