void fdp_init_graph(Agraph_t * g)
{
+ setEdgeType (g, ET_LINE);
GD_alg(g) = (void *) NEW(gdata); /* freed in cleanup_graph */
g->u.ndim = late_int(g, agfindattr(g, "dim"), 2, 2);
Ndim = g->u.ndim = MIN(g->u.ndim, MAXDIM);
}
static void
-fdpSplines (graph_t * g, char* str)
+fdpSplines (graph_t * g)
{
int trySplines = 0;
+ int et = EDGE_TYPE(g);
- if (str) {
- if (streq(str, "compound")) {
- trySplines = splineEdges(g, compoundEdges, 1);
+ if (et != ET_LINE) {
+ if (et == ET_COMPOUND) {
+ trySplines = splineEdges(g, compoundEdges, ET_SPLINE);
/* When doing the edges again, accept edges done by compoundEdges */
if (trySplines)
Nop = 2;
}
- if (trySplines || mapbool(str)) {
+ if (trySplines || (et == ET_SPLINE)) {
if (HAS_CLUST_EDGE(g)) {
agerr(AGWARN,
"splines and cluster edges not supported - using line segments\n");
} else {
- spline_edges1(g, 1);
+ spline_edges1(g, ET_SPLINE);
}
}
}
if (State < GVSPLINES)
- spline_edges1(g, 0);
+ spline_edges1(g, ET_LINE);
}
void fdp_layout(graph_t * g)
{
- char *str;
-
fdp_init_graph(g);
fdpLayout(g);
neato_set_aspect(g);
- str = agget(g, "splines");
- if (!str || *str) fdpSplines (g, str);
+ if (EDGE_TYPE(g) != ET_NONE) fdpSplines (g);
dotneato_postprocess(g);
}
return line;
}
+/* makePolyline:
+ */
+static void
+makePolyline(edge_t * e)
+{
+ int i, j;
+ Ppolyline_t line = ED_path(e);
+ int npts = 4 + 3*(line.pn-2);
+ point* ispline = N_GNEW(npts, point);
+ point p;
+
+ j = i = 0;
+ PF2P (line.ps[i], p);
+ ispline[j+1] = ispline[j] = p;
+ j += 2;
+ i++;
+ for (; i < line.pn-1; i++) {
+ PF2P (line.ps[i], p);
+ ispline[j+2] = ispline[j+1] = ispline[j] = p;
+ j += 3;
+ }
+ PF2P (line.ps[i], p);
+ ispline[j+1] = ispline[j] = p;
+
+ if (Verbose > 1)
+ fprintf(stderr, "polyline %s %s\n", e->tail->name, e->head->name);
+ clip_and_install(e, e, ispline, npts, &sinfo);
+ free(ispline);
+}
+
/* makeSpline:
* Construct a spline connecting the endpoints of e, avoiding the npoly
* obstacles obs.
* is not altered to reflect intra-cluster edges.
* If Nop > 1 and the spline exists, it is just copied.
*/
-static int _spline_edges(graph_t * g, double SEP, int splines)
+static int _spline_edges(graph_t * g, double SEP, int edgetype)
{
node_t *n;
edge_t *e;
path *P = NULL;
/* build configuration */
- if (splines) {
+ if ((edgetype == ET_SPLINE) || (edgetype == ET_PLINE)) {
obs = N_NEW(agnnodes(g), Ppoly_t *);
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
obp = makeObstacle(n, SEP);
/* route edges */
if (Verbose)
fprintf(stderr, "Creating edges using %s\n",
- (vconfig ? "splines" : "line segments"));
+ (vconfig ? (edgetype == ET_SPLINE ? "splines" : "polylines") :
+ "line segments"));
if (vconfig) {
/* path-finding pass */
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
}
makeSelfArcs(P, e, GD_nodesep(g));
} else if (vconfig) {
- makeSpline(e, obs, npoly, TRUE);
+ if (edgetype == ET_SPLINE)
+ makeSpline(e, obs, npoly, TRUE);
+ else
+ makePolyline(e);
} else if (ED_count(e)) {
makeStraightEdge(g, e);
}
* Returns 0 on success.
*
* The edge function is given the graph, the separation to be added
- * around obstacles, and the type of edge. (At present, this is a boolean,
- * with 1 meaning splines and 0 meaning line segments.) It must guarantee
+ * around obstacles, and the type of edge. It must guarantee
* that all bounding boxes are current; in particular, the bounding box of
* g must reflect the addition of the edges.
*/
int
splineEdges(graph_t * g, int (*edgefn) (graph_t *, double, int),
- int splines)
+ int edgetype)
{
node_t *n;
edge_t *e;
}
dtclose(map);
- if (edgefn(g, SEP, splines))
+ if (edgefn(g, SEP, edgetype))
return 1;
State = GVSPLINES;
* Construct edges using default algorithm and given splines value.
* Return 0 on success.
*/
-int spline_edges1(graph_t * g, int splines)
+int spline_edges1(graph_t * g, int edgetype)
{
- return splineEdges(g, _spline_edges, splines);
+ return splineEdges(g, _spline_edges, edgetype);
}
/* spline_edges0:
*/
void spline_edges0(graph_t * g)
{
- char* s = agget(g, "splines");
-
+ int et = EDGE_TYPE (g->root);
neato_set_aspect(g);
- if (s && (*s == '\0')) return;
- spline_edges1(g, mapbool(s));
+ if (et == ET_NONE) return;
+ spline_edges1(g, et);
}
/* spline_edges: