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

Dogbone notches are now optional and can be set in the gnuplot file.

- cameo/cameo.c (main): use getopt
- cameo/cameo.c (main, usage, process_path): option -d to enable dog-bone
  notches (they're now disabled by default)
- cameo/path.h (struct path), cameo/path.c (path_new, path_from): added
  attribute "notch" to enable notches for a path
- cameo/gnuplot.c (gnuplot_read, gnuplot_do_write): read and write the
  #%notch hint
This commit is contained in:
Werner Almesberger
2010-11-01 19:15:35 -03:00
parent d77b4c8570
commit b47ef755ec
4 changed files with 35 additions and 12 deletions

View File

@@ -13,11 +13,14 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "path.h"
#include "gnuplot.h"
static int dog_bone = 0;
static void process_path(struct path *path, int inside)
{
@@ -26,9 +29,9 @@ static void process_path(struct path *path, int inside)
left = path_tool_is_left(path);
if (inside)
new = path_offset(path, !left, 0);
new = path_offset(path, !left, path->notch);
else
new = path_offset(path, left, 1);
new = path_offset(path, left, path->notch || dog_bone);
path_replace(path, new);
}
@@ -61,8 +64,10 @@ static void process_paths(struct path *paths)
static void usage(const char *name)
{
fprintf(stderr, "usage: %s r_mm [in.gnuplot [out.gnuplot]]\n",
name);
fprintf(stderr,
"usage: %s [-d] r_mm [in.gnuplot [out.gnuplot]]\n\n"
" -d put a dog-bone notch in each concave external corner\n"
, name);
exit(1);
}
@@ -72,16 +77,26 @@ int main(int argc, char **argv)
char *in = NULL, *out = NULL;
double r;
struct path *paths;
int c;
switch (argc) {
case 4:
out = argv[3];
/* fall through */
while ((c = getopt(argc, argv, "d")) != EOF)
switch (c) {
case 'd':
dog_bone = 1;
break;
default:
usage(*argv);
}
switch (argc-optind) {
case 3:
in = argv[2];
out = argv[optind+2];
/* fall through */
case 2:
r = atof(argv[1]);
in = argv[optind+1];
/* fall through */
case 1:
r = atof(argv[optind]);
break;
default:
usage(*argv);