diff --git a/solidify/main.pov b/solidify/main.pov index 487255c..bf107e2 100644 --- a/solidify/main.pov +++ b/solidify/main.pov @@ -14,7 +14,7 @@ light_source { } union { - Part + Part_batcvr pigment { rgb <0.9, 0.9, 0.9> } finish { brilliance 2 diff --git a/solidify/solid.c b/solidify/solid.c index 0322fa7..90df6b5 100644 --- a/solidify/solid.c +++ b/solidify/solid.c @@ -47,25 +47,45 @@ static void height_field(const char *name, const struct face *f, } -void povray(const struct solid *s) +static void sanitize(const char *s, char *res) +{ + while (*s) { + if ((*s >= 'A' && *s <= 'Z') || + (*s >= 'a' && *s <= 'z') || + (*s >= '0' && *s <= '9') || *s == '_') + *res = *s; + else + *res = '_'; + res++; + s++; + } + *res = 0; +} + + +void povray(const char *name, const struct solid *s) { struct matrix m; + char tmp[1000]; /* @@@ enough */ m.a[0][0] = m.a[1][1] = 1; m.a[0][1] = m.a[1][0] = 0; m.b[0] = m.b[1] = 0; - height_field("top.pgm", s->a, &m); - height_field("bot.pgm", s->b, &m); + sprintf(tmp, "%s-top.pgm", name); + height_field(tmp, s->a, &m); + sprintf(tmp, "%s-bot.pgm", name); + height_field(tmp, s->b, &m); /* * 1/65535 = 0.000015..., so we set the water level a bit lower, e.g., * to 0.0001 */ + sanitize(name, tmp); printf( -"#declare Part =\n" +"#declare Part_%s =\n" " intersection {\n" -" height_field { pgm \"top.pgm\" water_level 0.00001 smooth }\n" -" height_field { pgm \"bot.pgm\" water_level 0.00001 smooth }\n" -" }\n"); +" height_field { pgm \"%s-top.pgm\" water_level 0.00001 smooth }\n" +" height_field { pgm \"%s-bot.pgm\" water_level 0.00001 smooth }\n" +" }\n", tmp, name, name); } diff --git a/solidify/solid.h b/solidify/solid.h index 086d4cc..06a4ba8 100644 --- a/solidify/solid.h +++ b/solidify/solid.h @@ -19,6 +19,6 @@ struct solid { }; -void povray(const struct solid *s); +void povray(const char *name, const struct solid *s); #endif /* !SOLID_H */ diff --git a/solidify/solidify.c b/solidify/solidify.c index 413fe44..0fc41f7 100644 --- a/solidify/solidify.c +++ b/solidify/solidify.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -148,8 +149,15 @@ int main(int argc, char **argv) save_project(prj); - if (!isatty(1)) - povray(&prj->s); + if (!isatty(1)) { + const char *slash = strrchr(prj->name, '/'); + char tmp[1000]; /* @@@ enough */ + + strcpy(tmp, slash ? slash+1 : prj->name); + if (strchr(tmp, '.')) + *strchr(tmp, '.') = 0; + povray(tmp, &prj->s); + } return 0; }