mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 09:09:53 +02:00
51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
/*
|
|
* path.h - 2D path operations
|
|
*
|
|
* Written 2011 by Werner Almesberger
|
|
* Copyright 2011 by 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 PATH_H
|
|
#define PATH_H
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
struct vertex {
|
|
double x, y;
|
|
double r; /* minimum bend radius; 0 = use previous value */
|
|
double d; /* max. distance of corner from ideal arc; 0 = prev */
|
|
const char *tag;
|
|
struct vertex *next;
|
|
|
|
/*
|
|
* "len" is set by path_set_len to the distance to the next vertex, or
|
|
* 0 if this is the last vertex in the path. round_path adjusts "len"
|
|
* such that it corresponds to the length of the same part of the
|
|
* original path.
|
|
*/
|
|
double len;
|
|
};
|
|
|
|
struct path {
|
|
struct vertex *vertices;
|
|
struct vertex **last;
|
|
};
|
|
|
|
|
|
void free_path(struct path *path);
|
|
|
|
double path_set_length(struct path *path);
|
|
struct path *round_path(const struct path *path, double r, double d);
|
|
struct path *stretch_path(const struct path *path, double dist, double r);
|
|
|
|
struct path *load_path(FILE *file);
|
|
void save_path(FILE *file, const struct path *path);
|
|
|
|
#endif /* !PATH_H */
|