31 #include "config_auto.h"
70 result->
loop = outline;
87 newpt =
new EDGEPT(*srcpt);
96 }
while (srcpt != src.
loop);
111 this_edge = next_edge;
112 }
while (this_edge !=
loop);
122 }
while (pt !=
loop);
130 int tmp =
static_cast<int>(floor(pt->
pos.
x * rot.
x() -
131 pt->
pos.
y * rot.
y() + 0.5));
132 pt->
pos.
y =
static_cast<int>(floor(pt->
pos.
y * rot.
x() +
133 pt->
pos.
x * rot.
y() + 0.5));
136 }
while (pt !=
loop);
144 pt->
pos.
x += vec.
x();
145 pt->
pos.
y += vec.
y();
147 }
while (pt !=
loop);
155 pt->
pos.
x =
static_cast<int>(floor(pt->
pos.
x * factor + 0.5));
156 pt->
pos.
y =
static_cast<int>(floor(pt->
pos.
y * factor + 0.5));
158 }
while (pt !=
loop);
169 }
while (pt !=
loop);
186 if (this_edge->
pos.
x < minx)
187 minx = this_edge->
pos.
x;
188 if (this_edge->
pos.
y < miny)
189 miny = this_edge->
pos.
y;
190 if (this_edge->
pos.
x > maxx)
191 maxx = this_edge->
pos.
x;
192 if (this_edge->
pos.
y > maxy)
193 maxy = this_edge->
pos.
y;
195 this_edge = this_edge->
next;
196 }
while (this_edge !=
loop);
210 int* min_xp,
int* max_xp)
const {
216 int product =
CROSS(this_edge->
pos, vec);
219 this_edge = this_edge->
next;
220 }
while (this_edge !=
loop);
227 #ifndef GRAPHICS_DISABLED
231 window->
Pen(child_color);
243 }
while (pt !=
loop);
245 #endif // GRAPHICS_DISABLED
250 static TESSLINE** ApproximateOutlineList(C_OUTLINE_LIST* outlines,
253 C_OUTLINE_IT ol_it(outlines);
254 for (ol_it.mark_cycle_pt(); !ol_it.cycled_list(); ol_it.forward()) {
259 tail = &tessline->
next;
260 if (!outline->
child()->empty()) {
261 tail = ApproximateOutlineList(outline->
child(),
true, tail);
270 C_OUTLINE_IT ol_it = src->
out_list();
285 if ((*denorm)->block() !=
NULL &&
286 (*denorm)->block()->classify_rotation().y() != 0.0) {
288 int x_middle = (box.
left() + box.
right()) / 2;
289 int y_middle = (box.
top() + box.
bottom()) / 2;
290 rotated_blob =
new TBLOB(*
this);
291 const FCOORD& rotation = (*denorm)->block()->classify_rotation();
296 (rotation.
y() > 0 ? x_middle - box.
left() : box.
right() - x_middle);
298 x_middle, y_middle, 1.0
f, 1.0
f, 0.0
f, target_y);
311 srcline = srcline->next) {
313 if (outlines ==
NULL)
314 outlines = new_outline;
316 prev_outline->
next = new_outline;
317 prev_outline = new_outline;
324 outlines = next_outline) {
325 next_outline = outlines->next;
334 for (
TESSLINE* outline = outlines; outline !=
NULL; outline = outline->next) {
335 outline->Normalize(denorm);
344 for (
TESSLINE* outline = outlines; outline !=
NULL; outline = outline->next) {
345 outline->Rotate(rotation);
351 for (
TESSLINE* outline = outlines; outline !=
NULL; outline = outline->next) {
358 for (
TESSLINE* outline = outlines; outline !=
NULL; outline = outline->next) {
359 outline->Scale(factor);
365 for (
TESSLINE* outline = outlines; outline !=
NULL; outline = outline->next) {
366 outline->ComputeBoundingBox();
373 for (
TESSLINE* outline = outlines; outline !=
NULL; outline = outline->next)
385 if (outlines ==
NULL)
386 return TBOX(0, 0, 0, 0);
389 for (outline = outline->
next; outline !=
NULL; outline = outline->
next) {
395 #ifndef GRAPHICS_DISABLED
398 for (
TESSLINE* outline = outlines; outline !=
NULL; outline = outline->next)
399 outline->
plot(window, color, child_color);
401 #endif // GRAPHICS_DISABLED
410 for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
411 C_BLOB* blob = b_it.data();
414 tessword->
blobs = tblob;
425 float x_height,
bool numeric_mode,
427 int num_segments = 0;
432 TBOX blob_box = blob->bounding_box();
435 factor, factor * 1.5
f);
449 blob->Normalize(denorm);
458 for (
TBLOB* srcblob = src.
blobs; srcblob !=
NULL; srcblob = srcblob->next) {
463 prev_blob->
next = new_blob;
464 prev_blob = new_blob;
479 blob->ComputeBoundingBoxes();
486 TBOX box = blob->bounding_box();
496 for (
int i = 0; i < start && blob !=
NULL; ++i)
502 for (
int i = start + 1; i < end && next_blob !=
NULL; ++i) {
504 if (outline ==
NULL) {
509 outline = outline->
next;
514 TBLOB* dead_blob = next_blob;
515 next_blob = next_blob->
next;
516 blob->
next = next_blob;
521 #ifndef GRAPHICS_DISABLED
529 #endif // GRAPHICS_DISABLED
564 blob_end = bbox.
right();
566 for (
TBLOB* blob = blobs->
next; blob !=
NULL; blob = blob->next) {
567 TBOX curbox = blob->bounding_box();
568 width_record->
widths[i++] = curbox.
left() - blob_end;
570 blob_end = curbox.
right();
584 for (
TBLOB* b = blobs; b !=
NULL; b = b->next)
603 outline1 = outline1->next) {
604 if (outline1->is_hole)
607 static_cast<inT16>((outline1->topleft.x + outline1->botright.x) / 2),
608 static_cast<inT16>((outline1->topleft.y + outline1->botright.y) / 2));
609 int mid_prod1 =
CROSS(mid_pt1, vertical);
610 int min_prod1, max_prod1;
611 outline1->MinMaxCrossProduct(vertical, &min_prod1, &max_prod1);
613 outline2 = outline2->next) {
614 if (outline2->is_hole)
617 static_cast<inT16>((outline2->topleft.x + outline2->botright.x) / 2),
618 static_cast<inT16>((outline2->topleft.y + outline2->botright.y) / 2));
619 int mid_prod2 =
CROSS(mid_pt2, vertical);
620 int min_prod2, max_prod2;
621 outline2->MinMaxCrossProduct(vertical, &min_prod2, &max_prod2);
622 int mid_gap = abs(mid_prod2 - mid_prod1);
623 int overlap =
MIN(max_prod1, max_prod2) -
MAX(min_prod1, min_prod2);
624 if (mid_gap - overlap / 4 > max_gap) {
625 max_gap = mid_gap - overlap / 4;
627 *location += mid_pt2;
634 return max_gap > vertical.
y;
654 int location_prod =
CROSS(location, vertical);
656 while (outline !=
NULL) {
660 int mid_prod =
CROSS(mid_pt, vertical);
661 if (mid_prod < location_prod) {
664 outline1->
next = outline;
671 outline2->
next = outline;
676 outline = outline->
next;