📄 triangle.cpp
字号:
/* be part of a different triangle. */
#define dprev(triedge1, triedge2) \
lnext(triedge1, triedge2); \
symself(triedge2);
#define dprevself(triedge) \
lnextself(triedge); \
symself(triedge);
/* rnext() moves one edge counterclockwise about the adjacent triangle. */
/* (It's best understood by reading Guibas and Stolfi. It involves */
/* changing triangles twice.) */
#define rnext(triedge1, triedge2) \
sym(triedge1, triedge2); \
lnextself(triedge2); \
symself(triedge2);
#define rnextself(triedge) \
symself(triedge); \
lnextself(triedge); \
symself(triedge);
/* rnext() moves one edge clockwise about the adjacent triangle. */
/* (It's best understood by reading Guibas and Stolfi. It involves */
/* changing triangles twice.) */
#define rprev(triedge1, triedge2) \
sym(triedge1, triedge2); \
lprevself(triedge2); \
symself(triedge2);
#define rprevself(triedge) \
symself(triedge); \
lprevself(triedge); \
symself(triedge);
/* These primitives determine or set the origin, destination, or apex of a */
/* triangle. */
#define org(triedge, pointptr) \
pointptr = (point) (triedge).tri[plus1mod3[(triedge).orient] + 3]
#define dest(triedge, pointptr) \
pointptr = (point) (triedge).tri[minus1mod3[(triedge).orient] + 3]
#define apex(triedge, pointptr) \
pointptr = (point) (triedge).tri[(triedge).orient + 3]
#define setorg(triedge, pointptr) \
(triedge).tri[plus1mod3[(triedge).orient] + 3] = (triangle) pointptr
#define setdest(triedge, pointptr) \
(triedge).tri[minus1mod3[(triedge).orient] + 3] = (triangle) pointptr
#define setapex(triedge, pointptr) \
(triedge).tri[(triedge).orient + 3] = (triangle) pointptr
#define setvertices2null(triedge) \
(triedge).tri[3] = (triangle) NULL; \
(triedge).tri[4] = (triangle) NULL; \
(triedge).tri[5] = (triangle) NULL;
/* Bond two triangles together. */
#define bond(triedge1, triedge2) \
(triedge1).tri[(triedge1).orient] = encode(triedge2); \
(triedge2).tri[(triedge2).orient] = encode(triedge1)
/* Dissolve a bond (from one side). Note that the other triangle will still */
/* think it's connected to this triangle. Usually, however, the other */
/* triangle is being deleted entirely, or bonded to another triangle, so */
/* it doesn't matter. */
#define dissolve(triedge) \
(triedge).tri[(triedge).orient] = (triangle) dummytri
/* Copy a triangle/edge handle. */
#define triedgecopy(triedge1, triedge2) \
(triedge2).tri = (triedge1).tri; \
(triedge2).orient = (triedge1).orient
/* Test for equality of triangle/edge handles. */
#define triedgeequal(triedge1, triedge2) \
(((triedge1).tri == (triedge2).tri) && \
((triedge1).orient == (triedge2).orient))
/* Primitives to infect or cure a triangle with the virus. These rely on */
/* the assumption that all shell edges are aligned to four-byte boundaries.*/
#define infect(triedge) \
(triedge).tri[6] = (triangle) \
((unsigned long) (triedge).tri[6] | (unsigned long) 2l)
#define uninfect(triedge) \
(triedge).tri[6] = (triangle) \
((unsigned long) (triedge).tri[6] & ~ (unsigned long) 2l)
/* Test a triangle for viral infection. */
#define infected(triedge) \
(((unsigned long) (triedge).tri[6] & (unsigned long) 2l) != 0)
/* Check or set a triangle's attributes. */
#define elemattribute(triedge, attnum) \
((REAL *) (triedge).tri)[elemattribindex + (attnum)]
#define setelemattribute(triedge, attnum, value) \
((REAL *) (triedge).tri)[elemattribindex + (attnum)] = value
/* Check or set a triangle's maximum area bound. */
#define areabound(triedge) ((REAL *) (triedge).tri)[areaboundindex]
#define setareabound(triedge, value) \
((REAL *) (triedge).tri)[areaboundindex] = value
/********* Primitives for shell edges *********/
/* */
/* */
/* sdecode() converts a pointer to an oriented shell edge. The orientation */
/* is extracted from the least significant bit of the pointer. The two */
/* least significant bits (one for orientation, one for viral infection) */
/* are masked out to produce the real pointer. */
#define sdecode(sptr, edge) \
(edge).shorient = (int) ((unsigned long) (sptr) & (unsigned long) 1l); \
(edge).sh = (shelle *) \
((unsigned long) (sptr) & ~ (unsigned long) 3l)
/* sencode() compresses an oriented shell edge into a single pointer. It */
/* relies on the assumption that all shell edges are aligned to two-byte */
/* boundaries, so the least significant bit of (edge).sh is zero. */
#define sencode(edge) \
(shelle) ((unsigned long) (edge).sh | (unsigned long) (edge).shorient)
/* ssym() toggles the orientation of a shell edge. */
#define ssym(edge1, edge2) \
(edge2).sh = (edge1).sh; \
(edge2).shorient = 1 - (edge1).shorient
#define ssymself(edge) \
(edge).shorient = 1 - (edge).shorient
/* spivot() finds the other shell edge (from the same segment) that shares */
/* the same origin. */
#define spivot(edge1, edge2) \
sptr = (edge1).sh[(edge1).shorient]; \
sdecode(sptr, edge2)
#define spivotself(edge) \
sptr = (edge).sh[(edge).shorient]; \
sdecode(sptr, edge)
/* snext() finds the next shell edge (from the same segment) in sequence; */
/* one whose origin is the input shell edge's destination. */
#define snext(edge1, edge2) \
sptr = (edge1).sh[1 - (edge1).shorient]; \
sdecode(sptr, edge2)
#define snextself(edge) \
sptr = (edge).sh[1 - (edge).shorient]; \
sdecode(sptr, edge)
/* These primitives determine or set the origin or destination of a shell */
/* edge. */
#define sorg(edge, pointptr) \
pointptr = (point) (edge).sh[2 + (edge).shorient]
#define sdest(edge, pointptr) \
pointptr = (point) (edge).sh[3 - (edge).shorient]
#define setsorg(edge, pointptr) \
(edge).sh[2 + (edge).shorient] = (shelle) pointptr
#define setsdest(edge, pointptr) \
(edge).sh[3 - (edge).shorient] = (shelle) pointptr
/* These primitives read or set a shell marker. Shell markers are used to */
/* hold user boundary information. */
#define mark(edge) (* (int *) ((edge).sh + 6))
#define setmark(edge, value) \
* (int *) ((edge).sh + 6) = value
/* Bond two shell edges together. */
#define sbond(edge1, edge2) \
(edge1).sh[(edge1).shorient] = sencode(edge2); \
(edge2).sh[(edge2).shorient] = sencode(edge1)
/* Dissolve a shell edge bond (from one side). Note that the other shell */
/* edge will still think it's connected to this shell edge. */
#define sdissolve(edge) \
(edge).sh[(edge).shorient] = (shelle) dummysh
/* Copy a shell edge. */
#define shellecopy(edge1, edge2) \
(edge2).sh = (edge1).sh; \
(edge2).shorient = (edge1).shorient
/* Test for equality of shell edges. */
#define shelleequal(edge1, edge2) \
(((edge1).sh == (edge2).sh) && \
((edge1).shorient == (edge2).shorient))
/********* Primitives for interacting triangles and shell edges *********/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -