431 {
433 int left = box.
left();
434 int width = box.
width();
435 int bottom = box.
bottom();
437 return bottom;
438
441 C_OUTLINE_IT it(&outlines);
442 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
445 for (
int s = 0; s < outline->
pathlength(); ++s) {
446 if (pos.
y() < y_mins[pos.
x() - left])
447 y_mins[pos.
x() - left] = pos.
y();
448 pos += outline->
step(s);
449 }
450 }
451
452 int bottom_extent = 0;
453 for (int x = 0; x <= width; ++x) {
454 if (y_mins[x] == bottom || y_mins[x] == bottom + 1)
455 ++bottom_extent;
456 }
457
458 int best_min = box.
top();
459 int prev_run = 0;
460 int prev_y = box.
top();
461 int prev_prev_y = box.
top();
462 for (int x = 0; x < width; x += prev_run) {
463
464 int y_at_x = y_mins[x];
465 int run = 1;
466 while (x + run <= width && y_mins[x + run] == y_at_x) ++run;
467 if (y_at_x > bottom + 1) {
468
469 int total_run = run;
470
471 while (x + total_run <= width &&
472 (y_mins[x + total_run] == y_at_x ||
473 y_mins[x + total_run] == y_at_x + 1)) ++total_run;
474
475 if (prev_prev_y > y_at_x + 1 || x + total_run > width ||
476 y_mins[x + total_run] > y_at_x + 1) {
477
478
479 if (prev_run > 0 && prev_y == y_at_x + 1) total_run += prev_run;
480 if (total_run > bottom_extent && y_at_x < best_min) {
481 best_min = y_at_x;
482 }
483 }
484 }
485 prev_run = run;
486 prev_prev_y = prev_y;
487 prev_y = y_at_x;
488 }
489 return best_min == box.
top() ? bottom : best_min;
490}
const double kMaxPerimeterWidthRatio
void init_to_size(int size, const T &t)
ICOORD step(int index) const
const ICOORD & start_pos() const
int32_t pathlength() const
int16_t y() const
access_function
int16_t x() const
access function
TBOX bounding_box() const