~ubuntu-branches/ubuntu/vivid/tesseract/vivid

« back to all changes in this revision

Viewing changes to ccstruct/polyaprx.cpp

  • Committer: Package Import Robot
  • Author(s): Jeff Breidenbach
  • Date: 2014-02-03 11:10:20 UTC
  • mfrom: (1.3.1) (19.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140203111020-igquodd7pjlp3uri
Tags: 3.03.01-1
* New upstream release, includes critical fix to PDF rendering
* Complete leptonlib transition (see bug #735509)
* Promote from experimental to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *
18
18
 **********************************************************************/
19
19
 
20
 
#include "mfcpch.h"
21
20
#include          <stdio.h>
22
21
#ifdef __UNIX__
23
22
#include          <assert.h>
29
28
 
30
29
#define EXTERN
31
30
 
32
 
EXTERN BOOL_VAR (poly_debug, FALSE, "Debug old poly");
33
 
EXTERN BOOL_VAR (poly_wide_objects_better, TRUE,
34
 
"More accurate approx on wide things");
35
 
 
 
31
EXTERN BOOL_VAR(poly_debug, FALSE, "Debug old poly");
 
32
EXTERN BOOL_VAR(poly_wide_objects_better, TRUE,
 
33
                "More accurate approx on wide things");
36
34
 
37
35
#define FIXED       4            /*OUTLINE point is fixed */
38
36
 
53
51
 * tesspoly_outline
54
52
 *
55
53
 * Approximate an outline from chain codes form using the old tess algorithm.
 
54
 * If allow_detailed_fx is true, the EDGEPTs in the returned TBLOB
 
55
 * contain pointers to the input C_OUTLINEs that enable higher-resolution
 
56
 * feature extraction that does not use the polygonal approximation.
56
57
 **********************************************************************/
57
58
 
58
59
 
59
 
TESSLINE* ApproximateOutline(C_OUTLINE* c_outline) {
 
60
TESSLINE* ApproximateOutline(bool allow_detailed_fx, C_OUTLINE* c_outline) {
60
61
  EDGEPT *edgept;                // converted steps
61
62
  TBOX loop_box;                  // bounding box
62
63
  inT32 area;                    // loop area
88
89
      prev_result->next = new_pt;
89
90
      new_pt->prev = prev_result;
90
91
    }
 
92
    if (allow_detailed_fx) {
 
93
      new_pt->src_outline = edgept->src_outline;
 
94
      new_pt->start_step = edgept->start_step;
 
95
      new_pt->step_count = edgept->step_count;
 
96
    }
91
97
    prev_result = new_pt;
92
98
    edgept = edgept->next;
93
99
  }
129
135
  epindex = 0;
130
136
  prevdir = -1;
131
137
  count = 0;
 
138
  int prev_stepindex = 0;
132
139
  do {
133
140
    dir = c_outline->step_dir (stepindex);
134
141
    vec = c_outline->step (stepindex);
160
167
      epdir >>= 4;
161
168
      epdir &= 7;
162
169
      edgepts[epindex].flags[DIR] = epdir;
 
170
      edgepts[epindex].src_outline = c_outline;
 
171
      edgepts[epindex].start_step = prev_stepindex;
 
172
      edgepts[epindex].step_count = stepindex - prev_stepindex;
163
173
      epindex++;
164
174
      prevdir = dir;
165
175
      prev_vec = vec;
166
176
      count = 1;
 
177
      prev_stepindex = stepindex;
167
178
    }
168
179
    else
169
180
      count++;
178
189
  pos += prev_vec;
179
190
  edgepts[epindex].flags[RUNLENGTH] = count;
180
191
  edgepts[epindex].flags[FLAGS] = 0;
 
192
  edgepts[epindex].src_outline = c_outline;
 
193
  edgepts[epindex].start_step = prev_stepindex;
 
194
  edgepts[epindex].step_count = stepindex - prev_stepindex;
181
195
  edgepts[epindex].prev = &edgepts[epindex - 1];
182
196
  edgepts[epindex].next = &edgepts[0];
183
197
  prevdir += 64;