#include \int main(int argc, char *argv[]) {
tetgenio in, out; tetgenio::facet *f; tetgenio::polygon *p; int i;
// All indices start from 1. in.firstnumber = 1; in.numberofpoints = 8;
in.pointlist = new REAL[in.numberofpoints * 3]; in.pointlist[0] = 0; // node 1. in.pointlist[1] = 0; in.pointlist[2] = 0;
in.pointlist[3] = 2; // node 2. in.pointlist[4] = 0; in.pointlist[5] = 0;
in.pointlist[6] = 2; // node 3. in.pointlist[7] = 2; in.pointlist[8] = 0;
in.pointlist[9] = 0; // node 4. in.pointlist[10] = 2; in.pointlist[11] = 0; // Set node 5, 6, 7, 8. for (i = 4; i < 8; i++) {
in.pointlist[i * 3] = in.pointlist[(i - 4) * 3];
in.pointlist[i * 3 + 1] = in.pointlist[(i - 4 )*3+1]; in.pointlist[i * 3 + 2] = 12; }
in.numberoffacets = 6;
in.facetlist = new tetgenio::facet[in.numberoffacets]; in.facetmarkerlist = new int[in.numberoffacets]; // Facet 1. The leftmost facet. f = &in.facetlist[0]; f->numberofpolygons = 1;
f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; f->numberofholes = 0; f->holelist = NULL; p = &f->polygonlist[0]; p->numberofvertices = 4;
p->vertexlist = new int[p->numberofvertices]; p->vertexlist[0] = 1; p->vertexlist[1] = 2; p->vertexlist[2] = 3; 55
p->vertexlist[3] = 4;
// Facet 2. The rightmost facet. f = &in.facetlist[1]; f->numberofpolygons = 1;
f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; f->numberofholes = 0; f->holelist = NULL; p = &f->polygonlist[0]; p->numberofvertices = 4;
p->vertexlist = new int[p->numberofvertices]; p->vertexlist[0] = 5; p->vertexlist[1] = 6; p->vertexlist[2] = 7; p->vertexlist[3] = 8;
// Facet 3. The bottom facet. f = &in.facetlist[2]; f->numberofpolygons = 1;
f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; f->numberofholes = 0; f->holelist = NULL; p = &f->polygonlist[0]; p->numberofvertices = 4;
p->vertexlist = new int[p->numberofvertices]; p->vertexlist[0] = 1; p->vertexlist[1] = 5; p->vertexlist[2] = 6; p->vertexlist[3] = 2;
// Facet 4. The back facet. f = &in.facetlist[3]; f->numberofpolygons = 1;
f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; f->numberofholes = 0; f->holelist = NULL; p = &f->polygonlist[0]; p->numberofvertices = 4;
p->vertexlist = new int[p->numberofvertices]; p->vertexlist[0] = 2; p->vertexlist[1] = 6; p->vertexlist[2] = 7; p->vertexlist[3] = 3;
// Facet 5. The top facet. f = &in.facetlist[4]; f->numberofpolygons = 1;
f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; f->numberofholes = 0; 56
f->holelist = NULL; p = &f->polygonlist[0]; p->numberofvertices = 4;
p->vertexlist = new int[p->numberofvertices]; p->vertexlist[0] = 3; p->vertexlist[1] = 7; p->vertexlist[2] = 8; p->vertexlist[3] = 4;
// Facet 6. The front facet. f = &in.facetlist[5]; f->numberofpolygons = 1;
f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; f->numberofholes = 0; f->holelist = NULL; p = &f->polygonlist[0]; p->numberofvertices = 4;
p->vertexlist = new int[p->numberofvertices]; p->vertexlist[0] = 4; p->vertexlist[1] = 8; p->vertexlist[2] = 5; p->vertexlist[3] = 1;
// Set ’in.facetmarkerlist’ in.facetmarkerlist[0] = -1; in.facetmarkerlist[1] = -2; in.facetmarkerlist[2] = 0; in.facetmarkerlist[3] = 0; in.facetmarkerlist[4] = 0; in.facetmarkerlist[5] = 0;
// Output the PLC to files ’barin.node’ and ’barin.poly’. in.save_nodes(\in.save_poly(\
// Tetrahedralize the PLC. Switches are chosen to read a PLC (p), // do quality mesh generation (q) with a specified quality bound // (1.414), and apply a maximum volume constraint (a0.1). tetrahedralize(\
// Output mesh to files ’barout.node’, ’barout.ele’ and ’barout.face’. out.save_nodes(\out.save_elements(\out.save_faces(\return 0; }
附录
这一节给出了作为快速引用的一些扩展基本概念的简单介绍
Convex Hull n维空间顶点集V的凸壳,用convV标识,是包含V的最小凸壳集
Simplex a Simplex --- 是一个几何独立的顶点集S的凸壳。--的维数是小于顶点集S的顶点个数。特别地,在三维空间中最大几何独立的点的个数是4。我们有非空simplices of dimensions 0, 1, 2 and 3被分别称为vertices, edges,
triangles ,andtetrahedra。对于任何子集T ? S,the simplex τ =convT is σ的一个面,并且我们写成 τ ≤ σ . 如果T是一个S的一个合适的子集,那么τ是σ一个合适的字面。
Simplical Complex A simplical complex K是simplices的有限集,K中simplex的任何面一定在K中,并且K中任何两个交叉的simplices也是在一个面上。条件 (ii)允许两个simplices相邻,因为空集是唯一的空间simplex,它是任意simplex的面。图21(a)说明了一个二维空间的simplical complex.
Underlying Space simplices L集的潜在空间,用| L|标识,是内部的集合, σ ∈L intσ。(见图21(b)的说明)。只有当L是一个simplical complex ,| L|是拓扑的闭合集
Subcomplex K的subcomplex是simplices of K的子集,它也是一个simplical complex。可以参考图21(c)的例子