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