41 for (i=0; i < ind; i++) fputs(
" ", stderr);
81#define INSERT(cp) if(!first) first=cp; if(prev) prev->rightsib=cp; prev=cp;
101 size_t n_children = 0;
104 cp =
mkTree (subg, gp, ap, mp);
133static int nodecmp(
const void *x,
const void *y) {
136 if ((*p0)->area < (*p1)->area) {
139 if ((*p0)->area > (*p1)->area) {
151 if (
tree->n_children == 0)
return;
156 for (
size_t i = 0; i < nc; i++) {
162 double* areas_sorted =
gv_calloc(nc,
sizeof(
double));
163 for (
size_t i = 0; i < nc; i++) {
164 areas_sorted[i] = nodes[i]->
area;
171 crec.
x[0] =
tree->r.x[0];
172 crec.
x[1] =
tree->r.x[1];
175 m = (h + w -
disc)/2.0;
176 crec.
size[0] = w - m;
177 crec.
size[1] = h - m;
178 recs =
tree_map(nc, areas_sorted, crec);
181 fprintf (stderr,
"rec %f %f %f %f\n",
tree->r.x[0],
tree->r.x[1],
tree->r.size[0],
tree->r.size[1]);
182 for (
size_t i = 0; i < nc; i++) {
183 nodes[i]->
r = recs[i];
185 fprintf (stderr,
"%f - %f %f %f %f = %f (%f %f %f %f)\n", areas_sorted[i],
186 recs[i].x[0]-recs[i].size[0]*0.5, recs[i].x[1]-recs[i].size[1]*0.5,
187 recs[i].x[0]+recs[i].size[0]*0.5, recs[i].x[1]+recs[i].size[1]*0.5, recs[i].size[0]*recs[i].size[1],
188 recs[i].x[0], recs[i].x[1], recs[i].size[0], recs[i].size[1]);
196 for (
size_t i = 0; i < nc; i++) {
209 snprintf(buf,
sizeof(buf),
"%.03f",
ND_ht(n)*0.7);
223 double x0, y0, wd, ht;
230 wd =
tree->r.size[0];
231 ht =
tree->r.size[1];
232 r.
LL.
x = x0 - wd/2.0;
233 r.
LL.
y = y0 - ht/2.0;
250 fprintf(stderr,
"%s coord %.5g %.5g ht %f width %f\n",
263 for (
size_t i = 0; i < nc; i++) {
281 root =
mkTree (g,gp,ap,mp);
283 root->
r = (
rectangle){{0, 0}, {sqrt(total + 0.1), sqrt(total + 0.1)}};
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static void * gv_alloc(size_t size)
void common_init_node(node_t *n)
double late_double(void *obj, attrsym_t *attr, double defaultValue, double minimum)
void gv_nodesize(node_t *n, bool flip)
#define PS2INCH(a_points)
int agxset(void *obj, Agsym_t *sym, const char *value)
char * agxget(void *obj, Agsym_t *sym)
#define agfindgraphattr(g, a)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
#define agfindnodeattr(g, a)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
textitem scanner parser str
static int nodecmp(const void *x, const void *y)
static double fullArea(treenode_t *p, attrsym_t *mp)
static double getArea(void *obj, attrsym_t *ap)
static void finishNode(node_t *n)
static treenode_t * mkTreeNode(Agnode_t *n, attrsym_t *ap)
void patchworkLayout(Agraph_t *g)
static void walkTree(treenode_t *tree)
static void freeTree(treenode_t *tp)
static void layoutTree(treenode_t *tree)
static treenode_t * mkTree(Agraph_t *g, attrsym_t *gp, attrsym_t *ap, attrsym_t *mp)
static point center(point vertex[], size_t n)
rectangle * tree_map(size_t n, double *area, rectangle fillrec)