mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 10:41:45 +02:00
cameo: moved tool compensation from cameo.c to ops.c
- Makefile (OBJS): added ops.o - cameo.c, ops.h, ops.c (process_path, process_paths): moved from cameo.c to ops.c - ops.h, ops.c (process_paths), cameo.c (main): renamed process_paths to tool_comp_paths - ops.c (process_path, tool_comp_paths): renamed process_path to tool_comp_1
This commit is contained in:
parent
c8b62c2864
commit
2bf4559f3f
@ -15,7 +15,7 @@ PREFIX ?= /usr/local
|
|||||||
SHELL=/bin/bash
|
SHELL=/bin/bash
|
||||||
|
|
||||||
MAIN=cameo
|
MAIN=cameo
|
||||||
OBJS=cameo.o gerber.o gnuplot.o path.o lex.yy.o y.tab.o
|
OBJS=cameo.o gerber.o gnuplot.o ops.o path.o lex.yy.o y.tab.o
|
||||||
|
|
||||||
CFLAGS_WARN=-Wall -Wshadow -Wmissing-prototypes \
|
CFLAGS_WARN=-Wall -Wshadow -Wmissing-prototypes \
|
||||||
-Wmissing-declarations -Wno-format-zero-length
|
-Wmissing-declarations -Wno-format-zero-length
|
||||||
|
@ -16,50 +16,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "ops.h"
|
||||||
#include "gnuplot.h"
|
#include "gnuplot.h"
|
||||||
#include "gerber.h"
|
#include "gerber.h"
|
||||||
|
|
||||||
|
|
||||||
static void process_path(struct path *path, int inside, int dog_bone)
|
|
||||||
{
|
|
||||||
int left;
|
|
||||||
struct path *new;
|
|
||||||
|
|
||||||
left = path_tool_is_left(path);
|
|
||||||
if (inside)
|
|
||||||
new = path_offset(path, !left, path->notch);
|
|
||||||
else
|
|
||||||
new = path_offset(path, left, path->notch || dog_bone);
|
|
||||||
path_replace(path, new);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void process_paths(struct path *paths, int dog_bone)
|
|
||||||
{
|
|
||||||
struct path *leftmost, *path;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We don't have an algorithm (yet) that can detect which paths are
|
|
||||||
* inside other paths. Therefore, we fake it by looking for the path
|
|
||||||
* that contains lowest x coordinate. This ought to be the outer
|
|
||||||
* boundary of the piece.
|
|
||||||
*
|
|
||||||
* Note that this heuristic falls apart when a job consists of
|
|
||||||
* multiple pieces. In this case, the #%outside hint can be used to
|
|
||||||
* explicitly tell cameo to treat the path as an outside edge.
|
|
||||||
*/
|
|
||||||
|
|
||||||
leftmost = path_find_leftmost(paths);
|
|
||||||
for (path = paths; path; path = path->next)
|
|
||||||
if (path != leftmost && !path->outside)
|
|
||||||
process_path(path, 1, dog_bone);
|
|
||||||
for (path = paths; path; path = path->next)
|
|
||||||
if (path != leftmost && path->outside)
|
|
||||||
process_path(path, 0, dog_bone);
|
|
||||||
process_path(leftmost, 0, dog_bone);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void usage(const char *name)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -110,7 +71,7 @@ int main(int argc, char **argv)
|
|||||||
paths = gerber_read(in, r);
|
paths = gerber_read(in, r);
|
||||||
else
|
else
|
||||||
paths = gnuplot_read(in, r);
|
paths = gnuplot_read(in, r);
|
||||||
process_paths(paths, dog_bone);
|
tool_comp_paths(paths, dog_bone);
|
||||||
gnuplot_write(out, paths);
|
gnuplot_write(out, paths);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
55
cameo/ops.c
Normal file
55
cameo/ops.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* ops.c - Higher-level toolpath operations
|
||||||
|
*
|
||||||
|
* Written 2010 by Werner Almesberger
|
||||||
|
* Copyright 2010 Werner Almesberger
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "path.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void tool_comp_1(struct path *path, int inside, int dog_bone)
|
||||||
|
{
|
||||||
|
int left;
|
||||||
|
struct path *new;
|
||||||
|
|
||||||
|
left = path_tool_is_left(path);
|
||||||
|
if (inside)
|
||||||
|
new = path_offset(path, !left, path->notch);
|
||||||
|
else
|
||||||
|
new = path_offset(path, left, path->notch || dog_bone);
|
||||||
|
path_replace(path, new);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void tool_comp_paths(struct path *paths, int dog_bone)
|
||||||
|
{
|
||||||
|
struct path *leftmost, *path;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We don't have an algorithm (yet) that can detect which paths are
|
||||||
|
* inside other paths. Therefore, we fake it by looking for the path
|
||||||
|
* that contains lowest x coordinate. This ought to be the outer
|
||||||
|
* boundary of the piece.
|
||||||
|
*
|
||||||
|
* Note that this heuristic falls apart when a job consists of
|
||||||
|
* multiple pieces. In this case, the #%outside hint can be used to
|
||||||
|
* explicitly tell cameo to treat the path as an outside edge.
|
||||||
|
*/
|
||||||
|
|
||||||
|
leftmost = path_find_leftmost(paths);
|
||||||
|
for (path = paths; path; path = path->next)
|
||||||
|
if (path != leftmost && !path->outside)
|
||||||
|
tool_comp_1(path, 1, dog_bone);
|
||||||
|
for (path = paths; path; path = path->next)
|
||||||
|
if (path != leftmost && path->outside)
|
||||||
|
tool_comp_1(path, 0, dog_bone);
|
||||||
|
tool_comp_1(leftmost, 0, dog_bone);
|
||||||
|
}
|
23
cameo/ops.h
Normal file
23
cameo/ops.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* ops.h - Higher-level toolpath operations
|
||||||
|
*
|
||||||
|
* Written 2010 by Werner Almesberger
|
||||||
|
* Copyright 2010 Werner Almesberger
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OPS_H
|
||||||
|
#define OPS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
|
|
||||||
|
void tool_comp_paths(struct path *paths, int dog_bone);
|
||||||
|
|
||||||
|
#endif /* !OPS_H */
|
Loading…
Reference in New Issue
Block a user