Finds and deletes any duplicate outlines in this blob, without deleting their EDGEPTs.
| 493 | // Finds and deletes any duplicate outlines in this blob, without deleting |
| 494 | // their EDGEPTs. |
| 495 | void TBLOB::EliminateDuplicateOutlines() { |
| 496 | for (TESSLINE* outline = outlines; outline != NULL; outline = outline->next) { |
| 497 | TESSLINE* last_outline = outline; |
| 498 | for (TESSLINE* other_outline = outline->next; other_outline != NULL; |
| 499 | last_outline = other_outline, other_outline = other_outline->next) { |
| 500 | if (outline->SameBox(*other_outline)) { |
| 501 | last_outline->next = other_outline->next; |
| 502 | // This doesn't leak - the outlines share the EDGEPTs. |
| 503 | other_outline->loop = NULL; |
| 504 | delete other_outline; |
| 505 | other_outline = last_outline; |
| 506 | // If it is part of a cut, then it can't be a hole any more. |
| 507 | outline->is_hole = false; |
| 508 | } |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | // Swaps the outlines of *this and next if needed to keep the centers in |
| 514 | // increasing x. |