mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-22 23:43:00 +02:00
cameo/: make tool_comp_paths output paths in the order processed
This commit is contained in:
parent
828763b747
commit
639b0fa2d6
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* cameo.c - Toolpath adaptation and machine control
|
* cameo.c - Toolpath adaptation and machine control
|
||||||
*
|
*
|
||||||
* Written 2010 by Werner Almesberger
|
* Written 2010-2011 by Werner Almesberger
|
||||||
* Copyright 2010 Werner Almesberger
|
* Copyright 2010-2011 Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -100,7 +100,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);
|
||||||
tool_comp_paths(paths, dog_bone, 0);
|
paths = tool_comp_paths(paths, dog_bone, 0); /* @@@ memory leak */
|
||||||
gnuplot_write(out, paths);
|
gnuplot_write(out, paths);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -243,8 +243,12 @@ command:
|
|||||||
}
|
}
|
||||||
| TOK_OFFSET offset_options
|
| TOK_OFFSET offset_options
|
||||||
{
|
{
|
||||||
tool_comp_paths(paths,
|
struct path *new;
|
||||||
|
|
||||||
|
new = tool_comp_paths(paths,
|
||||||
!!($2 & OO_DOG), !!($2 & OO_INSIDE));
|
!!($2 & OO_DOG), !!($2 & OO_INSIDE));
|
||||||
|
clear_paths();
|
||||||
|
paths = new;
|
||||||
}
|
}
|
||||||
| TOK_OPTIMIZE
|
| TOK_OPTIMIZE
|
||||||
{
|
{
|
||||||
|
30
cameo/ops.c
30
cameo/ops.c
@ -19,23 +19,24 @@
|
|||||||
#include "ops.h"
|
#include "ops.h"
|
||||||
|
|
||||||
|
|
||||||
static void tool_comp_1(struct path *path, int inside, int dog_bone)
|
static struct path *tool_comp_1(const struct path *path, int inside,
|
||||||
|
int dog_bone)
|
||||||
{
|
{
|
||||||
int left;
|
int left;
|
||||||
struct path *new;
|
|
||||||
|
|
||||||
left = path_tool_is_left(path);
|
left = path_tool_is_left(path);
|
||||||
if (inside)
|
if (inside)
|
||||||
new = path_offset(path, !left, path->notch);
|
return path_offset(path, !left, path->notch);
|
||||||
else
|
else
|
||||||
new = path_offset(path, left, path->notch || dog_bone);
|
return path_offset(path, left, path->notch || dog_bone);
|
||||||
path_replace(path, new);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tool_comp_paths(struct path *paths, int dog_bone, int all_inside)
|
struct path *tool_comp_paths(const struct path *paths, int dog_bone,
|
||||||
|
int all_inside)
|
||||||
{
|
{
|
||||||
struct path *leftmost, *path;
|
const struct path *leftmost, *path;
|
||||||
|
struct path *new = NULL, **anchor = &new;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't have an algorithm (yet) that can detect which paths are
|
* We don't have an algorithm (yet) that can detect which paths are
|
||||||
@ -50,13 +51,18 @@ void tool_comp_paths(struct path *paths, int dog_bone, int all_inside)
|
|||||||
|
|
||||||
leftmost = path_find_leftmost(paths);
|
leftmost = path_find_leftmost(paths);
|
||||||
for (path = paths; path; path = path->next)
|
for (path = paths; path; path = path->next)
|
||||||
if (path != leftmost && (all_inside || !path->outside))
|
if (path != leftmost && (all_inside || !path->outside)) {
|
||||||
tool_comp_1(path, 1, dog_bone);
|
*anchor = tool_comp_1(path, 1, dog_bone);
|
||||||
|
anchor = &(*anchor)->next;
|
||||||
|
}
|
||||||
if (!all_inside)
|
if (!all_inside)
|
||||||
for (path = paths; path; path = path->next)
|
for (path = paths; path; path = path->next)
|
||||||
if (path != leftmost && path->outside)
|
if (path != leftmost && path->outside) {
|
||||||
tool_comp_1(path, 0, dog_bone);
|
*anchor = tool_comp_1(path, 0, dog_bone);
|
||||||
tool_comp_1(leftmost, all_inside, dog_bone);
|
anchor = &(*anchor)->next;
|
||||||
|
}
|
||||||
|
*anchor = tool_comp_1(leftmost, all_inside, dog_bone);
|
||||||
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
|
|
||||||
void tool_comp_paths(struct path *paths, int dog_bone, int all_inside);
|
struct path *tool_comp_paths(const struct path *paths, int dog_bone,
|
||||||
|
int all_inside);
|
||||||
struct path *try_drill(struct path *path, double d_min, double d_max);
|
struct path *try_drill(struct path *path, double d_min, double d_max);
|
||||||
struct path *try_mill(struct path *path, double diam, double step, int any);
|
struct path *try_mill(struct path *path, double diam, double step, int any);
|
||||||
struct path *optimize_paths(struct path *paths);
|
struct path *optimize_paths(struct path *paths);
|
||||||
|
16
cameo/path.c
16
cameo/path.c
@ -134,18 +134,6 @@ void path_add(struct path *path, double x, double y, double z)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void path_replace(struct path *old, struct path *new)
|
|
||||||
{
|
|
||||||
struct path *next = old->next;
|
|
||||||
|
|
||||||
free_points(old->first);
|
|
||||||
free((void *) old->id);
|
|
||||||
*old = *new;
|
|
||||||
old->next = next;
|
|
||||||
free(new);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct path *path_reverse(const struct path *path)
|
struct path *path_reverse(const struct path *path)
|
||||||
{
|
{
|
||||||
struct path *new;
|
struct path *new;
|
||||||
@ -348,10 +336,10 @@ struct path *path_offset(const struct path *path, int left, int notch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct path *path_find_leftmost(struct path *path)
|
const struct path *path_find_leftmost(const struct path *path)
|
||||||
{
|
{
|
||||||
const struct point *p;
|
const struct point *p;
|
||||||
struct path *best = NULL;
|
const struct path *best = NULL;
|
||||||
double best_x = HUGE_VAL;
|
double best_x = HUGE_VAL;
|
||||||
|
|
||||||
while (path) {
|
while (path) {
|
||||||
|
@ -32,11 +32,10 @@ struct path {
|
|||||||
|
|
||||||
struct path *path_new(double r_tool, const char *id);
|
struct path *path_new(double r_tool, const char *id);
|
||||||
void path_add(struct path *path, double x, double y, double z);
|
void path_add(struct path *path, double x, double y, double z);
|
||||||
void path_replace(struct path *old, struct path *new);
|
|
||||||
struct path *path_reverse(const struct path *path);
|
struct path *path_reverse(const struct path *path);
|
||||||
int path_tool_is_left(const struct path *path);
|
int path_tool_is_left(const struct path *path);
|
||||||
struct path *path_offset(const struct path *path, int left, int notch);
|
struct path *path_offset(const struct path *path, int left, int notch);
|
||||||
struct path *path_find_leftmost(struct path *path);
|
const struct path *path_find_leftmost(const struct path *path);
|
||||||
void path_free(struct path *path);
|
void path_free(struct path *path);
|
||||||
struct path *path_connect(struct path *path);
|
struct path *path_connect(struct path *path);
|
||||||
void path_stats(const struct path *path);
|
void path_stats(const struct path *path);
|
||||||
|
Loading…
Reference in New Issue
Block a user