Tesseract
3.02
|
00001 /* -*-C-*- 00002 ******************************************************************************** 00003 * 00004 * File: seam.h (Formerly seam.h) 00005 * Description: 00006 * Author: Mark Seaman, SW Productivity 00007 * Created: Fri Oct 16 14:37:00 1987 00008 * Modified: Thu May 16 17:05:52 1991 (Mark Seaman) marks@hpgrlt 00009 * Language: C 00010 * Package: N/A 00011 * Status: Reusable Software Component 00012 * 00013 * (c) Copyright 1987, Hewlett-Packard Company. 00014 ** Licensed under the Apache License, Version 2.0 (the "License"); 00015 ** you may not use this file except in compliance with the License. 00016 ** You may obtain a copy of the License at 00017 ** http://www.apache.org/licenses/LICENSE-2.0 00018 ** Unless required by applicable law or agreed to in writing, software 00019 ** distributed under the License is distributed on an "AS IS" BASIS, 00020 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00021 ** See the License for the specific language governing permissions and 00022 ** limitations under the License. 00023 * 00024 *********************************************************************************/ 00025 #ifndef SEAM_H 00026 #define SEAM_H 00027 00028 /*---------------------------------------------------------------------- 00029 I n c l u d e s 00030 ----------------------------------------------------------------------*/ 00031 #include "blobs.h" 00032 #include "split.h" 00033 #include "tessarray.h" 00034 00035 /*---------------------------------------------------------------------- 00036 T y p e s 00037 ----------------------------------------------------------------------*/ 00038 typedef float PRIORITY; /* PRIORITY */ 00039 00040 typedef struct seam_record 00041 { /* SEAM */ 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; /* SEAMS */ 00052 00053 extern SEAM *newseam(); 00054 00055 /*---------------------------------------------------------------------- 00056 M a c r o s 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 F u n c t i o n s 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); //SEAM *seam); 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