26 #include "allheaders.h"
30 #include "config_auto.h"
49 ):box (bot_left, top_right), start (startpt->pos) {
60 memset(steps, 0, step_mem());
63 for (stepindex = 0; stepindex < length; stepindex++) {
66 edgept = edgept->
next;
95 memset(steps, 0, step_mem());
97 lastdir = new_steps[length - 1];
99 for (stepindex = 0, srcindex = 0; srcindex < length;
100 stepindex++, srcindex++) {
101 new_box =
TBOX (pos, pos);
104 dir = new_steps[srcindex];
106 dirdiff = dir - prevdir;
107 pos +=
step (stepindex);
108 if ((dirdiff == 64 || dirdiff == -64) && stepindex > 0) {
110 prevdir = stepindex >= 0 ?
step_dir (stepindex) : lastdir;
118 if (dirdiff == 64 || dirdiff == -64) {
121 for (
int i = 0; i < stepindex; ++i)
125 while (stepindex > 1 && (dirdiff == 64 || dirdiff == -64));
126 stepcount = stepindex;
151 stepcount = srcline->stepcount * 2;
152 if (stepcount == 0) {
160 memset(steps, 0, step_mem());
162 for (
int iteration = 0; iteration < 2; ++iteration) {
163 DIR128 round1 = iteration == 0 ? 32 : 0;
164 DIR128 round2 = iteration != 0 ? 32 : 0;
165 pos = srcline->start;
167 prevpos.
rotate (rotation);
169 box =
TBOX (start, start);
171 for (stepindex = 0; stepindex < srcline->stepcount; stepindex++) {
172 pos += srcline->
step (stepindex);
174 destpos.
rotate (rotation);
176 while (destpos.
x () != prevpos.
x () || destpos.
y () != prevpos.
y ()) {
182 set_step(destindex++, dir + round1);
183 prevpos +=
step(destindex - 1);
187 -64 && dirdiff != 64)) {
188 set_step(destindex++, dir + round2);
189 prevpos +=
step(destindex - 1);
191 prevpos -=
step(destindex - 1);
193 prevpos -=
step(destindex - 1);
194 set_step(destindex - 1, dir + round2);
195 prevpos +=
step(destindex - 1);
200 prevpos +=
step(destindex - 1);
202 while (destindex >= 2 &&
206 prevpos -=
step(destindex - 1);
207 prevpos -=
step(destindex - 2);
211 new_box =
TBOX (destpos, destpos);
215 ASSERT_HOST (destpos.
x () == start.
x () && destpos.
y () == start.
y ());
217 while ((dirdiff == 64 || dirdiff == -64) && destindex > 1) {
220 for (
int i = 0; i < destindex; ++i)
228 stepcount = destindex;
230 for (stepindex = 0; stepindex < stepcount; stepindex++) {
231 destpos +=
step (stepindex);
233 ASSERT_HOST (destpos.
x () == start.
x () && destpos.
y () == start.
y ());
238 C_OUTLINE_IT ol_it(outlines);
244 ol_it.add_to_end(outline);
259 C_OUTLINE_IT it =
child ();
264 for (stepindex = 0; stepindex < total_steps; stepindex++) {
266 next_step =
step (stepindex);
267 if (next_step.
x () < 0)
269 else if (next_step.
x () > 0)
273 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
274 total += it.data ()->area ();
287 C_OUTLINE_IT it =
child();
290 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward())
291 total_steps += it.data()->pathlength();
312 if (total_steps == 0)
315 for (stepindex = 0; stepindex < total_steps; stepindex++) {
317 next_step =
step (stepindex);
318 if (next_step.
x () < 0)
320 else if (next_step.
x () > 0)
338 BOOL8 first_was_max_x;
339 BOOL8 first_was_max_y;
340 BOOL8 looking_for_max_x;
341 BOOL8 looking_for_min_x;
342 BOOL8 looking_for_max_y;
343 BOOL8 looking_for_min_y;
347 inT32 max_x, min_x, max_y, min_y;
348 inT32 initial_x, initial_y;
356 max_x = min_x = pos.
x ();
357 max_y = min_y = pos.
y ();
358 looking_for_max_x =
TRUE;
359 looking_for_min_x =
TRUE;
360 looking_for_max_y =
TRUE;
361 looking_for_min_y =
TRUE;
362 first_was_max_x =
FALSE;
363 first_was_max_y =
FALSE;
364 initial_x = pos.
x ();
365 initial_y = pos.
y ();
366 for (stepindex = 0; stepindex < total_steps; stepindex++) {
368 next_step =
step (stepindex);
370 if (next_step.
x () < 0) {
371 if (looking_for_max_x && pos.
x () < min_x)
373 if (looking_for_min_x && max_x - pos.
x () > threshold) {
374 if (looking_for_max_x) {
376 first_was_max_x =
FALSE;
379 looking_for_max_x =
TRUE;
380 looking_for_min_x =
FALSE;
384 else if (next_step.
x () > 0) {
385 if (looking_for_min_x && pos.
x () > max_x)
387 if (looking_for_max_x && pos.
x () - min_x > threshold) {
388 if (looking_for_min_x) {
390 first_was_max_x =
TRUE;
393 looking_for_max_x =
FALSE;
394 looking_for_min_x =
TRUE;
398 else if (next_step.
y () < 0) {
399 if (looking_for_max_y && pos.
y () < min_y)
401 if (looking_for_min_y && max_y - pos.
y () > threshold) {
402 if (looking_for_max_y) {
404 first_was_max_y =
FALSE;
407 looking_for_max_y =
TRUE;
408 looking_for_min_y =
FALSE;
413 if (looking_for_min_y && pos.
y () > max_y)
415 if (looking_for_max_y && pos.
y () - min_y > threshold) {
416 if (looking_for_min_y) {
418 first_was_max_y =
TRUE;
421 looking_for_max_y =
FALSE;
422 looking_for_min_y =
TRUE;
428 if (first_was_max_x && looking_for_min_x) {
429 if (max_x - initial_x > threshold)
434 else if (!first_was_max_x && looking_for_max_x) {
435 if (initial_x - min_x > threshold)
440 if (first_was_max_y && looking_for_min_y) {
441 if (max_y - initial_y > threshold)
446 else if (!first_was_max_y && looking_for_max_y) {
447 if (initial_y - min_y > threshold)
475 return other.box.
contains(this->box);
478 for (stepindex = 0; stepindex < stepcount
480 pos +=
step (stepindex);
484 for (stepindex = 0; stepindex < other.stepcount
487 pos += other.
step (stepindex);
511 for (stepindex = 0; stepindex < stepcount; stepindex++) {
512 stepvec =
step (stepindex);
514 if (vec.
y () <= 0 && vec.
y () + stepvec.
y () > 0) {
515 cross = vec * stepvec;
521 else if (vec.
y () > 0 && vec.
y () + stepvec.
y () <= 0) {
522 cross = vec * stepvec;
551 for (stepindex = 0; stepindex < stepcount; stepindex++) {
553 dirdiff = dir - prevdir;
554 ASSERT_HOST (dirdiff == 0 || dirdiff == 32 || dirdiff == -32);
576 halfsteps = (stepcount + 1) / 2;
577 for (stepindex = 0; stepindex < halfsteps; stepindex++) {
578 farindex = stepcount - stepindex - 1;
581 set_step (farindex, stepdir + halfturn);
595 C_OUTLINE_IT it(&children);
600 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
601 it.data ()->move (vec);
610 if (box.
width() < min_size || box.
height() < min_size) {
612 delete it->extract();
613 }
else if (!children.empty()) {
615 C_OUTLINE_IT child_it(&children);
616 for (child_it.mark_cycle_pt(); !child_it.cycled_list();
617 child_it.forward()) {
628 for (
int stepindex = 0; stepindex < stepcount; ++stepindex) {
630 if (next_step.
y() < 0) {
631 pixRasterop(pix, 0, top - pos.
y(), pos.
x() - left, 1,
632 PIX_NOT(PIX_DST),
NULL, 0, 0);
633 }
else if (next_step.
y() > 0) {
634 pixRasterop(pix, 0, top - pos.
y() - 1, pos.
x() - left, 1,
635 PIX_NOT(PIX_DST),
NULL, 0, 0);
645 for (
int stepindex = 0; stepindex < stepcount; ++stepindex) {
647 if (next_step.
y() < 0) {
648 pixSetPixel(pix, pos.
x() - left, top - pos.
y(), 1);
649 }
else if (next_step.
y() > 0) {
650 pixSetPixel(pix, pos.
x() - left - 1, top - pos.
y() - 1, 1);
651 }
else if (next_step.
x() < 0) {
652 pixSetPixel(pix, pos.
x() - left - 1, top - pos.
y(), 1);
653 }
else if (next_step.
x() > 0) {
654 pixSetPixel(pix, pos.
x() - left, top - pos.
y() - 1, 1);
666 #ifndef GRAPHICS_DISABLED
677 if (stepcount == 0) {
684 while (stepindex < stepcount) {
685 pos +=
step(stepindex);
689 while (stepindex < stepcount &&
691 pos +=
step(stepindex);
711 start = source.start;
714 stepcount = source.stepcount;
716 memmove (steps, source.steps, step_mem());
717 if (!children.empty ())
719 children.deep_copy(&source.children, &
deep_copy);
724 return step_coords[chaindir % 4];