Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
constraint.c File Reference
#include "config.h"
#include <cgraph/list.h>
#include <common/geom.h>
#include <math.h>
#include <neatogen/neato.h>
#include <neatogen/adjust.h>
#include <stddef.h>
#include <stdbool.h>
#include <util/alloc.h>
Include dependency graph for constraint.c:

Go to the source code of this file.

Data Structures

struct  nitem
 
struct  info
 

Macros

#define SCALE   10
 
#define SCALE2   (SCALE/2)
 

Typedefs

typedef struct nitem nitem
 
typedef int(* distfn) (box *, box *)
 
typedef int(* intersectfn) (nitem *, nitem *)
 

Functions

static int cmpitem (void *item1, void *item2)
 
static int distY (box *b1, box *b2)
 
static int distX (box *b1, box *b2)
 
static int intersectX0 (nitem *p, nitem *q)
 
static int intersectY0 (nitem *p, nitem *q)
 
static int intersectY (nitem *p, nitem *q)
 
static int intersectX (nitem *p, nitem *q)
 
static void mapGraphs (graph_t *g, graph_t *cg, distfn dist)
 
static graph_tmkNConstraintG (graph_t *g, Dt_t *list, intersectfn intersect, distfn dist)
 
static graph_tmkConstraintG (Dt_t *list, intersectfn intersect, distfn dist)
 
static void closeGraph (graph_t *cg)
 
static void constrainX (graph_t *g, nitem *nlist, int nnodes, intersectfn ifn, int ortho)
 
static void constrainY (graph_t *g, nitem *nlist, int nnodes, intersectfn ifn, int ortho)
 
static int overlaps (nitem *p, int cnt)
 
static void initItem (node_t *n, nitem *p, expand_t margin)
 
int cAdjust (graph_t *g, int mode)
 
static int sortf (const void *x, const void *y)
 
static double compress (info *nl, int nn)
 
static pointfmkOverlapSet (info *nl, size_t nn, size_t *cntp)
 
static pointf computeScaleXY (pointf *aarr, size_t m)
 
static double computeScale (pointf *aarr, size_t m)
 
int scAdjust (graph_t *g, int equal)
 

Variables

static Dtdisc_t constr
 

Macro Definition Documentation

◆ SCALE

#define SCALE   10

Definition at line 23 of file constraint.c.

◆ SCALE2

#define SCALE2   (SCALE/2)

Definition at line 24 of file constraint.c.

Typedef Documentation

◆ distfn

typedef int(* distfn) (box *, box *)

Definition at line 36 of file constraint.c.

◆ intersectfn

typedef int(* intersectfn) (nitem *, nitem *)

Definition at line 37 of file constraint.c.

◆ nitem

typedef struct nitem nitem

Function Documentation

◆ cAdjust()

int cAdjust ( graph_t g,
int  mode 
)

Definition at line 555 of file constraint.c.

References agfstnode(), agnnodes(), agnxtnode(), AM_ORTHO, AM_ORTHO_YX, AM_ORTHOXY, AM_ORTHOYX, AM_PORTHO, AM_PORTHO_YX, AM_PORTHOXY, AM_PORTHOYX, constrainX(), constrainY(), free(), gv_calloc(), initItem(), intersectX(), intersectX0(), intersectY(), intersectY0(), ND_pos, nitem::np, overlaps(), nitem::pos, PS2INCH, SCALE, sepFactor(), point::x, and point::y.

Referenced by removeOverlapWith().

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

◆ closeGraph()

static void closeGraph ( graph_t cg)
static

Definition at line 372 of file constraint.c.

References agclose(), agfstnode(), agnxtnode(), cg(), free_list, ND_in, and ND_out.

Referenced by constrainX(), and constrainY().

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

◆ cmpitem()

static int cmpitem ( void *  item1,
void *  item2 
)
static

Definition at line 39 of file constraint.c.

◆ compress()

static double compress ( info nl,
int  nn 
)
static

Definition at line 646 of file constraint.c.

References info::bb, info::ht2, OVERLAP, info::pos, info::wd2, pointf_s::x, and pointf_s::y.

Referenced by scAdjust().

Here is the caller graph for this function:

◆ computeScale()

static double computeScale ( pointf aarr,
size_t  m 
)
static

Definition at line 762 of file constraint.c.

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

Referenced by scAdjust().

Here is the caller graph for this function:

◆ computeScaleXY()

static pointf computeScaleXY ( pointf aarr,
size_t  m 
)
static

Definition at line 722 of file constraint.c.

References free(), gv_calloc(), scale(), sortf(), pointf_s::x, and pointf_s::y.

Referenced by scAdjust().

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

◆ constrainX()

static void constrainX ( graph_t g,
nitem nlist,
int  nnodes,
intersectfn  ifn,
int  ortho 
)
static

Definition at line 387 of file constraint.c.

References nitem::bb, cg(), closeGraph(), nitem::cnode, constr, delta, distX(), dtclose(), dtinsert, Dtobag, dtopen(), box::LL, mkConstraintG(), mkNConstraintG(), ND_rank, newpos(), nitem::pos, rank(), box::UR, nitem::val, and point::x.

Referenced by cAdjust().

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

◆ constrainY()

static void constrainY ( graph_t g,
nitem nlist,
int  nnodes,
intersectfn  ifn,
int  ortho 
)
static

Definition at line 425 of file constraint.c.

References agattr(), AGEDGE, agfstedge(), agfstnode(), AGNODE, agnxtedge(), agnxtnode(), agxset(), nitem::bb, cg(), closeGraph(), nitem::cnode, constr, delta, distY(), dtclose(), dtinsert, Dtobag, dtopen(), ED_minlen, box::LL, mkConstraintG(), mkNConstraintG(), ND_rank, newpos(), nitem::pos, rank(), box::UR, nitem::val, and point::y.

Referenced by cAdjust().

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

◆ distX()

static int distX ( box b1,
box b2 
)
static

Definition at line 65 of file constraint.c.

References box::LL, box::UR, and point::x.

Referenced by constrainX(), intersectX0(), and intersectY0().

Here is the caller graph for this function:

◆ distY()

static int distY ( box b1,
box b2 
)
static

Definition at line 60 of file constraint.c.

References box::LL, box::UR, and point::y.

Referenced by constrainY(), intersectX0(), and intersectY0().

Here is the caller graph for this function:

◆ initItem()

static void initItem ( node_t n,
nitem p,
expand_t  margin 
)
static

Definition at line 499 of file constraint.c.

References nitem::bb, expand_t::doAdd, box::LL, ND_height, ND_pos, ND_width, nitem::np, POINTS, nitem::pos, SCALE, SCALE2, box::UR, point::x, expand_t::x, point::y, and expand_t::y.

Referenced by cAdjust().

Here is the caller graph for this function:

◆ intersectX()

static int intersectX ( nitem p,
nitem q 
)
static

Definition at line 119 of file constraint.c.

References nitem::bb, box::LL, box::UR, and point::x.

Referenced by cAdjust().

Here is the caller graph for this function:

◆ intersectX0()

static int intersectX0 ( nitem p,
nitem q 
)
static

Definition at line 76 of file constraint.c.

References nitem::bb, distX(), distY(), box::LL, nitem::pos, box::UR, point::x, and point::y.

Referenced by cAdjust().

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

◆ intersectY()

static int intersectY ( nitem p,
nitem q 
)
static

Definition at line 114 of file constraint.c.

References nitem::bb, box::LL, box::UR, and point::y.

Referenced by cAdjust().

Here is the caller graph for this function:

◆ intersectY0()

static int intersectY0 ( nitem p,
nitem q 
)
static

Definition at line 98 of file constraint.c.

References nitem::bb, distX(), distY(), box::LL, nitem::pos, box::UR, point::x, and point::y.

Referenced by cAdjust().

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

◆ mapGraphs()

static void mapGraphs ( graph_t g,
graph_t cg,
distfn  dist 
)
static

Definition at line 126 of file constraint.c.

References agbindrec(), agedge(), agfstnode(), agfstout(), aghead, agnxtnode(), agnxtout(), nitem::bb, cg(), nitem::cnode, delta, dist(), ED_minlen, ED_weight, elist_append, ND_alg, ND_in, ND_out, and NULL.

Referenced by mkConstraintG().

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

◆ mkConstraintG()

static graph_t * mkConstraintG ( Dt_t list,
intersectfn  intersect,
distfn  dist 
)
static

Definition at line 271 of file constraint.c.

References agbindrec(), agclose(), agedge(), agnameof(), agnode(), agopen(), Agstrictdirected, alloc_elist, cg(), nitem::cnode, cnt(), dist(), dtflatten(), dtlink, ED_minlen, ED_weight, elist_append, GD_nlist, intersect(), mapGraphs(), ND_alg, ND_in, ND_next, ND_out, nitem::np, NULL, prev, SCALE, nitem::val, and nitem::vnode.

Referenced by constrainX(), and constrainY().

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

◆ mkNConstraintG()

static graph_t * mkNConstraintG ( graph_t g,
Dt_t list,
intersectfn  intersect,
distfn  dist 
)
static

Definition at line 212 of file constraint.c.

References agbindrec(), agedge(), agfindedge, agfstout(), aghead, agnameof(), agnode(), agnxtout(), agopen(), Agstrictdirected, alloc_elist, nitem::bb, cg(), nitem::cnode, delta, dist(), dtflatten(), dtlink, ED_minlen, ED_weight, elist_append, GD_nlist, intersect(), ND_alg, ND_in, ND_next, ND_out, nitem::np, and NULL.

Referenced by constrainX(), and constrainY().

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

◆ mkOverlapSet()

static pointf * mkOverlapSet ( info nl,
size_t  nn,
size_t *  cntp 
)
static

Definition at line 684 of file constraint.c.

References info::bb, info::ht2, OVERLAP, info::pos, S, info::wd2, pointf_s::x, and pointf_s::y.

Referenced by scAdjust().

Here is the caller graph for this function:

◆ overlaps()

static int overlaps ( nitem p,
int  cnt 
)
static

Definition at line 479 of file constraint.c.

References nitem::bb, cnt(), and OVERLAP.

Referenced by adjust(), cAdjust(), and countOverlap().

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

◆ scAdjust()

int scAdjust ( graph_t g,
int  equal 
)

Definition at line 787 of file constraint.c.

References agfstnode(), agnnodes(), agnxtnode(), info::bb, compress(), computeScale(), computeScaleXY(), expand_t::doAdd, free(), gv_calloc(), info::ht2, boxf::LL, mkOverlapSet(), ND_height, ND_pos, ND_width, info::np, info::pos, PS2INCH, sepFactor(), boxf::UR, Verbose, info::wd2, pointf_s::x, expand_t::x, pointf_s::y, and expand_t::y.

Referenced by removeOverlapWith().

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

◆ sortf()

static int sortf ( const void *  x,
const void *  y 
)
static

Definition at line 631 of file constraint.c.

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

Referenced by computeScaleXY().

Here is the caller graph for this function:

Variable Documentation

◆ constr

Dtdisc_t constr
static
Initial value:
= {
offsetof(nitem, val),
sizeof(int),
offsetof(nitem, link),
}
static int cmpitem(void *item1, void *item2)
Definition constraint.c:39
node NULL
Definition grammar.y:163

Definition at line 51 of file constraint.c.

Referenced by constrainX(), constrainY(), is_nonconstraint(), and nonconstraint_edge().