31 TBOX box(location_.
x, location_.
y, location_.
x, location_.
y);
32 for (
int s = 0; s < num_splits_; ++s) {
40 float max_total_priority)
const {
41 int dist = location_.
x - other.location_.
x;
42 if (-max_x_dist < dist && dist < max_x_dist &&
43 num_splits_ + other.num_splits_ <= kMaxNumSplits &&
44 priority_ + other.priority_ < max_total_priority &&
54 priority_ += other.priority_;
55 location_ += other.location_;
58 for (uint8_t s = 0; s < other.num_splits_ && num_splits_ < kMaxNumSplits; ++s)
59 splits_[num_splits_++] = other.splits_[s];
68 return num_splits_ == 0 || splits_[0].
IsHealthy(blob, min_points, min_area);
77 int insert_index,
bool modify) {
78 for (
int s = 0; s < insert_index; ++s) {
81 if (!
FindBlobWidth(blobs, insert_index, modify))
return false;
82 for (
int s = insert_index; s < seams.
size(); ++s) {
83 if (!seams[s]->
FindBlobWidth(blobs, s + 1, modify))
return false;
97 for (
int s = 0; s < num_splits_; ++s) {
98 const SPLIT& split = splits_[s];
101 for (
int b = index + 1; !found_split && b < blobs.
size(); ++b) {
103 if (found_split && b - index > widthp_ && modify) widthp_ = b - index;
106 for (
int b = index - 1; !found_split && b >= 0; --b) {
108 if (found_split && index - b > widthn_ && modify) widthn_ = index - b;
110 if (found_split) ++num_found;
112 return num_found == num_splits_;
118 for (
int s = 0; s < num_splits_; ++s) {
140 while (outline->
next) outline = outline->
next;
145 for (
int s = 0; s < num_splits_; ++s) {
155 tprintf(
" %6.2f @ (%d,%d), p=%d, n=%d ", priority_, location_.
x, location_.
y,
157 for (
int s = 0; s < num_splits_; ++s) {
159 if (s + 1 < num_splits_)
tprintf(
", ");
167 if (!seams.
empty()) {
169 for (
int x = 0; x < seams.
size(); ++x) {
177 #ifndef GRAPHICS_DISABLED
180 for (
int s = 0; s < num_splits_; ++s) splits_[s].
Mark(window);
190 for (
int x = first; x <
last; ++x) seams[x]->
Reveal();
192 TESSLINE* outline = blobs[first]->outlines;
193 int next_blob = first + 1;
195 while (outline !=
nullptr && next_blob <=
last) {
196 if (outline->
next == blobs[next_blob]->outlines) {
197 outline->
next =
nullptr;
198 outline = blobs[next_blob]->outlines;
201 outline = outline->
next;
211 TESSLINE* outline = blobs[first]->outlines;
215 for (
int x = first; x <
last; ++x) {
216 SEAM *seam = seams[x];
217 if (x - seam->widthn_ >= first && x + seam->widthp_ <
last) seam->
Hide();
218 while (outline->
next) outline = outline->
next;
219 outline->
next = blobs[x + 1]->outlines;
225 for (
int s = 0; s < num_splits_; ++s) {
232 for (
int s = 0; s < num_splits_; ++s) {
239 int centered_maxwidth,
double center_knob,
240 double width_change_knob)
const {
241 if (num_splits_ == 0)
return 0.0f;
242 for (
int s = 1; s < num_splits_; ++s) {
245 float full_priority =
247 splits_[0].
FullPriority(xmin, xmax, overlap_knob, centered_maxwidth,
248 center_knob, width_change_knob);
249 for (
int s = num_splits_ - 1; s >= 1; --s) {
252 return full_priority;
266 for (
int b = 1; b < word->
NumBlobs(); ++b) {
267 TBOX bbox = word->
blobs[b - 1]->bounding_box();
268 TBOX nbox = word->
blobs[b]->bounding_box();
269 location.
x = (bbox.
right() + nbox.
left()) / 2;