1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-04-21 12:27:27 +03:00

Accept multiple paths and distinguish between inner paths and the outer path.

- cameo/path.h, cameo/path.c (path_replace): replace a path in a list of
  paths with a different path
- cameo/path.h, cameo/path.c (path_find_leftmost): find the leftmost path
  in a list of paths
- cameo/path.h, cameo/path.c (path_free): move freeing of points to separate
  function free_points, for sharing with path_replace
- cameo/cameo.c (main): move path processing to new function process_paths
- cameo/cameo.c (process_paths): treat the leftmost path a outside path and
  process it last. Treat all others as inside paths.
This commit is contained in:
Werner Almesberger
2010-11-01 17:23:19 -03:00
parent d465acbeb5
commit 17afa3e2bb
3 changed files with 74 additions and 18 deletions

View File

@@ -13,12 +13,38 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "path.h"
#include "gnuplot.h"
static void process_path(struct path *path, int inside)
{
int left;
struct path *new;
left = path_tool_is_left(path);
if (inside)
new = path_offset(path, !left, 0);
else
new = path_offset(path, left, 1);
path_replace(path, new);
}
static void process_paths(struct path *paths)
{
struct path *leftmost, *path;
leftmost = path_find_leftmost(paths);
for (path = paths; path; path = path->next)
if (path != leftmost)
process_path(path, 1);
process_path(leftmost, 0);
}
static void usage(const char *name)
{
fprintf(stderr, "usage: %s r_mm [in.gnuplot [out.gnuplot]]\n",
@@ -32,7 +58,6 @@ int main(int argc, char **argv)
char *in = NULL, *out = NULL;
double r;
struct path *paths;
int left;
switch (argc) {
case 4:
@@ -48,16 +73,9 @@ int main(int argc, char **argv)
usage(*argv);
}
/*
* To do:
* - handle multiple paths
*/
paths = gnuplot_read(in, r);
assert(!paths->next); /* we don't handle this yet */
// paths = path_reverse(paths);
left = path_tool_is_left(paths);
paths = path_offset(paths, left, 1);
process_paths(paths);
gnuplot_write(out, paths);
return 0;
}