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 if (maxRadius < child->radius) {
190 maxRadius = child->
radius;
192 diameter += 2 * child->
radius + min_dist;
219 double childAngle, childRadius, incidentAngle;
220 double mindistAngle, rotateAngle, midAngle = 0.0;
221 int midChild,
cnt = 0;
225 double d, deltaX, deltaY;
227 childRadius =
info->scale *
info->minRadius;
231 childRadius = fmax(childRadius, d);
232 d = 2 *
M_PI * childRadius -
info->diameter;
234 min_dist += d /
info->childCount;
237 childAngle =
info->theta -
info->diameter / (2 * childRadius);
239 if ((childRadius +
info->maxRadius) > snRadius)
240 snRadius = childRadius +
info->maxRadius;
242 mindistAngle = min_dist / childRadius;
244 midChild = (
info->childCount + 1) / 2;
245 for (child = stp->
cp; child; child = child->
next) {
251 incidentAngle = child->
radius / childRadius;
253 if (childAngle != 0) {
254 if (
info->childCount == 2)
257 childAngle += incidentAngle;
261 firstAngle = childAngle;
263 lastAngle = childAngle;
265 if (
info->childCount == 1) {
266 childAngle =
info->theta;
268 childAngle += incidentAngle + mindistAngle / 2;
272 deltaX = childRadius * cos(childAngle);
273 deltaY = childRadius * sin(childAngle);
280 rotateAngle =
getRotation(child, deltaX, deltaY, childAngle);
281 applyDelta(child, deltaX, deltaY, rotateAngle);
284 childAngle += incidentAngle + mindistAngle;
286 childAngle += incidentAngle + mindistAngle / 2;
290 midAngle = childAngle;
310static double position(
size_t childCount,
size_t length, nodelist_t *nodepath,
315 double maxRadius = 0.0;
328 state.nodeAngle = 2 *
M_PI / (double)length;
329 state.firstAngle = -1;
330 state.lastAngle = -1;
332 for (
size_t item = 0;
item < nodelist_size(nodepath); ++
item) {
335 theta = counter *
state.nodeAngle;
339 parents[num_parents].
n = n;
340 parents[num_parents].
theta = theta;
341 maxRadius =
getInfo (parents+num_parents, &
state, min_dist);
346 if (num_parents == 1)
347 parents->
scale = 1.0;
348 else if (num_parents == 2) {
358 for (i = 0; i < num_parents; i++) {
359 if (i+1 == num_parents) {
372 for (i = 0; i < num_parents; i++) {
384 if (childCount == 1) {
385 applyDelta(sn, -(maxRadius + min_dist / 2), 0, 0);
386 sn->
radius += min_dist / 2 + maxRadius;
401 double centerAngle =
M_PI;
404 size_t childCount = 0;
413 size_t length = nodelist_size(&longest_path);
417 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)