mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 00:41:10 +02:00
cameo: array steps can now be specifed as item size plus border
- lang.y (align, bbox): moved bounding box calculation to separate function (for sharing) - lang.y: array sizes can specified as the size of the respective dimension of the bounding box plus a border - README: documented use of border size with "array"
This commit is contained in:
parent
6f30bab648
commit
ee3a3e6162
@ -109,7 +109,13 @@ The reference point is specified with a number as follows:
|
||||
|
||||
"array" is used when cutting several copies of the same piece. The first
|
||||
two arguments define the step between pieces while the second two
|
||||
arguments define how many steps in each direction are taken.
|
||||
arguments define how many steps in each direction are taken. A step size
|
||||
can be specified as the total distance, or as the border to add to the
|
||||
respective dimension of the bounding box of the current path. In the
|
||||
latter case, the border size is prefix with a plus sign. Example:
|
||||
|
||||
array 37mm 19mm 0 1
|
||||
array +3mm +3mm 0 1
|
||||
|
||||
"align" moves the toolpath to an absolute position while "array" and
|
||||
"translate" move relative to the current position. The total translation
|
||||
|
72
cameo/lang.y
72
cameo/lang.y
@ -102,26 +102,38 @@ static void ref_pick_xy(int ref, double xa, double ya, double xb, double yb,
|
||||
}
|
||||
|
||||
|
||||
static void bbox(const struct path *path,
|
||||
double *xa, double *ya, double *xb, double *yb)
|
||||
{
|
||||
const struct point *p;
|
||||
int first = 1;
|
||||
|
||||
*xa = *ya = *xb = *yb = 0;
|
||||
|
||||
while (path) {
|
||||
for (p = path->first; p; p = p->next) {
|
||||
if (first || p->x < *xa)
|
||||
*xa = p->x;
|
||||
if (first || p->x > *xb)
|
||||
*xb = p->x;
|
||||
if (first || p->y < *ya)
|
||||
*ya = p->y;
|
||||
if (first || p->y > *yb)
|
||||
*yb = p->y;
|
||||
first = 0;
|
||||
}
|
||||
path = path->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void align(int ref, double x, double y)
|
||||
{
|
||||
const struct path *path;
|
||||
const struct point *p;
|
||||
double xa = 0, ya = 0, xb = 0, yb = 0;
|
||||
double xr, yr, xd, yd;
|
||||
int first = 1;
|
||||
|
||||
for (path = paths; path; path = path->next)
|
||||
for (p = path->first; p; p = p->next) {
|
||||
if (first || p->x < xa)
|
||||
xa = p->x;
|
||||
if (first || p->x > xb)
|
||||
xb = p->x;
|
||||
if (first || p->y < ya)
|
||||
ya = p->y;
|
||||
if (first || p->y > yb)
|
||||
yb = p->y;
|
||||
first = 0;
|
||||
}
|
||||
bbox(paths, &xa, &ya, &xb, &yb);
|
||||
|
||||
ref_pick_xy(ref, xa, ya, xb, yb, &xr, &yr);
|
||||
xd = x-xr;
|
||||
@ -183,7 +195,7 @@ static struct path **classify(struct path **anchor, struct path *path)
|
||||
%token <str> STRING
|
||||
|
||||
%type <str> opt_filename
|
||||
%type <num> dimen number
|
||||
%type <num> dimen number x_size y_size
|
||||
%type <oopt> offset_options offset_option
|
||||
|
||||
%%
|
||||
@ -210,7 +222,7 @@ command:
|
||||
ref_pick_xy(ref, $3, $4, $5, $6, &x, &y);
|
||||
align(ref, x, y);
|
||||
}
|
||||
| TOK_ARRAY dimen dimen number number
|
||||
| TOK_ARRAY x_size y_size number number
|
||||
{
|
||||
double x = $2*$4;
|
||||
double y = $3*$5;
|
||||
@ -357,6 +369,34 @@ dimen:
|
||||
}
|
||||
;
|
||||
|
||||
x_size:
|
||||
dimen
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
| '+' dimen
|
||||
{
|
||||
double xa, ya, xb, yb;
|
||||
|
||||
bbox(paths, &xa, &ya, &xb, &yb);
|
||||
$$ = xb-xa+$2;
|
||||
}
|
||||
;
|
||||
|
||||
y_size:
|
||||
dimen
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
| '+' dimen
|
||||
{
|
||||
double xa, ya, xb, yb;
|
||||
|
||||
bbox(paths, &xa, &ya, &xb, &yb);
|
||||
$$ = yb-ya+$2;
|
||||
}
|
||||
;
|
||||
|
||||
number:
|
||||
NUM_IMP_MIL
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user