~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to dotneato/neatogen/site.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This software may only be used by you under license from AT&T Corp.
 
3
    ("AT&T").  A copy of AT&T's Source Code Agreement is available at
 
4
    AT&T's Internet website having the URL:
 
5
    <http://www.research.att.com/sw/tools/graphviz/license/source.html>
 
6
    If you received this software without first entering into a license
 
7
    with AT&T, you have an infringing copy of this software and cannot use
 
8
    it without violating AT&T's intellectual property rights.
 
9
*/
 
10
#pragma prototyped
 
11
#include "mem.h"
 
12
#include "site.h"
 
13
#include <math.h>
 
14
 
 
15
#ifdef DMALLOC
 
16
#include "dmalloc.h"
 
17
#endif
 
18
 
 
19
int             siteidx;
 
20
Site            *bottomsite;
 
21
 
 
22
static Freelist         sfl;
 
23
static int              nvertices;
 
24
 
 
25
void
 
26
siteinit()
 
27
{
 
28
    /* float sn; */
 
29
 
 
30
    freeinit(&sfl, sizeof (Site));
 
31
    nvertices = 0;
 
32
    /* sn = nsites+4; */
 
33
    /* sqrt_nsites = sqrt(sn); */
 
34
}
 
35
 
 
36
 
 
37
Site *
 
38
getsite ()
 
39
{
 
40
    return ((Site *) getfree(&sfl));
 
41
}
 
42
 
 
43
float 
 
44
dist(Site *s, Site *t)
 
45
{
 
46
    float ans;
 
47
    float dx,dy;
 
48
 
 
49
    dx = s->coord.x - t->coord.x;
 
50
    dy = s->coord.y - t->coord.y;
 
51
    ans = sqrt(dx*dx + dy*dy);
 
52
    return ans;
 
53
}
 
54
 
 
55
 
 
56
void 
 
57
makevertex(Site *v)
 
58
{
 
59
    v -> sitenbr = nvertices;
 
60
    nvertices += 1;
 
61
#ifdef STANDALONE
 
62
    out_vertex(v);
 
63
#endif
 
64
}
 
65
 
 
66
 
 
67
void
 
68
deref(Site *v)
 
69
{
 
70
    v -> refcnt -= 1;
 
71
    if (v -> refcnt == 0 ) makefree(v, &sfl);
 
72
}
 
73
 
 
74
void
 
75
ref(Site *v)
 
76
{
 
77
    v -> refcnt += 1;
 
78
}