Ben NanoNote 3D scans
Sign in or create your account | Project List | Help
Ben NanoNote 3D scans Commit Details
Date: | 2010-09-25 02:28:42 (12 years 11 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 01d8e411f34d448b83fdb1cbfa4b63b0ac95fe6b |
Message: | Use the project name to disambiguate names in POV-Ray output. - solidify/main.pov: change name from "Part" to "Part_batcvr" - solidify/solid.h (povray), solidify/solid.c (sanitize, povray): use the project name as prefix for PGM files and a suffix for the object name - solidify/solidify.c (main): pass the project's basename to povray() |
Files: |
solidify/main.pov (1 diff) solidify/solid.c (1 diff) solidify/solid.h (1 diff) solidify/solidify.c (2 diffs) |
Change Details
solidify/main.pov | ||
---|---|---|
14 | 14 | } |
15 | 15 | |
16 | 16 | union { |
17 | Part | |
17 | Part_batcvr | |
18 | 18 | pigment { rgb <0.9, 0.9, 0.9> } |
19 | 19 | finish { |
20 | 20 | brilliance 2 |
solidify/solid.c | ||
---|---|---|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | void povray(const struct solid *s) | |
50 | static void sanitize(const char *s, char *res) | |
51 | { | |
52 | while (*s) { | |
53 | if ((*s >= 'A' && *s <= 'Z') || | |
54 | (*s >= 'a' && *s <= 'z') || | |
55 | (*s >= '0' && *s <= '9') || *s == '_') | |
56 | *res = *s; | |
57 | else | |
58 | *res = '_'; | |
59 | res++; | |
60 | s++; | |
61 | } | |
62 | *res = 0; | |
63 | } | |
64 | ||
65 | ||
66 | void povray(const char *name, const struct solid *s) | |
51 | 67 | { |
52 | 68 | struct matrix m; |
69 | char tmp[1000]; /* @@@ enough */ | |
53 | 70 | |
54 | 71 | m.a[0][0] = m.a[1][1] = 1; |
55 | 72 | m.a[0][1] = m.a[1][0] = 0; |
56 | 73 | m.b[0] = m.b[1] = 0; |
57 | 74 | |
58 | height_field("top.pgm", s->a, &m); | |
59 | height_field("bot.pgm", s->b, &m); | |
75 | sprintf(tmp, "%s-top.pgm", name); | |
76 | height_field(tmp, s->a, &m); | |
77 | sprintf(tmp, "%s-bot.pgm", name); | |
78 | height_field(tmp, s->b, &m); | |
60 | 79 | |
61 | 80 | /* |
62 | 81 | * 1/65535 = 0.000015..., so we set the water level a bit lower, e.g., |
63 | 82 | * to 0.0001 |
64 | 83 | */ |
84 | sanitize(name, tmp); | |
65 | 85 | printf( |
66 | "#declare Part =\n" | |
86 | "#declare Part_%s =\n" | |
67 | 87 | " intersection {\n" |
68 | " height_field { pgm \"top.pgm\" water_level 0.00001 smooth }\n" | |
69 | " height_field { pgm \"bot.pgm\" water_level 0.00001 smooth }\n" | |
70 | " }\n"); | |
88 | " height_field { pgm \"%s-top.pgm\" water_level 0.00001 smooth }\n" | |
89 | " height_field { pgm \"%s-bot.pgm\" water_level 0.00001 smooth }\n" | |
90 | " }\n", tmp, name, name); | |
71 | 91 | } |
solidify/solid.h | ||
---|---|---|
19 | 19 | }; |
20 | 20 | |
21 | 21 | |
22 | void povray(const struct solid *s); | |
22 | void povray(const char *name, const struct solid *s); | |
23 | 23 | |
24 | 24 | #endif /* !SOLID_H */ |
solidify/solidify.c | ||
---|---|---|
14 | 14 | #include <stdlib.h> |
15 | 15 | #include <stdio.h> |
16 | 16 | #include <unistd.h> |
17 | #include <string.h> | |
17 | 18 | #include <locale.h> |
18 | 19 | #include <gtk/gtk.h> |
19 | 20 | |
... | ... | |
148 | 149 | |
149 | 150 | save_project(prj); |
150 | 151 | |
151 | if (!isatty(1)) | |
152 | povray(&prj->s); | |
152 | if (!isatty(1)) { | |
153 | const char *slash = strrchr(prj->name, '/'); | |
154 | char tmp[1000]; /* @@@ enough */ | |
155 | ||
156 | strcpy(tmp, slash ? slash+1 : prj->name); | |
157 | if (strchr(tmp, '.')) | |
158 | *strchr(tmp, '.') = 0; | |
159 | povray(tmp, &prj->s); | |
160 | } | |
153 | 161 | |
154 | 162 | return 0; |
155 | 163 | } |
Branches:
master