Public factory to build a TabVector from a list of boxes. The TabVector will be of the given alignment type. The input vertical vector is used in fitting, and the output vertical_x, vertical_y have the resulting line vector added to them if the alignment is not ragged. The extended_start_y and extended_end_y are the maximum possible extension to the line segment that can be used to align with othe
| 180 | // extension to the line segment that can be used to align with others. |
| 181 | // The input CLIST of BLOBNBOX good_points is consumed and taken over. |
| 182 | TabVector* TabVector::FitVector(TabAlignment alignment, ICOORD vertical, |
| 183 | int extended_start_y, int extended_end_y, |
| 184 | BLOBNBOX_CLIST* good_points, |
| 185 | int* vertical_x, int* vertical_y) { |
| 186 | TabVector* vector = new TabVector(extended_start_y, extended_end_y, |
| 187 | alignment, good_points); |
| 188 | if (!vector->Fit(vertical, false)) { |
| 189 | delete vector; |
| 190 | return NULL; |
| 191 | } |
| 192 | if (!vector->IsRagged()) { |
| 193 | vertical = vector->endpt_ - vector->startpt_; |
| 194 | int weight = vector->BoxCount(); |
| 195 | *vertical_x += vertical.x() * weight; |
| 196 | *vertical_y += vertical.y() * weight; |
| 197 | } |
| 198 | return vector; |
| 199 | } |
| 200 | |
| 201 | // Build a ragged TabVector by copying another's direction, shifting it |
| 202 | // to match the given blob, and making its initial extent the height |