Back to index

wims  3.65+svn20090927
Functions | Variables
main.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include "vdefs.h"

Go to the source code of this file.

Functions

Sitenextone (void)
void readsites (void)
int main (int argc, char *argv[])
int scomp (const void *vs1, const void *vs2)

Variables

int sorted
int triangulate
int plot
int debug
int nsites
int siteidx
float xmin
float xmax
float ymin
float ymax
Sitesites
Freelist sfl

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 19 of file main.c.

    {
    int c ;
    Site *(*next)() ;

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

    freeinit(&sfl, sizeof(Site)) ;
    readsites() ;
    next = nextone ;
    siteidx = 0 ;
    geominit() ;
    if (plot)
        {
        plotinit() ;
        }
    voronoi(next) ;
    return (0) ;
    }

Here is the call graph for this function:

Site * nextone ( void  )

Definition at line 70 of file main.c.

    {
    Site * s ;

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

Here is the caller graph for this function:

void readsites ( void  )

Definition at line 88 of file main.c.

    {
    int i ;
    char *s = getenv("wims_exec_parm");

    if (!s || !*s) exit(0); /* nothing to do */

    while (isspace(*s)) s++;
    if (*s == '-' && s[1] == 't')
    {
      s += 2; triangulate = 1;
      while (isspace(*s)) s++;
    }

    nsites = 0 ;
    sites = (Site *) myalloc(4000 * sizeof(Site));
    while (sscanf(s, "%f %f", &sites[nsites].coord.x,
&sites[nsites].coord.y) !=EOF)
        {
        sites[nsites].sitenbr = nsites ;
        sites[nsites++].refcnt = 0 ;
        if (nsites % 4000 == 0)
            sites = (Site *)
realloc(sites,(nsites+4000)*sizeof(Site));
        s = strchr(s, '\n');
        if (!s++) break;
        }

    qsort((void *)sites, nsites, sizeof(Site), scomp) ;
    xmin = sites[0].coord.x ;
    xmax = sites[0].coord.x ;
    for (i = 1 ; i < nsites ; ++i)
        {
        if(sites[i].coord.x < xmin)
            {
            xmin = sites[i].coord.x ;
            }
        if (sites[i].coord.x > xmax)
            {
            xmax = sites[i].coord.x ;
            }
        }
    ymin = sites[0].coord.y ;
    ymax = sites[nsites-1].coord.y ;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

int scomp ( const void *  vs1,
const void *  vs2 
)

Definition at line 43 of file main.c.

    {
    Point * s1 = (Point *)vs1 ;
    Point * s2 = (Point *)vs2 ;

    if (s1->y < s2->y)
        {
        return (-1) ;
        }
    if (s1->y > s2->y)
        {
        return (1) ;
        }
    if (s1->x < s2->x)
        {
        return (-1) ;
        }
    if (s1->x > s2->x)
        {
        return (1) ;
        }
    return (0) ;
    }

Here is the caller graph for this function:


Variable Documentation

int debug

Definition at line 13 of file main.c.

int nsites

Definition at line 13 of file main.c.

int plot

Definition at line 13 of file main.c.

Definition at line 16 of file main.c.

int siteidx

Definition at line 13 of file main.c.

Definition at line 15 of file main.c.

int sorted

Definition at line 13 of file main.c.

Definition at line 13 of file main.c.

float xmax

Definition at line 14 of file main.c.

float xmin

Definition at line 14 of file main.c.

float ymax

Definition at line 14 of file main.c.

float ymin

Definition at line 14 of file main.c.