wordrec/olutil.cpp File Reference

#include "olutil.h"
#include "structures.h"
#include "blobs.h"
#include "const.h"

Go to the source code of this file.

Functions


Function Documentation

void check_outline_mem (  ) 

Check the memory allocator for outlines.

Definition at line 39 of file olutil.cpp.

References newoutline(), olinestruct::next, and oldoutline.

Referenced by apply_seam(), and undo_seam().

00039                          { 
00040   TESSLINE *outline;
00041 
00042   outline = newoutline ();
00043   outline->next = newoutline ();
00044   oldoutline (outline->next);
00045   oldoutline(outline); 
00046 
00047   outline = newoutline ();
00048   outline->next = newoutline ();
00049   oldoutline (outline->next);
00050   oldoutline(outline); 
00051 }

void correct_blob_order ( TBLOB blob1,
TBLOB blob2 
)

Check to see if the blobs are in the correct order.

If they are not then swap which outlines are attached to which blobs.

Definition at line 60 of file olutil.cpp.

References blob_origin(), blobstruct::outlines, and TPOINT::x.

Referenced by form_two_blobs().

00060                                                     { 
00061   TPOINT origin1;
00062   TPOINT origin2;
00063   TESSLINE *temp;
00064 
00065   blob_origin(blob1, &origin1); 
00066   blob_origin(blob2, &origin2); 
00067 
00068   if (origin1.x > origin2.x) {
00069     temp = blob2->outlines;
00070     blob2->outlines = blob1->outlines;
00071     blob1->outlines = temp;
00072   }
00073 }

void eliminate_duplicate_outlines ( TBLOB blob  ) 

Find and delete any duplicate outline records in this blob.

Definition at line 80 of file olutil.cpp.

References olinestruct::next, oldoutline, blobstruct::outlines, and same_outline_bounds.

Referenced by form_two_blobs(), and undo_seam().

00080                                                { 
00081   TESSLINE *outline;
00082   TESSLINE *other_outline;
00083   TESSLINE *last_outline;
00084 
00085   for (outline = blob->outlines; outline; outline = outline->next) {
00086 
00087     for (last_outline = outline, other_outline = outline->next;
00088       other_outline;
00089     last_outline = other_outline, other_outline = other_outline->next) {
00090 
00091       if (same_outline_bounds (outline, other_outline)) {
00092         last_outline->next = other_outline->next;
00093         oldoutline(other_outline); 
00094         other_outline = last_outline;
00095       }
00096     }
00097   }
00098 }

void setup_blob_outlines ( TBLOB blob  ) 

Set up each of the outlines in this blob.

Definition at line 138 of file olutil.cpp.

References olinestruct::next, blobstruct::outlines, and setup_outline().

Referenced by form_two_blobs(), and undo_seam().

00138                                       { 
00139   TESSLINE *outline;
00140 
00141   for (outline = blob->outlines; outline; outline = outline->next) {
00142     setup_outline(outline); 
00143   }
00144 }

void setup_outline ( TESSLINE outline  ) 

Create a new outline structure from this

Definition at line 105 of file olutil.cpp.

References olinestruct::botright, olinestruct::loop, MAXINT, edgeptstruct::next, edgeptstruct::pos, olinestruct::topleft, TPOINT::x, and TPOINT::y.

Referenced by make_single_split(), and setup_blob_outlines().

00105                                       { 
00106   register EDGEPT *this_edge;
00107   register int minx = MAXINT;
00108   register int miny = MAXINT;
00109   register int maxx = -MAXINT;
00110   register int maxy = -MAXINT;
00111 
00112   /* Find boundaries */
00113   this_edge = outline->loop;
00114   do {
00115     if (this_edge->pos.x < minx)
00116       minx = this_edge->pos.x;
00117     if (this_edge->pos.y < miny)
00118       miny = this_edge->pos.y;
00119     if (this_edge->pos.x > maxx)
00120       maxx = this_edge->pos.x;
00121     if (this_edge->pos.y > maxy)
00122       maxy = this_edge->pos.y;
00123     this_edge = this_edge->next;
00124   }
00125   while (this_edge != outline->loop);
00126   /* Reset bounds */
00127   outline->topleft.x = minx;
00128   outline->topleft.y = maxy;
00129   outline->botright.x = maxx;
00130   outline->botright.y = miny;
00131 }


Generated on Wed Feb 28 19:49:28 2007 for Tesseract by  doxygen 1.5.1