Date: | 2012-03-18 21:57:04 (12 years 10 days ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 5a599e14f6e5ef17ab80ed09148fbb949ecf5bf6 |
Message: | cameo: don't duplicate paths already cleared by the outline Also pass information on whether we're about to enter or leave a polygon. |
Files: |
cameo/area.c (4 diffs) |
Change Details
cameo/area.c | ||
---|---|---|
182 | 182 | |
183 | 183 | |
184 | 184 | static int hit_path(double fx, double fy, double tx, double ty, |
185 | const struct path *path, int inside, double r, double *x) | |
185 | const struct path *path, int inside, int enter, double r, double *x) | |
186 | 186 | { |
187 | 187 | const struct point *p; |
188 | 188 | int left; |
... | ... | |
234 | 234 | |
235 | 235 | |
236 | 236 | static void do_line(const struct path *path, const struct path **sub, |
237 | double xa, double xb, double y, double r_tool, struct path **res) | |
237 | double xa, double xb, double y, double r_tool, double overlap, | |
238 | struct path **res) | |
238 | 239 | { |
239 | 240 | const struct path *last = path; |
240 | 241 | const struct path **s; |
... | ... | |
242 | 243 | double x, next; |
243 | 244 | |
244 | 245 | printf(" y=%g\n", y); |
245 | if (!hit_path(xa-3*r_tool, y, xb, y, last, 1, r_tool, &x)) | |
246 | if (!hit_path(xa-3*r_tool, y, xb, y, last, 1, 0, r_tool, &x)) | |
246 | 247 | return; |
247 | 248 | while (1) { |
248 | 249 | printf(" x=%g\n", x); |
249 | 250 | next = xb; |
250 | 251 | last = NULL; |
251 | if (hit_path(x, y, xb, y, path, 1, r_tool, &next)) | |
252 | if (hit_path(x, y, xb, y, path, 1, 1, r_tool, &next)) | |
252 | 253 | last = path; |
253 | 254 | for (s = sub; *s; s++) |
254 | if (hit_path(x, y, next, y, *s, 0, r_tool, &next)) | |
255 | if (hit_path(x, y, next, y, *s, 0, 1, r_tool, &next)) | |
255 | 256 | last = *s; |
256 | new = path_new(r_tool, ""); | |
257 | path_add(new, x, y, path->first->z); | |
258 | path_add(new, next, y, path->first->z); | |
259 | new->next = *res; | |
260 | *res = new; | |
257 | if (next-x > 2*r_tool-2*overlap) { | |
258 | new = path_new(r_tool, ""); | |
259 | path_add(new, x, y, path->first->z); | |
260 | path_add(new, next, y, path->first->z); | |
261 | new->next = *res; | |
262 | *res = new; | |
263 | } | |
261 | 264 | if (!last) |
262 | 265 | return; |
263 | if (!hit_path(next+EPSILON, y, xb, y, last, last == path, | |
266 | if (!hit_path(next+EPSILON, y, xb, y, last, last == path, 0, | |
264 | 267 | r_tool, &x)) |
265 | 268 | return; |
266 | 269 | } |
... | ... | |
291 | 294 | return; |
292 | 295 | sub = subordinates(paths, path); |
293 | 296 | xa += r_tool; |
294 | ya += r_tool; | |
297 | ya += 3*r_tool-overlap; | |
295 | 298 | xb -= r_tool; |
296 | yb -= r_tool; | |
299 | yb -= 3*r_tool-overlap; | |
297 | 300 | n = ceil((yb-ya)/(2*r_tool-overlap)); |
298 | 301 | printf("x[%g:%g] y[%g:%g] n=%d\n", xa, xb, ya, yb, n); |
299 | 302 | for (i = 0; i <= n; i++) |
300 | do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n), r_tool, | |
301 | res); | |
303 | do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n), | |
304 | r_tool, overlap, res); | |
302 | 305 | for (s = sub; *s; s++) { |
303 | 306 | sub2 = subordinates(paths, *s); |
304 | 307 | for (s2 = sub2; *s2; s2++) |
Branches:
master