1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-01-03 21:20:15 +02:00

slicer/slice.c: repeat lower cuts at intermediate points

This commit is contained in:
Werner Almesberger 2015-01-08 08:07:21 -03:00
parent c82ea10493
commit 6a12d4724b

View File

@ -23,6 +23,7 @@
struct line { struct line {
float ax, ay; float ax, ay;
float bx, by; float bx, by;
float cz;
struct line *next; struct line *next;
}; };
@ -87,6 +88,7 @@ fprintf(stderr, "zero point\n");
line->ay = a->y; line->ay = a->y;
line->bx = b->x; line->bx = b->x;
line->by = b->y; line->by = b->y;
line->cz = c->z;
line->next = z->lines; line->next = z->lines;
z->lines = line; z->lines = line;
} }
@ -112,24 +114,38 @@ void slice(struct v f[3])
/* ----- Dumping ----------------------------------------------------------- */ /* ----- Dumping ----------------------------------------------------------- */
static gboolean dump(gpointer key, gpointer value, gpointer data) static gboolean dump_layer(gpointer key, gpointer value, gpointer data)
{ {
const struct z *z = value; const struct z *z0 = data;
const struct z *z1 = value;
const struct line *line; const struct line *line;
if (!z->present) if (z0->z > z1->z)
return 0; return 0;
for (line = z->lines; line; line = line->next) if (!z1->present)
printf("%f %f %f\n%f %f %f\n\n\n", return 0;
line->ax, line->ay, z->z, for (line = z0->lines; line; line = line->next)
line->bx, line->by, z->z); if (line->cz >= z1->z)
printf("%f %f %f\n%f %f %f\n\n\n",
line->ax, line->ay, z1->z,
line->bx, line->by, z1->z);
return 0;
}
static gboolean dump_range(gpointer key, gpointer value, gpointer data)
{
const struct z *z = value;
if (z->present)
g_tree_foreach(tree, dump_layer, value);
return 0; return 0;
} }
void slice_dump(void) void slice_dump(void)
{ {
g_tree_foreach(tree, dump, NULL); g_tree_foreach(tree, dump_range, NULL);
} }