43 for (i=0; i < ind; i++) fputs(
" ", stderr);
83#define INSERT(cp) if(!first) first=cp; if(prev) prev->rightsib=cp; prev=cp;
103 size_t n_children = 0;
106 cp =
mkTree (subg, gp, ap, mp);
135static int nodecmp(
const void *x,
const void *y) {
138 if ((*p0)->area < (*p1)->area) {
141 if ((*p0)->area > (*p1)->area) {
149 if (
tree->n_children == 0)
return;
155 for (
size_t i = 0; i < nc; i++) {
161 double* areas_sorted =
gv_calloc(nc,
sizeof(
double));
162 for (
size_t i = 0; i < nc; i++) {
163 areas_sorted[i] =
LIST_GET(&nodes, i)->area;
165 const double h =
tree->r.size[1];
166 const double w =
tree->r.size[0];
167 const double delta = h - w;
169 const double m = (h + w -
disc) / 2.0;
171 .size = {w - m, h - m}};
174 fprintf (stderr,
"rec %f %f %f %f\n",
tree->r.x[0],
tree->r.x[1],
tree->r.size[0],
tree->r.size[1]);
175 for (
size_t i = 0; i < nc; i++) {
178 fprintf (stderr,
"%f - %f %f %f %f = %f (%f %f %f %f)\n", areas_sorted[i],
179 recs[i].x[0]-recs[i].size[0]*0.5, recs[i].x[1]-recs[i].size[1]*0.5,
180 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],
181 recs[i].x[0], recs[i].x[1], recs[i].size[0], recs[i].size[1]);
189 for (
size_t i = 0; i < nc; i++) {
202 snprintf(buf,
sizeof(buf),
"%.03f",
ND_ht(n)*0.7);
216 double x0, y0, wd, ht;
223 wd =
tree->r.size[0];
224 ht =
tree->r.size[1];
225 r.
LL.
x = x0 - wd/2.0;
226 r.
LL.
y = y0 - ht/2.0;
243 fprintf(stderr,
"%s coord %.5g %.5g ht %f width %f\n",
256 for (
size_t i = 0; i < nc; i++) {
274 root =
mkTree (g,gp,ap,mp);
276 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.
Arithmetic helper functions.
static bool is_exactly_zero(double v)
is a value precisely 0.0?
textitem scanner parser str
type-generic dynamically expanding list
#define LIST_APPEND(list, item)
#define LIST_RESERVE(list, capacity)
#define LIST_SORT(list, cmp)
#define LIST_GET(list, index)
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)