-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ennetws
committed
Feb 24, 2012
0 parents
commit df71f2e
Showing
26 changed files
with
13,985 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
POSIX getopt for Windows | ||
AT&T Public License | ||
Code given out at the 1985 UNIFORUM conference in Dallas. | ||
*/ | ||
|
||
#ifndef __GNUC__ | ||
|
||
#include <string> | ||
#include "getopt.h" | ||
#include <stdio.h> | ||
|
||
#define NULL 0 | ||
#define EOF (-1) | ||
#define ERR(s, c) if(opterr){\ | ||
char errbuf[2];\ | ||
errbuf[0] = c; errbuf[1] = '\n';\ | ||
fputs(argv[0], stderr);\ | ||
fputs(s, stderr);\ | ||
fputc(c, stderr);} | ||
//(void) write(2, argv[0], (unsigned)strlen(argv[0]));\ | ||
//(void) write(2, s, (unsigned)strlen(s));\ | ||
//(void) write(2, errbuf, 2);} | ||
|
||
int opterr = 1; | ||
int optind = 1; | ||
int optopt; | ||
char *optarg; | ||
|
||
int getopt( int argc, char **argv, char *opts) | ||
{ | ||
static int sp = 1; | ||
register int c; | ||
register char *cp; | ||
|
||
if(sp == 1) | ||
if(optind >= argc || | ||
argv[optind][0] != '-' || argv[optind][1] == '\0') | ||
return(EOF); | ||
else if(strcmp(argv[optind], "--") == NULL) { | ||
optind++; | ||
return(EOF); | ||
} | ||
optopt = c = argv[optind][sp]; | ||
if(c == ':' || (cp=strchr(opts, c)) == NULL) { | ||
ERR(": illegal option -- ", c); | ||
if(argv[optind][++sp] == '\0') { | ||
optind++; | ||
sp = 1; | ||
} | ||
return('?'); | ||
} | ||
if(*++cp == ':') { | ||
if(argv[optind][sp+1] != '\0') | ||
optarg = &argv[optind++][sp+1]; | ||
else if(++optind >= argc) { | ||
ERR(": option requires an argument -- ", c); | ||
sp = 1; | ||
return('?'); | ||
} else | ||
optarg = argv[optind++]; | ||
sp = 1; | ||
} else { | ||
if(argv[optind][++sp] == '\0') { | ||
sp = 1; | ||
optind++; | ||
} | ||
optarg = NULL; | ||
} | ||
return(c); | ||
} | ||
|
||
#endif /* __GNUC__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
POSIX getopt for Windows | ||
AT&T Public License | ||
Code given out at the 1985 UNIFORUM conference in Dallas. | ||
*/ | ||
|
||
#ifdef __GNUC__ | ||
#include <getopt.h> | ||
#endif | ||
#ifndef __GNUC__ | ||
|
||
#ifndef _WINGETOPT_H_ | ||
#define _WINGETOPT_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern int opterr; | ||
extern int optind; | ||
extern int optopt; | ||
extern char *optarg; | ||
extern int getopt(int argc, char **argv, char *opts); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _GETOPT_H_ */ | ||
#endif /* __GNUC__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Power Crust software, by Nina Amenta, Sunghee Choi and Ravi Krishna Kolluri. | ||
* Copyright (c) 2000 by the University of Texas | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose without fee under the GNU Public License is hereby granted, | ||
* provided that this entire notice is included in all copies of any software | ||
* which is or includes a copy or modification of this software and in all copies | ||
* of the supporting documentation for such software. | ||
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED | ||
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY | ||
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY | ||
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. | ||
*/ | ||
|
||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <stdarg.h> | ||
#include <assert.h> | ||
#include <float.h> | ||
#include <math.h> | ||
#include "hull.h" | ||
|
||
extern struct polelabel *adjlist; | ||
struct heap_array *heap_A; | ||
int heap_length; | ||
int heap_size = 0; | ||
|
||
void init_heap(int num) | ||
{ | ||
heap_A = (struct heap_array *)calloc(num, sizeof(struct heap_array)); | ||
heap_size = 0; | ||
heap_length = num; | ||
fprintf(DFILE,"heap %d initialized\n", num); | ||
} | ||
|
||
void heapify(int hi) | ||
{ | ||
int largest; | ||
int temp; | ||
double td; | ||
|
||
if ((LEFT(hi) <= heap_size) && (heap_A[LEFT(hi)].pri > heap_A[hi].pri)) | ||
largest = LEFT(hi); | ||
else largest = hi; | ||
|
||
if ((RIGHT(hi) <= heap_size) && (heap_A[RIGHT(hi)].pri > heap_A[largest].pri)) | ||
largest = RIGHT(hi); | ||
|
||
if (largest != hi) { | ||
temp = heap_A[hi].pid; | ||
heap_A[hi].pid = heap_A[largest].pid; | ||
adjlist[heap_A[hi].pid].hid = hi; | ||
heap_A[largest].pid = temp; | ||
adjlist[heap_A[largest].pid].hid = largest; | ||
td = heap_A[hi].pri; | ||
heap_A[hi].pri = heap_A[largest].pri; | ||
heap_A[largest].pri = td; | ||
heapify(largest); | ||
} | ||
|
||
} | ||
|
||
int extract_max() | ||
{ | ||
int max; | ||
|
||
if (heap_size < 1) return -1; | ||
max = heap_A[1].pid; | ||
heap_A[1].pid = heap_A[heap_size].pid; | ||
heap_A[1].pri = heap_A[heap_size].pri; | ||
adjlist[heap_A[1].pid].hid = 1; | ||
heap_size--; | ||
heapify(1); | ||
return max; | ||
} | ||
|
||
int insert_heap(int pi, double pr) | ||
{ | ||
int i; | ||
|
||
heap_size++; | ||
/*printf("heap_size %d\n",heap_size); */ | ||
i = heap_size; | ||
while ((i>1)&&(heap_A[PARENT(i)].pri < pr)) { | ||
heap_A[i].pid = heap_A[PARENT(i)].pid; | ||
heap_A[i].pri = heap_A[PARENT(i)].pri; | ||
adjlist[heap_A[i].pid].hid = i; | ||
i = PARENT(i); | ||
}; | ||
heap_A[i].pri = pr; | ||
heap_A[i].pid = pi; | ||
adjlist[pi].hid = i; | ||
return i; | ||
} | ||
|
||
void update(int hi, double pr) | ||
/* make the element heap_A[hi].pr = pr ... */ | ||
{ | ||
int pi,i; | ||
|
||
heap_A[hi].pri = pr; | ||
pi = heap_A[hi].pid; | ||
|
||
if (pr > heap_A[PARENT(hi)].pri) { | ||
i = hi; | ||
while ((i>1)&&(heap_A[PARENT(i)].pri < pr)) { | ||
heap_A[i].pid = heap_A[PARENT(i)].pid; | ||
heap_A[i].pri = heap_A[PARENT(i)].pri; | ||
adjlist[heap_A[i].pid].hid = i; | ||
i = PARENT(i); | ||
}; | ||
heap_A[i].pri = pr; | ||
heap_A[i].pid = pi; | ||
adjlist[pi].hid = i; | ||
} | ||
else heapify(hi); | ||
} | ||
|
||
|
||
|
Oops, something went wrong.