32static int debugleveln(
edge_t* e,
int i)
41static void showPoints(
pointf ps[],
int pn)
47 for (bi = 0; bi < pn; bi++) {
64 pointf *
ps,
size_t *startp,
size_t *endp,
75 j =
info->swapEnds(e);
76 uint32_t sflag, eflag;
78 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++)
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;
195 double save_real_size;
203 save_real_size =
ND_rw(n);
206 left_inside =
ND_shape(n)->fns->insidefn(&inside_context, c);
207 ND_rw(n) = save_real_size;
208 shape_clip0(&inside_context, n, curve, left_inside);
237 int clipTail, clipHead;
268 inside_t inside_context = {.
s = {.
n = tn, .bp = tbox}};
269 for (start = 0; start < pn - 4; start += 3) {
272 if (!
ND_shape(tn)->fns->insidefn(&inside_context, p2))
279 inside_t inside_context = {.
s = {.
n = hn, .bp = hbox}};
280 for (end = pn - 4; end > 0; end -= 3) {
283 if (!
ND_shape(hn)->fns->insidefn(&inside_context, p2))
289 for (; start < pn - 4; start += 3)
292 for (; end > 0; end -= 3)
296 for (
size_t i = start; i < end + 4; ) {
298 newspl->
list[i - start] =
ps[i];
303 newspl->
list[i - start] =
ps[i];
306 newspl->
list[i - start] =
ps[i];
312 newspl->
size = end - start + 4;
318 double s_in, s_out, m_in, m_out;
323 for (cnt_in = 0; (e =
ND_in(n).list[cnt_in]); cnt_in++)
325 for (cnt_out = 0; (e =
ND_out(n).list[cnt_out]); cnt_out++)
327 const double x1 =
ND_coord(n).x - s_in / cnt_in;
329 m_in = atan2(y1, x1);
330 const double x2 = s_out / cnt_out -
ND_coord(n).x;
332 m_out = atan2(y2, x2);
333 return (m_in + m_out) / 2.0;
373#define HT2(n) (ND_ht(n)/2)
446 else if (side &
LEFT) {
502 else if (side &
LEFT) {
642 else if (side &
LEFT) {
700 else if (side &
LEFT) {
774int vertices[] = {12,4,6,2,3,1,9,8};
775int i, tail_i, head_i;
777{11,12,13,14,15,16,17,18},
778{21,22,23,24,25,26,27,28},
779{31,32,33,34,35,36,37,38},
780{41,42,43,44,45,46,47,48},
781{51,52,53,54,55,56,57,58},
782{61,62,63,64,65,66,67,68},
783{71,72,73,74,75,76,77,78},
784{81,82,83,84,85,86,87,88}
787 tail_i = head_i = -1;
789 if(head_side == vertices[i]){
795 if(tail_side == vertices[i]){
801if( tail_i < 0 || head_i < 0)
804 return pair_a[tail_i][head_i];
813 double hy, ty, stepx,
dx,
dy, height;
818 stepx = fmax(sizex / 2.0 / (
double)
cnt, 2.0);
826 if (tp.
x >= hp.
x)
sgn = 1;
839 ty = fmin(
dy, 3 * (tp.
y +
dy - np.
y));
840 hy = fmin(
dy, 3 * (hp.
y +
dy - np.
y));
841 for (
size_t i = 0; i <
cnt; i++) {
849 {tp.
x +
dx, tp.
y - ty / 3},
851 {(tp.
x + hp.
x) / 2, np.
y -
dy},
853 {hp.
x -
dx, hp.
y - hy / 3},
866 dy += height - stepy;
868 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
871 if (debugleveln(e,1))
872 showPoints (
points, pointn);
880 double hy, ty, stepx,
dx,
dy, height;
888 stepx = fmax(sizex / 2.0 / (
double)
cnt, 2.0);
896 if (tp.
x >= hp.
x)
sgn = 1;
946 ty = fmin(
dy, 3 * (np.
y +
dy - tp.
y));
947 hy = fmin(
dy, 3 * (np.
y +
dy - hp.
y));
948 for (
size_t i = 0; i <
cnt; i++) {
956 {tp.
x +
dx, tp.
y + ty / 3},
958 {(tp.
x + hp.
x) / 2, np.
y +
dy},
960 {hp.
x -
dx, hp.
y + hy / 3},
973 dy += height - stepy;
975 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
978 if (debugleveln(e,1))
979 showPoints (
points, pointn);
987 double hx, tx, stepy,
dx,
dy, width;
995 stepy = fmax(sizey / 2.0 / (
double)
cnt, 2.0);
1003 if (tp.
y >= hp.
y)
sgn = 1;
1011 case 65:
if(tp.
y == hp.
y)
1017 tx = fmin(
dx, 3 * (np.
x +
dx - tp.
x));
1018 hx = fmin(
dx, 3 * (np.
x +
dx - hp.
x));
1019 for (
size_t i = 0; i <
cnt; i++) {
1027 {tp.
x + tx / 3, tp.
y +
dy},
1029 {np.
x +
dx, (tp.
y + hp.
y) / 2},
1031 {hp.
x + hx / 3, hp.
y -
dy},
1044 dx += width - stepx;
1046 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
1049 if (debugleveln(e,1))
1050 showPoints (
points, pointn);
1058 double hx, tx, stepy,
dx,
dy, width;
1066 stepy = fmax(sizey / 2.0 / (
double)
cnt, 2.0);
1076 if (tp.
y >= hp.
y)
sgn = 1;
1091 tx = fmin(
dx, 3 * (tp.
x +
dx - np.
x));
1092 hx = fmin(
dx, 3 * (hp.
x +
dx - np.
x));
1093 for (
size_t i = 0; i <
cnt; i++) {
1101 {tp.
x - tx / 3, tp.
y +
dy},
1103 {np.
x -
dx, (tp.
y + hp.
y) / 2},
1105 {hp.
x - hx / 3, hp.
y -
dy},
1118 dx += width - stepx;
1121 const size_t pointn =
sizeof(
points) /
sizeof(
points[0]);
1124 if (debugleveln(e,1))
1125 showPoints (
points, pointn);
1251 for (
size_t i = 0; i < spl->
size; i++) {
1253 for (
size_t j = 0, k = 3; k < bz.
size; j += 3, k += 3) {
1260 for (
size_t i = 0; i < spl->
size; i++) {
1262 for (
size_t j = 0, k = 3; k < bz.
size; j += 3, k += 3) {
1351 const double angle = atan2(
pf.y - pe.
y,
pf.x - pe.
x) +
1369 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(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 bezier 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)
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)
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)
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)
static bool streq(const char *a, const char *b)
are a and b equal?
size_t nbox
number of subdivisions
int(* pf)(void *, char *,...)