* divide_blobs * * Create two blobs by grouping the outlines in the appropriate blob. * The outlines that are beyond the location point are moved to the * other blob. The ones whose x location is less than that point are * retained in the original blob. **********************************************************************/
| 981 | * retained in the original blob. |
| 982 | **********************************************************************/ |
| 983 | void divide_blobs(TBLOB *blob, TBLOB *other_blob, bool italic_blob, |
| 984 | const TPOINT& location) { |
| 985 | TPOINT vertical = italic_blob ? kDivisibleVerticalItalic |
| 986 | : kDivisibleVerticalUpright; |
| 987 | TESSLINE *outline1 = NULL; |
| 988 | TESSLINE *outline2 = NULL; |
| 989 | |
| 990 | TESSLINE *outline = blob->outlines; |
| 991 | blob->outlines = NULL; |
| 992 | int location_prod = CROSS(location, vertical); |
| 993 | |
| 994 | while (outline != NULL) { |
| 995 | TPOINT mid_pt( |
| 996 | static_cast<inT16>((outline->topleft.x + outline->botright.x) / 2), |
| 997 | static_cast<inT16>((outline->topleft.y + outline->botright.y) / 2)); |
| 998 | int mid_prod = CROSS(mid_pt, vertical); |
| 999 | if (mid_prod < location_prod) { |
| 1000 | // Outline is in left blob. |
| 1001 | if (outline1) |
| 1002 | outline1->next = outline; |
| 1003 | else |
| 1004 | blob->outlines = outline; |
| 1005 | outline1 = outline; |
| 1006 | } else { |
| 1007 | // Outline is in right blob. |
| 1008 | if (outline2) |
| 1009 | outline2->next = outline; |
| 1010 | else |
| 1011 | other_blob->outlines = outline; |
| 1012 | outline2 = outline; |
| 1013 | } |
| 1014 | outline = outline->next; |
| 1015 | } |
| 1016 | |
| 1017 | if (outline1) |
| 1018 | outline1->next = NULL; |
| 1019 | if (outline2) |
| 1020 | outline2->next = NULL; |
| 1021 | } |