247 int ext_start_y, ext_end_y;
248 BLOBNBOX_CLIST good_points;
252 int pt_count = AlignTabs(align_params,
false, bbox, &good_points, &ext_end_y);
253 pt_count += AlignTabs(align_params,
true, bbox, &good_points, &ext_start_y);
254 BLOBNBOX_C_IT it(&good_points);
256 box = it.data()->bounding_box();
257 int end_y = box.
top();
258 int end_x = align_params.right_tab ? box.
right() : box.
left();
260 box = it.data()->bounding_box();
261 int start_x = align_params.right_tab ? box.
right() : box.
left();
262 int start_y = box.
bottom();
268 bool at_least_2_crossings = AtLeast2LineCrossings(&good_points);
269 if ((pt_count >= align_params.min_points &&
270 end_y - start_y >= align_params.min_length &&
271 (align_params.ragged ||
273 at_least_2_crossings) {
274 int confirmed_points = 0;
276 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
278 if (align_params.right_tab) {
287 if (!align_params.ragged ||
288 confirmed_points + confirmed_points < pt_count) {
291 tprintf(
"Confirming tab vector of %d pts starting at %d,%d\n",
295 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
297 if (align_params.right_tab) {
308 align_params.vertical,
309 ext_start_y, ext_end_y,
311 vertical_x, vertical_y);
312 result->set_intersects_other_lines(at_least_2_crossings);
315 result->Print(
"After fitting");
319 tprintf(
"Ragged tab used too many used points: %d out of %d\n",
320 confirmed_points, pt_count);
323 tprintf(
"Tab vector failed basic tests: pt count %d vs min %d, " 324 "length %d vs min %d, min grad %g\n",
325 pt_count, align_params.min_points, end_y - start_y,
const TBOX & bounding_box() const
static bool WithinTestRegion(int detail_level, int x, int y)
TabType right_tab_type() const
const double kMinTabGradient
void set_right_tab_type(TabType new_type)
static TabVector * FitVector(TabAlignment alignment, ICOORD vertical, int extended_start_y, int extended_end_y, BLOBNBOX_CLIST *good_points, int *vertical_x, int *vertical_y)
void set_left_tab_type(TabType new_type)
TabType left_tab_type() const