230 int ext_start_y, ext_end_y;
231 BLOBNBOX_CLIST good_points;
235 int pt_count = AlignTabs(align_params,
false, bbox, &good_points, &ext_end_y);
236 pt_count += AlignTabs(align_params,
true, bbox, &good_points, &ext_start_y);
237 BLOBNBOX_C_IT it(&good_points);
239 box = it.data()->bounding_box();
240 int end_y = box.
top();
241 int end_x = align_params.right_tab ? box.
right() : box.
left();
243 box = it.data()->bounding_box();
244 int start_x = align_params.right_tab ? box.
right() : box.
left();
245 int start_y = box.
bottom();
251 bool at_least_2_crossings = AtLeast2LineCrossings(&good_points);
252 if ((pt_count >= align_params.min_points &&
253 end_y - start_y >= align_params.min_length &&
254 (align_params.ragged ||
256 at_least_2_crossings) {
257 int confirmed_points = 0;
259 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
261 if (align_params.right_tab) {
270 if (!align_params.ragged ||
271 confirmed_points + confirmed_points < pt_count) {
274 tprintf(
"Confirming tab vector of %d pts starting at %d,%d\n",
278 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
280 if (align_params.right_tab) {
291 align_params.vertical,
292 ext_start_y, ext_end_y,
294 vertical_x, vertical_y);
295 result->set_intersects_other_lines(at_least_2_crossings);
298 result->Print(
"After fitting");
302 tprintf(
"Ragged tab used too many used points: %d out of %d\n",
303 confirmed_points, pt_count);
306 tprintf(
"Tab vector failed basic tests: pt count %d vs min %d, " 307 "length %d vs min %d, min grad %g\n",
308 pt_count, align_params.min_points, end_y - start_y,
static bool WithinTestRegion(int detail_level, int x, int y)
void set_right_tab_type(TabType new_type)
const double kMinTabGradient
TabType right_tab_type() const
TabType left_tab_type() const
DLLSYM void tprintf(const char *format,...)
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 TBOX & bounding_box() const
void set_left_tab_type(TabType new_type)