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);
#define edge_window_wait()
void combine_seam(const SeamPile &seam_pile, const SEAM *seam, SeamQueue *seam_queue)
DLLSYM void tprintf(const char *format,...)
void Mark(ScrollView *window) const
#define update_edge_window()
void choose_best_seam(SeamQueue *seam_queue, const SPLIT *split, PRIORITY priority, SEAM **seam_result, TBLOB *blob, SeamPile *seam_pile)
void Print(const char *label) const
void prioritize_points(TESSLINE *outline, PointHeap *points)
const Pair & get(int index) const
#define is_exterior_point(edge, point)
int WeightedDistance(const EDGEPT &other, int x_factor) const
void vertical_projection_point(EDGEPT *split_point, EDGEPT *target_point, EDGEPT **best_point, EDGEPT_CLIST *new_points)
float FullPriority(int xmin, int xmax, double overlap_knob, int centered_maxwidth, double center_knob, double width_change_knob) const
int chop_centered_maxwidth
void remove_edgept(EDGEPT *point)
void try_vertical_splits(EDGEPT *points[MAX_NUM_POINTS], int16_t num_points, EDGEPT_CLIST *new_points, SeamQueue *seam_queue, SeamPile *seam_pile, SEAM **seam, TBLOB *blob)
int chop_min_outline_points
double chop_width_change_knob
bool CombineableWith(const SEAM &other, int max_x_dist, float max_total_priority) const
bool IsHealthy(const TBLOB &blob, int min_points, int min_area) const
void set_key(const Key &new_key)
bool wordrec_display_splits
void try_point_pairs(EDGEPT *points[MAX_NUM_POINTS], int16_t num_points, SeamQueue *seam_queue, SeamPile *seam_pile, SEAM **seam, TBLOB *blob)
bool PopWorst(Pair *entry)
#define partial_split_priority(split)
void set_data(Data *new_data)
SEAM * pick_good_seam(TBLOB *blob)
bool UsesPoint(const EDGEPT *point) const
TBOX bounding_box() const
void draw_blob_edges(TBLOB *blob)
void add_seam_to_queue(float new_priority, SEAM *new_seam, SeamQueue *seams)
const Pair & PeekTop() const
int chop_min_outline_area
void CombineWith(const SEAM &other)