248 int ext_start_y, ext_end_y;
249 BLOBNBOX_CLIST good_points;
253 int pt_count = AlignTabs(align_params,
false, bbox, &good_points, &ext_end_y);
254 pt_count += AlignTabs(align_params,
true, bbox, &good_points, &ext_start_y);
255 BLOBNBOX_C_IT it(&good_points);
257 box = it.data()->bounding_box();
258 int end_y = box.
top();
259 int end_x = align_params.right_tab ? box.
right() : box.
left();
261 box = it.data()->bounding_box();
262 int start_x = align_params.right_tab ? box.
right() : box.
left();
263 int start_y = box.
bottom();
269 bool at_least_2_crossings = AtLeast2LineCrossings(&good_points);
270 if ((pt_count >= align_params.min_points &&
271 end_y - start_y >= align_params.min_length &&
272 (align_params.ragged ||
274 at_least_2_crossings) {
275 int confirmed_points = 0;
277 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
279 if (align_params.right_tab) {
288 if (!align_params.ragged ||
289 confirmed_points + confirmed_points < pt_count) {
292 tprintf(
"Confirming tab vector of %d pts starting at %d,%d\n",
296 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
298 if (align_params.right_tab) {
309 align_params.vertical,
310 ext_start_y, ext_end_y,
312 vertical_x, vertical_y);
313 result->set_intersects_other_lines(at_least_2_crossings);
316 result->Print(
"After fitting");
320 tprintf(
"Ragged tab used too many used points: %d out of %d\n",
321 confirmed_points, pt_count);
324 tprintf(
"Tab vector failed basic tests: pt count %d vs min %d, "
325 "length %d vs min %d, min grad %g\n",
326 pt_count, align_params.min_points, end_y - start_y,
327 align_params.min_length, abs(end_x - start_x) * kMinTabGradient);
const TBOX & bounding_box() const
void set_right_tab_type(TabType new_type)
const double kMinTabGradient
TabType left_tab_type() 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)
DLLSYM void tprintf(const char *format,...)
static bool WithinTestRegion(int detail_level, int x, int y)
TabType right_tab_type() const
void set_left_tab_type(TabType new_type)