227 int ext_start_y, ext_end_y;
228 BLOBNBOX_CLIST good_points;
232 int pt_count = AlignTabs(align_params,
false, bbox, &good_points, &ext_end_y);
233 pt_count += AlignTabs(align_params,
true, bbox, &good_points, &ext_start_y);
234 BLOBNBOX_C_IT it(&good_points);
236 box = it.data()->bounding_box();
237 int end_y = box.
top();
238 int end_x = align_params.right_tab ? box.
right() : box.
left();
240 box = it.data()->bounding_box();
241 int start_x = align_params.right_tab ? box.
right() : box.
left();
242 int start_y = box.
bottom();
248 bool at_least_2_crossings = AtLeast2LineCrossings(&good_points);
249 if ((pt_count >= align_params.min_points &&
250 end_y - start_y >= align_params.min_length &&
251 (align_params.ragged ||
253 at_least_2_crossings) {
254 int confirmed_points = 0;
256 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
258 if (align_params.right_tab) {
267 if (!align_params.ragged ||
268 confirmed_points + confirmed_points < pt_count) {
271 tprintf(
"Confirming tab vector of %d pts starting at %d,%d\n",
275 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
277 if (align_params.right_tab) {
288 align_params.vertical,
289 ext_start_y, ext_end_y,
291 vertical_x, vertical_y);
292 result->set_intersects_other_lines(at_least_2_crossings);
295 result->Print(
"After fitting");
299 tprintf(
"Ragged tab used too many used points: %d out of %d\n",
300 confirmed_points, pt_count);
303 tprintf(
"Tab vector failed basic tests: pt count %d vs min %d, " 304 "length %d vs min %d, min grad %g\n",
305 pt_count, align_params.min_points, end_y - start_y,
306 align_params.min_length, abs(end_x - start_x) * kMinTabGradient);
void set_right_tab_type(TabType new_type)
static bool WithinTestRegion(int detail_level, int x, int y)
TabType right_tab_type() const
const TBOX & bounding_box() const
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)
const double kMinTabGradient
void set_left_tab_type(TabType new_type)
TabType left_tab_type() const