34static int debugleveln(
edge_t* e,
int i)
43static void showPoints(
pointf ps[],
int pn)
49 for (bi = 0; bi < pn; bi++) {
66 pointf *
ps,
size_t *startp,
size_t *endp,
77 j =
info->swapEnds(e);
78 uint32_t sflag, eflag;
80 if (
info->splineMerge(hn))
111 pointf * sp,
bool left_inside)
114 double low, high, t, *idir, *odir;
136 t = (high + low) / 2.0;
138 if (
inside(inside_context, pt)) {
140 for (i = 0; i < 4; i++)
146 }
while (fabs(opt.
x - pt.
x) > .5 || fabs(opt.
y - pt.
y) > .5);
148 for (i = 0; i < 4; i++)
151 for (i = 0; i < 4; i++)
166 double save_real_size;
169 save_real_size =
ND_rw(n);
170 for (i = 0; i < 4; i++) {
177 for (i = 0; i < 4; i++) {
181 ND_rw(n) = save_real_size;
197 double save_real_size;
205 save_real_size =
ND_rw(n);
208 left_inside =
ND_shape(n)->fns->insidefn(&inside_context, c);
209 ND_rw(n) = save_real_size;
210 shape_clip0(&inside_context, n, curve, left_inside);
239 int clipTail, clipHead;
270 inside_t inside_context = {.
s = {.
n = tn, .bp = tbox}};
271 for (start = 0; start < pn - 4; start += 3) {
274 if (!
ND_shape(tn)->fns->insidefn(&inside_context, p2))
281 inside_t inside_context = {.
s = {.
n = hn, .bp = hbox}};
282 for (end = pn - 4; end > 0; end -= 3) {
285 if (!
ND_shape(hn)->fns->insidefn(&inside_context, p2))
291 for (; start < pn - 4; start += 3)
294 for (; end > 0; end -= 3)
298 for (
size_t i = start; i < end + 4; ) {
300 newspl->
list[i - start] =
ps[i];
305 newspl->
list[i - start] =
ps[i];
308 newspl->
list[i - start] =
ps[i];
314 newspl->
size = end - start + 4;
320 double s_in, s_out, m_in, m_out;
325 for (cnt_in = 0; (e =
ND_in(n).list[cnt_in]); cnt_in++)
327 for (cnt_out = 0; (e =
ND_out(n).list[cnt_out]); cnt_out++)
329 const double x1 =
ND_coord(n).x - s_in / cnt_in;
331 m_in = atan2(y1, x1);
332 const double x2 = s_out / cnt_out -
ND_coord(n).x;
334 m_out = atan2(y2, x2);
335 return (m_in + m_out) / 2.0;
375#define HT2(n) (ND_ht(n)/2)
448 else if (side &
LEFT) {
504 else if (side &
LEFT) {
644 else if (side &
LEFT) {
702 else if (side &
LEFT) {
776int vertices[] = {12,4,6,2,3,1,9,8};
777int i, tail_i, head_i;
779{11,12,13,14,15,16,17,18},
780{21,22,23,24,25,26,27,28},
781{31,32,33,34,35,36,37,38},
782{41,42,43,44,45,46,47,48},
783{51,52,53,54,55,56,57,58},
784{61,62,63,64,65,66,67,68},
785{71,72,73,74,75,76,77,78},
786{81,82,83,84,85,86,87,88}
789 tail_i = head_i = -1;
791 if(head_side == vertices[i]){
797 if(tail_side == vertices[i]){
803if( tail_i < 0 || head_i < 0)
806 return pair_a[tail_i][head_i];
815 double hy, ty, stepx,
dx,
dy, height;
820 stepx = fmax(sizex / 2.0 / (
double)
cnt, 2.0);
828 if (tp.
x >= hp.
x)
sgn = 1;
841 ty = fmin(
dy, 3 * (tp.
y +
dy - np.
y));
842 hy = fmin(
dy, 3 * (hp.
y +
dy - np.
y));
843 for (
size_t i = 0; i <
cnt; i++) {
851 {tp.
x +
dx, tp.
y - ty / 3},
853 {(tp.
x + hp.
x) / 2, np.
y -
dy},
855 {hp.
x -
dx, hp.
y - hy / 3},
868 dy += height - stepy;
870 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
873 if (debugleveln(e,1))
874 showPoints (
points, pointn);
882 double hy, ty, stepx,
dx,
dy, height;
890 stepx = fmax(sizex / 2.0 / (
double)
cnt, 2.0);
898 if (tp.
x >= hp.
x)
sgn = 1;
948 ty = fmin(
dy, 3 * (np.
y +
dy - tp.
y));
949 hy = fmin(
dy, 3 * (np.
y +
dy - hp.
y));
950 for (
size_t i = 0; i <
cnt; i++) {
958 {tp.
x +
dx, tp.
y + ty / 3},
960 {(tp.
x + hp.
x) / 2, np.
y +
dy},
962 {hp.
x -
dx, hp.
y + hy / 3},
975 dy += height - stepy;
977 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
980 if (debugleveln(e,1))
981 showPoints (
points, pointn);
989 double hx, tx, stepy,
dx,
dy, width;
997 stepy = fmax(sizey / 2.0 / (
double)
cnt, 2.0);
1005 if (tp.
y >= hp.
y)
sgn = 1;
1013 case 65:
if(tp.
y == hp.
y)
1019 tx = fmin(
dx, 3 * (np.
x +
dx - tp.
x));
1020 hx = fmin(
dx, 3 * (np.
x +
dx - hp.
x));
1021 for (
size_t i = 0; i <
cnt; i++) {
1029 {tp.
x + tx / 3, tp.
y +
dy},
1031 {np.
x +
dx, (tp.
y + hp.
y) / 2},
1033 {hp.
x + hx / 3, hp.
y -
dy},
1046 dx += width - stepx;
1048 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
1051 if (debugleveln(e,1))
1052 showPoints (
points, pointn);
1060 double hx, tx, stepy,
dx,
dy, width;
1068 stepy = fmax(sizey / 2.0 / (
double)
cnt, 2.0);
1078 if (tp.
y >= hp.
y)
sgn = 1;
1093 tx = fmin(
dx, 3 * (tp.
x +
dx - np.
x));
1094 hx = fmin(
dx, 3 * (hp.
x +
dx - np.
x));
1095 for (
size_t i = 0; i <
cnt; i++) {
1103 {tp.
x - tx / 3, tp.
y +
dy},
1105 {np.
x -
dx, (tp.
y + hp.
y) / 2},
1107 {hp.
x - hx / 3, hp.
y -
dy},
1120 dx += width - stepx;
1123 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
1126 if (debugleveln(e,1))
1127 showPoints (
points, pointn);
1253 for (
size_t i = 0; i < spl->
size; i++) {
1255 for (
size_t j = 0, k = 3; k < bz.
size; j += 3, k += 3) {
1262 for (
size_t i = 0; i < spl->
size; i++) {
1264 for (
size_t j = 0, k = 3; k < bz.
size; j += 3, k += 3) {
1353 const double angle = atan2(
pf.y - pe.
y,
pf.x - pe.
x) +
1371 agerrorf(
"getsplinepoints: no spline points available for edge (%s,%s)\n",
Dynamically expanding string buffers.
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static char * agxbdisown(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static void * gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size)
static char * gv_strdup(const char *original)
static void * gv_calloc(size_t nmemb, size_t size)
static void * gv_alloc(size_t size)
size_t arrowStartClip(edge_t *e, pointf *ps, size_t startp, size_t endp, bezier *spl, uint32_t sflag)
size_t arrowEndClip(edge_t *e, pointf *ps, size_t startp, size_t endp, bezier *spl, uint32_t eflag)
void arrowOrthoClip(edge_t *e, pointf *ps, size_t startp, size_t endp, bezier *spl, uint32_t sflag, uint32_t eflag)
static bool inside(inside_t *inside_context, pointf p)
void arrow_flags(Agedge_t *e, uint32_t *sflag, uint32_t *eflag)
pointf Bezier(const pointf *V, double t, pointf *Left, pointf *Right)
double late_double(void *obj, attrsym_t *attr, double defaultValue, double minimum)
pointf dotneato_closest(splines *spl, pointf pt)
void updateBB(graph_t *g, textlabel_t *lp)
#define PORT_LABEL_DISTANCE
void update_bb_bz(boxf *bb, pointf *cp)
static double dist(int dim, double *x, double *y)
#define APPROXEQPT(p, q, tol)
geometric functions (e.g. on points and boxes)
static WUR pointf mid_pointf(pointf p, pointf q)
static WUR pointf add_pointf(pointf p, pointf q)
Agsym_t * E_labeldistance
static int cnt(Dict_t *d, Dtlink_t **set)
char * agxget(void *obj, Agsym_t *sym)
void agerrorf(const char *fmt,...)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
Arithmetic helper functions.
#define LIST_APPEND(list, item)
static int sgn(int x)
sgn, as defined in Graphics Gems I, §11.8, pp. 99
static void merge(edge_t *e, int minlen, int weight)
port resolvePort(node_t *n, node_t *other, port *oldport)
bezier * new_spline(edge_t *e, size_t sz)
create and attach a new Bézier of size sz to the edge d
void endpath(path *P, edge_t *e, int et, pathend_t *endp, bool merge)
void makePortLabels(edge_t *e)
add head and tail labels if necessary and update bounding box
splines * getsplinepoints(edge_t *e)
static double conc_slope(node_t *n)
void clip_and_install(edge_t *fe, node_t *hn, pointf *ps, size_t pn, splineInfo *info)
static void selfLeft(edge_t *edges[], size_t cnt, double stepx, double sizey, splineInfo *sinfo)
double selfRightSpace(edge_t *e)
static void arrow_clip(edge_t *fe, node_t *hn, pointf *ps, size_t *startp, size_t *endp, bezier *spl, splineInfo *info)
static void selfRight(edge_t *edges[], size_t cnt, double stepx, double sizey, splineInfo *sinfo)
void shape_clip(node_t *n, pointf curve[4])
static int convert_sides_to_points(int tail_side, int head_side)
static void shape_clip0(inside_t *inside_context, node_t *n, pointf curve[4], bool left_inside)
static void selfBottom(edge_t *edges[], size_t cnt, double sizex, double stepy, splineInfo *sinfo)
void addEdgeLabels(edge_t *e)
static void selfTop(edge_t *edges[], size_t cnt, double sizex, double stepy, splineInfo *sinfo)
pointf edgeMidpoint(graph_t *g, edge_t *e)
void beginpath(path *P, edge_t *e, int et, pathend_t *endp, bool merge)
void makeSelfEdge(edge_t *edges[], size_t cnt, double sizex, double sizey, splineInfo *sinfo)
static pointf polylineMidpoint(splines *spl, pointf *pp, pointf *pq)
void add_box(path *P, boxf b)
static void endPoints(splines *spl, pointf *p, pointf *q)
extract the actual end points of the spline, where they touch the node
void bezier_clip(inside_t *inside_context, bool(*inside)(inside_t *inside_context, pointf p), pointf *sp, bool left_inside)
int place_portlabel(edge_t *e, bool head_p)
static bool streq(const char *a, const char *b)
are a and b equal?
size_t nbox
number of subdivisions
int(* pf)(void *, char *,...)