Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
neatosplines.c File Reference
#include <assert.h>
#include "config.h"
#include <limits.h>
#include <math.h>
#include <neatogen/neato.h>
#include <neatogen/adjust.h>
#include <pathplan/pathplan.h>
#include <pathplan/vispath.h>
#include <neatogen/multispline.h>
#include <stdbool.h>
#include <stddef.h>
#include <util/alloc.h>
#include <util/unreachable.h>
Include dependency graph for neatosplines.c:

Go to the source code of this file.

Data Structures

struct  edgeinfo
 
struct  edgeitem
 

Macros

#define BOUNDARY_PORT(e)   ((ED_tail_port(e).side)||(ED_head_port(e).side))
 

Functions

static bool spline_merge (node_t *n)
 
static bool swap_ends_p (edge_t *e)
 
static void make_barriers (Ppoly_t **poly, int npoly, int pp, int qp, Pedge_t **barriers, size_t *n_barriers)
 
static Ppoint_t genPt (double x, double y, pointf c)
 
static Ppoint_t recPt (double x, double y, pointf c, expand_t *m)
 
static void * newitem (void *p, Dtdisc_t *disc)
 
static int cmpitems (void *k1, void *k2)
 
static edge_tequivEdge (Dt_t *map, edge_t *e)
 
void makeSelfArcs (edge_t *e, int stepx)
 
static double ellipse_tangent_slope (double a, double b, pointf p)
 
static pointf line_intersection (linef l0, linef l1)
 
static pointf circumscribed_polygon_corner_about_ellipse (double a, double b, size_t i, size_t nsides)
 
Ppoly_tmakeObstacle (node_t *n, expand_t *pmargin, bool isOrtho)
 
Ppolyline_t getPath (edge_t *e, vconfig_t *vconfig, bool chkPts)
 
static void makePolyline (edge_t *e)
 
void makeSpline (edge_t *e, Ppoly_t **obs, int npoly, bool chkPts)
 
static int spline_edges_ (graph_t *g, expand_t *pmargin, int edgetype)
 
int splineEdges (graph_t *g, int(*edgefn)(graph_t *, expand_t *, int), int edgetype)
 
int spline_edges1 (graph_t *g, int edgetype)
 
void spline_edges0 (graph_t *g, bool set_aspect)
 
static void shiftClusters (graph_t *g, pointf offset)
 
void spline_edges (graph_t *g)
 
static void scaleEdge (edge_t *e, double xf, double yf)
 
static void scaleBB (graph_t *g, double xf, double yf)
 
static void translateE (edge_t *e, pointf offset)
 
static void translateG (Agraph_t *g, pointf offset)
 
void neato_translate (Agraph_t *g)
 
static bool _neato_set_aspect (graph_t *g)
 
bool neato_set_aspect (graph_t *g)
 

Variables

static splineInfo sinfo
 
Dtdisc_t edgeItemDisc
 

Macro Definition Documentation

◆ BOUNDARY_PORT

#define BOUNDARY_PORT (   e)    ((ED_tail_port(e).side)||(ED_head_port(e).side))

Definition at line 579 of file neatosplines.c.

Function Documentation

◆ _neato_set_aspect()

static bool _neato_set_aspect ( graph_t g)
static

Definition at line 1025 of file neatosplines.c.

References agfstnode(), agfstout(), agnxtnode(), agnxtout(), ED_spl, exch_xyf(), GD_bb, GD_drawing, GD_flip, ND_pos, neato_translate(), Nop, R_EXPAND, R_FILL, R_VALUE, Agraph_s::root, scale(), scaleBB(), scaleEdge(), and pointf_s::y.

Referenced by neato_set_aspect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ circumscribed_polygon_corner_about_ellipse()

static pointf circumscribed_polygon_corner_about_ellipse ( double  a,
double  b,
size_t  i,
size_t  nsides 
)
static

calculate a corner of a polygon circumscribed about an ellipse

Parameters
aHalf the width of the ellipse, i.e., the maximum x value
bHalf the height of the ellipse, i.e., the maximum y value
iIndex of the polygon corner
nsidesNumber of sides of the polygon
Returns
Polygon corner at index i

Definition at line 300 of file neatosplines.c.

References ellipse_tangent_slope(), line_intersection(), M_PI, pointf_s::x, and pointf_s::y.

Referenced by makeObstacle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmpitems()

static int cmpitems ( void *  k1,
void *  k2 
)
static

Definition at line 121 of file neatosplines.c.

References edgeinfo::n1, edgeinfo::n2, edgeinfo::p1, edgeinfo::p2, pointf_s::x, and pointf_s::y.

◆ ellipse_tangent_slope()

static double ellipse_tangent_slope ( double  a,
double  b,
pointf  p 
)
static

calculate the slope of the tangent of an ellipse

The equation for the slope m of the tangent of an ellipse as a function of x * is given by:

      bx

m = ± ――――――――――


a √ a²- x²

or

m = ± (b * x) / (a * sqrt(a * a - x * x))

We know that the slope is negative in the first and third quadrant, i.e., when the signs of x and y are the same, so we use that to select the correct slope.

Parameters
aHalf the width of the ellipse, i.e., the maximum x value
bHalf the height of the ellipse, i.e., the maximum y value
pA point on the ellipse periphery in which to calculate the slope of the tangent
Returns
The slope of the tangent in point p

Definition at line 270 of file neatosplines.c.

References pointf_s::x, and pointf_s::y.

Referenced by circumscribed_polygon_corner_about_ellipse().

Here is the caller graph for this function:

◆ equivEdge()

static edge_t * equivEdge ( Dt_t map,
edge_t e 
)
static

Definition at line 168 of file neatosplines.c.

References aghead, agtail, dtinsert, edgeitem::e, ED_head_port, ED_tail_port, edgeitem::id, edgeinfo::n1, edgeinfo::n2, edgeinfo::p1, edgeinfo::p2, pointf_s::x, and pointf_s::y.

Referenced by splineEdges().

Here is the caller graph for this function:

◆ genPt()

static Ppoint_t genPt ( double  x,
double  y,
pointf  c 
)
static

Definition at line 78 of file neatosplines.c.

References pointf_s::x, Pxy_t::x, pointf_s::y, and Pxy_t::y.

Referenced by makeObstacle().

Here is the caller graph for this function:

◆ getPath()

Ppolyline_t getPath ( edge_t e,
vconfig_t vconfig,
bool  chkPts 
)

Definition at line 502 of file neatosplines.c.

References add_pointf(), aghead, agtail, ED_head_port, ED_tail_port, ND_coord, ND_lim, Pobspath(), and POLYID_NONE.

Referenced by compoundEdges(), and spline_edges_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ line_intersection()

static pointf line_intersection ( linef  l0,
linef  l1 
)
static

calculate the intersection of two lines

Parameters
l0First line
l1Second line
Returns
Intersection of the two lines

Definition at line 285 of file neatosplines.c.

References linef::m, linef::p, pointf_s::x, and pointf_s::y.

Referenced by circumscribed_polygon_corner_about_ellipse().

Here is the caller graph for this function:

◆ make_barriers()

static void make_barriers ( Ppoly_t **  poly,
int  npoly,
int  pp,
int  qp,
Pedge_t **  barriers,
size_t *  n_barriers 
)
static

Definition at line 45 of file neatosplines.c.

References Pedge_t::a, Pedge_t::b, and gv_calloc().

Referenced by makeSpline().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeObstacle()

Ppoly_t * makeObstacle ( node_t n,
expand_t pmargin,
bool  isOrtho 
)

Definition at line 326 of file neatosplines.c.

References field_t::b, circumscribed_polygon_corner_about_ellipse(), expand_t::doAdd, genPt(), gv_alloc(), gv_calloc(), INCH2PS, late_double(), boxf::LL, N_penwidth, ND_coord, ND_ht, ND_lw, ND_outline_height, ND_outline_width, ND_rw, ND_shape_info, NULL, penwidth, Ppoly_t::pn, polyBB(), Ppoly_t::ps, recPt(), SH_EPSF, SH_POINT, SH_POLY, SH_RECORD, shapeOf(), UNREACHABLE, boxf::UR, pointf_s::x, expand_t::x, Pxy_t::x, pointf_s::y, expand_t::y, and Pxy_t::y.

