tesseract  4.00.00dev
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 ----------------------------------------------------------------------*/
44 
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  if (!edgept)
100  return;
101 
102  float x = edgept->pos.x;
103  float y = edgept->pos.y;
104  EDGEPT *this_edge = edgept;
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
bool wordrec_display_all_blobs
Definition: render.cpp:49
TESSLINE * next
Definition: blobs.h:258
TPOINT pos
Definition: blobs.h:163
Definition: callcpp.h:34
void render_edgepts(void *window, EDGEPT *edgept, C_COL color)
Definition: render.cpp:98
Definition: callcpp.h:38
C_COL
Definition: callcpp.h:32
ScrollView * c_create_window(const char *name, inT16 xpos, inT16 ypos, inT16 xsize, inT16 ysize, double xmin, double xmax, double ymin, double ymax)
Definition: callcpp.cpp:55
TESSLINE * outlines
Definition: blobs.h:377
bool wordrec_display_all_words
Definition: render.cpp:51
Definition: callcpp.h:39
void render_outline(void *window, TESSLINE *outline, C_COL color)
Definition: render.cpp:124
Definition: callcpp.h:36
#define BOOL_VAR(name, val, comment)
Definition: params.h:279
Definition: callcpp.h:37
void display_blob(TBLOB *blob, C_COL color)
Definition: render.cpp:64
void render_blob(void *window, TBLOB *blob, C_COL color)
Definition: render.cpp:83
bool wordrec_blob_pause
Definition: render.cpp:53
void c_move(void *win, double x, double y)
Definition: callcpp.cpp:79
void c_clear_window(void *win)
Definition: callcpp.cpp:104
Definition: callcpp.h:35
void c_draw(void *win, double x, double y)
Definition: callcpp.cpp:88
EDGEPT * loop
Definition: blobs.h:257
inT16 x
Definition: blobs.h:71
EDGEPT * next
Definition: blobs.h:169
Definition: blobs.h:76
C_COL color_list[]
Definition: render.cpp:45
void c_line_color_index(void *win, C_COL index)
Definition: callcpp.cpp:70
inT16 y
Definition: blobs.h:72
Definition: blobs.h:261
ScrollView * blob_window
Definition: render.cpp:43