File: voronoi_main.c

package info (click to toggle)
libmath-geometry-voronoi-perl 1.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 308 kB
  • sloc: ansic: 1,052; perl: 259; makefile: 2
file content (77 lines) | stat: -rwxr-xr-x 1,411 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*** MAIN.C ***/

#include <stdio.h>
#include <stdlib.h>  /* realloc(), qsort() */


#include "vdefs.h"

Site * readone(void), * nextone(void) ;
void readsites(void) ;

int sorted, triangulate, plot, debug, nsites, siteidx ;
double xmin, xmax, ymin, ymax ;
Site * sites ;
Freelist sfl ;
AV *lines_out, *edges_out, *vertices_out;

int
compute_voronoi(Site *sites_in, int nsites_in, 
                double xmin_in, double xmax_in, 
                double ymin_in, double ymax_in, 
                int debug_in,
                AV *lines_out_in, 
                AV *edges_out_in, 
                AV *vertices_out_in)
    {
    int c ;
    Site *(*next)() ;

    freeinit(&sfl, sizeof(Site)) ;

    sorted = triangulate = plot = debug = 0 ;
    debug = debug_in;

    lines_out = lines_out_in;
    edges_out = edges_out_in;
    vertices_out = vertices_out_in;
    
    nsites = nsites_in;
    sites = sites_in;
    xmin = xmin_in;
    xmax = xmax_in;
    ymin = ymin_in;
    ymax = ymax_in;

    next = nextone;

    siteidx = 0 ;
    geominit() ;
    if (plot)
        {
        plotinit() ;
        }
    voronoi(next) ;

    free_all();
    return (0) ;
}

/*** return a single in-storage site ***/

Site *
nextone(void)
    {
    Site * s ;

    if (siteidx < nsites)
        {
        s = &sites[siteidx++];
        return (s) ;
        }
    else
        {
        return ((Site *)NULL) ;
        }
    }