30static int debugleveln(
edge_t* e,
int i)
39static void showPoints(
pointf ps[],
int pn)
45 for (bi = 0; bi < pn; bi++) {
63 pointf *
ps,
size_t *startp,
size_t *endp,
74 j =
info->swapEnds(e);
75 uint32_t sflag, eflag;
77 if (
info->splineMerge(hn))
109 pointf * sp,
bool left_inside)
112 double low, high, t, *idir, *odir;
134 t = (high + low) / 2.0;
136 if (
inside(inside_context, pt)) {
138 for (i = 0; i < 4; i++)
144 }
while (fabs(opt.
x - pt.
x) > .5 || fabs(opt.
y - pt.
y) > .5);
146 for (i = 0; i < 4; i++)
149 for (i = 0; i < 4; i++)
165 double save_real_size;
168 save_real_size =
ND_rw(n);
169 for (i = 0; i < 4; i++) {
176 for (i = 0; i < 4; i++) {
180 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);
242 int clipTail, clipHead;
273 inside_t inside_context = {.
s = {.
n = tn, .bp = tbox}};
274 for (start = 0; start < pn - 4; start += 3) {
277 if (!
ND_shape(tn)->fns->insidefn(&inside_context, p2))
284 inside_t inside_context = {.
s = {.
n = hn, .bp = hbox}};
285 for (end = pn - 4; end > 0; end -= 3) {
288 if (!
ND_shape(hn)->fns->insidefn(&inside_context, p2))
294 for (; start < pn - 4; start += 3)
297 for (; end > 0; end -= 3)
301 for (
size_t i = start; i < end + 4; ) {
303 newspl->
list[i - start] =
ps[i];
308 newspl->
list[i - start] =
ps[i];
311 newspl->
list[i - start] =
ps[i];
317 newspl->
size = end - start + 4;
323 double s_in, s_out, m_in, m_out;
328 for (cnt_in = 0; (e =
ND_in(n).list[cnt_in]); cnt_in++)
330 for (cnt_out = 0; (e =
ND_out(n).list[cnt_out]); cnt_out++)
332 const double x1 =
ND_coord(n).x - s_in / cnt_in;
334 m_in = atan2(y1, x1);
335 const double x2 = s_out / cnt_out -
ND_coord(n).x;
337 m_out = atan2(y2, x2);
338 return (m_in + m_out) / 2.0;
379#define HT2(n) (ND_ht(n)/2)
452 else if (side &
LEFT) {
508 else if (side &
LEFT) {
648 else if (side &
LEFT) {
706 else if (side &
LEFT) {
780int vertices[] = {12,4,6,2,3,1,9,8};
781int i, tail_i, head_i;
783{11,12,13,14,15,16,17,18},
784{21,22,23,24,25,26,27,28},
785{31,32,33,34,35,36,37,38},
786{41,42,43,44,45,46,47,48},
787{51,52,53,54,55,56,57,58},
788{61,62,63,64,65,66,67,68},
789{71,72,73,74,75,76,77,78},
790{81,82,83,84,85,86,87,88}
793 tail_i = head_i = -1;
795 if(head_side == vertices[i]){
801 if(tail_side == vertices[i]){
807if( tail_i < 0 || head_i < 0)
810 return pair_a[tail_i][head_i];
819 double hy, ty, stepx,
dx,
dy, height;
824 stepx = fmax(sizex / 2.0 / (
double)
cnt, 2.0);
832 if (tp.
x >= hp.
x)
sgn = 1;
845 ty = fmin(
dy, 3 * (tp.
y +
dy - np.
y));
846 hy = fmin(
dy, 3 * (hp.
y +
dy - np.
y));
847 for (
size_t i = 0; i <
cnt; i++) {
855 {tp.
x +
dx, tp.
y - ty / 3},
857 {(tp.
x + hp.
x) / 2, np.
y -
dy},
859 {hp.
x -
dx, hp.
y - hy / 3},
872 dy += height - stepy;
874 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
877 if (debugleveln(e,1))
878 showPoints (
points, pointn);
886 double hy, ty, stepx,
dx,
dy, height;
894 stepx = fmax(sizex / 2.0 / (
double)
cnt, 2.0);
902 if (tp.
x >= hp.
x)
sgn = 1;
952 ty = fmin(
dy, 3 * (np.
y +
dy - tp.
y));
953 hy = fmin(
dy, 3 * (np.
y +
dy - hp.
y));
954 for (
size_t i = 0; i <
cnt; i++) {
962 {tp.
x +
dx, tp.
y + ty / 3},
964 {(tp.
x + hp.
x) / 2, np.
y +
dy},
966 {hp.
x -
dx, hp.
y + hy / 3},
979 dy += height - stepy;
981 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
984 if (debugleveln(e,1))
985 showPoints (
points, pointn);
993 double hx, tx, stepy,
dx,
dy, width;
1001 stepy = fmax(sizey / 2.0 / (
double)
cnt, 2.0);
1009 if (tp.
y >= hp.
y)
sgn = 1;
1017 case 65:
if(tp.
y == hp.
y)
1023 tx = fmin(
dx, 3 * (np.
x +
dx - tp.
x));
1024 hx = fmin(
dx, 3 * (np.
x +
dx - hp.
x));
1025 for (
size_t i = 0; i <
cnt; i++) {
1033 {tp.
x + tx / 3, tp.
y +
dy},
1035 {np.
x +
dx, (tp.
y + hp.
y) / 2},
1037 {hp.
x + hx / 3, hp.
y -
dy},
1050 dx += width - stepx;
1052 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
1055 if (debugleveln(e,1))
1056 showPoints (
points, pointn);
1064 double hx, tx, stepy,
dx,
dy, width;
1072 stepy = fmax(sizey / 2.0 / (
double)
cnt, 2.0);
1082 if (tp.
y >= hp.
y)
sgn = 1;
1097 tx = fmin(
dx, 3 * (tp.
x +
dx - np.
x));
1098 hx = fmin(
dx, 3 * (hp.
x +
dx - np.
x));
1099 for (
size_t i = 0; i <
cnt; i++) {
1107 {tp.
x - tx / 3, tp.
y +
dy},
1109 {np.
x -
dx, (tp.
y + hp.
y) / 2},
1111 {hp.
x - hx / 3, hp.
y -
dy},
1124 dx += width - stepx;
1127 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
1130 if (debugleveln(e,1))
1131 showPoints (
points, pointn);
1265 for (
size_t i = 0; i < spl->
size; i++) {
1267 for (
size_t j = 0, k = 3; k < bz.
size; j += 3, k += 3) {
1274 for (
size_t i = 0; i < spl->
size; i++) {
1276 for (
size_t j = 0, k = 3; k < bz.
size; j += 3, k += 3) {
1305 d.
x = (q.
x + p.
x) / 2.;
1306 d.
y = (p.
y + q.
y) / 2.;
1316#define LEFTOF(a,b,c) (((a.y - b.y)*(c.x - b.x) - (c.y - b.y)*(a.x - b.x)) > 0)
1317#define MAXLABELWD (POINTS_PER_INCH/2.0)
1328#define AGXGET(o,a) agxget(o,a)
1357 bez = &spl->
list[0];
1363 for (
size_t i = 0; i < 4; i++)
1364 c[i] = bez->
list[i];
1374 for (
size_t i = 0; i < 4; i++)
1375 c[i] = bez->
list[bez->
size - 4 + i];
1379 angle = atan2(
pf.y - pe.
y,
pf.x - pe.
x) +
1396 agerrorf(
"getsplinepoints: no spline points available for edge (%s,%s)\n",
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(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)
static pointf add_pointf(pointf p, pointf q)
Agsym_t * E_labeldistance
static int cnt(Dict_t *d, Dtlink_t **set)
void agerrorf(const char *fmt,...)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
Arithmetic helper functions.
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)
void endpath(path *P, edge_t *e, int et, pathend_t *endp, bool merge)
void makePortLabels(edge_t *e)
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)
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 selfLeft(edge_t *edges[], size_t ind, 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 selfRight(edge_t *edges[], size_t ind, size_t cnt, double stepx, double sizey, splineInfo *sinfo)
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 ind, size_t cnt, double sizex, double stepy, splineInfo *sinfo)
void addEdgeLabels(edge_t *e)
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 ind, 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)
void bezier_clip(inside_t *inside_context, bool(*inside)(inside_t *inside_context, pointf p), pointf *sp, bool left_inside)
static void selfTop(edge_t *edges[], size_t ind, size_t cnt, double sizex, double stepy, splineInfo *sinfo)
int place_portlabel(edge_t *e, bool head_p)
size_t nbox
number of subdivisions
int(* pf)(void *, char *,...)