Referenced by addGraphObjs(), and spline_edges_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makePolyline()

static void makePolyline ( edge_t e)
static

Definition at line 520 of file neatosplines.c.

References addEdgeLabels(), aghead, agnameof(), agtail, clip_and_install(), ED_path, make_polyline(), Ppoly_t::pn, Ppoly_t::ps, sinfo, and Verbose.

Referenced by spline_edges_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeSelfArcs()

void makeSelfArcs ( edge_t e,
int  stepx 
)

Definition at line 217 of file neatosplines.c.

References agraphof(), agtail, cnt(), Concentrate, ED_count, ED_label, ED_to_virt, free(), gv_calloc(), makePortLabels(), makeSelfEdge(), sinfo, and updateBB().

Referenced by compoundEdges(), and spline_edges_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeSpline()

void makeSpline ( edge_t e,
Ppoly_t **  obs,
int  npoly,
bool  chkPts 
)

Definition at line 540 of file neatosplines.c.

References addEdgeLabels(), agerrorf(), aghead, agnameof(), agtail, clip_and_install(), ED_path, free(), in_poly(), make_barriers(), Ppoly_t::pn, POLYID_NONE, Proutespline(), Ppoly_t::ps, sinfo, Verbose, Pxy_t::x, and Pxy_t::y.

Referenced by compoundEdges(), and spline_edges_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ neato_set_aspect()

bool neato_set_aspect ( graph_t g)

Definition at line 1116 of file neatosplines.c.

References _neato_set_aspect(), agfstnode(), agnxtnode(), ND_coord, ND_pos, and POINTS_PER_INCH.

Referenced by fdp_layout(), init_nop(), and spline_edges0().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ neato_translate()

void neato_translate ( Agraph_t g)

Definition at line 993 of file neatosplines.c.

References agfstnode(), agfstout(), agnxtnode(), agnxtout(), ED_spl, GD_bb, ND_pos, ND_xlabel, offset, PS2INCH, translateE(), translateG(), pointf_s::x, and pointf_s::y.

Referenced by _neato_set_aspect(), and init_nop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newitem()

static void * newitem ( void *  p,
Dtdisc_t disc 
)
static

Definition at line 108 of file neatosplines.c.

References disc, edgeitem::e, ED_count, gv_alloc(), and edgeitem::id.

Here is the call graph for this function:

◆ recPt()

static Ppoint_t recPt ( double  x,
double  y,
pointf  c,
expand_t m 
)
static

Definition at line 87 of file neatosplines.c.

References pointf_s::x, expand_t::x, Pxy_t::x, pointf_s::y, expand_t::y, and Pxy_t::y.

Referenced by makeObstacle().

Here is the caller graph for this function:

◆ scaleBB()

static void scaleBB ( graph_t g,
double  xf,
double  yf 
)
static

Definition at line 911 of file neatosplines.c.

References GD_bb, GD_clust, GD_label, GD_n_cluster, and scaleBB().

Referenced by _neato_set_aspect(), and scaleBB().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scaleEdge()

static void scaleEdge ( edge_t e,
double  xf,
double  yf 
)
static

Definition at line 854 of file neatosplines.c.

References aghead, agtail, ED_head_label, ED_label, ED_spl, ED_tail_label, bezier::eflag, bezier::ep, bezier::list, ND_pos, POINTS_PER_INCH, bezier::sflag, bezier::size, bezier::sp, pointf_s::x, and pointf_s::y.

Referenced by _neato_set_aspect().

Here is the caller graph for this function:

◆ shiftClusters()

static void shiftClusters ( graph_t g,
pointf  offset 
)
static

Definition at line 815 of file neatosplines.c.

References GD_bb, GD_clust, GD_n_cluster, offset, and shiftClusters().

Referenced by shiftClusters(), and spline_edges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spline_edges()

void spline_edges ( graph_t g)

Definition at line 833 of file neatosplines.c.

References agfstnode(), agnxtnode(), compute_bb(), GD_bb, ND_pos, offset, PS2INCH, shiftClusters(), and spline_edges0().

