Graphviz
2.41.20171026.1811
Main Page
Data Structures
Files
File List
Globals
lib
neatogen
site.c
Go to the documentation of this file.
1
/* $Id$ $Revision$ */
2
/* vim:set shiftwidth=4 ts=8: */
3
4
/*************************************************************************
5
* Copyright (c) 2011 AT&T Intellectual Property
6
* All rights reserved. This program and the accompanying materials
7
* are made available under the terms of the Eclipse Public License v1.0
8
* which accompanies this distribution, and is available at
9
* http://www.eclipse.org/legal/epl-v10.html
10
*
11
* Contributors: See CVS logs. Details at http://www.graphviz.org/
12
*************************************************************************/
13
14
#include "
mem.h
"
15
#include "
site.h
"
16
#include <math.h>
17
18
19
int
siteidx
;
20
Site
*
bottomsite
;
21
22
static
Freelist
sfl;
23
static
int
nvertices;
24
25
void
siteinit
()
26
{
27
/* double sn; */
28
29
freeinit
(&sfl,
sizeof
(
Site
));
30
nvertices = 0;
31
/* sn = nsites+4; */
32
/* sqrt_nsites = sqrt(sn); */
33
}
34
35
36
Site
*
getsite
()
37
{
38
return
((
Site
*)
getfree
(&sfl));
39
}
40
41
double
dist
(
Site
*
s
,
Site
* t)
42
{
43
double
ans;
44
double
dx, dy;
45
46
dx = s->
coord
.
x
- t->
coord
.
x
;
47
dy = s->
coord
.
y
- t->
coord
.
y
;
48
ans = sqrt(dx * dx + dy * dy);
49
return
ans;
50
}
51
52
53
void
makevertex
(
Site
* v)
54
{
55
v->
sitenbr
= nvertices;
56
nvertices += 1;
57
#ifdef STANDALONE
58
out_vertex(v);
59
#endif
60
}
61
62
63
void
deref
(
Site
* v)
64
{
65
v->
refcnt
-= 1;
66
if
(v->
refcnt
== 0)
67
makefree
(v, &sfl);
68
}
69
70
void
ref
(
Site
* v)
71
{
72
v->
refcnt
+= 1;
73
}
Site::refcnt
int refcnt
Definition:
site.h:29
bottomsite
Site * bottomsite
Definition:
site.c:20
site.h
mem.h
getsite
Site * getsite()
Definition:
site.c:36
Point::y
double y
Definition:
geometry.h:27
getfree
void * getfree(Freelist *)
Definition:
memory.c:62
siteinit
void siteinit()
Definition:
site.c:25
Site
Definition:
site.h:26
siteidx
int siteidx
Definition:
site.c:19
Point::x
double x
Definition:
geometry.h:27
makefree
void makefree(void *, Freelist *)
Definition:
memory.c:86
freelist
Definition:
mem.h:29
s
Definition:
grammar.c:79
deref
void deref(Site *v)
Definition:
site.c:63
ref
void ref(Site *v)
Definition:
site.c:70
dist
double dist(Site *s, Site *t)
Definition:
site.c:41
Site::coord
Point coord
Definition:
site.h:27
Site::sitenbr
int sitenbr
Definition:
site.h:28
makevertex
void makevertex(Site *v)
Definition:
site.c:53
freeinit
void freeinit(Freelist *, int)
Definition:
memory.c:43
Generated by
1.8.5