wordrec/split.cpp File Reference

#include "split.h"
#include "structures.h"
#include "debug.h"
#include "hideedge.h"
#include "callcpp.h"

Go to the source code of this file.

Functions


Function Documentation

void delete_split ( SPLIT split  ) 

Remove this split from existance.

Take if off the display list and deallocate its memory.

Definition at line 66 of file split.cpp.

Referenced by delete_seam().

00066                                 { 
00067   if (split) {
00068     free_split(split); 
00069   }
00070 }

void init_splitter_vars (  ) 

Create and initialize references to debug variables that control operations in this file.

Definition at line 55 of file split.cpp.

Referenced by init_ms_debug().

00055                           { 
00056   make_display_splits(); 
00057 }

EDGEPT* make_edgept ( int  x,
int  y,
EDGEPT next,
EDGEPT prev 
)

Create an EDGEPT and hook it into an existing list of edge points.

Definition at line 77 of file split.cpp.

References edgeptstruct::flags, newedgept(), edgeptstruct::next, edgeptstruct::pos, edgeptstruct::prev, reveal_edge, edgeptstruct::vec, TPOINT::x, and TPOINT::y.

Referenced by near_point(), and split_outline().

00077                                                               { 
00078   EDGEPT *this_edgept;
00079   /* Create point */
00080   this_edgept = newedgept ();
00081   this_edgept->pos.x = x;
00082   this_edgept->pos.y = y;
00083   /* Hook it up */
00084   this_edgept->next = next;
00085   this_edgept->prev = prev;
00086   prev->next = this_edgept;
00087   next->prev = this_edgept;
00088   /* Set up vec entries */
00089   this_edgept->vec.x = this_edgept->next->pos.x - x;
00090   this_edgept->vec.y = this_edgept->next->pos.y - y;
00091   this_edgept->prev->vec.x = x - this_edgept->prev->pos.x;
00092   this_edgept->prev->vec.y = y - this_edgept->prev->pos.y;
00093 
00094   reveal_edge(this_edgept); 
00095   this_edgept->flags[1] = 0;
00096 
00097   return (this_edgept);
00098 }

SPLIT* new_split ( EDGEPT point1,
EDGEPT point2 
)

Create a new split record, initialize it, & put on the display list.

Definition at line 105 of file split.cpp.

References split_record::point1, and split_record::point2.

Referenced by try_point_pairs(), and try_vertical_splits().

00105                                                  { 
00106   SPLIT *s;
00107   s = (SPLIT *) newsplit ();
00108   s->point1 = point1;
00109   s->point2 = point2;
00110   return (s);
00111 }

void print_split ( SPLIT split  ) 

Print a list of splits.

Show the coordinates of both points in each split.

Definition at line 120 of file split.cpp.

References cprintf(), split_record::point1, split_record::point2, edgeptstruct::pos, TPOINT::x, and TPOINT::y.

Referenced by print_seam().

00120                                { 
00121   if (split) {
00122     cprintf ("(%d,%d)--(%d,%d)",
00123       split->point1->pos.x, split->point1->pos.y,
00124       split->point2->pos.x, split->point2->pos.y);
00125   }
00126 }

void split_outline ( EDGEPT join_point1,
EDGEPT join_point2 
)

Split between these two edge points.

Apply a split and return a pointer to the other side of the split.

Definition at line 135 of file split.cpp.

References assert(), make_edgept(), edgeptstruct::next, edgeptstruct::pos, TPOINT::x, and TPOINT::y.

Referenced by make_single_split(), and seam_priority().

00135                                                              { 
00136   EDGEPT *join_point1a;
00137   EDGEPT *temp2;
00138   EDGEPT *temp1;
00139 
00140   assert (join_point1 != join_point2);
00141 
00142   temp2 = join_point2->next;
00143   temp1 = join_point1->next;
00144   /* Create two new points */
00145   join_point1a = make_edgept (join_point1->pos.x,
00146     join_point1->pos.y, temp1, join_point2);
00147 
00148   make_edgept (join_point2->pos.x, join_point2->pos.y, temp2, join_point1);
00149 }

void unsplit_outlines ( EDGEPT p1,
EDGEPT p2 
)

Remove the split that was put between these two points.

Definition at line 156 of file split.cpp.

References assert(), edgeptstruct::next, oldedgept(), edgeptstruct::pos, edgeptstruct::prev, edgeptstruct::vec, TPOINT::x, and TPOINT::y.

Referenced by seam_priority(), and undo_single_split().

00156                                               { 
00157   EDGEPT *tmp1 = p1->next;
00158   EDGEPT *tmp2 = p2->next;
00159 
00160   assert (p1 != p2);
00161 
00162   tmp1->next->prev = p2;
00163   tmp2->next->prev = p1;
00164 
00165   p1->next = tmp2->next;
00166   p2->next = tmp1->next;
00167 
00168   oldedgept(tmp1); 
00169   oldedgept(tmp2); 
00170 
00171   p1->vec.x = p1->next->pos.x - p1->pos.x;
00172   p1->vec.y = p1->next->pos.y - p1->pos.y;
00173 
00174   p2->vec.x = p2->next->pos.x - p2->pos.x;
00175   p2->vec.y = p2->next->pos.y - p2->pos.y;
00176 }


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