-#include <assert.h>
#include "../q.h"
#include "active.h"
free(a);
}
-void actlist_verify_and_dump(actlist_t*a, int32_t y)
+void actlist_dump(actlist_t*a, int32_t y)
{
segment_t*s = a->list;
- assert(!s || !s->left);
double lastx;
+ char bad = 0;
while(s) {
if(y) {
double x = ((double)s->delta.x*(y-s->a.y)/s->delta.y)+s->a.x;
if(s!=a->list) {
- if(lastx>x) fprintf(stderr, "?%f<->%f? ", lastx, x);
+ if(lastx>x)
+ fprintf(stderr, "?%f<->%f? ", lastx, x);
}
lastx = x;
}
- assert(!s->left || s->left->right == s);
- assert(!s->right || s->right->left == s);
fprintf(stderr, "[%d]", s->nr);
s = s->right;
if(s) fprintf(stderr, " ");
else fprintf(stderr, "\n");
}
}
+void actlist_verify(actlist_t*a, int32_t y)
+{
+ segment_t*s = a->list;
+ assert(!s || !s->left);
+ segment_t*l = 0;
+ while(s) {
+ if(y) {
+ if(l) {
+ /* we need to re-evaluate the x of the previous segment. if we
+ try to store it, it might end up being converted to a double,
+ which will make it non-equal to (and possibly larger than) the
+ "long double" the FPU has in it's register. This only happens
+ when compiler optimizations are turned on. */
+ assert((XPOS(s, y) - XPOS(l, y)) >= 0);
+ assert(XDIFF(s,l,y) >= 0);
+ }
+ l = s;
+ }
+ assert(!s->left || s->left->right == s);
+ assert(!s->right || s->right->left == s);
+ s = s->right;
+ }
+}
segment_t* actlist_find(actlist_t*a, point_t p1, point_t p2)
{
return a->list;
}
+segment_t* actlist_rightmost(actlist_t*a)
+{
+ /* this is only used in checks, so it doesn't matter that it's slow */
+ segment_t*s = a->list;
+ segment_t*last = 0;
+ while(s) {
+ last = s;
+ s = s->right;
+ }
+ return last;
+}
+
segment_t* actlist_left(actlist_t*a, segment_t*s)
{
return s->left;