Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
render.cpp
Go to the documentation of this file.
1 /* -*-C-*-
2 ********************************************************************************
3 *
4 * File: render.c (Formerly render.c)
5 * Description: Convert the various data type into line lists
6 * Author: Mark Seaman, OCR Technology
7 * Created: Fri Jul 28 13:14:48 1989
8 * Modified: Mon Jul 15 10:23:37 1991 (Mark Seaman) marks@hpgrlt
9 * Language: C
10 * Package: N/A
11 * Status: Experimental (Do Not Distribute)
12 *
13 * (c) Copyright 1989, 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 #include "render.h"
26 #include "blobs.h"
27
28 #ifdef __UNIX__
29 #include <assert.h>
30 #endif
31 #include <math.h>
32
33 #include "vecfuncs.h"
34
35 // Include automatically generated configuration file if running autoconf.
36 #ifdef HAVE_CONFIG_H
37 #include "config_auto.h"
38 #endif
39
40 /*----------------------------------------------------------------------
41 V a r i a b l e s
42 ----------------------------------------------------------------------*/
43 ScrollView *blob_window = NULL;
44
45 C_COL color_list[] = {
46 Red, Cyan, Yellow, Blue, Green, White
47 };
48
49 BOOL_VAR(wordrec_display_all_blobs, 0, "Display Blobs");
50
51 BOOL_VAR(wordrec_display_all_words, 0, "Display Words");
52
53 BOOL_VAR(wordrec_blob_pause, 0, "Blob pause");
54
55 /*----------------------------------------------------------------------
56 F u n c t i o n s
57 ----------------------------------------------------------------------*/
58 #ifndef GRAPHICS_DISABLED
59 /**********************************************************************
60 * display_blob
61 *
62 * Macro to display blob in a window.
63 **********************************************************************/
64 void display_blob(TBLOB *blob, C_COL color) {
65 /* Size of drawable */
66 if (blob_window == NULL) {
67 blob_window = c_create_window ("Blobs", 520, 10,
68 500, 256, -1000.0, 1000.0, 0.0, 256.0);
69 }
70 else {
71 c_clear_window(blob_window);
72 }
73
74 render_blob(blob_window, blob, color);
75 }
76
77 /**********************************************************************
78 * render_blob
79 *
80 * Create a list of line segments that represent the expanded outline
81 * that was supplied as input.
82 **********************************************************************/
83 void render_blob(void *window, TBLOB *blob, C_COL color) {
84 /* No outline */
85 if (!blob)
86 return;
87
88 render_outline (window, blob->outlines, color);
89 }
90
91
92 /**********************************************************************
93 * render_edgepts
94 *
95 * Create a list of line segments that represent the expanded outline
96 * that was supplied as input.
97 **********************************************************************/
98 void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
99 float x = edgept->pos.x;
100 float y = edgept->pos.y;
101 EDGEPT *this_edge = edgept;
102
103 if (!edgept)
104 return;
105
106 c_line_color_index(window, color);
107 c_move(window, x, y);
108 do {
109 this_edge = this_edge->next;
110 x = this_edge->pos.x;
111 y = this_edge->pos.y;
112 c_draw(window, x, y);
113 }
114 while (edgept != this_edge);
115 }
116
117
118 /**********************************************************************
119 * render_outline
120 *
121 * Create a list of line segments that represent the expanded outline
122 * that was supplied as input.
123 **********************************************************************/
124 void render_outline(void *window,
125 TESSLINE *outline,
126 C_COL color) {
127 /* No outline */
128 if (!outline)
129 return;
130 /* Draw Compact outline */
131 if (outline->loop)
132 render_edgepts (window, outline->loop, color);
133 /* Add on next outlines */
134 render_outline (window, outline->next, color);
135 }
136
137 #endif // GRAPHICS_DISABLED