29static int debugleveln(
edge_t* e,
int i)
38static void showPoints(
pointf ps[],
int pn)
44 for (bi = 0; bi < pn; bi++) {
62 pointf *
ps,
size_t *startp,
size_t *endp,
73 j =
info->swapEnds(e);
74 uint32_t sflag, eflag;
76 if (
info->splineMerge(hn))
108 pointf * sp,
bool left_inside)
111 double low, high, t, *idir, *odir;
133 t = (high + low) / 2.0;
135 if (
inside(inside_context, pt)) {
137 for (i = 0; i < 4; i++)
143 }
while (fabs(opt.
x - pt.
x) > .5 || fabs(opt.
y - pt.
y) > .5);
145 for (i = 0; i < 4; i++)
148 for (i = 0; i < 4; i++)
164 double save_real_size;
167 save_real_size =
ND_rw(n);
168 for (i = 0; i < 4; i++) {
175 for (i = 0; i < 4; i++) {
179 ND_rw(n) = save_real_size;
196 double save_real_size;
204 save_real_size =
ND_rw(n);
207 left_inside =
ND_shape(n)->fns->insidefn(&inside_context, c);
208 ND_rw(n) = save_real_size;
209 shape_clip0(&inside_context, n, curve, left_inside);
244 int clipTail, clipHead;
279 inside_t inside_context = {.
s = {.
n = tn, .bp = tbox}};
280 for (start = 0; start < pn - 4; start += 3) {
283 if (!
ND_shape(tn)->fns->insidefn(&inside_context, p2))
290 inside_t inside_context = {.
s = {.
n = hn, .bp = hbox}};
291 for (end = pn - 4; end > 0; end -= 3) {
294 if (!
ND_shape(hn)->fns->insidefn(&inside_context, p2))
300 for (; start < pn - 4; start += 3)
303 for (; end > 0; end -= 3)
307 for (
size_t i = start; i < end + 4; ) {
309 newspl->
list[i - start] =
ps[i];
314 newspl->
list[i - start] =
ps[i];
317 newspl->
list[i - start] =
ps[i];
323 newspl->
size = end - start + 4;
329 double s_in, s_out, m_in, m_out;
335 for (cnt_in = 0; (e =
ND_in(n).list[cnt_in]); cnt_in++)
337 for (cnt_out = 0; (e =
ND_out(n).list[cnt_out]); cnt_out++)
341 m_in = atan2(p.
y, p.
x);
344 m_out = atan2(p.
y, p.
x);
345 return (m_in + m_out) / 2.0;
386#define HT2(n) (ND_ht(n)/2)
459 else if (side &
LEFT) {
515 else if (side &
LEFT) {
655 else if (side &
LEFT) {
713 else if (side &
LEFT) {
787int vertices[] = {12,4,6,2,3,1,9,8};
788int i, tail_i, head_i;
790{11,12,13,14,15,16,17,18},
791{21,22,23,24,25,26,27,28},
792{31,32,33,34,35,36,37,38},
793{41,42,43,44,45,46,47,48},
794{51,52,53,54,55,56,57,58},
795{61,62,63,64,65,66,67,68},
796{71,72,73,74,75,76,77,78},
797{81,82,83,84,85,86,87,88}
800 tail_i = head_i = -1;
802 if(head_side == vertices[i]){
808 if(tail_side == vertices[i]){
814if( tail_i < 0 || head_i < 0)
817 return pair_a[tail_i][head_i];
826 double hy, ty, stepx,
dx,
dy, height;
832 stepx = fmax(sizex / 2.0 / (
double)
cnt, 2.0);
840 if (tp.
x >= hp.
x)
sgn = 1;
853 ty = fmin(
dy, 3 * (tp.
y +
dy - np.
y));
854 hy = fmin(
dy, 3 * (hp.
y +
dy - np.
y));
855 for (
size_t i = 0; i <
cnt; i++) {
879 dy += height - stepy;
883 if (debugleveln(e,1))
884 showPoints (
points, pointn);
892 double hy, ty, stepx,
dx,
dy, height;
901 stepx = fmax(sizex / 2.0 / (
double)
cnt, 2.0);
909 if (tp.
x >= hp.
x)
sgn = 1;
959 ty = fmin(
dy, 3 * (np.
y +
dy - tp.
y));
960 hy = fmin(
dy, 3 * (np.
y +
dy - hp.
y));
961 for (
size_t i = 0; i <
cnt; i++) {
985 dy += height - stepy;
989 if (debugleveln(e,1))
990 showPoints (
points, pointn);
998 double hx, tx, stepy,
dx,
dy, width;
1007 stepy = fmax(sizey / 2.0 / (
double)
cnt, 2.0);
1015 if (tp.
y >= hp.
y)
sgn = 1;
1023 case 65:
if(tp.
y == hp.
y)
1029 tx = fmin(
dx, 3 * (np.
x +
dx - tp.
x));
1030 hx = fmin(
dx, 3 * (np.
x +
dx - hp.
x));
1031 for (
size_t i = 0; i <
cnt; i++) {
1055 dx += width - stepx;
1059 if (debugleveln(e,1))
1060 showPoints (
points, pointn);
1068 double hx, tx, stepy,
dx,
dy, width;
1077 stepy = fmax(sizey / 2.0 / (
double)
cnt, 2.0);
1087 if (tp.
y >= hp.
y)
sgn = 1;
1102 tx = fmin(
dx, 3 * (tp.
x +
dx - np.
x));
1103 hx = fmin(
dx, 3 * (hp.
x +
dx - np.
x));
1104 for (
size_t i = 0; i <
cnt; i++) {
1129 dx += width - stepx;
1134 if (debugleveln(e,1))
1135 showPoints (
points, pointn);
1269 for (
size_t i = 0; i < spl->
size; i++) {
1271 for (
size_t j = 0, k = 3; k < bz.
size; j += 3, k += 3) {
1278 for (
size_t i = 0; i < spl->
size; i++) {
1280 for (
size_t j = 0, k = 3; k < bz.
size; j += 3, k += 3) {
1309 d.
x = (q.
x + p.
x) / 2.;
1310 d.
y = (p.
y + q.
y) / 2.;
1320#define LEFTOF(a,b,c) (((a.y - b.y)*(c.x - b.x) - (c.y - b.y)*(a.x - b.x)) > 0)
1321#define MAXLABELWD (POINTS_PER_INCH/2.0)
1332#define AGXGET(o,a) agxget(o,a)
1361 bez = &spl->
list[0];
1367 for (
size_t i = 0; i < 4; i++)
1368 c[i] = bez->
list[i];
1378 for (
size_t i = 0; i < 4; i++)
1379 c[i] = bez->
list[bez->
size - 4 + i];
1383 angle = atan2(
pf.y - pe.
y,
pf.x - pe.
x) +
1400 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.
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 *,...)