📄 tetgen.h
字号:
face ss; REAL key; REAL cent[3]; point forg, fdest, fapex, foppo; point noppo; struct badface *previtem, *nextitem; };///////////////////////////////////////////////////////////////////////////////// //// The pbcdata structure //// //// A pbcdata stores data of a periodic boundary condition defined on a pair //// of facets or segments. Let f1 and f2 define a pbcgroup. 'fmark' saves the //// facet markers of f1 and f2; 'ss' contains two subfaces belong to f1 and //// f2, respectively. Let s1 and s2 define a segment pbcgroup. 'segid' are //// the segment ids of s1 and s2; 'ss' contains two segments belong to s1 and //// s2, respectively. 'transmat' are two transformation matrices. transmat[0] //// transforms a point of f1 (or s1) into a point of f2 (or s2), transmat[1] //// does the inverse. //// ///////////////////////////////////////////////////////////////////////////////// struct pbcdata { int fmark[2]; int segid[2]; face ss[2]; REAL transmat[2][4][4]; };///////////////////////////////////////////////////////////////////////////////// //// The list, link and queue data structures //// //// These data types are used to manipulate a set of (same-typed) data items. //// For a given set S = {a, b, c, ...}, a list stores the elements of S in a //// piece of continuous memory. It allows quickly accessing each element of S,//// thus is suitable for storing a fix-sized set. While a link stores its //// elements incontinuously. It allows quickly inserting or deleting an item, //// thus is suitable for storing a size-variable set. A queue is basically a //// special case of a link where one data element joins the link at the end //// and leaves in an ordered fashion at the other end. //// ///////////////////////////////////////////////////////////////////////////////// // The compfunc data type. "compfunc" is a pointer to a linear-order // function, which takes two 'void*' arguments and returning an 'int'. // // A function: int cmp(const T &, const T &), is said to realize a // linear order on the type T if there is a linear order <= on T such // that for all x and y in T satisfy the following relation: // -1 if x < y. // comp(x, y) = 0 if x is equivalent to y. // +1 if x > y. typedef int (*compfunc) (const void *, const void *); // The predefined compare functions for primitive data types. They // take two pointers of the corresponding date type, perform the // comparation, and return -1, 0 or 1 indicating the default linear // order of them. static int compare_2_ints(const void* x, const void* y); static int compare_2_longs(const void* x, const void* y); static int compare_2_unsignedlongs(const void* x, const void* y); // The function used to determine the size of primitive data types and // set the corresponding predefined linear order functions for them. static void set_compfunc(char* str, int* itembytes, compfunc* pcomp);///////////////////////////////////////////////////////////////////////////////// //// List data structure. //// //// A 'list' is an array of items with automatically reallocation of memory. //// It behaves like an array. //// //// 'base' is the starting address of the array; The memory unit in list is //// byte, i.e., sizeof(char). 'itembytes' is the size of each item in byte, //// so that the next item in list will be found at the next 'itembytes' //// counted from the current position. //// //// 'items' is the number of items stored in list. 'maxitems' indicates how //// many items can be stored in this list. 'expandsize' is the increasing //// size (items) when the list is full. //// //// 'comp' is a pointer pointing to a linear order function for the list. //// default it is set to 'NULL'. //// //// The index of list always starts from zero, i.e., for a list L contains //// n elements, the first element is L[0], and the last element is L[n-1]. //// This feature lets lists like C/C++ arrays. //// ///////////////////////////////////////////////////////////////////////////////// class list { public: char *base; int itembytes; int items, maxitems, expandsize; compfunc comp; public: list(int itbytes, compfunc pcomp, int mitems = 256, int exsize = 128) { listinit(itbytes, pcomp, mitems, exsize); } list(char* str, int mitems = 256, int exsize = 128) { set_compfunc(str, &itembytes, &comp); listinit(itembytes, comp, mitems, exsize); } ~list() { free(base); } void *operator[](int i) { return (void *) (base + i * itembytes); } void listinit(int itbytes, compfunc pcomp, int mitems, int exsize); void setcomp(compfunc compf) { comp = compf; } void clear() { items = 0; } int len() { return items; } void *append(void* appitem); void *insert(int pos, void* insitem); void del(int pos, int order); int hasitem(void* checkitem); void sort(); }; ///////////////////////////////////////////////////////////////////////////////// //// Memorypool data structure. //// //// A type used to allocate memory. (It is incorporated from Shewchuk's //// Triangle program) //// //// firstblock is the first block of items. nowblock is the block from which //// items are currently being allocated. nextitem points to the next slab //// of free memory for an item. deaditemstack is the head of a linked list //// (stack) of deallocated items that can be recycled. unallocateditems is //// the number of items that remain to be allocated from nowblock. //// //// Traversal is the process of walking through the entire list of items, and //// is separate from allocation. Note that a traversal will visit items on //// the "deaditemstack" stack as well as live items. pathblock points to //// the block currently being traversed. pathitem points to the next item //// to be traversed. pathitemsleft is the number of items that remain to //// be traversed in pathblock. //// //// itemwordtype is set to POINTER or FLOATINGPOINT, and is used to suggest //// what sort of word the record is primarily made up of. alignbytes //// determines how new records should be aligned in memory. itembytes and //// itemwords are the length of a record in bytes (after rounding up) and //// words. itemsperblock is the number of items allocated at once in a //// single block. items is the number of currently allocated items. //// maxitems is the maximum number of items that have been allocated at //// once; it is the current number of items plus the number of records kept //// on deaditemstack. //// ///////////////////////////////////////////////////////////////////////////////// class memorypool { public: void **firstblock, **nowblock; void *nextitem; void *deaditemstack; void **pathblock; void *pathitem; wordtype itemwordtype; int alignbytes; int itembytes, itemwords; int itemsperblock; long items, maxitems; int unallocateditems; int pathitemsleft; public: memorypool(); memorypool(int, int, enum wordtype, int); ~memorypool(); void poolinit(int, int, enum wordtype, int); void restart(); void *alloc(); void dealloc(void*); void traversalinit(); void *traverse(); }; ///////////////////////////////////////////////////////////////////////////////// //// Link data structure. //// //// A 'link' is a double linked nodes. It uses the memorypool data structure //// for memory management. Following is an image of a link. //// //// head-> ____0____ ____1____ ____2____ _________<-tail //// |__next___|--> |__next___|--> |__next___|--> |__NULL___| //// |__NULL___|<-- |__prev___|<-- |__prev___|<-- |__prev___| //// | | |_ _| |_ _| | | //// | | |_ Data1 _| |_ Data2 _| | | //// |_________| |_________| |_________| |_________| //// //// The unit size for storage is size of pointer, which may be 4-byte (in 32- //// bit machine) or 8-byte (in 64-bit machine). The real size of an item is //// stored in 'linkitembytes'. //// //// 'head' and 'tail' are pointers pointing to the first and last nodes. They //// do not conatin data (See above). //// //// 'nextlinkitem' is a pointer pointing to a node which is the next one will //// be traversed. 'curpos' remembers the position (1-based) of the current //// traversing node. //// //// 'linkitems' indicates how many items in link. Note it is different with //// 'items' of memorypool. //// //// The index of link starts from 1, i.e., for a link K contains n elements, //// the first element of the link is K[1], and the last element is K[n]. //// See the above figure. //// ///////////////////////////////////////////////////////////////////////////////// class link : public memorypool { public: void **head, **tail; void *nextlink
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -