tesseract 4.1.1
Loading...
Searching...
No Matches
render.cpp
Go to the documentation of this file.
1/* -*-C-*-
2 ********************************************************************************
3 *
4 * File: render.cpp (Formerly render.c)
5 * Description: Convert the various data type into line lists
6 * Author: Mark Seaman, OCR Technology
7 *
8 * (c) Copyright 1989, Hewlett-Packard Company.
9 ** Licensed under the Apache License, Version 2.0 (the "License");
10 ** you may not use this file except in compliance with the License.
11 ** You may obtain a copy of the License at
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 ** Unless required by applicable law or agreed to in writing, software
14 ** distributed under the License is distributed on an "AS IS" BASIS,
15 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 ** See the License for the specific language governing permissions and
17 ** limitations under the License.
18 *
19 *********************************************************************************/
20#include "render.h"
21#include "blobs.h"
22
23#include <cmath>
24
25// Include automatically generated configuration file if running autoconf.
26#ifdef HAVE_CONFIG_H
27#include "config_auto.h"
28#endif
29
30/*----------------------------------------------------------------------
31 V a r i a b l e s
32----------------------------------------------------------------------*/
34
37};
38
40
41BOOL_VAR(wordrec_blob_pause, 0, "Blob pause");
42
43/*----------------------------------------------------------------------
44 F u n c t i o n s
45----------------------------------------------------------------------*/
46#ifndef GRAPHICS_DISABLED
47/**********************************************************************
48 * display_blob
49 *
50 * Macro to display blob in a window.
51 **********************************************************************/
52void display_blob(TBLOB *blob, C_COL color) {
53 /* Size of drawable */
54 if (blob_window == nullptr) {
55 blob_window = c_create_window ("Blobs", 520, 10,
56 500, 256, -1000.0, 1000.0, 0.0, 256.0);
57 }
58 else {
60 }
61
62 render_blob(blob_window, blob, color);
63}
64
65/**********************************************************************
66 * render_blob
67 *
68 * Create a list of line segments that represent the expanded outline
69 * that was supplied as input.
70 **********************************************************************/
71void render_blob(void *window, TBLOB *blob, C_COL color) {
72 /* No outline */
73 if (!blob)
74 return;
75
76 render_outline (window, blob->outlines, color);
77}
78
79
80/**********************************************************************
81 * render_edgepts
82 *
83 * Create a list of line segments that represent the expanded outline
84 * that was supplied as input.
85 **********************************************************************/
86void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
87 if (!edgept)
88 return;
89
90 float x = edgept->pos.x;
91 float y = edgept->pos.y;
92 EDGEPT *this_edge = edgept;
93
94 c_line_color_index(window, color);
95 c_move(window, x, y);
96 do {
97 this_edge = this_edge->next;
98 x = this_edge->pos.x;
99 y = this_edge->pos.y;
100 c_draw(window, x, y);
101 }
102 while (edgept != this_edge);
103}
104
105
106/**********************************************************************
107 * render_outline
108 *
109 * Create a list of line segments that represent the expanded outline
110 * that was supplied as input.
111 **********************************************************************/
112void render_outline(void *window,
113 TESSLINE *outline,
114 C_COL color) {
115 /* No outline */
116 if (!outline)
117 return;
118 /* Draw Compact outline */
119 if (outline->loop)
120 render_edgepts (window, outline->loop, color);
121 /* Add on next outlines */
122 render_outline (window, outline->next, color);
123}
124
125#endif // GRAPHICS_DISABLED
#define BOOL_VAR(name, val, comment)
Definition: params.h:306
void c_draw(void *win, double x, double y)
Definition: callcpp.cpp:80
void c_move(void *win, double x, double y)
Definition: callcpp.cpp:71
void c_line_color_index(void *win, C_COL index)
Definition: callcpp.cpp:62
ScrollView * c_create_window(const char *name, int16_t xpos, int16_t ypos, int16_t xsize, int16_t ysize, double xmin, double xmax, double ymin, double ymax)
Definition: callcpp.cpp:47
void c_clear_window(void *win)
Definition: callcpp.cpp:96
C_COL
Definition: callcpp.h:27
@ Cyan
Definition: callcpp.h:33
@ White
Definition: callcpp.h:29
@ Yellow
Definition: callcpp.h:31
@ Green
Definition: callcpp.h:32
@ Red
Definition: callcpp.h:30
@ Blue
Definition: callcpp.h:34
ScrollView * blob_window
Definition: render.cpp:33
bool wordrec_display_all_blobs
Definition: render.cpp:39
void display_blob(TBLOB *blob, C_COL color)
Definition: render.cpp:52
bool wordrec_blob_pause
Definition: render.cpp:41
void render_edgepts(void *window, EDGEPT *edgept, C_COL color)
Definition: render.cpp:86
C_COL color_list[]
Definition: render.cpp:35
void render_outline(void *window, TESSLINE *outline, C_COL color)
Definition: render.cpp:112
void render_blob(void *window, TBLOB *blob, C_COL color)
Definition: render.cpp:71
int16_t x
Definition: blobs.h:93
int16_t y
Definition: blobs.h:94
Definition: blobs.h:99
EDGEPT * next
Definition: blobs.h:192
TPOINT pos
Definition: blobs.h:186
EDGEPT * loop
Definition: blobs.h:280
TESSLINE * next
Definition: blobs.h:281
Definition: blobs.h:284
TESSLINE * outlines
Definition: blobs.h:400