00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SEAM_H
00026 #define SEAM_H
00027
00028
00029
00030
00031 #include "blobs.h"
00032 #include "split.h"
00033 #include "tessarray.h"
00034
00035
00036
00037
00038 typedef float PRIORITY;
00039
00040 typedef struct seam_record
00041 {
00042 PRIORITY priority;
00043 inT8 widthp;
00044 inT8 widthn;
00045 TPOINT location;
00046 SPLIT *split1;
00047 SPLIT *split2;
00048 SPLIT *split3;
00049 } SEAM;
00050
00051 typedef ARRAY SEAMS;
00052
00053 extern SEAM *newseam();
00054
00055
00056
00057
00064 #define clone_seam(dest,source) \
00065 if (source) { \
00066 (dest) = newseam (); \
00067 (dest)->location = (source)->location; \
00068 (dest)->widthp = (source)->widthp; \
00069 (dest)->widthn = (source)->widthn; \
00070 (dest)->priority = (source)->priority; \
00071 clone_split ((dest)->split1, (source)->split1); \
00072 clone_split ((dest)->split2, (source)->split2); \
00073 clone_split ((dest)->split3, (source)->split3); \
00074 } \
00075 else { \
00076 (dest) = (SEAM*) NULL; \
00077 } \
00078
00079
00087 #define exact_point(p1,p2) \
00088 (! ((p1->pos.x - p2->pos.x) || (p1->pos.y - p2->pos.y)))
00089
00090
00091
00092
00093 bool point_in_split(SPLIT *split, EDGEPT *point1, EDGEPT *point2);
00094
00095 bool point_in_seam(SEAM *seam, SPLIT *split);
00096
00097 bool point_used_by_split(SPLIT *split, EDGEPT *point);
00098
00099 bool point_used_by_seam(SEAM *seam, EDGEPT *point);
00100
00101 SEAMS add_seam(SEAMS seam_list, SEAM *seam);
00102
00103 void combine_seams(SEAM *dest_seam, SEAM *source_seam);
00104
00105 void delete_seam(void *arg);
00106
00107 SEAMS start_seam_list(TBLOB *blobs);
00108
00109 void free_seam_list(SEAMS seam_list);
00110
00111 bool test_insert_seam(SEAMS seam_list,
00112 int index,
00113 TBLOB *left_blob,
00114 TBLOB *first_blob);
00115
00116 SEAMS insert_seam(SEAMS seam_list,
00117 int index,
00118 SEAM *seam,
00119 TBLOB *left_blob,
00120 TBLOB *first_blob);
00121
00122 int account_splits_right(SEAM *seam, TBLOB *blob);
00123
00124 int account_splits_left(SEAM *seam, TBLOB *blob, TBLOB *end_blob);
00125
00126 void account_splits_left_helper(SEAM *seam, TBLOB *blob, TBLOB *end_blob,
00127 inT32 *depth, inT8 *width, inT8 *found_em);
00128
00129 bool find_split_in_blob(SPLIT *split, TBLOB *blob);
00130
00131 SEAM *join_two_seams(SEAM *seam1, SEAM *seam2);
00132
00133 SEAM *new_seam(PRIORITY priority,
00134 const TPOINT& location,
00135 SPLIT *split1,
00136 SPLIT *split2,
00137 SPLIT *split3);
00138
00139 SEAMS new_seam_list();
00140
00141 void print_seam(const char *label, SEAM *seam);
00142
00143 void print_seams(const char *label, SEAMS seams);
00144
00145 int shared_split_points(SEAM *seam1, SEAM *seam2);
00146
00147 void break_pieces(TBLOB *blobs, SEAMS seams, inT16 start, inT16 end);
00148
00149 void join_pieces(TBLOB *piece_blobs, SEAMS seams, inT16 start, inT16 end);
00150
00151 void hide_seam(SEAM *seam);
00152
00153 void hide_edge_pair(EDGEPT *pt1, EDGEPT *pt2);
00154
00155 void reveal_seam(SEAM *seam);
00156
00157 void reveal_edge_pair(EDGEPT *pt1, EDGEPT *pt2);
00158
00159 #endif