tesseract
3.03
|
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 00034 /*---------------------------------------------------------------------- 00035 T y p e s 00036 ----------------------------------------------------------------------*/ 00037 typedef float PRIORITY; /* PRIORITY */ 00038 00039 struct SEAM { 00040 // Constructor that was formerly new_seam. 00041 SEAM(PRIORITY priority0, const TPOINT& location0, 00042 SPLIT *splita, SPLIT *splitb, SPLIT *splitc) 00043 : priority(priority0), widthp(0), widthn(0), location(location0), 00044 split1(splita), split2(splitb), split3(splitc) {} 00045 // Copy constructor that was formerly clone_seam. 00046 SEAM(const SEAM& src) 00047 : priority(src.priority), widthp(src.widthp), widthn(src.widthn), 00048 location(src.location) { 00049 clone_split(split1, src.split1); 00050 clone_split(split2, src.split2); 00051 clone_split(split3, src.split3); 00052 } 00053 // Destructor was delete_seam. 00054 ~SEAM() { 00055 if (split1) 00056 delete_split(split1); 00057 if (split2) 00058 delete_split(split2); 00059 if (split3) 00060 delete_split(split3); 00061 } 00062 00063 PRIORITY priority; 00064 inT8 widthp; 00065 inT8 widthn; 00066 TPOINT location; 00067 SPLIT *split1; 00068 SPLIT *split2; 00069 SPLIT *split3; 00070 }; 00071 00079 #define exact_point(p1,p2) \ 00080 (! ((p1->pos.x - p2->pos.x) || (p1->pos.y - p2->pos.y))) 00081 00082 /*---------------------------------------------------------------------- 00083 F u n c t i o n s 00084 ----------------------------------------------------------------------*/ 00085 bool point_in_split(SPLIT *split, EDGEPT *point1, EDGEPT *point2); 00086 00087 bool point_in_seam(const SEAM *seam, SPLIT *split); 00088 00089 bool point_used_by_split(SPLIT *split, EDGEPT *point); 00090 00091 bool point_used_by_seam(SEAM *seam, EDGEPT *point); 00092 00093 void combine_seams(SEAM *dest_seam, SEAM *source_seam); 00094 00095 void start_seam_list(TWERD *word, GenericVector<SEAM*>* seam_array); 00096 00097 bool test_insert_seam(const GenericVector<SEAM*>& seam_array, 00098 TWERD *word, int index); 00099 00100 void insert_seam(const TWERD *word, int index, SEAM *seam, 00101 GenericVector<SEAM*>* seam_array); 00102 00103 int account_splits(const SEAM *seam, const TWERD *word, int blob_index, 00104 int blob_direction); 00105 00106 bool find_split_in_blob(SPLIT *split, TBLOB *blob); 00107 00108 SEAM *join_two_seams(const SEAM *seam1, const SEAM *seam2); 00109 00110 void print_seam(const char *label, SEAM *seam); 00111 00112 void print_seams(const char *label, const GenericVector<SEAM*>& seams); 00113 00114 int shared_split_points(const SEAM *seam1, const SEAM *seam2); 00115 00116 void break_pieces(const GenericVector<SEAM*>& seams, 00117 int first, int last, TWERD *word); 00118 00119 void join_pieces(const GenericVector<SEAM*>& seams, 00120 int first, int last, TWERD *word); 00121 00122 void hide_seam(SEAM *seam); 00123 00124 void hide_edge_pair(EDGEPT *pt1, EDGEPT *pt2); 00125 00126 void reveal_seam(SEAM *seam); 00127 00128 void reveal_edge_pair(EDGEPT *pt1, EDGEPT *pt2); 00129 00130 #endif