Referenced by circo_layout(), neato_layout(), sfdp_layout(), and twopi_layout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spline_edges0()

void spline_edges0 ( graph_t g,
bool  set_aspect 
)

Definition at line 799 of file neatosplines.c.

References agwarningf(), EDGE_TYPE, EDGETYPE_NONE, EDGETYPE_ORTHO, EDGETYPE_PLINE, GD_flags, neato_set_aspect(), Agraph_s::root, set_aspect(), and spline_edges1().

Referenced by doEdges(), init_nop(), osage_layout(), and spline_edges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spline_edges1()

int spline_edges1 ( graph_t g,
int  edgetype 
)

Definition at line 780 of file neatosplines.c.

References spline_edges_(), and splineEdges().

Referenced by fdpSplines(), osage_layout(), and spline_edges0().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spline_edges_()

static int spline_edges_ ( graph_t g,
expand_t pmargin,
int  edgetype 
)
static

Definition at line 590 of file neatosplines.c.

References add_pointf(), addEdgeLabels(), agfstnode(), agfstout(), aghead, agnnodes(), agnxtnode(), agnxtout(), agwarningf(), BOUNDARY_PORT, cnt(), Concentrate, ED_count, ED_head_port, ED_path, ED_spl, ED_tail_port, ED_to_virt, EDGETYPE_ORTHO, EDGETYPE_PLINE, EDGETYPE_SPLINE, free(), freeRouter(), GD_nodesep, getPath(), gv_calloc(), head, makeMultiSpline(), makeObstacle(), makePolyline(), makeSelfArcs(), makeSpline(), makeStraightEdge(), mkRouter(), ND_coord, ND_lim, Nop, orthoEdges(), Plegal_arrangement(), Pobsclose(), Pobsopen(), POLYID_NONE, ps, Agraph_s::root, sinfo, Verbose, expand_t::x, and expand_t::y.

Referenced by spline_edges1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spline_merge()

static bool spline_merge ( node_t n)
static

Definition at line 30 of file neatosplines.c.

◆ splineEdges()

int splineEdges ( graph_t g,
int(*)(graph_t *, expand_t *, int)  edgefn,
int  edgetype 
)

Definition at line 732 of file neatosplines.c.

References agfstnode(), agfstout(), agnxtnode(), agnxtout(), dtclose(), dtopen(), Dtoset, ED_count, ED_spl, ED_to_virt, edgeItemDisc, equivEdge(), esepFactor(), GVSPLINES, Nop, resolvePorts(), and State.

Referenced by fdpSplines(), and spline_edges1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap_ends_p()

static bool swap_ends_p ( edge_t e)
static

Definition at line 36 of file neatosplines.c.

◆ translateE()

static void translateE ( edge_t e,
pointf  offset 
)
static

Definition at line 933 of file neatosplines.c.

References ED_head_label, ED_label, ED_spl, ED_tail_label, ED_xlabel, bezier::eflag, bezier::ep, bezier::list, offset, bezier::sflag, bezier::size, bezier::sp, pointf_s::x, and pointf_s::y.

Referenced by neato_translate().

Here is the caller graph for this function:

◆ translateG()

static void translateG ( Agraph_t g,
pointf  offset 
)
static

Definition at line 975 of file neatosplines.c.

References GD_bb, GD_clust, GD_label, GD_n_cluster, offset, and translateG().

Referenced by neato_translate(), and translateG().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ edgeItemDisc

Dtdisc_t edgeItemDisc
Initial value:
= {
offsetof(edgeitem, id),
sizeof(edgeinfo),
offsetof(edgeitem, link),
}
void free(void *)
static int cmpitems(void *k1, void *k2)
static void * newitem(void *p, Dtdisc_t *disc)

Definition at line 152 of file neatosplines.c.

Referenced by splineEdges().

◆ sinfo

splineInfo sinfo
static
Initial value:
= {.swapEnds = swap_ends_p,
.splineMerge = spline_merge}
static bool swap_ends_p(edge_t *e)
static bool spline_merge(node_t *n)

Definition at line 42 of file neatosplines.c.

Referenced by makePolyline(), makeSelfArcs(), makeSpline(), and spline_edges_().