29 #include "config_auto.h"
40 #define partial_split_priority(split) \
41 (grade_split_length(split) + grade_sharpness(split))
46 #define SPLIT_CLOSENESS 20
48 #define MAX_NUM_SEAMS 150
50 #define NO_FULL_PRIORITY -1
52 #define BAD_PRIORITY 9999.0
67 if (new_seam ==
nullptr)
return;
69 tprintf(
"Pushing new seam with priority %g :", new_priority);
70 new_seam->
Print(
"seam: ");
74 if (seams->
PopWorst(&old_pair) && old_pair.
key() <= new_priority) {
76 tprintf(
"Old seam staying with priority %g\n", old_pair.
key());
79 seams->
Push(&old_pair);
82 tprintf(
"New seam with priority %g beats old worst seam with %g\n",
83 new_priority, old_pair.
key());
86 SeamPair new_pair(new_priority, new_seam);
87 seams->
Push(&new_pair);
111 my_priority = priority;
112 if (split !=
nullptr) {
116 seam =
new SEAM(my_priority, split_point, *split);
126 while (!seam_queue->
empty()) {
128 seam_queue->
Pop(&seam_pair);
135 sprintf (str,
"Full my_priority %0.0f, ", my_priority);
139 if ((*seam_result ==
nullptr || (*seam_result)->
priority() > my_priority) &&
145 *seam_result =
new SEAM(*seam);
146 (*seam_result)->set_priority(my_priority);
164 seam_pile->
Push(&pair);
167 seam_pile->
PeekTop().key() > seam_pair.
key()) {
170 seam_pile->
Pop(&pair);
175 seam_pile->
Push(&pair);
199 for (
int x = 0; x < seam_pile.
size(); ++x) {
200 const SEAM *this_one = seam_pile.
get(x).data();
219 EDGEPT_CLIST new_points;
220 SEAM *seam =
nullptr;
222 int16_t num_points = 0;
224 #ifndef GRAPHICS_DISABLED
232 for (outline = blob->
outlines; outline; outline = outline->
next)
236 points[num_points++] = point_heap.
PeekTop().data;
237 point_heap.
Pop(
nullptr);
243 try_point_pairs(points, num_points, &seam_queue, &seam_pile, &seam, blob);
245 &seam_queue, &seam_pile, &seam, blob);
247 if (seam ==
nullptr) {
254 EDGEPT_C_IT it(&new_points);
255 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
256 EDGEPT *inserted_point = it.data();
257 if (seam ==
nullptr || !seam->
UsesPoint(inserted_point)) {
258 for (outline = blob->
outlines; outline; outline = outline->
next) {
259 if (outline->
loop == inserted_point) {
272 #ifndef GRAPHICS_DISABLED
307 for (x = 0; x < num_points; x++) {
308 for (y = x + 1; y < num_points; y++) {
312 points[x] != points[y]->next && points[y] != points[x]->next &&
315 SPLIT split(points[x], points[y]);
337 EDGEPT_CLIST *new_points,
342 EDGEPT *vertical_point =
nullptr;
347 for (x = 0; x < num_points; x++) {
348 vertical_point =
nullptr;
349 for (outline = blob->
outlines; outline; outline = outline->
next) {
351 &vertical_point, new_points);
354 if (vertical_point && points[x] != vertical_point->
next &&
355 vertical_point != points[x]->
next &&
358 SPLIT split(points[x], vertical_point);