24 #define FASTEDGELENGTH 256 33 "More accurate approx on wide things");
43 #define fixed_dist 20 //really an int_variable 44 #define approx_dist 15 //really an int_variable 64 EDGEPT* edgepts = stack_edgepts;
73 area = loop_box.
width();
80 EDGEPT* prev_result = NULL;
84 new_pt->
prev = prev_result;
85 if (prev_result == NULL) {
88 prev_result->
next = new_pt;
89 new_pt->
prev = prev_result;
91 if (allow_detailed_fx) {
97 edgept = edgept->
next;
99 while (edgept != startpt);
100 prev_result->
next = result;
101 result->
prev = prev_result;
102 if (edgepts != stack_edgepts)
137 int prev_stepindex = 0;
139 dir = c_outline->
step_dir (stepindex);
140 vec = c_outline->
step (stepindex);
141 if (stepindex < length - 1
142 && c_outline->
step_dir (stepindex + 1) - dir == -32) {
144 vec += c_outline->
step (stepindex + 1);
154 edgepts[epindex].
pos.
x = pos.
x ();
155 edgepts[epindex].
pos.
y = pos.
y ();
157 edgepts[epindex].
vec.
x = prev_vec.
x ();
158 edgepts[epindex].
vec.
y = prev_vec.
y ();
161 edgepts[epindex].
prev = &edgepts[epindex - 1];
163 edgepts[epindex].
next = &edgepts[epindex + 1];
165 epdir = (
DIR128) 0 - prevdir;
168 edgepts[epindex].
flags[
DIR] = epdir;
171 edgepts[epindex].
step_count = stepindex - prev_stepindex;
176 prev_stepindex = stepindex;
180 stepindex += stepinc;
182 while (stepindex < length);
183 edgepts[epindex].
pos.
x = pos.
x ();
184 edgepts[epindex].
pos.
y = pos.
y ();
186 edgepts[epindex].
vec.
x = prev_vec.
x ();
187 edgepts[epindex].
vec.
y = prev_vec.
y ();
193 edgepts[epindex].
step_count = stepindex - prev_stepindex;
194 edgepts[epindex].
prev = &edgepts[epindex - 1];
195 edgepts[epindex].
next = &edgepts[0];
197 epdir = (
DIR128) 0 - prevdir;
200 edgepts[epindex].
flags[
DIR] = epdir;
201 edgepts[0].
prev = &edgepts[epindex];
225 int d01, d12, d23, gapmin;
226 TPOINT d01vec, d12vec, d23vec;
227 EDGEPT *edgefix, *startfix;
228 EDGEPT *edgefix0, *edgefix1, *edgefix2, *edgefix3;
235 edgept = edgept->
next;
245 edgept = edgept->
next;
249 if (((dir1 - dir2 + 1) & 7) < 3) {
251 edgept = edgept->
next;
259 if (edgept == loopstart)
266 linestart = linestart->
prev;
271 || (edgept->
flags[
DIR] == dir1 && sum1 >= sum2)
273 || (edgept->
flags[
DIR] == dir2 && sum2 >= sum1))
274 && linestart->
next != edgept))
275 edgept = edgept->
next;
281 while (edgept != loopstart && !stopped);
290 edgept1 = edgept->
next;
293 edgept = edgept->
next;
295 while (edgept != start);
310 edgept = edgept->
next;
312 while (edgept != start);
325 edgept = edgept->
next;
327 while (edgept != start);
329 edgept = edgept->
next;
332 edgept = edgept->
next;
334 edgept = edgept->
next;
337 edgept = edgept->
next;
339 edgept = edgept->
next;
342 edgept = edgept->
next;
344 edgept = edgept->
next;
350 if (fixed_count <= 3)
379 edgept = edgept->
next;
381 if (edgept == startfix)
383 edgept = edgept->
next;
388 while ((edgefix != startfix) && (!stopped));
422 edgept = edgept->
next;
424 while (edgept != startpt);
440 edgept = edgept->
next;
443 && edgept != loopstart && edgesum < 126);
446 (
"Poly2:starting at (%d,%d)+%d=(%d,%d),%d to (%d,%d)\n",
448 linestart->
vec.
x, linestart->
vec.
y, edgesum, edgept->
pos.
x,
451 cutline(linestart, edgept, area);
454 && edgept != loopstart)
455 edgept = edgept->
next;
458 while (edgept != loopstart);
463 edgept = edgept->
next;
466 while (edgept != loopstart);
474 edgept = edgept->
next;
477 linestart->
next = edgept;
478 edgept->
prev = linestart;
482 while (edgept != loopstart);
519 if (vecsum.
x == 0 && vecsum.
y == 0) {
525 vlen = vecsum.
x > 0 ? vecsum.
x : -vecsum.
x;
528 else if (-vecsum.
y > vlen)
534 squaresum = ptcount = 0;
538 perp =
CROSS (vec, vecsum);
545 tprintf (
"Cutline:Final perp=%d\n", perp);
546 if (perp > maxperp) {
550 vec.
x += edge->
vec.
x;
551 vec.
y += edge->
vec.
y;
554 while (edge !=
last);
569 perp = (squaresum << 8) / (perp * ptcount);
572 perp = (squaresum / perp << 8) / ptcount;
575 tprintf (
"Cutline:A=%d, max=%.2f(%.2f%%), msd=%.2f(%.2f%%)\n",
576 area, maxperp / 256.0, maxperp * 200.0 / area,
577 perp / 256.0, perp * 300.0 / area);
578 if (maxperp *
par1 >= 10 * area || perp *
par2 >= 10 * area || vlen >= 126) {
581 cutline(first, maxpoint, area);
EDGEPT * edgesteps_to_edgepts(C_OUTLINE *c_outline, EDGEPT edgepts[])
static TESSLINE * BuildFromOutlineList(EDGEPT *outline)
ICOORD step(int index) const
#define point_diff(p, p1, p2)
void fix2(EDGEPT *start, int area)
inT16 x() const
access function
const TBOX & bounding_box() const
EXTERN bool poly_wide_objects_better
void cutline(EDGEPT *first, EDGEPT *last, int area)
const ICOORD & start_pos() const
DIR128 step_dir(int index) const
TESSLINE * ApproximateOutline(bool allow_detailed_fx, C_OUTLINE *c_outline)
#define BOOL_VAR(name, val, comment)
EDGEPT * poly2(EDGEPT *startpt, int area)
inT16 y() const
access_function