📄 pelqhull.h
字号:
/***** -geom.c prototypes (duplicated from geom.h) ****************/facetT *qh_findbest (pointT *point, facetT *facet, boolT bestoutside, unsigned firstid, realT *dist, boolT *isoutside, int *numpart);boolT qh_gram_schmidt(int dim, realT **rows);void qh_projectinput (void);void qh_randommatrix (realT *buffer, int dim, realT **row);void qh_rotateinput (realT **rows);void qh_scaleinput (void);/***** -global.c prototypes (alphabetical) ***********************/#define GAMBIT_EXCEPTIONS#ifdef GAMBIT_EXCEPTIONS#include "base/gmisc.h"#include "base/gtext.h"class ErrorInQhull : public gException {public: virtual ~ErrorInQhull(); gText Description(void) const;};#endifvoid qhull_fatal(int); void qh_freebuffers (void);void qh_freeqhull (boolT allmem);void qh_init_qhull_command (int argc, char *argv[]);void qh_initbuffers (coordT *points, int numpoints, int dim, boolT ismalloc);void qh_initflags (char *command);void qh_initqhull_buffers (void);void qh_initqhull_globals (coordT *points, int numpoints, int dim, boolT ismalloc);void qh_initqhull_mem (void);void qh_initqhull_start (FILE *infile, FILE *outfile, FILE *errfile);void qh_initthresholds (char *command);#if qh_QHpointervoid qh_restore_qhull (qhT **oldqh);qhT *qh_save_qhull (void);#endif/**************************************************************************//****************** some definitions from qhull_a.h ***********************//**************************************************************************//********* -poly.c prototypes (duplicated from poly.h) **********************/void qh_check_output (void);void qh_check_points (void);setT *qh_facetvertices (facetT *facetlist, setT *facets, boolT allfacets);pointT *qh_point (int id);setT *qh_pointfacet (void /*qh.facet_list*/);int qh_pointid (pointT *point);setT *qh_pointvertex (void /*qh.facet_list*/);/********* -stat.c prototypes (duplicated from stat.h) **********************/void qh_collectstatistics (void);void qh_freestatistics (void);void qh_initstatistics (void);void qh_printallstatistics (FILE *fp, char *string);void qh_printstatistics (FILE *fp, char *string);/* ======= -constants- ====================== System dependent constants-SECticks ticks per second from clock()-RANDOMmax maximum random number and random generator, default is random() Memory constants for calling qh_meminitbuffers in global.c-MEMalign memory alignment (see mem.h). If using gcc, best alignment is #define qh_MEMalign fmax_(__alignof__(realT),__alignof__(void *))-MEMbufsize memory buffer size-MEMinitbuf initial memory buffer size. It should hold enough facets to keep outsidesets in short memory.-HASHfactor total hash slots / used hash slots-VERIFYdirect verify all points against all facets if op count smaller-MAXrandom maximum random number-ORIENTclock true if clockwise orientation on output Conditional compilation-KEEPstatistics 1 removes most of statistic gathering and reporting it reduces code by about 8%, time is the same.-QUICKhelp use abbreviated help messages for degenerate inputs-UNIX true if compiling for UNIX*/#define qh_SECticks 1E6 /* CLOCKS_PER_SECOND for clock() */#if 0 /* use 1 if your compiler supports random(), otherwise use 0 *//* #define qh_RANDOMmax ((realT)0x7fffffffUL) */ /* 31 bits, random()/MAX */#define qh_RANDOMint random()#define qh_RANDOMseed_(seed) srandom(seed);#else/* #define qh_RANDOMmax ((realT)32767) */ /* 15 bits (System 5) */#ifdef __BORLANDC__ #define qh_RANDOMmax 1073741823 #else#define qh_RANDOMmax 2147483647 /* Kludge added, ignorantly, by AMM */#endif // __BORLANDC__ /* WARNING: Sun produces 31 bits from rand() */#define qh_RANDOMint rand()#define qh_RANDOMseed_(seed) srand((unsigned)seed);#endif#define qh_MEMalign fmax_(sizeof(realT), sizeof(void *))#define qh_MEMbufsize 0x8000 /* allocate 32K memory buffers */#define qh_MEMinitbuf 0x10000 /* initially allocate 64K buffer */#define qh_HASHfactor 2 /* (int) at worst 50% occupancy for qh hash_table and normally 25% occupancy */#define qh_VERIFYdirect 100000 /* if more tests, use qh_findbest instead */#define qh_ORIENTclock 0 /* counter clockwise for Geomview inward */#define qh_KEEPstatistics 1 /* 0 to take out statistics */#define qh_QUICKhelp 0 /* 1 for short help messages */#define qh_UNIX 1 /* 1 if compiling for UNIX *//**************************************************************************//************** definitions and signatures from mem.h *********************//**************************************************************************//* to avoid bus errors, memory allocation must consider alignment requirements. malloc() automatically takes care of alignment. Since mem.c manages its own memory, we need to explicitly specify alignment in qh_meminitbuffers(). A safe choice is sizeof(double). sizeof(float) may be used if doubles do not occur in data structures and pointers are the same size. Be careful of machines (e.g., DEC Alpha) with large pointers. If gcc is available, use __alignof__(double) or fmax_(__alignof__(float), __alignof__(void *)). see qhull_a.h for qhull's alignment*/#define qhmem_ERRmem 4 /* matches qh_ERRmem in qhull.h */#define qhmem_ERRqhull 5 /* matches qh_ERRqhull in qhull.h *//*----------------------------------------qhmemT - global memory structure for mem.c users should ignore qhmem except for writing extensions qhmem could be swapable like qh and qhstat, but then multiple qh's and qhmem's would need to keep in synch. A swapable qhmem would also waste memory buffers. As long as memory operations are atomic, there is no problem with multiple qh structures being active at the same time. If you need separate address spaces, you can swap the contents of qhmem.*/typedef struct qhmemT qhmemT;extern qhmemT qhmem; /* allocated in mem.c */struct qhmemT { /* global memory management variables */ int BUFsize; /* size of memory allocation buffer */ int BUFinit; /* initial size of memory allocation buffer */ int TABLEsize; /* actual number of sizes in free list table */ int NUMsizes; /* maximum number of sizes in free list table */ int LASTsize; /* last size in free list table */ int ALIGNmask; /* worst-case alignment, must be 2^n-1 */ void **freelists; /* free list table, linked by offset 0 */ int *sizetable; /* size of each freelist */ int *indextable; /* size->index table */ void *curbuffer; /* current buffer, linked by offset 0 */ void *freemem; /* free memory in curbuffer */ int freesize; /* size of free memory in bytes */ void *tempstack; /* stack of temporary memory, managed by users */ FILE *ferr; /* file for reporting errors */ int IStracing; /* =5 if tracing memory allocations */ int cntquick; /* count of quick allocations */ /* remove statistics doesn't effect speed */ int cntshort; /* count of short allocations */ int cntlong; /* count of long allocations */ int curlong; /* current count of inuse, long allocations */ int freeshort; /* count of short memfrees */ int freelong; /* count of long memfrees */ int totshort; /* total size of short allocations */ int totlong; /* total size of long allocations */ int maxlong; /* maximum totlong */ int cntlarger; /* count of setlarger's */ int totlarger; /* total copied by setlarger */};/* ======= -macros =========== qh_memalloc_(size, freelistp, object) returns object of size bytes assumes size<=qhmem.LASTsize and void **freelistp is a tempqh_memfree_(object, size, freelistp) free up quick object object may be NULL assumes size<=qhmem.LASTsize and void **freelistp is a temp*/#define qh_memalloc_(size, freelistp, object) {\ freelistp= (void **)(qhmem.freelists + qhmem.indextable[size]);\ if ((object= (setT *)*freelistp)) {\ qhmem.cntquick++; \ *freelistp= *((void **)*freelistp);\ }else object= (setT *)qh_memalloc (size);}#define float_qh_memalloc_(size, freelistp, object) {\ freelistp= (void **)(qhmem.freelists + qhmem.indextable[size]);\ if ((object= (float *)*freelistp)) {\ qhmem.cntquick++; \ *freelistp= *((void **)*freelistp);\ }else object= (float *)qh_memalloc (size);}#define facetT_qh_memalloc_(size, freelistp, object) {\ freelistp= (void **)(qhmem.freelists + qhmem.indextable[size]);\ if ((object= (facetT *)*freelistp)) {\ qhmem.cntquick++; \ *freelistp= *((void **)*freelistp);\ }else object= (facetT *)qh_memalloc (size);}#define ridgeT_qh_memalloc_(size, freelistp, object) {\ freelistp= (void **)(qhmem.freelists + qhmem.indextable[size]);\ if ((object= (ridgeT *)*freelistp)) {\ qhmem.cntquick++; \ *freelistp= *((void **)*freelistp);\ }else object= (ridgeT *)qh_memalloc (size);}#define mergeT_qh_memalloc_(size, freelistp, object) {\ freelistp= (void **)(qhmem.freelists + qhmem.indextable[size]);\ if ((object= (mergeT *)*freelistp)) {\ qhmem.cntquick++; \ *freelistp= *((void **)*freelistp);\ }else object= (mergeT *)qh_memalloc (size);}#define qh_memfree_(object, size, freelistp) {\ if (object) { \ qhmem .freeshort++;\ freelistp= qhmem.freelists + qhmem.indextable[size];\ *((void **)object)= *freelistp;\ *freelistp= object;}}/* ======= -functions =========== see mem.c for definitions User level functions-memalloc allocate memory-memfree free memory-memstatistics print memory statistics Initialization and termination functions-meminit initialize memory-meminitbuffers initialize memory buffers-memsize define a free list for a size-memsetup set up memory (activates memalloc/free)-memfreeshort free up all memory buffers*//*---------- -prototypes in alphabetical order -----------*/void *qh_memalloc(int insize);void qh_memfree (void *object, int size);void qh_memfreeshort (int *curlong, int *totlong);void qh_meminit (FILE *ferr);void qh_meminitbuffers (int tracelevel, int alignment, int numsizes, int bufsize, int bufinit);void qh_memsetup (void);void qh_memsize(int size);void qh_memstatistics (FILE *fp);/**** end mem.h ****//**************************************************************************//************** definitions and signatures from set.h *********************//**************************************************************************//* -----------------------------------------------constants and flags*/#define SETelemsize sizeof(void *) /* specifies size of set element in bytes *//* ================= -structures- ===============*/#ifndef DEFsetT#define DEFsetT 1typedef struct setT setT; /* a set is a sorted or unsorted array of pointers */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -