Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
site.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#include <neatogen/mem.h>
12#include <neatogen/site.h>
13#include <math.h>
14
15
18
20static size_t nvertices;
21
22void siteinit(void)
23{
24 freeinit(&sfl, sizeof(Site));
25 nvertices = 0;
26}
27
28
30{
31 return getfree(&sfl);
32}
33
34double dist(Site * s, Site * t)
35{
36 double ans;
37 double dx, dy;
38
39 dx = s->coord.x - t->coord.x;
40 dy = s->coord.y - t->coord.y;
41 ans = hypot(dx, dy);
42 return ans;
43}
44
45
47{
48 v->sitenbr = nvertices;
49 ++nvertices;
50}
51
52void deref(Site * v)
53{
54 --v->refcnt;
55 if (v->refcnt == 0)
56 makefree(v, &sfl);
57}
58
59void ref(Site * v)
60{
61 ++v->refcnt;
62}
static float dy
Definition draw.c:38
static float dx
Definition draw.c:37
void * getfree(Freelist *)
Definition memory.c:60
void makefree(void *, Freelist *)
Definition memory.c:83
void freeinit(Freelist *, int)
Definition memory.c:41
static Freelist sfl
Definition site.c:19
int siteidx
Definition site.c:16
static size_t nvertices
Definition site.c:20
void ref(Site *v)
Definition site.c:59
void siteinit(void)
Definition site.c:22
void deref(Site *v)
Definition site.c:52
double dist(Site *s, Site *t)
Definition site.c:34
Site * getsite(void)
Definition site.c:29
Site * bottomsite
Definition site.c:17
void makevertex(Site *v)
Definition site.c:46
double x
Definition geometry.h:23
double y
Definition geometry.h:23
Definition site.h:22
Point coord
Definition site.h:23
size_t sitenbr
Definition site.h:24
unsigned refcnt
Definition site.h:25
Definition mem.h:21
Definition grammar.c:93