Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
seam.h
Go to the documentation of this file.
1 /* -*-C-*-
2  ********************************************************************************
3  *
4  * File: seam.h (Formerly seam.h)
5  * Description:
6  * Author: Mark Seaman, SW Productivity
7  * Created: Fri Oct 16 14:37:00 1987
8  * Modified: Thu May 16 17:05:52 1991 (Mark Seaman) marks@hpgrlt
9  * Language: C
10  * Package: N/A
11  * Status: Reusable Software Component
12  *
13  * (c) Copyright 1987, Hewlett-Packard Company.
14  ** Licensed under the Apache License, Version 2.0 (the "License");
15  ** you may not use this file except in compliance with the License.
16  ** You may obtain a copy of the License at
17  ** http://www.apache.org/licenses/LICENSE-2.0
18  ** Unless required by applicable law or agreed to in writing, software
19  ** distributed under the License is distributed on an "AS IS" BASIS,
20  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  ** See the License for the specific language governing permissions and
22  ** limitations under the License.
23  *
24  *********************************************************************************/
25 #ifndef SEAM_H
26 #define SEAM_H
27 
28 /*----------------------------------------------------------------------
29  I n c l u d e s
30 ----------------------------------------------------------------------*/
31 #include "blobs.h"
32 #include "split.h"
33 #include "tessarray.h"
34 
35 /*----------------------------------------------------------------------
36  T y p e s
37 ----------------------------------------------------------------------*/
38 typedef float PRIORITY; /* PRIORITY */
39 
40 typedef struct seam_record
41 { /* SEAM */
49 } SEAM;
50 
51 typedef ARRAY SEAMS; /* SEAMS */
52 
53 extern SEAM *newseam();
54 
55 /*----------------------------------------------------------------------
56  M a c r o s
57 ----------------------------------------------------------------------*/
64 #define clone_seam(dest,source) \
65 if (source) { \
66  (dest) = newseam (); \
67  (dest)->location = (source)->location; \
68  (dest)->widthp = (source)->widthp; \
69  (dest)->widthn = (source)->widthn; \
70  (dest)->priority = (source)->priority; \
71  clone_split ((dest)->split1, (source)->split1); \
72  clone_split ((dest)->split2, (source)->split2); \
73  clone_split ((dest)->split3, (source)->split3); \
74 } \
75 else { \
76  (dest) = (SEAM*) NULL; \
77 } \
78 
79 
87 #define exact_point(p1,p2) \
88  (! ((p1->pos.x - p2->pos.x) || (p1->pos.y - p2->pos.y)))
89 
90 /*----------------------------------------------------------------------
91  F u n c t i o n s
92 ----------------------------------------------------------------------*/
93 bool point_in_split(SPLIT *split, EDGEPT *point1, EDGEPT *point2);
94 
95 bool point_in_seam(SEAM *seam, SPLIT *split);
96 
97 bool point_used_by_split(SPLIT *split, EDGEPT *point);
98 
99 bool point_used_by_seam(SEAM *seam, EDGEPT *point);
100 
101 SEAMS add_seam(SEAMS seam_list, SEAM *seam);
102 
103 void combine_seams(SEAM *dest_seam, SEAM *source_seam);
104 
105 void delete_seam(void *arg); //SEAM *seam);
106 
107 SEAMS start_seam_list(TBLOB *blobs);
108 
109 void free_seam_list(SEAMS seam_list);
110 
111 bool test_insert_seam(SEAMS seam_list,
112  int index,
113  TBLOB *left_blob,
114  TBLOB *first_blob);
115 
116 SEAMS insert_seam(SEAMS seam_list,
117  int index,
118  SEAM *seam,
119  TBLOB *left_blob,
120  TBLOB *first_blob);
121 
122 int account_splits_right(SEAM *seam, TBLOB *blob);
123 
124 int account_splits_left(SEAM *seam, TBLOB *blob, TBLOB *end_blob);
125 
126 void account_splits_left_helper(SEAM *seam, TBLOB *blob, TBLOB *end_blob,
127  inT32 *depth, inT8 *width, inT8 *found_em);
128 
129 bool find_split_in_blob(SPLIT *split, TBLOB *blob);
130 
131 SEAM *join_two_seams(SEAM *seam1, SEAM *seam2);
132 
133 SEAM *new_seam(PRIORITY priority,
134  const TPOINT& location,
135  SPLIT *split1,
136  SPLIT *split2,
137  SPLIT *split3);
138 
140 
141 void print_seam(const char *label, SEAM *seam);
142 
143 void print_seams(const char *label, SEAMS seams);
144 
145 int shared_split_points(SEAM *seam1, SEAM *seam2);
146 
147 void break_pieces(TBLOB *blobs, SEAMS seams, inT16 start, inT16 end);
148 
149 void join_pieces(TBLOB *piece_blobs, SEAMS seams, inT16 start, inT16 end);
150 
151 void hide_seam(SEAM *seam);
152 
153 void hide_edge_pair(EDGEPT *pt1, EDGEPT *pt2);
154 
155 void reveal_seam(SEAM *seam);
156 
157 void reveal_edge_pair(EDGEPT *pt1, EDGEPT *pt2);
158 
159 #endif