• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "split.h"
32 #include "tessarray.h"
33 
34 /*----------------------------------------------------------------------
35               T y p e s
36 ----------------------------------------------------------------------*/
37 typedef float PRIORITY;          /*  PRIORITY  */
38 
39 typedef struct seam_record
40 {                                /*  SEAM  */
41   PRIORITY priority;
42   inT8 widthp;
43   inT8 widthn;
44   inT16 location;
45   SPLIT *split1;
46   SPLIT *split2;
47   SPLIT *split3;
48 } SEAM;
49 
50 typedef ARRAY SEAMS;             /*  SEAMS  */
51 
52 extern SEAM *newseam();
53 
54 /*----------------------------------------------------------------------
55               M a c r o s
56 ----------------------------------------------------------------------*/
57 /**********************************************************************
58  * clone_seam
59  *
60  * Create a new seam record and copy the contents of this seam into it.
61  **********************************************************************/
62 
63 #define clone_seam(dest,source)                       \
64 if (source) {                                       \
65 	(dest) = newseam ();                     \
66 	(dest)->location = (source)->location;           \
67 	(dest)->widthp = (source)->widthp;           \
68 	(dest)->widthn = (source)->widthn;           \
69 	(dest)->priority = (source)->priority;           \
70 	clone_split ((dest)->split1, (source)->split1);  \
71 	clone_split ((dest)->split2, (source)->split2);  \
72 	clone_split ((dest)->split3, (source)->split3);  \
73 }                                                   \
74 else {                                              \
75 	(dest) = (SEAM*) NULL;                           \
76 }                                                   \
77 
78 
79 /**********************************************************************
80  * exact_point
81  *
82  * Return TRUE if the point positions are the exactly the same. The
83  * parameters must be of type (EDGEPT*).
84  **********************************************************************/
85 
86 #define exact_point(p1,p2)                    \
87 	(! ((p1->pos.x - p2->pos.x) || (p1->pos.y - p2->pos.y)))
88 
89 /*----------------------------------------------------------------------
90               F u n c t i o n s
91 ----------------------------------------------------------------------*/
92 bool point_in_split(SPLIT *split, EDGEPT *point1, EDGEPT *point2);
93 
94 bool point_in_seam(SEAM *seam, SPLIT *split);
95 
96 SEAMS add_seam(SEAMS seam_list, SEAM *seam);
97 
98 void combine_seams(SEAM *dest_seam, SEAM *source_seam);
99 
100 void delete_seam(void *arg);  //SEAM  *seam);
101 
102 void free_seam_list(SEAMS seam_list);
103 
104 bool test_insert_seam(SEAMS seam_list,
105                       int index,
106                       TBLOB *left_blob,
107                       TBLOB *first_blob);
108 
109 SEAMS insert_seam(SEAMS seam_list,
110                   int index,
111                   SEAM *seam,
112                   TBLOB *left_blob,
113                   TBLOB *first_blob);
114 
115 int account_splits_right(SEAM *seam, TBLOB *blob);
116 
117 int account_splits_left(SEAM *seam, TBLOB *blob, TBLOB *end_blob);
118 
119 bool find_split_in_blob(SPLIT *split, TBLOB *blob);
120 
121 SEAM *join_two_seams(SEAM *seam1, SEAM *seam2);
122 
123 SEAM *new_seam(PRIORITY priority,
124                int x_location,
125                SPLIT *split1,
126                SPLIT *split2,
127                SPLIT *split3);
128 
129 SEAMS new_seam_list();
130 
131 void print_seam(const char *label, SEAM *seam);
132 
133 void print_seams(const char *label, SEAMS seams);
134 
135 int shared_split_points(SEAM *seam1, SEAM *seam2);
136 #endif
137