38 TBOX box(location_.
x, location_.
y, location_.
x, location_.
y);
39 for (
int s = 0; s < num_splits_; ++s) {
47 float max_total_priority)
const {
48 int dist = location_.
x - other.location_.
x;
49 if (-max_x_dist < dist && dist < max_x_dist &&
50 num_splits_ + other.num_splits_ <= kMaxNumSplits &&
51 priority_ + other.priority_ < max_total_priority &&
61 priority_ += other.priority_;
62 location_ += other.location_;
65 for (uint8_t s = 0; s < other.num_splits_ && num_splits_ < kMaxNumSplits; ++s)
66 splits_[num_splits_++] = other.splits_[s];
75 return num_splits_ == 0 || splits_[0].
IsHealthy(blob, min_points, min_area);
84 int insert_index,
bool modify) {
85 for (
int s = 0; s < insert_index; ++s) {
88 if (!
FindBlobWidth(blobs, insert_index, modify))
return false;
89 for (
int s = insert_index; s < seams.
size(); ++s) {
90 if (!seams[s]->
FindBlobWidth(blobs, s + 1, modify))
return false;
104 for (
int s = 0; s < num_splits_; ++s) {
105 const SPLIT& split = splits_[s];
108 for (
int b = index + 1; !found_split && b < blobs.
size(); ++b) {
110 if (found_split && b - index > widthp_ && modify) widthp_ = b - index;
113 for (
int b = index - 1; !found_split && b >= 0; --b) {
115 if (found_split && index - b > widthn_ && modify) widthn_ = index - b;
117 if (found_split) ++num_found;
119 return num_found == num_splits_;
125 for (
int s = 0; s < num_splits_; ++s) {
147 while (outline->
next) outline = outline->
next;
152 for (
int s = 0; s < num_splits_; ++s) {
162 tprintf(
" %6.2f @ (%d,%d), p=%d, n=%d ", priority_, location_.
x, location_.
y,
164 for (
int s = 0; s < num_splits_; ++s) {
166 if (s + 1 < num_splits_)
tprintf(
", ");
174 if (!seams.
empty()) {
176 for (
int x = 0; x < seams.
size(); ++x) {
184 #ifndef GRAPHICS_DISABLED 187 for (
int s = 0; s < num_splits_; ++s) splits_[s].
Mark(window);
197 for (
int x = first; x <
last; ++x) seams[x]->
Reveal();
199 TESSLINE* outline = blobs[first]->outlines;
200 int next_blob = first + 1;
202 while (outline !=
nullptr && next_blob <=
last) {
203 if (outline->
next == blobs[next_blob]->outlines) {
204 outline->
next =
nullptr;
205 outline = blobs[next_blob]->outlines;
208 outline = outline->
next;
218 TESSLINE* outline = blobs[first]->outlines;
222 for (
int x = first; x <
last; ++x) {
223 SEAM *seam = seams[x];
224 if (x - seam->widthn_ >= first && x + seam->widthp_ <
last) seam->
Hide();
225 while (outline->
next) outline = outline->
next;
226 outline->
next = blobs[x + 1]->outlines;
232 for (
int s = 0; s < num_splits_; ++s) {
239 for (
int s = 0; s < num_splits_; ++s) {
246 int centered_maxwidth,
double center_knob,
247 double width_change_knob)
const {
248 if (num_splits_ == 0)
return 0.0f;
249 for (
int s = 1; s < num_splits_; ++s) {
252 float full_priority =
254 splits_[0].
FullPriority(xmin, xmax, overlap_knob, centered_maxwidth,
255 center_knob, width_change_knob);
256 for (
int s = num_splits_ - 1; s >= 1; --s) {
259 return full_priority;
273 for (
int b = 1; b < word->
NumBlobs(); ++b) {
274 TBOX bbox = word->
blobs[b - 1]->bounding_box();
275 TBOX nbox = word->
blobs[b]->bounding_box();
276 location.
x = (bbox.
right() + nbox.
left()) / 2;
void UnsplitOutlines() const
void Mark(ScrollView *window) const
bool IsHealthy(const TBLOB &blob, int min_points, int min_area) const
TBOX bounding_box() const
void start_seam_list(TWERD *word, GenericVector< SEAM *> *seam_array)
void UnsplitOutlineList(TBLOB *blob) const
void ApplySeam(bool italic_blob, TBLOB *blob, TBLOB *other_blob) const
static void JoinPieces(const GenericVector< SEAM *> &seams, const GenericVector< TBLOB *> &blobs, int first, int last)
static void BreakPieces(const GenericVector< SEAM *> &seams, const GenericVector< TBLOB *> &blobs, int first, int last)
void SplitOutline() const
TBOX bounding_box() const
bool PrepareToInsertSeam(const GenericVector< SEAM *> &seams, const GenericVector< TBLOB *> &blobs, int insert_index, bool modify)
void Print(const char *label) const
void EliminateDuplicateOutlines()
bool CombineableWith(const SEAM &other, int max_x_dist, float max_total_priority) const
bool SharesPosition(const SEAM &other) const
DLLSYM void tprintf(const char *format,...)
float FullPriority(int xmin, int xmax, double overlap_knob, int centered_maxwidth, double center_knob, double width_change_knob) const
bool OverlappingSplits(const SEAM &other) const
bool IsHealthy(const TBLOB &blob, int min_points, int min_area) const
GenericVector< TBLOB * > blobs
void ComputeBoundingBoxes()
void SplitOutlineList(TESSLINE *outlines) const
bool ContainedByBlob(const TBLOB &blob) const
void UndoSeam(TBLOB *blob, TBLOB *other_blob) const
static void PrintSeams(const char *label, const GenericVector< SEAM *> &seams)
void CorrectBlobOrder(TBLOB *next)
bool FindBlobWidth(const GenericVector< TBLOB *> &blobs, int index, bool modify)
void CombineWith(const SEAM &other)
void divide_blobs(TBLOB *blob, TBLOB *other_blob, bool italic_blob, const TPOINT &location)
float FullPriority(int xmin, int xmax, double overlap_knob, int centered_maxwidth, double center_knob, double width_change_knob) const