36 #include "config_auto.h" 47 #define partial_split_priority(split) \ 48 (grade_split_length(split) + grade_sharpness(split)) 53 #define SPLIT_CLOSENESS 20 55 #define MAX_NUM_SEAMS 150 57 #define MAX_OLD_SEAMS 150 58 #define NO_FULL_PRIORITY -1 60 #define BAD_PRIORITY 9999.0 75 if (new_seam ==
nullptr)
return;
77 tprintf(
"Pushing new seam with priority %g :", new_priority);
78 new_seam->
Print(
"seam: ");
82 if (seams->
PopWorst(&old_pair) && old_pair.
key() <= new_priority) {
84 tprintf(
"Old seam staying with priority %g\n", old_pair.
key());
87 seams->
Push(&old_pair);
90 tprintf(
"New seam with priority %g beats old worst seam with %g\n",
91 new_priority, old_pair.
key());
94 SeamPair new_pair(new_priority, new_seam);
95 seams->
Push(&new_pair);
119 my_priority = priority;
120 if (split !=
nullptr) {
124 seam =
new SEAM(my_priority, split_point, *split);
134 while (!seam_queue->
empty()) {
136 seam_queue->
Pop(&seam_pair);
143 sprintf (str,
"Full my_priority %0.0f, ", my_priority);
147 if ((*seam_result ==
nullptr || (*seam_result)->
priority() > my_priority) &&
153 *seam_result =
new SEAM(*seam);
154 (*seam_result)->set_priority(my_priority);
172 seam_pile->
Push(&pair);
175 seam_pile->
PeekTop().key() > seam_pair.
key()) {
178 seam_pile->
Pop(&pair);
183 seam_pile->
Push(&pair);
207 for (
int x = 0; x < seam_pile.
size(); ++x) {
208 const SEAM *this_one = seam_pile.
get(x).data();
227 EDGEPT_CLIST new_points;
228 SEAM *seam =
nullptr;
230 int16_t num_points = 0;
232 #ifndef GRAPHICS_DISABLED 240 for (outline = blob->
outlines; outline; outline = outline->
next)
244 points[num_points++] = point_heap.
PeekTop().data;
245 point_heap.
Pop(
nullptr);
251 try_point_pairs(points, num_points, &seam_queue, &seam_pile, &seam, blob);
253 &seam_queue, &seam_pile, &seam, blob);
255 if (seam ==
nullptr) {
262 EDGEPT_C_IT it(&new_points);
263 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
264 EDGEPT *inserted_point = it.data();
265 if (seam ==
nullptr || !seam->
UsesPoint(inserted_point)) {
266 for (outline = blob->
outlines; outline; outline = outline->
next) {
267 if (outline->
loop == inserted_point) {
280 #ifndef GRAPHICS_DISABLED 315 for (x = 0; x < num_points; x++) {
316 for (y = x + 1; y < num_points; y++) {
320 points[x] != points[y]->next && points[y] != points[x]->next &&
323 SPLIT split(points[x], points[y]);
345 EDGEPT_CLIST *new_points,
350 EDGEPT *vertical_point =
nullptr;
355 for (x = 0; x < num_points; x++) {
356 vertical_point =
nullptr;
357 for (outline = blob->
outlines; outline; outline = outline->
next) {
359 &vertical_point, new_points);
362 if (vertical_point && points[x] != vertical_point->
next &&
363 vertical_point != points[x]->
next &&
366 SPLIT split(points[x], vertical_point);
bool PopWorst(Pair *entry)
void Mark(ScrollView *window) const
const Pair & get(int index) const
bool IsHealthy(const TBLOB &blob, int min_points, int min_area) const
bool UsesPoint(const EDGEPT *point) const
bool wordrec_display_splits
SEAM * pick_good_seam(TBLOB *blob)
void combine_seam(const SeamPile &seam_pile, const SEAM *seam, SeamQueue *seam_queue)
int chop_centered_maxwidth
void remove_edgept(EDGEPT *point)
double chop_width_change_knob
void set_data(Data *new_data)
void Print(const char *label) const
int chop_min_outline_area
#define edge_window_wait()
int chop_min_outline_points
void set_key(const Key &new_key)
bool CombineableWith(const SEAM &other, int max_x_dist, float max_total_priority) const
const Pair & PeekTop() const
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)
DLLSYM void tprintf(const char *format,...)
TBOX bounding_box() const
#define update_edge_window()
#define partial_split_priority(split)
void prioritize_points(TESSLINE *outline, PointHeap *points)
void choose_best_seam(SeamQueue *seam_queue, const SPLIT *split, PRIORITY priority, SEAM **seam_result, TBLOB *blob, SeamPile *seam_pile)
void vertical_projection_point(EDGEPT *split_point, EDGEPT *target_point, EDGEPT **best_point, EDGEPT_CLIST *new_points)
int WeightedDistance(const EDGEPT &other, int x_factor) const
void add_seam_to_queue(float new_priority, SEAM *new_seam, SeamQueue *seams)
void try_point_pairs(EDGEPT *points[MAX_NUM_POINTS], int16_t num_points, SeamQueue *seam_queue, SeamPile *seam_pile, SEAM **seam, TBLOB *blob)
#define is_exterior_point(edge, point)
void CombineWith(const SEAM &other)
float FullPriority(int xmin, int xmax, double overlap_knob, int centered_maxwidth, double center_knob, double width_change_knob) const
void draw_blob_edges(TBLOB *blob)