53 double len2, newX, newY;
67 size_t count = nodelist_size(list);
69 return theta -
M_PI / 2.0;
76 mindist2 =
LEN2(newX, newY);
86 len2 =
LEN2(newX, newY);
87 if (len2 < mindist2) {
94 double rho = sn->
rad0;
95 double r = sn->
radius - rho;
98 const double R = hypot(x, y);
100 double phi = atan2(n_y, n_x + r);
101 double l = r - rho / cos(phi);
103 theta +=
M_PI / 2.0 - phi - asin(l / R * cos(phi));
107 if (theta > 2 *
M_PI)
128 const double tmpX =
ND_pos(n)[0];
129 const double tmpY =
ND_pos(n)[1];
130 const double cosR = cos(
rotate);
131 const double sinR = sin(
rotate);
133 const double X = tmpX * cosR - tmpY * sinR;
134 const double Y = tmpX * sinR + tmpY * cosR;
182 double maxRadius = 0;
186 for (child = stp->
cp; child; child = child->
next) {
189 maxRadius = fmax(maxRadius, child->
radius);
190 diameter += 2 * child->
radius + min_dist;
217 double childAngle, childRadius, incidentAngle;
218 double mindistAngle, rotateAngle, midAngle = 0.0;
219 int midChild,
cnt = 0;
223 double d, deltaX, deltaY;
225 childRadius =
info->scale *
info->minRadius;
229 childRadius = fmax(childRadius, d);
230 d = 2 *
M_PI * childRadius -
info->diameter;
232 min_dist += d /
info->childCount;
235 childAngle =
info->theta -
info->diameter / (2 * childRadius);
237 snRadius = fmax(snRadius, childRadius +
info->maxRadius);
239 mindistAngle = min_dist / childRadius;
241 midChild = (
info->childCount + 1) / 2;
242 for (child = stp->
cp; child; child = child->
next) {
248 incidentAngle = child->
radius / childRadius;
250 if (childAngle != 0) {
251 if (
info->childCount == 2)
254 childAngle += incidentAngle;
258 firstAngle = childAngle;
260 lastAngle = childAngle;
262 if (
info->childCount == 1) {
263 childAngle =
info->theta;
265 childAngle += incidentAngle + mindistAngle / 2;
269 deltaX = childRadius * cos(childAngle);
270 deltaY = childRadius * sin(childAngle);
277 rotateAngle =
getRotation(child, deltaX, deltaY, childAngle);
278 applyDelta(child, deltaX, deltaY, rotateAngle);
281 childAngle += incidentAngle + mindistAngle;
283 childAngle += incidentAngle + mindistAngle / 2;
287 midAngle = childAngle;
307static double position(
size_t childCount,
size_t length, nodelist_t *nodepath,
312 double maxRadius = 0.0;
329 for (
size_t item = 0;
item < nodelist_size(nodepath); ++
item) {
336 parents[num_parents].
n = n;
337 parents[num_parents].
theta = theta;
338 maxRadius =
getInfo (parents+num_parents, &state, min_dist);
343 if (num_parents == 1)
344 parents->
scale = 1.0;
345 else if (num_parents == 2) {
355 for (i = 0; i < num_parents; i++) {
356 if (i+1 == num_parents) {
369 for (i = 0; i < num_parents; i++) {
381 if (childCount == 1) {
382 applyDelta(sn, -(maxRadius + min_dist / 2), 0, 0);
383 sn->
radius += min_dist / 2 + maxRadius;
398 double centerAngle =
M_PI;
401 size_t childCount = 0;
403 doBlock(g, child, min_dist, state);
408 nodelist_t longest_path =
layout_block(g, sn, min_dist, state);
410 size_t length = nodelist_size(&longest_path);
414 centerAngle =
position(childCount, length, &longest_path, sn, min_dist);
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
nodelist_t layout_block(Agraph_t *g, block_t *sn, double min_dist, circ_state *state)
static void applyDelta(block_t *sn, double x, double y, double rotate)
static void doBlock(Agraph_t *g, block_t *sn, double min_dist, circ_state *state)
static void setInfo(posinfo_t *p0, posinfo_t *p1, double delta)
static void positionChildren(posinfo_t *info, posstate *stp, size_t length, double min_dist)
static double getRotation(block_t *sn, double x, double y, double theta)
static double getInfo(posinfo_t *pi, posstate *stp, double min_dist)
get size info for blocks attached to the given node.
void circPos(Agraph_t *g, block_t *sn, circ_state *state)
#define X(prefix, name, str, type, subtype,...)
static int cnt(Dict_t *d, Dtlink_t **set)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
#define neighbor(t, i, edim, elist)
static void rotate(int n, int dim, double *x, double angle)