tetgen.h
Go to the documentation of this file.
1 // //
3 // TetGen //
4 // //
5 // A Quality Tetrahedral Mesh Generator and 3D Delaunay Triangulator //
6 // //
7 // Version 1.4 //
8 // September 6, December 13, 2010 //
9 // January 19, 2011 //
10 // //
11 // Copyright (C) 2002--2011 //
12 // Hang Si //
13 // Research Group: Numerical Mathematics and Scientific Computing //
14 // Weierstrass Institute for Applied Analysis and Stochastics (WIAS) //
15 // Mohrenstr. 39, 10117 Berlin, Germany //
16 // si@wias-berlin.de //
17 // //
18 // TetGen is freely available through the website: http://wias-berlin.de/software/tetgen/. //
19 // It may be copied, modified, and redistributed for non-commercial use. //
20 // Please consult the file LICENSE for the detailed copyright notices. //
21 // //
23 
25 // //
26 // TetGen is a library to generate tetrahedral meshes for 3D domains. It's //
27 // main purpose is to generate suitable tetrahedral meshes for numerical //
28 // simulations using finite element and finite volume methods. //
29 // //
30 // TetGen incorporates a suit of geometrical and mesh generation algorithms. //
31 // A brief description of algorithms used in TetGen is found in the first //
32 // section of the user's manual. References are given for users who are //
33 // interesting in these approaches. The main references are given below: //
34 // //
35 // The efficient Delaunay tetrahedralization algorithm is: H. Edelsbrunner //
36 // and N. R. Shah, "Incremental Topological Flipping Works for Regular //
37 // Triangulations". Algorithmica 15: 223--241, 1996. //
38 // //
39 // The constrained Delaunay tetrahedralization algorithm is described in: //
40 // H. Si and K. Gaertner, "Meshing Piecewise Linear Complexes by Constr- //
41 // ained Delaunay Tetrahedralizations". In Proceeding of the 14th Inter- //
42 // national Meshing Roundtable. September 2005. //
43 // //
44 // The mesh refinement algorithm is from: Hang Si, "Adaptive Tetrahedral //
45 // Mesh Generation by Constrained Delaunay Refinement". International //
46 // Journal for Numerical Methods in Engineering, 75(7): 856--880, 2008. //
47 // //
48 // The mesh data structure of TetGen is a combination of two types of mesh //
49 // data structures. The tetrahedron-based mesh data structure introduced //
50 // by Shewchuk is eligible for tetrahedralization algorithms. The triangle //
51 // -edge data structure developed by Muecke is adopted for representing //
52 // boundary elements: subfaces and subsegments. //
53 // //
54 // J. R. Shewchuk, "Delaunay Refinement Mesh Generation". PhD thesis, //
55 // Carnegie Mellon University, Pittsburgh, PA, 1997. //
56 // //
57 // E. P. Muecke, "Shapes and Implementations in Three-Dimensional //
58 // Geometry". PhD thesis, Univ. of Illinois, Urbana, Illinois, 1993. //
59 // //
60 // The research of mesh generation is definitly on the move. Many State-of- //
61 // the-art algorithms need implementing and evaluating. I heartily welcome //
62 // any new algorithm especially for generating quality conforming Delaunay //
63 // meshes and anisotropic conforming Delaunay meshes. //
64 // //
65 // TetGen is supported by the "pdelib" project of Weierstrass Institute for //
66 // Applied Analysis and Stochastics (WIAS) in Berlin. It is a collection //
67 // of software components for solving non-linear partial differential //
68 // equations including 2D and 3D mesh generators, sparse matrix solvers, //
69 // and scientific visualization tools, etc. For more information please //
70 // visit: http://www.wias-berlin.de/software/pdelib. //
71 // //
73 
75 // //
76 // tetgen.h //
77 // //
78 // Header file of the TetGen library. Also is the user-level header file. //
79 // //
81 
82 #ifndef tetgenH
83 #define tetgenH
84 
85 #include <stdio.h>
86 #include <stdlib.h>
87 #include <string.h>
88 #include <math.h>
89 #include <time.h>
90 #include <assert.h>
91 
92 // The types 'intptr_t' and 'uintptr_t' are signed and unsigned integer types,
93 // respectively. They are guaranteed to be the same width as a pointer.
94 // They are defined in <stdint.h> by the C99 Standard.
95 // However, Microsoft Visual C++ doesn't ship with this header file yet. We
96 // need to define them. (Thanks to Steven G. Johnson from MIT for the
97 // following piece of code.)
98 
99 // Define the _MSC_VER symbol if you are using Microsoft Visual C++.
100 
101 // #define _MSC_VER
102 
103 // Define the _WIN64 symbol if you are running TetGen on Win64.
104 
105 // #define _WIN64
106 
107 #ifdef _MSC_VER // Microsoft Visual C++
108 # ifdef _WIN64
109  typedef __int64 intptr_t;
110  typedef unsigned __int64 uintptr_t;
111 # else // not _WIN64
112  typedef int intptr_t;
113  typedef unsigned int uintptr_t;
114 # endif
115 #else // not Visual C++
116 # include <stdint.h>
117 #endif
118 
119 // To compile TetGen as a library instead of an executable program, define
120 // the TETLIBRARY symbol.
121 
122 #define TETLIBRARY
123 
124 // Uncomment the following line to disable assert macros. These macros are
125 // inserted in places where I hope to catch bugs.
126 
127 // #define NDEBUG
128 
129 // To insert lots of self-checks for internal errors, define the SELF_CHECK
130 // symbol. This will slow down the program a bit.
131 
132 // #define SELF_CHECK
133 
134 // For single precision ( which will save some memory and reduce paging ),
135 // define the symbol SINGLE by using the -DSINGLE compiler switch or by
136 // writing "#define SINGLE" below.
137 //
138 // For double precision ( which will allow you to refine meshes to a smaller
139 // edge length), leave SINGLE undefined.
140 
141 // #define SINGLE
142 
143 #ifdef SINGLE
144  #define REAL float
145 #else
146  #define REAL double
147 #endif // not defined SINGLE
148 
150 // //
151 // TetGen Library Overview //
152 // //
153 // TetGen library is comprised by several data types and global functions. //
154 // //
155 // There are three main data types: tetgenio, tetgenbehavior, and tetgenmesh.//
156 // Tetgenio is used to pass data into and out of TetGen library; tetgenbeha- //
157 // vior keeps the runtime options and thus controls the behaviors of TetGen; //
158 // tetgenmesh, the biggest data type I've ever defined, contains mesh data //
159 // structures and mesh traversing and transformation operators. The meshing //
160 // algorithms are implemented on top of it. These data types are defined as //
161 // C++ classes. //
162 // //
163 // There are few global functions. tetrahedralize() is provided for calling //
164 // TetGen from another program. Two functions: orient3d() and insphere() are //
165 // incorporated from a public C code provided by Shewchuk. They performing //
166 // exact geometrical tests. //
167 // //
169 
171 // //
172 // Class tetgenio //
173 // //
174 // The interface for passing data into and out of the library of TetGen. //
175 // //
176 // The tetgenio data structure is actually a collection of arrays of points, //
177 // facets, tetrahedra, and so forth. The library will read and write these //
178 // arrays according to the options specified in tetgenbehavior structure. //
179 // //
180 // If you want to program with the library of TetGen, it's necessary for you //
181 // to understand this data type,while the other two structures can be hidden //
182 // through calling the global function "tetrahedralize()". Each array corre- //
183 // sponds to a list of data in the file formats of TetGen. It is necessary //
184 // to understand TetGen's input/output file formats (see user's manual). //
185 // //
186 // Once an object of tetgenio is declared, no array is created. One has to //
187 // allocate enough memory for them, e.g., use the "new" operator in C++. On //
188 // deletion of the object, the memory occupied by these arrays needs to be //
189 // freed. Routine deinitialize() will be automatically called. It will de- //
190 // allocate the memory for an array if it is not a NULL. However, it assumes //
191 // that the memory is allocated by the C++ "new" operator. If you use malloc //
192 // (), you should free() them and set the pointers to NULLs before reaching //
193 // deinitialize(). //
194 // //
195 // tetgenio ontains routines for reading and writing TetGen's files, i.e., //
196 // .node, .poly, .smesh, .ele, .face, and .edge files. Both the library of //
197 // TetGen and TetView use these routines to process input files. //
198 // //
200 
201 class tetgenio {
202 
203  public:
204 
205  // Maximum number of characters in a file name (including the null).
206  enum {FILENAMESIZE = 1024};
207 
208  // Maxi. numbers of chars in a line read from a file (incl. the null).
209  enum {INPUTLINESIZE = 1024};
210 
211  // The polygon data structure. A "polygon" describes a simple polygon
212  // (no holes). It is not necessarily convex. Each polygon contains a
213  // number of corners (points) and the same number of sides (edges).
214  // Note that the points of the polygon must be given in either counter-
215  // clockwise or clockwise order and they form a ring, so every two
216  // consective points forms an edge of the polygon.
217  typedef struct {
220  } polygon;
221 
222  static void init(polygon* p) {
223  p->vertexlist = (int *) NULL;
224  p->numberofvertices = 0;
225  }
226 
227  // The facet data structure. A "facet" describes a facet. Each facet is
228  // a polygonal region possibly with holes, edges, and points in it.
229  typedef struct {
234  } facet;
235 
236  static void init(facet* f) {
237  f->polygonlist = (polygon *) NULL;
238  f->numberofpolygons = 0;
239  f->holelist = (REAL *) NULL;
240  f->numberofholes = 0;
241  }
242 
243  // A 'voroedge' is an edge of the Voronoi diagram. It corresponds to a
244  // Delaunay face. Each voroedge is either a line segment connecting
245  // two Voronoi vertices or a ray starting from a Voronoi vertex to an
246  // "infinite vertex". 'v1' and 'v2' are two indices pointing to the
247  // list of Voronoi vertices. 'v1' must be non-negative, while 'v2' may
248  // be -1 if it is a ray, in this case, the unit normal of this ray is
249  // given in 'vnormal'.
250  typedef struct {
251  int v1, v2;
252  REAL vnormal[3];
253  } voroedge;
254 
255  // A 'vorofacet' is an facet of the Voronoi diagram. It corresponds to a
256  // Delaunay edge. Each Voronoi facet is a convex polygon formed by a
257  // list of Voronoi edges, it may not be closed. 'c1' and 'c2' are two
258  // indices pointing into the list of Voronoi cells, i.e., the two cells
259  // share this facet. 'elist' is an array of indices pointing into the
260  // list of Voronoi edges, 'elist[0]' saves the number of Voronoi edges
261  // (including rays) of this facet.
262  typedef struct {
263  int c1, c2;
264  int *elist;
265  } vorofacet;
266 
267  // The periodic boundary condition group data structure. A "pbcgroup"
268  // contains the definition of a pbc and the list of pbc point pairs.
269  // 'fmark1' and 'fmark2' are the facetmarkers of the two pbc facets f1
270  // and f2, respectively. 'transmat' is the transformation matrix which
271  // maps a point in f1 into f2. An array of pbc point pairs are saved
272  // in 'pointpairlist'. The first point pair is at indices [0] and [1],
273  // followed by remaining pairs. Two integers per pair.
274  typedef struct {
275  int fmark1, fmark2;
276  REAL transmat[4][4];
279  } pbcgroup;
280 
281  // A callback function for mesh refinement.
282  typedef bool (* TetSizeFunc)(REAL*, REAL*, REAL*, REAL*, REAL*, REAL);
283 
284  // Items are numbered starting from 'firstnumber' (0 or 1), default is 0.
286 
287  // Dimension of the mesh (2 or 3), default is 3.
288  int mesh_dim;
289 
290  // Does the lines in .node file contain index or not, default is TRUE.
291  bool useindex;
292 
293  // 'pointlist': An array of point coordinates. The first point's x
294  // coordinate is at index [0] and its y coordinate at index [1], its
295  // z coordinate is at index [2], followed by the coordinates of the
296  // remaining points. Each point occupies three REALs.
297  // 'pointattributelist': An array of point attributes. Each point's
298  // attributes occupy 'numberofpointattributes' REALs.
299  // 'pointmtrlist': An array of metric tensors at points. Each point's
300  // tensor occupies 'numberofpointmtr' REALs.
301  // `pointmarkerlist': An array of point markers; one int per point.
309 
310  // `elementlist': An array of element (triangle or tetrahedron) corners.
311  // The first element's first corner is at index [0], followed by its
312  // other corners in counterclockwise order, followed by any other
313  // nodes if the element represents a nonlinear element. Each element
314  // occupies `numberofcorners' ints.
315  // `elementattributelist': An array of element attributes. Each
316  // element's attributes occupy `numberofelementattributes' REALs.
317  // `elementconstraintlist': An array of constraints, i.e. triangle's
318  // area or tetrahedron's volume; one REAL per element. Input only.
319  // `neighborlist': An array of element neighbors; 3 or 4 ints per
320  // element. Output only.
328 
329  // `facetlist': An array of facets. Each entry is a structure of facet.
330  // `facetmarkerlist': An array of facet markers; one int per facet.
334 
335  // `holelist': An array of holes. The first hole's x, y and z
336  // coordinates are at indices [0], [1] and [2], followed by the
337  // remaining holes. Three REALs per hole.
340 
341  // `regionlist': An array of regional attributes and volume constraints.
342  // The first constraint's x, y and z coordinates are at indices [0],
343  // [1] and [2], followed by the regional attribute at index [3], foll-
344  // owed by the maximum volume at index [4]. Five REALs per constraint.
345  // Note that each regional attribute is used only if you select the `A'
346  // switch, and each volume constraint is used only if you select the
347  // `a' switch (with no number following).
350 
351  // `facetconstraintlist': An array of facet maximal area constraints.
352  // Two REALs per constraint. The first (at index [0]) is the facet
353  // marker (cast it to int), the second (at index [1]) is its maximum
354  // area bound.
357 
358  // `segmentconstraintlist': An array of segment max. length constraints.
359  // Three REALs per constraint. The first two (at indcies [0] and [1])
360  // are the indices of the endpoints of the segment, the third (at index
361  // [2]) is its maximum length bound.
364 
365  // 'pbcgrouplist': An array of periodic boundary condition groups.
368 
369  // `trifacelist': An array of triangular face endpoints. The first
370  // face's endpoints are at indices [0], [1] and [2], followed by the
371  // remaining faces. Three ints per face.
372  // `adjtetlist': An array of adjacent tetrahedra to the faces of
373  // trifacelist. Each face has at most two adjacent tets, the first
374  // face's adjacent tets are at [0], [1]. Two ints per face. A '-1'
375  // indicates outside (no adj. tet). This list is output when '-nn'
376  // switch is used.
377  // `trifacemarkerlist': An array of face markers; one int per face.
382 
383  // `edgelist': An array of edge endpoints. The first edge's endpoints
384  // are at indices [0] and [1], followed by the remaining edges. Two
385  // ints per edge.
386  // `edgemarkerlist': An array of edge markers; one int per edge.
387  int *edgelist;
390 
391  // 'vpointlist': An array of Voronoi vertex coordinates (like pointlist).
392  // 'vedgelist': An array of Voronoi edges. Each entry is a 'voroedge'.
393  // 'vfacetlist': An array of Voronoi facets. Each entry is a 'vorofacet'.
394  // 'vcelllist': An array of Voronoi cells. Each entry is an array of
395  // indices pointing into 'vfacetlist'. The 0th entry is used to store
396  // the length of this array.
400  int **vcelllist;
405 
406  // A callback function.
408 
409  // Input & output routines.
410  bool load_node_call(FILE* infile, int markers, char* nodefilename);
411  bool load_node(char* filebasename);
412  bool load_var(char*);
413  bool load_mtr(char*);
414  bool load_poly(char*);
415  bool load_pbc(char*);
416  bool load_off(char*);
417  bool load_ply(char*);
418  bool load_stl(char*);
419  bool load_medit(char*);
420  bool load_vtk(char*);
421  bool load_plc(char*, int);
422  bool load_tetmesh(char*);
423  void save_nodes(char*);
424  void save_elements(char*);
425  void save_faces(char*);
426  void save_edges(char*);
427  void save_neighbors(char*);
428  void save_poly(char*);
429 
430  // Read line and parse string functions.
431  char *readline(char* string, FILE* infile, int *linenumber);
432  char *findnextfield(char* string);
433  char *readnumberline(char* string, FILE* infile, char* infilename);
434  char *findnextnumber(char* string);
435 
436  // Initialize routine.
437  void initialize()
438  {
439  firstnumber = 0; // Default item index is numbered from Zero.
440  mesh_dim = 3; // Default mesh dimension is 3.
441  useindex = true;
442 
443  pointlist = (REAL *) NULL;
444  pointattributelist = (REAL *) NULL;
445  pointmtrlist = (REAL *) NULL;
446  pointmarkerlist = (int *) NULL;
447  numberofpoints = 0;
449  numberofpointmtrs = 0;
450 
451  tetrahedronlist = (int *) NULL;
452  tetrahedronattributelist = (REAL *) NULL;
453  tetrahedronvolumelist = (REAL *) NULL;
454  neighborlist = (int *) NULL;
455  numberoftetrahedra = 0;
456  numberofcorners = 4; // Default is 4 nodes per element.
458 
459  trifacelist = (int *) NULL;
460  adjtetlist = (int *) NULL;
461  trifacemarkerlist = (int *) NULL;
462  numberoftrifaces = 0;
463 
464  facetlist = (facet *) NULL;
465  facetmarkerlist = (int *) NULL;
466  numberoffacets = 0;
467 
468  edgelist = (int *) NULL;
469  edgemarkerlist = (int *) NULL;
470  numberofedges = 0;
471 
472  holelist = (REAL *) NULL;
473  numberofholes = 0;
474 
475  regionlist = (REAL *) NULL;
476  numberofregions = 0;
477 
478  facetconstraintlist = (REAL *) NULL;
480  segmentconstraintlist = (REAL *) NULL;
482 
483  pbcgrouplist = (pbcgroup *) NULL;
484  numberofpbcgroups = 0;
485 
486  vpointlist = (REAL *) NULL;
487  vedgelist = (voroedge *) NULL;
488  vfacetlist = (vorofacet *) NULL;
489  vcelllist = (int **) NULL;
490  numberofvpoints = 0;
491  numberofvedges = 0;
492  numberofvfacets = 0;
493  numberofvcells = 0;
494 
495  tetunsuitable = NULL;
496  }
497 
498  // Free the memory allocated in 'tetgenio'.
500  {
501  facet *f;
502  polygon *p;
503  pbcgroup *pg;
504  int i, j;
505 
506  // This routine assumes that the memory was allocated by
507  // C++ memory allocation operator 'new'.
508 
509  if (pointlist != (REAL *) NULL) {
510  delete [] pointlist;
511  }
512  if (pointattributelist != (REAL *) NULL) {
513  delete [] pointattributelist;
514  }
515  if (pointmtrlist != (REAL *) NULL) {
516  delete [] pointmtrlist;
517  }
518  if (pointmarkerlist != (int *) NULL) {
519  delete [] pointmarkerlist;
520  }
521 
522  if (tetrahedronlist != (int *) NULL) {
523  delete [] tetrahedronlist;
524  }
525  if (tetrahedronattributelist != (REAL *) NULL) {
526  delete [] tetrahedronattributelist;
527  }
528  if (tetrahedronvolumelist != (REAL *) NULL) {
529  delete [] tetrahedronvolumelist;
530  }
531  if (neighborlist != (int *) NULL) {
532  delete [] neighborlist;
533  }
534 
535  if (trifacelist != (int *) NULL) {
536  delete [] trifacelist;
537  }
538  if (adjtetlist != (int *) NULL) {
539  delete [] adjtetlist;
540  }
541  if (trifacemarkerlist != (int *) NULL) {
542  delete [] trifacemarkerlist;
543  }
544 
545  if (edgelist != (int *) NULL) {
546  delete [] edgelist;
547  }
548  if (edgemarkerlist != (int *) NULL) {
549  delete [] edgemarkerlist;
550  }
551 
552  if (facetlist != (facet *) NULL) {
553  for (i = 0; i < numberoffacets; i++) {
554  f = &facetlist[i];
555  for (j = 0; j < f->numberofpolygons; j++) {
556  p = &f->polygonlist[j];
557  delete [] p->vertexlist;
558  }
559  delete [] f->polygonlist;
560  if (f->holelist != (REAL *) NULL) {
561  delete [] f->holelist;
562  }
563  }
564  delete [] facetlist;
565  }
566  if (facetmarkerlist != (int *) NULL) {
567  delete [] facetmarkerlist;
568  }
569 
570  if (holelist != (REAL *) NULL) {
571  delete [] holelist;
572  }
573  if (regionlist != (REAL *) NULL) {
574  delete [] regionlist;
575  }
576  if (facetconstraintlist != (REAL *) NULL) {
577  delete [] facetconstraintlist;
578  }
579  if (segmentconstraintlist != (REAL *) NULL) {
580  delete [] segmentconstraintlist;
581  }
582  if (pbcgrouplist != (pbcgroup *) NULL) {
583  for (i = 0; i < numberofpbcgroups; i++) {
584  pg = &(pbcgrouplist[i]);
585  if (pg->pointpairlist != (int *) NULL) {
586  delete [] pg->pointpairlist;
587  }
588  }
589  delete [] pbcgrouplist;
590  }
591  if (vpointlist != (REAL *) NULL) {
592  delete [] vpointlist;
593  }
594  if (vedgelist != (voroedge *) NULL) {
595  delete [] vedgelist;
596  }
597  if (vfacetlist != (vorofacet *) NULL) {
598  for (i = 0; i < numberofvfacets; i++) {
599  delete [] vfacetlist[i].elist;
600  }
601  delete [] vfacetlist;
602  }
603  if (vcelllist != (int **) NULL) {
604  for (i = 0; i < numberofvcells; i++) {
605  delete [] vcelllist[i];
606  }
607  delete [] vcelllist;
608  }
609  }
610 
611  // Constructor & destructor.
614 };
615 
617 // //
618 // Class tetgenbehavior //
619 // //
620 // The object holding a collection of options controlling TetGen's behavior. //
621 // See "command line switches" in User's manual. //
622 // //
623 // parse_commandline() provides an simple interface to set the vaules of the //
624 // variables. It accepts the standard parameters (e.g., 'argc' and 'argv') //
625 // that pass to C/C++ main() function. Alternatively a string which contains //
626 // the command line options can be used as its parameter. //
627 // //
629 
631 
632  public:
633 
634  // Labels define the objects which are acceptable by TetGen. They are
635  // recognized by the file extensions.
636  // - NODES, a list of nodes (.node);
637  // - POLY, a piecewise linear complex (.poly or .smesh);
638  // - OFF, a polyhedron (.off, Geomview's file format);
639  // - PLY, a polyhedron (.ply, file format from gatech);
640  // - STL, a surface mesh (.stl, stereolithography format);
641  // - MEDIT, a surface mesh (.mesh, Medit's file format);
642  // - MESH, a tetrahedral mesh (.ele).
643  // If no extension is available, the imposed commandline switch
644  // (-p or -r) implies the object.
645 
647 
648  // Variables of command line switches. Each variable corresponds to a
649  // switch and will be initialized.
650 
651  int plc; // '-p' switch, 0.
652  int quality; // '-q' switch, 0.
653  int refine; // '-r' switch, 0.
654  int coarse; // '-R' switch, 0.
655  int metric; // '-m' switch, 0.
656  int varvolume; // '-a' switch without number, 0.
657  int fixedvolume; // '-a' switch with number, 0.
658  int insertaddpoints; // '-i' switch, 0.
659  int regionattrib; // '-A' switch, 0.
660  int conformdel; // '-D' switch, 0.
661  int diagnose; // '-d' switch, 0.
662  int zeroindex; // '-z' switch, 0.
663  int btree; // -u, 1.
664  int max_btreenode_size; // number after -u, 100.
665  int optlevel; // number specified after '-s' switch, 3.
666  int optpasses; // number specified after '-ss' switch, 3.
667  int order; // element order, specified after '-o' switch, 1.
668  int facesout; // '-f' switch, 0.
669  int edgesout; // '-e' switch, 0.
670  int neighout; // '-n' switch, 0.
671  int voroout; // '-v',switch, 0.
672  int meditview; // '-g' switch, 0.
673  int gidview; // '-G' switch, 0.
674  int geomview; // '-O' switch, 0.
675  int vtkview; // '-K' switch, 0.
676  int nobound; // '-B' switch, 0.
677  int nonodewritten; // '-N' switch, 0.
678  int noelewritten; // '-E' switch, 0.
679  int nofacewritten; // '-F' switch, 0.
680  int noiterationnum; // '-I' switch, 0.
681  int nomerge; // '-M',switch, 0.
682  int nobisect; // count of how often '-Y' switch is selected, 0.
683  int noflip; // do not perform flips. '-X' switch. 0.
684  int nojettison; // do not jettison redundants nodes. '-J' switch. 0.
685  int steiner; // number after '-S' switch. 0.
686  int fliprepair; // '-X' switch, 1.
687  int offcenter; // '-R' switch, 0.
688  int docheck; // '-C' switch, 0.
689  int quiet; // '-Q' switch, 0.
690  int verbose; // count of how often '-V' switch is selected, 0.
691  int useshelles; // '-p', '-r', '-q', '-d', or '-R' switch, 0.
692  int maxflipedgelinksize; // The maximum flippable edge link size 10.
693  REAL minratio; // number after '-q' switch, 2.0.
694  REAL goodratio; // number calculated from 'minratio', 0.0.
695  REAL minangle; // minimum angle bound, 20.0.
696  REAL goodangle; // cosine squared of minangle, 0.0.
697  REAL maxvolume; // number after '-a' switch, -1.0.
698  REAL mindihedral; // number after '-qq' switch, 5.0.
699  REAL maxdihedral; // number after '-qqq' switch, 165.0.
700  REAL alpha1; // number after '-m' switch, sqrt(2).
701  REAL alpha2; // number after '-mm' switch, 1.0.
702  REAL alpha3; // number after '-mmm' switch, 0.6.
703  REAL epsilon; // number after '-T' switch, 1.0e-8.
704  REAL epsilon2; // number after '-TT' switch, 1.0e-5.
705  enum objecttype object; // determined by -p, or -r switch. NONE.
706 
707  // Variables used to save command line switches and in/out file names.
708  char commandline[1024];
709  char infilename[1024];
710  char outfilename[1024];
711  char addinfilename[1024];
712  char bgmeshfilename[1024];
713 
714  void syntax();
715  void usage();
716 
717  // Command line parse routine.
718  bool parse_commandline(int argc, char **argv);
719  bool parse_commandline(char *switches) {
720  return parse_commandline(0, &switches);
721  }
722 
723  // Initialize all variables.
725  {
726  plc = 0;
727  quality = 0;
728  refine = 0;
729  coarse = 0;
730  metric = 0;
731  minratio = 2.0;
732  goodratio = 0.0;
733  minangle = 20.0;
734  goodangle = 0.0;
735  maxdihedral = 165.0;
736  mindihedral = 5.0;
737  varvolume = 0;
738  fixedvolume = 0;
739  maxvolume = -1.0;
740  regionattrib = 0;
741  insertaddpoints = 0;
742  diagnose = 0;
743  offcenter = 0;
744  conformdel = 0;
745  alpha1 = sqrt(2.0);
746  alpha2 = 1.0;
747  alpha3 = 0.6;
748  zeroindex = 0;
749  btree = 1;
750  max_btreenode_size = 100;
751  facesout = 0;
752  edgesout = 0;
753  neighout = 0;
754  voroout = 0;
755  meditview = 0;
756  gidview = 0;
757  geomview = 0;
758  vtkview = 0;
759  optlevel = 3;
760  optpasses = 3;
761  order = 1;
762  nojettison = 0;
763  nobound = 0;
764  nonodewritten = 0;
765  noelewritten = 0;
766  nofacewritten = 0;
767  noiterationnum = 0;
768  nobisect = 0;
769  noflip = 0;
770  steiner = -1;
771  fliprepair = 1;
772  nomerge = 0;
773  docheck = 0;
774  quiet = 0;
775  verbose = 0;
776  useshelles = 0;
777  maxflipedgelinksize = 10;
778  epsilon = 1.0e-8;
779  epsilon2 = 1.0e-5;
780  object = NONE;
781 
782  commandline[0] = '\0';
783  infilename[0] = '\0';
784  outfilename[0] = '\0';
785  addinfilename[0] = '\0';
786  bgmeshfilename[0] = '\0';
787  }
788 
790  {
791  }
792 };
793 
795 // //
796 // Class tetgenmesh //
797 // //
798 // The object to store, generate, and refine a tetrahedral mesh. //
799 // //
800 // It implements the mesh data structures and functions to create and update //
801 // a tetrahedral mesh according to the specified options. //
802 // //
804 
805 class tetgenmesh {
806 
807  public:
808 
809  // Maximum number of characters in a file name (including the null).
810  enum {FILENAMESIZE = 1024};
811 
812  // For efficiency, a variety of data structures are allocated in bulk.
813  // The following constants determine how many of each structure is
814  // allocated at once.
815  enum {VERPERBLOCK = 4092, SUBPERBLOCK = 4092, ELEPERBLOCK = 8188};
816 
817  // Used for the point location scheme of Mucke, Saias, and Zhu, to
818  // decide how large a random sample of tetrahedra to inspect.
819  enum {SAMPLEFACTOR = 11};
820 
821  // Labels that signify two edge rings of a triangle (see Muecke's thesis).
822  enum {CCW = 0, CW = 1};
823 
824  // Labels that signify whether a record consists primarily of pointers
825  // or of floating-point words. Used for data alignment.
827 
828  // Labels that signify the type of a vertex.
831 
832  // Labels that signify the type of a subface/subsegment.
834 
835  // Labels that signify the type of flips can be applied on a face.
837 
838  // Labels that signify the result of triangle-triangle intersection test.
843 
844  // Labels that signify the result of point location.
847 
848  // Labels that signify the result of vertex insertion.
851 
852  // Labels that signify the result of direction finding.
855 
857 // //
858 // Mesh elements //
859 // //
860 // There are four types of mesh elements: tetrahedra, subfaces, subsegments, //
861 // and points, where subfaces and subsegments are triangles and edges which //
862 // appear on boundaries. A tetrahedralization of a 3D point set comprises //
863 // tetrahedra and points; a surface mesh of a 3D domain comprises subfaces //
864 // subsegments and points. The elements of all the four types consist of a //
865 // tetrahedral mesh of a 3D domain. However, TetGen uses three data types: //
866 // 'tetrahedron', 'shellface', and 'point'. A 'tetrahedron' is a tetrahedron;//
867 // while a 'shellface' can be either a subface or a subsegment; and a 'point'//
868 // is a point. These three data types, linked by pointers comprise a mesh. //
869 // //
870 // A tetrahedron primarily consists of a list of 4 pointers to its corners, //
871 // a list of 4 pointers to its adjoining tetrahedra, a list of 4 pointers to //
872 // its adjoining subfaces (when subfaces are needed). Optinoally, (depending //
873 // on the selected switches), it may contain an arbitrary number of user- //
874 // defined floating-point attributes, an optional maximum volume constraint //
875 // (for -a switch), and a pointer to a list of high-order nodes (-o2 switch).//
876 // Since the size of a tetrahedron is not determined until running time. //
877 // //
878 // The data structure of tetrahedron also stores the geometrical information.//
879 // Let t be a tetrahedron, v0, v1, v2, and v3 be the 4 nodes corresponding //
880 // to the order of their storage in t. v3 always has a negative orientation //
881 // with respect to v0, v1, v2 (ie,, v3 lies above the oriented plane passes //
882 // through v0, v1, v2). Let the 4 faces of t be f0, f1, f2, and f3. Vertices //
883 // of each face are stipulated as follows: f0 (v0, v1, v2), f1 (v0, v3, v1), //
884 // f2 (v1, v3, v2), f3 (v2, v3, v0). //
885 // //
886 // A subface has 3 pointers to vertices, 3 pointers to adjoining subfaces, 3 //
887 // pointers to adjoining subsegments, 2 pointers to adjoining tetrahedra, a //
888 // boundary marker(an integer). Like a tetrahedron, the pointers to vertices,//
889 // subfaces, and subsegments are ordered in a way that indicates their geom- //
890 // etric relation. Let s be a subface, v0, v1 and v2 be the 3 nodes corres- //
891 // ponding to the order of their storage in s, e0, e1 and e2 be the 3 edges,//
892 // then we have: e0 (v0, v1), e1 (v1, v2), e2 (v2, v0). //
893 // //
894 // A subsegment has exactly the same data fields as a subface has, but only //
895 // uses some of them. It has 2 pointers to its endpoints, 2 pointers to its //
896 // adjoining (and collinear) subsegments, a pointer to a subface containing //
897 // it (there may exist any number of subfaces having it, choose one of them //
898 // arbitrarily). The geometric relation between its endpoints and adjoining //
899 // subsegments is kept with respect to the storing order of its endpoints. //
900 // //
901 // The data structure of point is relatively simple. A point is a list of //
902 // floating-point numbers, starting with the x, y, and z coords, followed by //
903 // an arbitrary number of optional user-defined floating-point attributes, //
904 // an integer boundary marker, an integer for the point type, and a pointer //
905 // to a tetrahedron (used for speeding up point location). //
906 // //
907 // For a tetrahedron on a boundary (or a hull) of the mesh, some or all of //
908 // the adjoining tetrahedra may not be present. For an interior tetrahedron, //
909 // often no neighboring subfaces are present, Such absent tetrahedra and //
910 // subfaces are never represented by the NULL pointers; they are represented //
911 // by two special records: `dummytet', the tetrahedron fills "outer space", //
912 // and `dummysh', the vacuous subfaces which are omnipresent. //
913 // //
914 // Tetrahedra and adjoining subfaces are glued together through the pointers //
915 // saved in each data fields of them. Subfaces and adjoining subsegments are //
916 // connected in the same fashion. However, there are no pointers directly //
917 // gluing tetrahedra and adjoining subsegments. For the purpose of saving //
918 // space, the connections between tetrahedra and subsegments are entirely //
919 // mediated through subfaces. The following part explains how subfaces are //
920 // connected in TetGen. //
921 // //
923 
925 // //
926 // Subface-subface and subface-subsegment connections //
927 // //
928 // Adjoining subfaces sharing a common edge are connected in such a way that //
929 // they form a face ring around the edge. It is indeed a single linked list //
930 // which is cyclic, e.g., one can start from any subface in it and traverse //
931 // back. When the edge is not a subsegment, the ring only has two coplanar //
932 // subfaces which are pointing to each other. Otherwise, the face ring may //
933 // have any number of subfaces (and are not all coplanar). //
934 // //
935 // How is the face ring formed? Let s be a subsegment, f is one of subfaces //
936 // containing s as an edge. The direction of s is stipulated from its first //
937 // endpoint to its second (according to their storage in s). Once the dir of //
938 // s is determined, the other two edges of f are oriented to follow this dir.//
939 // The "directional normal" N_f is a vector formed from any point in f and a //
940 // points orthogonally above f. //
941 // //
942 // The face ring of s is a cyclic ordered set of subfaces containing s, i.e.,//
943 // F(s) = {f1, f2, ..., fn}, n >= 1. Where the order is defined as follows: //
944 // let fi, fj be two faces in F(s), the "normal-angle", NAngle(i,j) (range //
945 // from 0 to 360 degree) is the angle between the N_fi and N_fj; then fi is //
946 // in front of fj (or symbolically, fi < fj) if there exists another fk in //
947 // F(s), and NAangle(k, i) < NAngle(k, j). The face ring of s is: f1 < f2 < //
948 // ... < fn < f1. //
949 // //
950 // The easiest way to imagine how a face ring is formed is to use the right- //
951 // hand rule. Make a fist using your right hand with the thumb pointing to //
952 // the direction of the subsegment. The face ring is connected following the //
953 // direction of your fingers. //
954 // //
955 // The subface and subsegment are also connected through pointers stored in //
956 // their own data fields. Every subface has a pointer to its adjoining sub- //
957 // segment. However, a subsegment only has one pointer to a subface which is //
958 // containing it. Such subface can be chosen arbitrarily, other subfaces are //
959 // found through the face ring. //
960 // //
962 
963  // The tetrahedron data structure. Fields of a tetrahedron contains:
964  // - a list of four adjoining tetrahedra;
965  // - a list of four vertices;
966  // - a list of four subfaces (optional, used for -p switch);
967  // - a list of user-defined floating-point attributes (optional);
968  // - a volume constraint (optional, used for -a switch);
969  // - an integer of element marker (optional, used for -n switch);
970  // - a pointer to a list of high-ordered nodes (optional, -o2 switch);
971 
972  typedef REAL **tetrahedron;
973 
974  // The shellface data structure. Fields of a shellface contains:
975  // - a list of three adjoining subfaces;
976  // - a list of three vertices;
977  // - a list of two adjoining tetrahedra;
978  // - a list of three adjoining subsegments;
979  // - a pointer to a badface containing it (used for -q);
980  // - an area constraint (optional, used for -q);
981  // - an integer for boundary marker;
982  // - an integer for type: SHARPSEGMENT, NONSHARPSEGMENT, ...;
983  // - an integer for pbc group (optional, if in->pbcgrouplist exists);
984 
985  typedef REAL **shellface;
986 
987  // The point data structure. It is actually an array of REALs:
988  // - x, y and z coordinates;
989  // - a list of user-defined point attributes (optional);
990  // - a list of REALs of a user-defined metric tensor (optional);
991  // - a pointer to a simplex (tet, tri, edge, or vertex);
992  // - a pointer to a parent (or duplicate) point;
993  // - a pointer to a tet in background mesh (optional);
994  // - a pointer to another pbc point (optional);
995  // - an integer for boundary marker;
996  // - an integer for verttype: INPUTVERTEX, FREEVERTEX, ...;
997 
998  typedef REAL *point;
999 
1001 // //
1002 // Mesh handles //
1003 // //
1004 // Two special data types, 'triface' and 'face' are defined for maintaining //
1005 // and updating meshes. They are like pointers (or handles), which allow you //
1006 // to hold one particular part of the mesh, i.e., a tetrahedron, a triangle, //
1007 // an edge and a vertex. However, these data types do not themselves store //
1008 // any part of the mesh. The mesh is made of the data types defined above. //
1009 // //
1010 // Muecke's "triangle-edge" data structure is the prototype for these data //
1011 // types. It allows a universal representation for every tetrahedron, //
1012 // triangle, edge and vertex. For understanding the following descriptions //
1013 // of these handle data structures, readers are required to read both the //
1014 // introduction and implementation detail of "triangle-edge" data structure //
1015 // in Muecke's thesis. //
1016 // //
1017 // A 'triface' represents a face of a tetrahedron and an oriented edge of //
1018 // the face simultaneously. It has a pointer 'tet' to a tetrahedron, an //
1019 // integer 'loc' (range from 0 to 3) as the face index, and an integer 'ver' //
1020 // (range from 0 to 5) as the edge version. A face of the tetrahedron can be //
1021 // uniquly determined by the pair (tet, loc), and an oriented edge of this //
1022 // face can be uniquly determined by the triple (tet, loc, ver). Therefore, //
1023 // different usages of one triface are possible. If we only use the pair //
1024 // (tet, loc), it refers to a face, and if we add the 'ver' additionally to //
1025 // the pair, it is an oriented edge of this face. //
1026 // //
1027 // A 'face' represents a subface and an oriented edge of it simultaneously. //
1028 // It has a pointer 'sh' to a subface, an integer 'shver'(range from 0 to 5) //
1029 // as the edge version. The pair (sh, shver) determines a unique oriented //
1030 // edge of this subface. A 'face' is also used to represent a subsegment, //
1031 // in this case, 'sh' points to the subsegment, and 'shver' indicates the //
1032 // one of two orientations of this subsegment, hence, it only can be 0 or 1. //
1033 // //
1034 // Mesh navigation and updating are accomplished through a set of mesh //
1035 // manipulation primitives which operate on trifaces and faces. They are //
1036 // introduced below. //
1037 // //
1039 
1040  class triface {
1041 
1042  public:
1043 
1045  int loc, ver;
1046 
1047  // Constructors;
1048  triface() : tet(0), loc(0), ver(0) {}
1049  // Operators;
1051  tet = t.tet; loc = t.loc; ver = t.ver;
1052  return *this;
1053  }
1055  return tet == t.tet && loc == t.loc && ver == t.ver;
1056  }
1058  return tet != t.tet || loc != t.loc || ver != t.ver;
1059  }
1060  };
1061 
1062  class face {
1063 
1064  public:
1065 
1067  int shver;
1068 
1069  // Constructors;
1070  face() : sh(0), shver(0) {}
1071  // Operators;
1072  face& operator=(const face& s) {
1073  sh = s.sh; shver = s.shver;
1074  return *this;
1075  }
1076  bool operator==(face& s) {return (sh == s.sh) && (shver == s.shver);}
1077  bool operator!=(face& s) {return (sh != s.sh) || (shver != s.shver);}
1078  };
1079 
1081 // //
1082 // The badface structure //
1083 // //
1084 // A multiple usages structure. Despite of its name, a 'badface' can be used //
1085 // to represent the following objects: //
1086 // - a face of a tetrahedron which is (possibly) non-Delaunay; //
1087 // - an encroached subsegment or subface; //
1088 // - a bad-quality tetrahedron, i.e, has too large radius-edge ratio; //
1089 // - a sliver, i.e., has good radius-edge ratio but nearly zero volume; //
1090 // - a degenerate tetrahedron (see routine checkdegetet()). //
1091 // - a recently flipped face (saved for undoing the flip later). //
1092 // //
1093 // It has the following fields: 'tt' holds a tetrahedron; 'ss' holds a sub- //
1094 // segment or subface; 'cent' is the circumcent of 'tt' or 'ss', 'key' is a //
1095 // special value depending on the use, it can be either the square of the //
1096 // radius-edge ratio of 'tt' or the flipped type of 'tt'; 'forg', 'fdest', //
1097 // 'fapex', and 'foppo' are vertices saved for checking the object in 'tt' //
1098 // or 'ss' is still the same when it was stored; 'noppo' is the fifth vertex //
1099 // of a degenerate point set. 'previtem' and 'nextitem' implement a double //
1100 // link for managing many basfaces. //
1101 // //
1103 
1104  struct badface {
1112  };
1113 
1115 // //
1116 // Elementary flip data structure //
1117 // //
1118 // A data structure to record three types of elementary flips, which are //
1119 // 2-to-3, 3-to-2, and 2-to-2 flips. //
1120 // //
1122 
1123  class elemflip {
1124 
1125  public:
1126 
1127  enum fliptype ft; // ft \in {T23, T32, T22}.
1130 
1132  ft = T23; // Default.
1133  pset1[0] = pset1[1] = pset1[2] = (point) NULL;
1134  pset2[0] = pset2[1] = pset2[2] = (point) NULL;
1135  }
1136 
1137  };
1138 
1140 // //
1141 // The pbcdata structure //
1142 // //
1143 // A pbcdata stores data of a periodic boundary condition defined on a pair //
1144 // of facets or segments. Let f1 and f2 define a pbcgroup. 'fmark' saves the //
1145 // facet markers of f1 and f2; 'ss' contains two subfaces belong to f1 and //
1146 // f2, respectively. Let s1 and s2 define a segment pbcgroup. 'segid' are //
1147 // the segment ids of s1 and s2; 'ss' contains two segments belong to s1 and //
1148 // s2, respectively. 'transmat' are two transformation matrices. transmat[0] //
1149 // transforms a point of f1 (or s1) into a point of f2 (or s2), transmat[1] //
1150 // does the inverse. //
1151 // //
1153 
1154  struct pbcdata {
1155  int fmark[2];
1156  int segid[2];
1157  face ss[2];
1158  REAL transmat[2][4][4];
1159  };
1160 
1162 // //
1163 // Fast lookup tables for mesh manipulation primitives. //
1164 // //
1165 // Mesh manipulation primitives (given below) are basic operations on mesh //
1166 // data structures. They answer basic queries on mesh handles, such as "what //
1167 // is the origin (or destination, or apex) of the face?", "what is the next //
1168 // (or previous) edge in the edge ring?", and "what is the next face in the //
1169 // face ring?", and so on. //
1170 // //
1171 // The implementation of teste basic queries can take advangtage of the fact //
1172 // that the mesh data structures additionally store geometric informations. //
1173 // For example, we have ordered the 4 vertices (from 0 to 3) and the 4 faces //
1174 // (from 0 to 3) of a tetrahedron, and for each face of the tetrahedron, a //
1175 // sequence of vertices has stipulated, therefore the origin of any face of //
1176 // the tetrahedron can be quickly determined by a table 'locver2org', which //
1177 // takes the index of the face and the edge version as inputs. A list of //
1178 // fast lookup tables are defined below. They're just like global variables. //
1179 // These tables are initialized at the runtime. //
1180 // //
1182 
1183  // For enext() primitive, uses 'ver' as the index.
1184  static int ve[6];
1185 
1186  // For org(), dest() and apex() primitives, uses 'ver' as the index.
1187  static int vo[6], vd[6], va[6];
1188 
1189  // For org(), dest() and apex() primitives, uses 'loc' as the first
1190  // index and 'ver' as the second index.
1191  static int locver2org[4][6];
1192  static int locver2dest[4][6];
1193  static int locver2apex[4][6];
1194 
1195  // For oppo() primitives, uses 'loc' as the index.
1196  static int loc2oppo[4];
1197 
1198  // For fnext() primitives, uses 'loc' as the first index and 'ver' as
1199  // the second index, returns an array containing a new 'loc' and a
1200  // new 'ver'. Note: Only valid for 'ver' equals one of {0, 2, 4}.
1201  static int locver2nextf[4][6][2];
1202 
1203  // The edge number (from 0 to 5) of a tet is defined as follows:
1204  static int locver2edge[4][6];
1205  static int edge2locver[6][2];
1206 
1207  // The map from a given face ('loc') to the other three faces in the tet.
1208  // and the map from a given face's edge ('loc', 'ver') to other two
1209  // faces in the tet opposite to this edge. (used in speeding the Bowyer-
1210  // Watson cavity construction).
1211  static int locpivot[4][3];
1212  static int locverpivot[4][6][2];
1213 
1214  // For enumerating three edges of a triangle.
1215  static int plus1mod3[3];
1216  static int minus1mod3[3];
1217 
1219 // //
1220 // Mesh manipulation primitives //
1221 // //
1222 // A serial of mesh operations such as topological maintenance, navigation, //
1223 // local modification, etc., is accomplished through a set of mesh manipul- //
1224 // ation primitives. These primitives are indeed very simple functions which //
1225 // take one or two handles ('triface's and 'face's) as parameters, perform //
1226 // basic operations such as "glue two tetrahedra at a face", "return the //
1227 // origin of a tetrahedron", "return the subface adjoining at the face of a //
1228 // tetrahedron", and so on. //
1229 // //
1231 
1232  // Primitives for tetrahedra.
1233  inline void decode(tetrahedron ptr, triface& t);
1234  inline tetrahedron encode(triface& t);
1235  inline void sym(triface& t1, triface& t2);
1236  inline void symself(triface& t);
1237  inline void bond(triface& t1, triface& t2);
1238  inline void dissolve(triface& t);
1239  inline point org(triface& t);
1240  inline point dest(triface& t);
1241  inline point apex(triface& t);
1242  inline point oppo(triface& t);
1243  inline void setorg(triface& t, point pointptr);
1244  inline void setdest(triface& t, point pointptr);
1245  inline void setapex(triface& t, point pointptr);
1246  inline void setoppo(triface& t, point pointptr);
1247  inline void esym(triface& t1, triface& t2);
1248  inline void esymself(triface& t);
1249  inline void enext(triface& t1, triface& t2);
1250  inline void enextself(triface& t);
1251  inline void enext2(triface& t1, triface& t2);
1252  inline void enext2self(triface& t);
1253  inline bool fnext(triface& t1, triface& t2);
1254  inline bool fnextself(triface& t);
1255  inline void symedge(triface& t1, triface& t2);
1256  inline void symedgeself(triface& t);
1257  inline void tfnext(triface& t1, triface& t2);
1258  inline void tfnextself(triface& t);
1259  inline void enextfnext(triface& t1, triface& t2);
1260  inline void enextfnextself(triface& t);
1261  inline void enext2fnext(triface& t1, triface& t2);
1262  inline void enext2fnextself(triface& t);
1263  inline REAL elemattribute(tetrahedron* ptr, int attnum);
1264  inline void setelemattribute(tetrahedron* ptr, int attnum, REAL value);
1265  inline REAL volumebound(tetrahedron* ptr);
1266  inline void setvolumebound(tetrahedron* ptr, REAL value);
1267  inline int getelemmarker(tetrahedron* ptr);
1268  inline void setelemmarker(tetrahedron* ptr, int value);
1269  inline void infect(triface& t);
1270  inline void uninfect(triface& t);
1271  inline bool infected(triface& t);
1272  inline void marktest(triface& t);
1273  inline void unmarktest(triface& t);
1274  inline bool marktested(triface& t);
1275  inline void markface(triface& t);
1276  inline void unmarkface(triface& t);
1277  inline bool facemarked(triface& t);
1278  inline void markedge(triface& t);
1279  inline void unmarkedge(triface& t);
1280  inline bool edgemarked(triface& t);
1281 
1282  // Primitives for subfaces and subsegments.
1283  inline void sdecode(shellface sptr, face& s);
1284  inline shellface sencode(face& s);
1285  inline void spivot(face& s1, face& s2);
1286  inline void spivotself(face& s);
1287  inline void sbond(face& s1, face& s2);
1288  inline void sbond1(face& s1, face& s2);
1289  inline void sdissolve(face& s);
1290  inline point sorg(face& s);
1291  inline point sdest(face& s);
1292  inline point sapex(face& s);
1293  inline void setsorg(face& s, point pointptr);
1294  inline void setsdest(face& s, point pointptr);
1295  inline void setsapex(face& s, point pointptr);
1296  inline void sesym(face& s1, face& s2);
1297  inline void sesymself(face& s);
1298  inline void senext(face& s1, face& s2);
1299  inline void senextself(face& s);
1300  inline void senext2(face& s1, face& s2);
1301  inline void senext2self(face& s);
1302  inline void sfnext(face&, face&);
1303  inline void sfnextself(face&);
1304  inline badface* shell2badface(face& s);
1305  inline void setshell2badface(face& s, badface* value);
1306  inline REAL areabound(face& s);
1307  inline void setareabound(face& s, REAL value);
1308  inline int shellmark(face& s);
1309  inline void setshellmark(face& s, int value);
1310  inline enum shestype shelltype(face& s);
1311  inline void setshelltype(face& s, enum shestype value);
1312  inline int shellpbcgroup(face& s);
1313  inline void setshellpbcgroup(face& s, int value);
1314  inline void sinfect(face& s);
1315  inline void suninfect(face& s);
1316  inline bool sinfected(face& s);
1317 
1318  // Primitives for interacting tetrahedra and subfaces.
1319  inline void tspivot(triface& t, face& s);
1320  inline void stpivot(face& s, triface& t);
1321  inline void tsbond(triface& t, face& s);
1322  inline void tsdissolve(triface& t);
1323  inline void stdissolve(face& s);
1324 
1325  // Primitives for interacting subfaces and subsegs.
1326  inline void sspivot(face& s, face& edge);
1327  inline void ssbond(face& s, face& edge);
1328  inline void ssdissolve(face& s);
1329 
1330  inline void tsspivot1(triface& t, face& seg);
1331  inline void tssbond1(triface& t, face& seg);
1332  inline void tssdissolve1(triface& t);
1333 
1334  // Primitives for points.
1335  inline int pointmark(point pt);
1336  inline void setpointmark(point pt, int value);
1337  inline enum verttype pointtype(point pt);
1338  inline void setpointtype(point pt, enum verttype value);
1339  inline void pinfect(point pt);
1340  inline void puninfect(point pt);
1341  inline bool pinfected(point pt);
1342  inline tetrahedron point2tet(point pt);
1343  inline void setpoint2tet(point pt, tetrahedron value);
1344  inline shellface point2sh(point pt);
1345  inline void setpoint2sh(point pt, shellface value);
1346  inline shellface point2seg(point pt);
1347  inline void setpoint2seg(point pt, shellface value);
1348  inline point point2ppt(point pt);
1349  inline void setpoint2ppt(point pt, point value);
1350  inline tetrahedron point2bgmtet(point pt);
1351  inline void setpoint2bgmtet(point pt, tetrahedron value);
1352  inline point point2pbcpt(point pt);
1353  inline void setpoint2pbcpt(point pt, point value);
1354 
1355  // Advanced primitives.
1356  inline void adjustedgering(triface& t, int direction);
1357  inline void adjustedgering(face& s, int direction);
1358  inline bool isdead(triface* t);
1359  inline bool isdead(face* s);
1360  inline bool isfacehaspoint(triface* t, point testpoint);
1361  inline bool isfacehaspoint(face* t, point testpoint);
1362  inline bool isfacehasedge(face* s, point tend1, point tend2);
1363  inline bool issymexist(triface* t);
1370  bool findorg(triface* t, point dorg);
1371  bool findorg(face* s, point dorg);
1372  void findedge(triface* t, point eorg, point edest);
1373  void findedge(face* s, point eorg, point edest);
1374  void getonextseg(face* s, face* lseg);
1375  void getseghasorg(face* sseg, point dorg);
1379  void printsh(face*);
1380 
1382 // //
1383 // Arraypool //
1384 // //
1385 // Each arraypool contains an array of pointers to a number of blocks. Each //
1386 // block contains the same fixed number of objects. Each index of the array //
1387 // addesses a particular object in the pool. The most significant bits add- //
1388 // ress the index of the block containing the object. The less significant //
1389 // bits address this object within the block. //
1390 // //
1391 // 'objectbytes' is the size of one object in blocks; 'log2objectsperblock' //
1392 // is the base-2 logarithm of 'objectsperblock'; 'objects' counts the number //
1393 // of allocated objects; 'totalmemory' is the totoal memorypool in bytes. //
1394 // //
1396 
1397  class arraypool {
1398 
1399  public:
1400 
1405  char **toparray;
1406  long objects;
1407  unsigned long totalmemory;
1408 
1409  void restart();
1410  void poolinit(int sizeofobject, int log2objperblk);
1411  char* getblock(int objectindex);
1412  void* lookup(int objectindex);
1413  int newindex(void **newptr);
1414 
1415  arraypool(int sizeofobject, int log2objperblk);
1417  };
1418 
1419 // fastlookup() -- A fast, unsafe operation. Return the pointer to the object
1420 // with a given index. Note: The object's block must have been allocated,
1421 // i.e., by the function newindex().
1422 
1423 #define fastlookup(pool, index) \
1424  (void *) ((pool)->toparray[(index) >> (pool)->log2objectsperblock] + \
1425  ((index) & ((pool)->objectsperblock - 1)) * (pool)->objectbytes)
1426 
1427 
1428 // A function: int cmp(const T &, const T &), is said to realize a
1429 // linear order on the type T if there is a linear order <= on T such
1430 // that for all x and y in T satisfy the following relation:
1431 // -1 if x < y.
1432 // comp(x, y) = 0 if x is equivalent to y.
1433 // +1 if x > y.
1434 // A 'compfunc' is a pointer to a linear-order function.
1435 
1436  typedef int (*compfunc) (const void *, const void *);
1437 
1439 // //
1440 // List //
1441 // //
1442 // An array of items with automatically reallocation of memory. //
1443 // //
1444 // 'base' is the starting address of the array. 'itembytes' is the size of //
1445 // each item in byte. //
1446 // //
1447 // 'items' is the number of items stored in list. 'maxitems' indicates how //
1448 // many items can be stored in this list. 'expandsize' is the increasing //
1449 // size (items) when the list is full. //
1450 // //
1451 // The index of list always starts from zero, i.e., for a list L contains //
1452 // n elements, the first element is L[0], and the last element is L[n-1]. //
1453 // //
1455 
1456  class list {
1457 
1458  public:
1459 
1460  char *base;
1464 
1465  list(int itbytes, compfunc pcomp, int mitems = 256, int exsize = 128) {
1466  listinit(itbytes, pcomp, mitems, exsize);
1467  }
1468  ~list() { free(base); }
1469 
1470  void *operator[](int i) { return (void *) (base + i * itembytes); }
1471 
1472  void listinit(int itbytes, compfunc pcomp, int mitems, int exsize);
1473  void setcomp(compfunc compf) { comp = compf; }
1474  void clear() { items = 0; }
1475  int len() { return items; }
1476  void *append(void* appitem);
1477  void *insert(int pos, void* insitem);
1478  void del(int pos, int order);
1479  int hasitem(void* checkitem);
1480  };
1481 
1483 // //
1484 // Memorypool //
1485 // //
1486 // A type used to allocate memory. //
1487 // //
1488 // firstblock is the first block of items. nowblock is the block from which //
1489 // items are currently being allocated. nextitem points to the next slab //
1490 // of free memory for an item. deaditemstack is the head of a linked list //
1491 // (stack) of deallocated items that can be recycled. unallocateditems is //
1492 // the number of items that remain to be allocated from nowblock. //
1493 // //
1494 // Traversal is the process of walking through the entire list of items, and //
1495 // is separate from allocation. Note that a traversal will visit items on //
1496 // the "deaditemstack" stack as well as live items. pathblock points to //
1497 // the block currently being traversed. pathitem points to the next item //
1498 // to be traversed. pathitemsleft is the number of items that remain to //
1499 // be traversed in pathblock. //
1500 // //
1501 // itemwordtype is set to POINTER or FLOATINGPOINT, and is used to suggest //
1502 // what sort of word the record is primarily made up of. alignbytes //
1503 // determines how new records should be aligned in memory. itembytes and //
1504 // itemwords are the length of a record in bytes (after rounding up) and //
1505 // words. itemsperblock is the number of items allocated at once in a //
1506 // single block. items is the number of currently allocated items. //
1507 // maxitems is the maximum number of items that have been allocated at //
1508 // once; it is the current number of items plus the number of records kept //
1509 // on deaditemstack. //
1510 // //
1512 
1513  class memorypool {
1514 
1515  public:
1516 
1518  void *nextitem;
1520  void **pathblock;
1521  void *pathitem;
1529 
1531  memorypool(int, int, enum wordtype, int);
1533 
1534  void poolinit(int, int, enum wordtype, int);
1535  void restart();
1536  void *alloc();
1537  void dealloc(void*);
1539  void *traverse();
1540  };
1541 
1543 // //
1544 // Queue //
1545 // //
1546 // A 'queue' is a FIFO data structure. //
1547 // //
1549 
1550  class queue : public memorypool {
1551 
1552  public:
1553 
1554  void **head, **tail;
1556  int linkitems; // Not count 'head' and 'tail'.
1557 
1558  queue(int bytecount, int itemcount = 256) {
1559  linkitembytes = bytecount;
1560  poolinit(bytecount + sizeof(void *), itemcount, POINTER, 0);
1561  head = (void **) alloc();
1562  tail = (void **) alloc();
1563  *head = (void *) tail;
1564  *tail = NULL;
1565  linkitems = 0;
1566  }
1567 
1568  void clear() {
1569  // Reset the pool.
1570  restart();
1571  // Initialize all variables.
1572  head = (void **) alloc();
1573  tail = (void **) alloc();
1574  *head = (void *) tail;
1575  *tail = NULL;
1576  linkitems = 0;
1577  }
1578 
1579  long len() { return linkitems; }
1580  bool empty() { return linkitems == 0; }
1581 
1582  void *push(void* newitem) {
1583  void **newnode = tail;
1584  if (newitem != (void *) NULL) {
1585  memcpy((void *)(newnode + 1), newitem, linkitembytes);
1586  }
1587  tail = (void **) alloc();
1588  *tail = NULL;
1589  *newnode = (void *) tail;
1590  linkitems++;
1591  return (void *)(newnode + 1);
1592  }
1593 
1594  void *pop() {
1595  if (linkitems > 0) {
1596  void **deadnode = (void **) *head;
1597  *head = *deadnode;
1598  dealloc((void *) deadnode);
1599  linkitems--;
1600  return (void *)(deadnode + 1);
1601  } else {
1602  return NULL;
1603  }
1604  }
1605  };
1606 
1608 // //
1609 // Memory managment routines //
1610 // //
1612 
1613  void dummyinit(int, int);
1626 
1630  void makesegmentmap(int*&, shellface**&);
1631  void makesubfacemap(int*&, shellface**&);
1633 
1635 // //
1636 // Geometric functions //
1637 // //
1639 
1640  // PI is the ratio of a circle's circumference to its diameter.
1641  static REAL PI;
1642 
1643  // Triangle-triangle intersection test
1649  REAL, REAL);
1650  enum interresult tri_edge_inter(REAL*, REAL*, REAL*, REAL*, REAL*);
1651  enum interresult tri_tri_inter(REAL*, REAL*, REAL*, REAL*, REAL*, REAL*);
1652  int tri_edge_2d(point, point, point, point, point, point, int, int*, int*);
1653  int tri_edge_test(point, point, point, point, point, point, int, int*, int*);
1654 
1655  // Geometric tests
1659  bool iscoplanar(REAL*, REAL*, REAL*, REAL*, REAL vol6, REAL eps);
1660  bool iscospheric(REAL*, REAL*, REAL*, REAL*, REAL*, REAL vol24, REAL eps);
1661 
1662  // Linear algebra functions
1663  inline REAL dot(REAL* v1, REAL* v2);
1664  inline void cross(REAL* v1, REAL* v2, REAL* n);
1665  bool lu_decmp(REAL lu[4][4], int n, int* ps, REAL* d, int N);
1666  void lu_solve(REAL lu[4][4], int n, int* ps, REAL* b, int N);
1667 
1668  // Geometric calculations
1669  inline REAL distance(REAL* p1, REAL* p2);
1671  REAL shortdistance(REAL* p, REAL* e1, REAL* e2, REAL* e3);
1673  void projpt2edge(REAL* p, REAL* e1, REAL* e2, REAL* prj);
1674  void projpt2face(REAL* p, REAL* f1, REAL* f2, REAL* f3, REAL* prj);
1675  void facenormal(REAL* pa, REAL* pb, REAL* pc, REAL* n, REAL* nlen);
1676  void facenormal2(point pa, point pb, point pc, REAL *n, int pivot);
1677  void edgeorthonormal(REAL* e1, REAL* e2, REAL* op, REAL* n);
1680  void tetallnormal(point, point, point, point, REAL N[4][3], REAL* volume);
1682  bool circumsphere(REAL*, REAL*, REAL*, REAL*, REAL* cent, REAL* radius);
1684  void rotatepoint(REAL* p, REAL rotangle, REAL* p1, REAL* p2);
1685  void planelineint(REAL*, REAL*, REAL*, REAL*, REAL*, REAL*, REAL*);
1686 
1687  // Point location routines.
1688  unsigned long randomnation(unsigned int choices);
1690  void randomsample(point searchpt, triface *searchtet);
1691  enum locateresult locate(point searchpt, triface* searchtet);
1692  enum locateresult locate2(point searchpt, triface* searchtet, arraypool*);
1693  enum locateresult preciselocate(point searchpt, triface* searchtet, long);
1695  enum locateresult hullwalk(point searchpt, triface* hulltet);
1696  enum locateresult locatesub(point searchpt, face* searchsh, int, REAL);
1698  enum locateresult locateseg(point searchpt, face* searchseg);
1700 
1702 // //
1703 // Mesh update functions //
1704 // //
1706 
1713  long lawson3d(queue* flipqueue);
1714  long lawson(queue* flipqueue);
1715 
1718  bool removeedgebyflip22(REAL *key, int, triface*, queue*);
1722 
1728 
1729  void formstarpolyhedron(point pt, list* tetlist, list* verlist, bool);
1733  void formbowatcavity(point bp, face* bpseg, face* bpsh, int* n, int* nmax,
1734  list** sublists, list** subceillists, list** tetlists,
1735  list** ceillists);
1736  void releasebowatcavity(face*, int, list**, list**, list**, list**);
1737  bool validatebowatcavityquad(point bp, list* ceillist, REAL maxcosd);
1738  void updatebowatcavityquad(list* tetlist, list* ceillist);
1739  void updatebowatcavitysub(list* sublist, list* subceillist, int* cutcount);
1740  bool trimbowatcavity(point bp, face* bpseg, int n, list** sublists,
1741  list** subceillists, list** tetlists,list** ceillists,
1742  REAL maxcosd);
1743  void bowatinsertsite(point bp, face* splitseg, int n, list** sublists,
1744  list** subceillists, list** tetlists, list** ceillists,
1745  list* verlist, queue* flipque, bool chkencseg,
1746  bool chkencsub, bool chkbadtet);
1747 
1749 // //
1750 // Delaunay tetrahedralization functions //
1751 // //
1753 
1754  // Point sorting routines.
1755  void btree_sort(point*, int, int, REAL, REAL, REAL, REAL, REAL, REAL, int);
1756  void btree_insert(point insertpt);
1757  void btree_search(point searchpt, triface* searchtet);
1758  void ordervertices(point* vertexarray, int arraysize);
1759 
1760  enum locateresult insertvertexbw(point insertpt, triface *searchtet,
1761  bool bwflag, bool visflag,
1762  bool noencsegflag, bool noencsubflag);
1763  bool unifypoint(point testpt, triface*, enum locateresult, REAL);
1764  bool incrflipdelaunay(triface*, point*, long, bool, bool, REAL, queue*);
1766 
1768 // //
1769 // Surface triangulation functions //
1770 // //
1772 
1773  enum locateresult sinsertvertex(point insertpt, face *splitsh,face *splitseg,
1774  bool bwflag, bool cflag);
1775  void formstarpolygon(point pt, list* trilist, list* verlist);
1776  void getfacetabovepoint(face* facetsh);
1777  bool incrflipdelaunaysub(int shmark, REAL eps, list*, int, REAL*, queue*);
1778  enum finddirectionresult finddirectionsub(face* searchsh, point tend);
1780  bool scoutsegmentsub(face* searchsh, point tend);
1781  void flipedgerecursive(face* flipedge, queue* flipqueue);
1782  void constrainededge(face* startsh, point tend, queue* flipqueue);
1783  void recoversegment(point tstart, point tend, queue* flipqueue);
1785  void plaguesub(memorypool* viri);
1786  void carveholessub(int holes, REAL* holelist, memorypool* viri);
1787  void triangulate(int shmark, REAL eps, list* ptlist, list* conlist,int holes,
1788  REAL* holelist, memorypool* viri, queue*);
1789  void retrievenewsubs(list* newshlist, bool removeseg);
1792  void mergefacets(queue* flipqueue);
1793  long meshsurface();
1794 
1795  // Detect intersecting facets of PLC.
1796  void interecursive(shellface** subfacearray, int arraysize, int axis,
1797  REAL bxmin, REAL bxmax, REAL bymin, REAL bymax,
1798  REAL bzmin, REAL bzmax, int* internum);
1800 
1802 // //
1803 // Constrained Delaunay tetrahedralization functions //
1804 // //
1806 
1807  // Segment recovery routines.
1808  void markacutevertices(REAL acuteangle);
1809  enum finddirectionresult finddirection(triface* searchtet, point, long);
1810  enum interresult finddirection2(triface* searchtet, point);
1811  enum interresult finddirection3(triface* searchtet, point);
1813  void getsegmentsplitpoint2(face* sseg, point refpt, REAL* vt);
1814  void getsegmentsplitpoint3(face* sseg, point refpt, REAL* vt);
1816 
1817  // Facets recovery routines.
1818  enum interresult scoutsubface(face* ssub, triface* searchtet, int);
1819  enum interresult scoutcrosstet(face* ssub, triface* searchtet, arraypool*);
1820  void recoversubfacebyflips(face* pssub, triface* crossface, arraypool*);
1824  arraypool*, arraypool*);
1830 
1831  void formskeleton(clock_t&);
1832 
1833  // Carving out holes and concavities routines.
1834  void infecthull(memorypool *viri);
1835  void plague(memorypool *viri);
1836  void regionplague(memorypool *viri, REAL attribute, REAL volume);
1839  void carveholes();
1840 
1842 // //
1843 // Steiner points removal functions //
1844 // //
1846 
1847  void initializecavity(list* floorlist, list* ceillist, list* frontlist,
1848  list* ptlist, list* gluelist);
1850  void retrievenewtets(list* newtetlist);
1851  void insertauxsubface(triface* front, triface* idfront);
1852  bool scoutfront(triface* front, triface* idfront);
1853  void gluefronts(triface* front, triface* front1, list* gluetetlist,
1854  list* glueshlist);
1855  bool identifyfronts(list* frontlist,list* misfrontlist,list* gluetetlist,
1856  list* glueshlist);
1857  void detachauxsubfaces(list* newtetlist);
1858  bool carvecavity(list* newtetlist, list* outtetlist, list* gluetetlist,
1859  queue* flipque);
1860 
1861  void replacepolygonsubs(list* oldshlist, list* newshlist);
1862  void orientnewsubs(list* newshlist, face* orientsh, REAL* norm);
1863  bool registerelemflip(enum fliptype ft, point pa1, point pb1, point pc1,
1864  point pa2, point pb2, point pc2);
1866  bool removeedgebyflips(triface* remedge, int*);
1867  bool removefacebyflips(triface* remface, int*);
1868  bool recoveredgebyflips(triface* searchtet, point pb, int*);
1869  bool recoverfacebyflips(triface* front, int*);
1870  bool constrainedcavity(triface* oldtet, list* floorlist, list* ceillist,
1871  list* ptlist, list* frontlist, list* misfrontlist,
1872  list* newtetlist, list* gluetetlist, list* glueshlist,
1873  queue* flipque);
1875  bool relocatepoint(point steinpt, triface* oldtet, list*, list*, queue*);
1876  bool findcollapseedge(point suppt, point* conpt, list* oldtetlist, list*);
1877  void collapseedge(point suppt, point conpt, list* oldtetlist, list*);
1878  void deallocfaketets(list* frontlist);
1879  void restorepolyhedron(list* oldtetlist);
1880  bool suppressfacetpoint(face* supsh, list* frontlist, list* misfrontlist,
1881  list* ptlist, list* conlist, memorypool* viri,
1882  queue* flipque, bool noreloc, bool optflag);
1883  bool suppresssegpoint(face* supseg, list* spinshlist, list* newsegshlist,
1884  list* frontlist, list* misfrontlist, list* ptlist,
1885  list* conlist, memorypool* viri, queue* flipque,
1886  bool noreloc, bool optflag);
1887  bool suppressvolpoint(triface* suptet, list* frontlist, list* misfrontlist,
1888  list* ptlist, queue* flipque, bool optflag);
1890 
1892 // //
1893 // Mesh rebuild functions //
1894 // //
1896 
1900  bool p1interpolatebgm(point pt, triface* bgmtet, long *scount);
1903 
1905 // //
1906 // Mesh refinement functions //
1907 // //
1909 
1910  void marksharpsegments(REAL sharpangle);
1912  void enqueueencsub(face* ss, point encpt, int quenumber, REAL* cent);
1913  badface* dequeueencsub(int* quenumber);
1914  void enqueuebadtet(triface* tt, REAL key, REAL* cent);
1917  bool checkseg4encroach(face* testseg, point testpt, point*, bool enqflag);
1918  bool checksub4encroach(face* testsub, point testpt, bool enqflag);
1919  bool checktet4badqual(triface* testtet, bool enqflag);
1920  bool acceptsegpt(point segpt, point refpt, face* splitseg);
1921  bool acceptfacpt(point facpt, list* subceillist, list* verlist);
1922  bool acceptvolpt(point volpt, list* ceillist, list* verlist);
1923  void getsplitpoint(point e1, point e2, point refpt, point newpt);
1924  void setnewpointsize(point newpt, point e1, point e2);
1925  bool splitencseg(point, face*, list*, list*, list*,queue*,bool,bool,bool);
1926  bool tallencsegs(point testpt, int n, list** ceillists);
1927  bool tallencsubs(point testpt, int n, list** ceillists);
1929  void repairencsegs(bool chkencsub, bool chkbadtet);
1930  void repairencsubs(bool chkbadtet);
1933 
1935 // //
1936 // Mesh optimization routines //
1937 // //
1939 
1940  bool checktet4ill(triface* testtet, bool enqflag);
1941  bool checktet4opt(triface* testtet, bool enqflag);
1942  bool removeedge(badface* remedge, bool optflag);
1943  bool smoothpoint(point smthpt, point, point, list*, bool, REAL*);
1944  bool smoothsliver(badface* remedge, list *starlist);
1945  bool splitsliver(badface* remedge, list *tetlist, list *ceillist);
1946  void tallslivers(bool optflag);
1947  void optimizemesh2(bool optflag);
1948 
1950 // //
1951 // Mesh output functions //
1952 // //
1954 
1956  void highorder();
1957  void numberedges();
1968  void outsmesh(char*);
1969  void outmesh2medit(char*);
1970  void outmesh2gid(char*);
1971  void outmesh2off(char*);
1972  void outmesh2vtk(char*);
1973 
1975 // //
1976 // Mesh check functions //
1977 // //
1979 
1980  int checkmesh();
1987  void statistics();
1988 
1990 // //
1991 // Debug functions //
1992 // //
1994  /*
1995  void ptet(triface* t);
1996  void psh(face* s);
1997  int pteti(int i, int j, int k, int l);
1998  void pface(int i, int j, int k);
1999  bool pedge(int i, int j);
2000  int psubface(int i, int j, int k);
2001  void psubseg(int i, int j);
2002  int pmark(point p);
2003  void pvert(point p);
2004  int pverti(int i);
2005  REAL test_orient3d(int i, int j, int k, int l);
2006  REAL test_insphere(int i, int j, int k, int l, int m);
2007  REAL test_insphere_s(int i, int j, int k, int l, int m);
2008  void print_tetarray(arraypool* tetarray);
2009  void print_tetlist(list* tetlist);
2010  void print_facearray(arraypool* facearray);
2011  void print_facelist(list* facelist);
2012  void print_subfacearray(arraypool* subfacearray);
2013  void print_subfacelist(list* subfacelist);
2014  void dump_facetof(face* pssub);
2015  void print_fliptetlist(triface *fliptet);
2016  void print_deaditemstack(void* deaditemstack);
2017  int check_deaditemstack(void* deaditemstack, uintptr_t addr);
2018  void print_abtetlist(triface *abtetlist, int len);
2019  int checkpoint2tetmap();
2020  int checkpoint2submap();
2021  int checkpoint2segmap();
2022  */
2024 // //
2025 // Class variables //
2026 // //
2028 
2029  // Pointer to the input data (a set of nodes, a PLC, or a mesh).
2031 
2032  // Pointer to the options (and filenames).
2034 
2035  // Pointer to a background mesh (contains size specification map).
2037 
2038  // Variables used to allocate and access memory for tetrahedra, subfaces
2039  // subsegments, points, encroached subfaces, encroached subsegments,
2040  // bad-quality tetrahedra, and so on.
2049 
2050  // Pointer to the 'tetrahedron' that occupies all of "outer space".
2052  tetrahedron *dummytetbase; // Keep base address so we can free it later.
2053 
2054  // Pointer to the omnipresent subface. Referenced by any tetrahedron,
2055  // or subface that isn't connected to a subface at that location.
2057  shellface *dummyshbase; // Keep base address so we can free it later.
2058 
2059  // Entry to find the binary tree nodes (-u option).
2061  // The maximum size of a btree node (number after -u option) is
2062  int max_btreenode_size; // <= b->max_btreenode_size.
2063  // The maximum btree depth (for bookkeeping).
2065 
2066  // Arrays used by Bowyer-Watson algorithm.
2069  // Stacks used by the boundary recovery algorithm.
2071 
2072  // Two handles used in constrained facet recovery.
2074 
2075  // An array for registering elementary flips.
2077 
2078  // An array of fixed edges for facet recovering by flips.
2080 
2081  // A point above the plane in which the facet currently being used lies.
2082  // It is used as a reference point for orient3d().
2084 
2085  // Array (size = numberoftetrahedra * 6) for storing high-order nodes of
2086  // tetrahedra (only used when -o2 switch is selected).
2088 
2089  // Arrays for storing and searching pbc data. 'subpbcgrouptable', (size
2090  // is numberofpbcgroups) for pbcgroup of subfaces. 'segpbcgrouptable',
2091  // a list for pbcgroup of segments. Because a segment can have several
2092  // pbcgroup incident on it, its size is unknown on input, it will be
2093  // found in 'createsegpbcgrouptable()'.
2096  // A map for searching the pbcgroups of a given segment. 'idx2segpglist'
2097  // (size = number of input segments + 1), and 'segpglist'.
2099 
2100  // Queues that maintain the bad (badly-shaped or too large) tetrahedra.
2101  // The tails are pointers to the pointers that have to be filled in to
2102  // enqueue an item. The queues are ordered from 63 (highest priority)
2103  // to 0 (lowest priority).
2106  int nextnonemptyq[64];
2108 
2109  // Pointer to a recently visited tetrahedron. Improves point location
2110  // if proximate points are inserted sequentially.
2112 
2113  REAL xmax, xmin, ymax, ymin, zmax, zmin; // Bounding box of points.
2114  REAL longest; // The longest possible edge length.
2115  REAL lengthlimit; // The limiting length of a new edge.
2116  long hullsize; // Number of faces of convex hull.
2117  long insegments; // Number of input segments.
2118  long meshedges; // Number of output mesh edges.
2119  int steinerleft; // Number of Steiner points not yet used.
2120  int sizeoftensor; // Number of REALs per metric tensor.
2121  int pointmtrindex; // Index to find the metric tensor of a point.
2122  int point2simindex; // Index to find a simplex adjacent to a point.
2123  int pointmarkindex; // Index to find boundary marker of a point.
2124  int point2pbcptindex; // Index to find a pbc point to a point.
2125  int highorderindex; // Index to find extra nodes for highorder elements.
2126  int elemattribindex; // Index to find attributes of a tetrahedron.
2127  int volumeboundindex; // Index to find volume bound of a tetrahedron.
2128  int elemmarkerindex; // Index to find marker of a tetrahedron.
2129  int shmarkindex; // Index to find boundary marker of a subface.
2130  int areaboundindex; // Index to find area bound of a subface.
2131  int checksubfaces; // Are there subfaces in the mesh yet?
2132  int checksubsegs; // Are there subsegs in the mesh yet?
2133  int checkpbcs; // Are there periodic boundary conditions?
2134  int varconstraint; // Are there variant (node, seg, facet) constraints?
2135  int nonconvex; // Is current mesh non-convex?
2136  int dupverts; // Are there duplicated vertices?
2137  int unuverts; // Are there unused vertices?
2138  int relverts; // The number of relocated vertices.
2139  int suprelverts; // The number of suppressed relocated vertices.
2140  int collapverts; // The number of collapsed relocated vertices.
2141  int unsupverts; // The number of unsuppressed vertices.
2142  int smoothsegverts; // The number of smoothed vertices.
2143  int jettisoninverts; // The number of jettisoned input vertices.
2144  long samples; // Number of random samples for point location.
2145  unsigned long randomseed; // Current random number seed.
2146  REAL macheps; // The machine epsilon.
2147  REAL cosmaxdihed, cosmindihed; // The cosine values of max/min dihedral.
2148  REAL minfaceang, minfacetdihed; // The minimum input (dihedral) angles.
2149  int maxcavfaces, maxcavverts; // The size of the largest cavity.
2151 
2152  // Algorithm statistical counters.
2164 
2165  long abovecount; // Number of abovepoints calculation.
2166  long bowatvolcount, bowatsubcount, bowatsegcount; // Bowyer-Watsons.
2167  long updvolcount, updsubcount, updsegcount; // Bow-Wat cavities updates.
2168  long failvolcount, failsubcount, failsegcount; // Bow-Wat fails.
2169  long outbowatcircumcount; // Number of circumcenters outside Bowat-cav.
2170  long r1count, r2count, r3count; // Numbers of edge splitting rules.
2171  long cdtenforcesegpts; // Number of CDT enforcement points.
2172  long rejsegpts, rejsubpts, rejtetpts; // Number of rejected points.
2173  long optcount[10]; // Numbers of various optimizing operations.
2174  long flip23s, flip32s, flip22s, flip44s; // Number of flips performed.
2175 
2177 // //
2178 // Class constructor & destructor //
2179 // //
2181 
2183  {
2184  bgm = (tetgenmesh *) NULL;
2185  in = (tetgenio *) NULL;
2186  b = (tetgenbehavior *) NULL;
2187 
2188  tetrahedrons = (memorypool *) NULL;
2189  subfaces = (memorypool *) NULL;
2190  subsegs = (memorypool *) NULL;
2191  points = (memorypool *) NULL;
2192  badsubsegs = (memorypool *) NULL;
2193  badsubfaces = (memorypool *) NULL;
2194  badtetrahedrons = (memorypool *) NULL;
2195  tet2segpool = NULL;
2196  tet2subpool = NULL;
2197 
2198  dummytet = (tetrahedron *) NULL;
2199  dummytetbase = (tetrahedron *) NULL;
2200  dummysh = (shellface *) NULL;
2201  dummyshbase = (shellface *) NULL;
2202 
2203  facetabovepointarray = (point *) NULL;
2204  abovepoint = (point) NULL;
2205  dummypoint = NULL;
2206  btreenode_list = (arraypool *) NULL;
2207  highordertable = (point *) NULL;
2208  subpbcgrouptable = (pbcdata *) NULL;
2209  segpbcgrouptable = (list *) NULL;
2210  idx2segpglist = (int *) NULL;
2211  segpglist = (int *) NULL;
2212 
2213  cavetetlist = NULL;
2214  cavebdrylist = NULL;
2215  caveoldtetlist = NULL;
2216  caveshlist = caveshbdlist = NULL;
2217  subsegstack = subfacstack = NULL;
2218 
2219  elemfliplist = (arraypool *) NULL;
2220  fixededgelist = (arraypool *) NULL;
2221 
2222  xmax = xmin = ymax = ymin = zmax = zmin = 0.0;
2223  longest = 0.0;
2224  hullsize = 0l;
2225  insegments = 0l;
2226  meshedges = 0l;
2227  pointmtrindex = 0;
2228  pointmarkindex = 0;
2229  point2simindex = 0;
2230  point2pbcptindex = 0;
2231  highorderindex = 0;
2232  elemattribindex = 0;
2233  volumeboundindex = 0;
2234  shmarkindex = 0;
2235  areaboundindex = 0;
2236  checksubfaces = 0;
2237  checksubsegs = 0;
2238  checkpbcs = 0;
2239  varconstraint = 0;
2240  nonconvex = 0;
2241  dupverts = 0;
2242  unuverts = 0;
2243  relverts = 0;
2244  suprelverts = 0;
2245  collapverts = 0;
2246  unsupverts = 0;
2247  jettisoninverts = 0;
2248  samples = 0l;
2249  randomseed = 1l;
2250  macheps = 0.0;
2252  b_steinerflag = false;
2253 
2255  orient3dcount = 0l;
2258  flip22count = 0l;
2259  inserthullcount = 0l;
2262  maxcavsize = maxregionsize = 0l;
2265 
2266  maxcavfaces = maxcavverts = 0;
2267  abovecount = 0l;
2270  outbowatcircumcount = 0l;
2272  r1count = r2count = r3count = 0l;
2273  cdtenforcesegpts = 0l;
2274  rejsegpts = rejsubpts = rejtetpts = 0l;
2275  flip23s = flip32s = flip22s = flip44s = 0l;
2276  } // tetgenmesh()
2277 
2279  {
2280  bgm = (tetgenmesh *) NULL;
2281  in = (tetgenio *) NULL;
2282  b = (tetgenbehavior *) NULL;
2283 
2284  if (tetrahedrons != (memorypool *) NULL) {
2285  delete tetrahedrons;
2286  }
2287  if (subfaces != (memorypool *) NULL) {
2288  delete subfaces;
2289  }
2290  if (subsegs != (memorypool *) NULL) {
2291  delete subsegs;
2292  }
2293  if (points != (memorypool *) NULL) {
2294  delete points;
2295  }
2296  if (tet2segpool != NULL) {
2297  delete tet2segpool;
2298  }
2299  if (tet2subpool != NULL) {
2300  delete tet2subpool;
2301  }
2302  if (dummytetbase != (tetrahedron *) NULL) {
2303  delete [] dummytetbase;
2304  }
2305  if (dummyshbase != (shellface *) NULL) {
2306  delete [] dummyshbase;
2307  }
2308  if (facetabovepointarray != (point *) NULL) {
2309  delete [] facetabovepointarray;
2310  }
2311  if (dummypoint != NULL) {
2312  delete [] dummypoint;
2313  }
2314  if (highordertable != (point *) NULL) {
2315  delete [] highordertable;
2316  }
2317  if (subpbcgrouptable != (pbcdata *) NULL) {
2318  delete [] subpbcgrouptable;
2319  }
2320  if (segpbcgrouptable != (list *) NULL) {
2321  delete segpbcgrouptable;
2322  delete [] idx2segpglist;
2323  delete [] segpglist;
2324  }
2325 
2326  if (cavetetlist != NULL) {
2327  delete cavetetlist;
2328  delete cavebdrylist;
2329  delete caveoldtetlist;
2330  }
2331  if (subsegstack != NULL) {
2332  delete subsegstack;
2333  }
2334  if (subfacstack != NULL) {
2335  delete subfacstack;
2336  }
2337  } // ~tetgenmesh()
2338 
2339 }; // End of class tetgenmesh.
2340 
2342 // //
2343 // tetrahedralize() Interface for using TetGen's library to generate //
2344 // Delaunay tetrahedralizations, constrained Delaunay //
2345 // tetrahedralizations, quality tetrahedral meshes. //
2346 // //
2347 // 'in' is an object of 'tetgenio' which contains a PLC you want to tetrahed-//
2348 // ralize or a previously generated tetrahedral mesh you want to refine. It //
2349 // must not be a NULL. 'out' is another object of 'tetgenio' for storing the //
2350 // generated tetrahedral mesh. It can be a NULL. If so, the output will be //
2351 // saved to file(s). If 'bgmin' != NULL, it contains a background mesh which //
2352 // defines a mesh size distruction function. //
2353 // //
2355 
2357  tetgenio *addin = NULL, tetgenio *bgmin = NULL);
2358 
2359 #ifdef TETLIBRARY
2360 void tetrahedralize(char *switches, tetgenio *in, tetgenio *out,
2361  tetgenio *addin = NULL, tetgenio *bgmin = NULL);
2362 #endif // #ifdef TETLIBRARY
2363 
2365 // //
2366 // terminatetetgen() Terminate TetGen with a given exit code. //
2367 // //
2369 
2370 inline void terminatetetgen(int x)
2371 {
2372 #ifdef TETLIBRARY
2373  throw x;
2374 #else
2375  switch (x) {
2376  case 1: // Out of memory.
2377  printf("Error: Out of memory.\n");
2378  break;
2379  case 2: // Encounter an internal error.
2380  printf(" Please report this bug to sihang@mail.berlios.de. Include\n");
2381  printf(" the message above, your input data set, and the exact\n");
2382  printf(" command line you used to run this program, thank you.\n");
2383  break;
2384  default:
2385  printf("Program stopped.\n");
2386  } // switch (x)
2387  exit(x);
2388 #endif // #ifdef TETLIBRARY
2389 }
2390 
2392 // //
2393 // Geometric predicates //
2394 // //
2395 // Return one of the values +1, 0, and -1 on basic geometric questions such //
2396 // as the orientation of point sets, in-circle, and in-sphere tests. They //
2397 // are basic units for implmenting geometric algorithms. TetGen uses two 3D //
2398 // geometric predicates: the orientation and in-sphere tests. //
2399 // //
2400 // Orientation test: let a, b, c be a sequence of 3 non-collinear points in //
2401 // R^3. They defines a unique hypeplane H. Let H+ and H- be the two spaces //
2402 // separated by H, which are defined as follows (using the left-hand rule): //
2403 // make a fist using your left hand in such a way that your fingers follow //
2404 // the order of a, b and c, then your thumb is pointing to H+. Given any //
2405 // point d in R^3, the orientation test returns +1 if d lies in H+, -1 if d //
2406 // lies in H-, or 0 if d lies on H. //
2407 // //
2408 // In-sphere test: let a, b, c, d be 4 non-coplanar points in R^3. They //
2409 // defines a unique circumsphere S. Given any point e in R^3, the in-sphere //
2410 // test returns +1 if e lies inside S, or -1 if e lies outside S, or 0 if e //
2411 // lies on S. //
2412 // //
2413 // The following routines use arbitrary precision floating-point arithmetic. //
2414 // They are provided by J. R. Schewchuk in public domain (http://www.cs.cmu. //
2415 // edu/~quake/robust.html). The source code are in "predicates.cxx". //
2416 // //
2418 
2422 
2424 // //
2425 // Inline functions of mesh data structures //
2426 // //
2428 
2429 // Some macros for convenience
2430 
2431 #define Div2 >> 1
2432 #define Mod2 & 01
2433 
2434 // NOTE: These bit operators should only be used in macros below.
2435 
2436 // Get orient(Range from 0 to 2) from face version(Range from 0 to 5).
2437 
2438 #define Orient(V) ((V) Div2)
2439 
2440 // Determine edge ring(0 or 1) from face version(Range from 0 to 5).
2441 
2442 #define EdgeRing(V) ((V) Mod2)
2443 
2444 //
2445 // Begin of primitives for tetrahedra
2446 //
2447 
2448 // Each tetrahedron contains four pointers to its neighboring tetrahedra,
2449 // with face indices. To save memory, both information are kept in a
2450 // single pointer. To make this possible, all tetrahedra are aligned to
2451 // eight-byte boundaries, so that the last three bits of each pointer are
2452 // zeros. A face index (in the range 0 to 3) is compressed into the last
2453 // two bits of each pointer by the function 'encode()'. The function
2454 // 'decode()' decodes a pointer, extracting a face index and a pointer to
2455 // the beginning of a tetrahedron.
2456 
2458  t.loc = (int) ((uintptr_t) (ptr) & (uintptr_t) 3);
2459  t.tet = (tetrahedron *) ((uintptr_t) (ptr) & ~(uintptr_t) 7);
2460 }
2461 
2463  return (tetrahedron) ((uintptr_t) t.tet | (uintptr_t) t.loc);
2464 }
2465 
2466 // sym() finds the abutting tetrahedron on the same face.
2467 
2468 inline void tetgenmesh::sym(triface& t1, triface& t2) {
2469  tetrahedron ptr = t1.tet[t1.loc];
2470  decode(ptr, t2);
2471 }
2472 
2474  tetrahedron ptr = t.tet[t.loc];
2475  decode(ptr, t);
2476 }
2477 
2478 // Bond two tetrahedra together at their faces.
2479 
2480 inline void tetgenmesh::bond(triface& t1, triface& t2) {
2481  t1.tet[t1.loc] = encode(t2);
2482  t2.tet[t2.loc] = encode(t1);
2483 }
2484 
2485 // Dissolve a bond (from one side). Note that the other tetrahedron will
2486 // still think it is connected to this tetrahedron. Usually, however,
2487 // the other tetrahedron is being deleted entirely, or bonded to another
2488 // tetrahedron, so it doesn't matter.
2489 
2491  t.tet[t.loc] = (tetrahedron) dummytet;
2492 }
2493 
2494 // These primitives determine or set the origin, destination, apex or
2495 // opposition of a tetrahedron with respect to 'loc' and 'ver'.
2496 
2498  return (point) t.tet[locver2org[t.loc][t.ver] + 4];
2499 }
2500 
2502  return (point) t.tet[locver2dest[t.loc][t.ver] + 4];
2503 }
2504 
2506  return (point) t.tet[locver2apex[t.loc][t.ver] + 4];
2507 }
2508 
2510  return (point) t.tet[loc2oppo[t.loc] + 4];
2511 }
2512 
2513 inline void tetgenmesh::setorg(triface& t, point pointptr) {
2514  t.tet[locver2org[t.loc][t.ver] + 4] = (tetrahedron) pointptr;
2515 }
2516 
2517 inline void tetgenmesh::setdest(triface& t, point pointptr) {
2518  t.tet[locver2dest[t.loc][t.ver] + 4] = (tetrahedron) pointptr;
2519 }
2520 
2521 inline void tetgenmesh::setapex(triface& t, point pointptr) {
2522  t.tet[locver2apex[t.loc][t.ver] + 4] = (tetrahedron) pointptr;
2523 }
2524 
2525 inline void tetgenmesh::setoppo(triface& t, point pointptr) {
2526  t.tet[loc2oppo[t.loc] + 4] = (tetrahedron) pointptr;
2527 }
2528 
2529 // These primitives were drived from Mucke's triangle-edge data structure
2530 // to change face-edge relation in a tetrahedron (esym, enext and enext2)
2531 // or between two tetrahedra (fnext).
2532 
2533 // If e0 = e(i, j), e1 = e(j, i), that is e0 and e1 are the two directions
2534 // of the same undirected edge of a face. e0.sym() = e1 and vice versa.
2535 
2536 inline void tetgenmesh::esym(triface& t1, triface& t2) {
2537  t2.tet = t1.tet;
2538  t2.loc = t1.loc;
2539  t2.ver = t1.ver + (EdgeRing(t1.ver) ? -1 : 1);
2540 }
2541 
2543  t.ver += (EdgeRing(t.ver) ? -1 : 1);
2544 }
2545 
2546 // If e0 and e1 are both in the same edge ring of a face, e1 = e0.enext().
2547 
2548 inline void tetgenmesh::enext(triface& t1, triface& t2) {
2549  t2.tet = t1.tet;
2550  t2.loc = t1.loc;
2551  t2.ver = ve[t1.ver];
2552 }
2553 
2555  t.ver = ve[t.ver];
2556 }
2557 
2558 // enext2() is equal to e2 = e0.enext().enext()
2559 
2560 inline void tetgenmesh::enext2(triface& t1, triface& t2) {
2561  t2.tet = t1.tet;
2562  t2.loc = t1.loc;
2563  t2.ver = ve[ve[t1.ver]];
2564 }
2565 
2567  t.ver = ve[ve[t.ver]];
2568 }
2569 
2570 // If f0 and f1 are both in the same face ring of a face, f1 = f0.fnext().
2571 // If f1 exists, return true. Otherwise, return false, i.e., f0 is a
2572 // boundary or hull face.
2573 
2574 inline bool tetgenmesh::fnext(triface& t1, triface& t2)
2575 {
2576  // Get the next face.
2577  t2.loc = locver2nextf[t1.loc][t1.ver][0];
2578  // Is the next face in the same tet?
2579  if (t2.loc != -1) {
2580  // It's in the same tet. Get the edge version.
2581  t2.ver = locver2nextf[t1.loc][t1.ver][1];
2582  t2.tet = t1.tet;
2583  } else {
2584  // The next face is in the neigbhour of 't1'.
2585  sym(t1, t2);
2586  if (t2.tet != dummytet) {
2587  // Find the corresponding edge in t2.
2588  point torg;
2589  int tloc, tver, i;
2590  t2.ver = 0;
2591  torg = org(t1);
2592  for (i = 0; (i < 3) && (org(t2) != torg); i++) {
2593  enextself(t2);
2594  }
2595  // Go to the next face in t2.
2596  tloc = t2.loc;
2597  tver = t2.ver;
2598  t2.loc = locver2nextf[tloc][tver][0];
2599  t2.ver = locver2nextf[tloc][tver][1];
2600  }
2601  }
2602  return t2.tet != dummytet;
2603 }
2604 
2606 {
2607  triface t2;
2608 
2609  // Get the next face.
2610  t2.loc = locver2nextf[t1.loc][t1.ver][0];
2611  // Is the next face in the same tet?
2612  if (t2.loc != -1) {
2613  // It's in the same tet. Get the edge version.
2614  t2.ver = locver2nextf[t1.loc][t1.ver][1];
2615  t1.loc = t2.loc;
2616  t1.ver = t2.ver;
2617  } else {
2618  // The next face is in the neigbhour of 't1'.
2619  sym(t1, t2);
2620  if (t2.tet != dummytet) {
2621  // Find the corresponding edge in t2.
2622  point torg;
2623  int i;
2624  t2.ver = 0;
2625  torg = org(t1);
2626  for (i = 0; (i < 3) && (org(t2) != torg); i++) {
2627  enextself(t2);
2628  }
2629  t1.loc = locver2nextf[t2.loc][t2.ver][0];
2630  t1.ver = locver2nextf[t2.loc][t2.ver][1];
2631  t1.tet = t2.tet;
2632  }
2633  }
2634  return t2.tet != dummytet;
2635 }
2636 
2637 // Given a face t1, find the face f2 in the adjacent tet. If t2 is not
2638 // a dummytet, then t1 and t2 refer to the same edge. Moreover, t2's
2639 // edge must be in 0th edge ring, e.g., t2.ver is one of {0, 2, 4}.
2640 // No matter what edge version t1 is.
2641 
2642 inline void tetgenmesh::symedge(triface& t1, triface& t2)
2643 {
2644  decode(t1.tet[t1.loc], t2);
2645  if (t2.tet != dummytet) {
2646  // Search the edge of t1 in t2.
2647  point tapex = apex(t1);
2648  if ((point) (t2.tet[locver2apex[t2.loc][0] + 4]) == tapex) {
2649  t2.ver = 0;
2650  } else if ((point) (t2.tet[locver2apex[t2.loc][2] + 4]) == tapex) {
2651  t2.ver = 2;
2652  } else {
2653  assert((point) (t2.tet[locver2apex[t2.loc][4] + 4]) == tapex);
2654  t2.ver = 4;
2655  }
2656  }
2657 }
2658 
2660 {
2661  tetrahedron ptr;
2662  point tapex;
2663 
2664  ptr = t.tet[t.loc];
2665  tapex = apex(t);
2666 
2667  decode(ptr, t);
2668  if (t.tet != dummytet) {
2669  // Search the edge of t1 in t2.
2670  if ((point) (t.tet[locver2apex[t.loc][0] + 4]) == tapex) {
2671  t.ver = 0;
2672  } else if ((point) (t.tet[locver2apex[t.loc][2] + 4]) == tapex) {
2673  t.ver = 2;
2674  } else {
2675  assert((point) (t.tet[locver2apex[t.loc][4] + 4]) == tapex);
2676  t.ver = 4;
2677  }
2678  }
2679 }
2680 
2681 // Given a face t1, find the next face t2 in the face ring, t1 and t2
2682 // are in two different tetrahedra. If the next face is a hull face,
2683 // t2 is dummytet.
2684 
2685 inline void tetgenmesh::tfnext(triface& t1, triface& t2)
2686 {
2687  int *iptr;
2688 
2689  if ((t1.ver & 1) == 0) {
2690  t2.tet = t1.tet;
2691  iptr = locver2nextf[t1.loc][t1.ver];
2692  t2.loc = iptr[0];
2693  t2.ver = iptr[1];
2694  symedgeself(t2); // t2.tet may be dummytet.
2695  } else {
2696  symedge(t1, t2);
2697  if (t2.tet != dummytet) {
2698  iptr = locver2nextf[t2.loc][t2.ver];
2699  t2.loc = iptr[0];
2700  t2.ver = iptr[1];
2701  }
2702  }
2703 }
2704 
2706 {
2707  int *iptr;
2708 
2709  if ((t.ver & 1) == 0) {
2710  iptr = locver2nextf[t.loc][t.ver];
2711  t.loc = iptr[0];
2712  t.ver = iptr[1];
2713  symedgeself(t); // t.tet may be dummytet.
2714  } else {
2715  symedgeself(t);
2716  if (t.tet != dummytet) {
2717  iptr = locver2nextf[t.loc][t.ver];
2718  t.loc = iptr[0];
2719  t.ver = iptr[1];
2720  }
2721  }
2722 }
2723 
2724 // enextfnext() and enext2fnext() are combination primitives of enext(),
2725 // enext2() and fnext().
2726 
2727 inline void tetgenmesh::enextfnext(triface& t1, triface& t2) {
2728  enext(t1, t2);
2729  fnextself(t2);
2730 }
2731 
2733  enextself(t);
2734  fnextself(t);
2735 }
2736 
2737 inline void tetgenmesh::enext2fnext(triface& t1, triface& t2) {
2738  enext2(t1, t2);
2739  fnextself(t2);
2740 }
2741 
2743  enext2self(t);
2744  fnextself(t);
2745 }
2746 
2747 // Check or set a tetrahedron's attributes.
2748 
2749 inline REAL tetgenmesh::elemattribute(tetrahedron* ptr, int attnum) {
2750  return ((REAL *) (ptr))[elemattribindex + attnum];
2751 }
2752 
2753 inline void tetgenmesh::
2754 setelemattribute(tetrahedron* ptr, int attnum, REAL value){
2755  ((REAL *) (ptr))[elemattribindex + attnum] = value;
2756 }
2757 
2758 // Check or set a tetrahedron's maximum volume bound.
2759 
2761  return ((REAL *) (ptr))[volumeboundindex];
2762 }
2763 
2765  ((REAL *) (ptr))[volumeboundindex] = value;
2766 }
2767 
2768 // Check or set a tetrahedron's marker.
2769 
2771  return ((int *) (ptr))[elemmarkerindex];
2772 }
2773 
2775  ((int *) (ptr))[elemmarkerindex] = value;
2776 }
2777 
2778 // infect(), infected(), uninfect() -- primitives to flag or unflag a
2779 // tetrahedron. The last bit of the element marker is flagged (1)
2780 // or unflagged (0).
2781 
2783  ((int *) (t.tet))[elemmarkerindex] |= (int) 1;
2784 }
2785 
2787  ((int *) (t.tet))[elemmarkerindex] &= ~(int) 1;
2788 }
2789 
2790 // Test a tetrahedron for viral infection.
2791 
2793  return (((int *) (t.tet))[elemmarkerindex] & (int) 1) != 0;
2794 }
2795 
2796 // marktest(), marktested(), unmarktest() -- primitives to flag or unflag a
2797 // tetrahedron. The last second bit of the element marker is marked (1)
2798 // or unmarked (0).
2799 // One needs them in forming Bowyer-Watson cavity, to mark a tetrahedron if
2800 // it has been checked (for Delaunay case) so later check can be avoided.
2801 
2803  ((int *) (t.tet))[elemmarkerindex] |= (int) 2;
2804 }
2805 
2807  ((int *) (t.tet))[elemmarkerindex] &= ~(int) 2;
2808 }
2809 
2811  return (((int *) (t.tet))[elemmarkerindex] & (int) 2) != 0;
2812 }
2813 
2814 // markface(), unmarkface(), facemarked() -- primitives to flag or unflag a
2815 // face of a tetrahedron. From the last 3rd to 6th bits are used for
2816 // face markers, e.g., the last third bit corresponds to loc = 0.
2817 // One use of the face marker is in flip algorithm. Each queued face (check
2818 // for locally Delaunay) is marked.
2819 
2821  ((int *) (t.tet))[elemmarkerindex] |= (int) (4<<(t).loc);
2822 }
2823 
2825  ((int *) (t.tet))[elemmarkerindex] &= ~(int) (4<<(t).loc);
2826 }
2827 
2829  return (((int *) (t.tet))[elemmarkerindex] & (int) (4<<(t).loc)) != 0;
2830 }
2831 
2832 // markedge(), unmarkedge(), edgemarked() -- primitives to flag or unflag an
2833 // edge of a tetrahedron. From the last 7th to 12th bits are used for
2834 // edge markers, e.g., the last 7th bit corresponds to the 0th edge, etc.
2835 // Remark: The last 7th bit is marked by 2^6 = 64.
2836 
2838  ((int *) (t.tet))[elemmarkerindex] |=
2839  (int) (64<<locver2edge[(t).loc][(t).ver]);
2840 }
2841 
2843  ((int *) (t.tet))[elemmarkerindex] &=
2844  ~(int) (64<<locver2edge[(t).loc][(t).ver]);
2845 }
2846 
2848  return (((int *) (t.tet))[elemmarkerindex] &
2849  (int) (64<<locver2edge[(t).loc][(t).ver])) != 0;
2850 }
2851 
2852 //
2853 // End of primitives for tetrahedra
2854 //
2855 
2856 //
2857 // Begin of primitives for subfaces/subsegments
2858 //
2859 
2860 // Each subface contains three pointers to its neighboring subfaces, with
2861 // edge versions. To save memory, both information are kept in a single
2862 // pointer. To make this possible, all subfaces are aligned to eight-byte
2863 // boundaries, so that the last three bits of each pointer are zeros. An
2864 // edge version (in the range 0 to 5) is compressed into the last three
2865 // bits of each pointer by 'sencode()'. 'sdecode()' decodes a pointer,
2866 // extracting an edge version and a pointer to the beginning of a subface.
2867 
2868 inline void tetgenmesh::sdecode(shellface sptr, face& s) {
2869  s.shver = (int) ((uintptr_t) (sptr) & (uintptr_t) 7);
2870  s.sh = (shellface *) ((uintptr_t) (sptr) & ~ (uintptr_t) 7);
2871 }
2872 
2874  return (shellface) ((uintptr_t) s.sh | (uintptr_t) s.shver);
2875 }
2876 
2877 // spivot() finds the other subface (from this subface) that shares the
2878 // same edge.
2879 
2880 inline void tetgenmesh::spivot(face& s1, face& s2) {
2881  shellface sptr = s1.sh[Orient(s1.shver)];
2882  sdecode(sptr, s2);
2883 }
2884 
2886  shellface sptr = s.sh[Orient(s.shver)];
2887  sdecode(sptr, s);
2888 }
2889 
2890 // sbond() bonds two subfaces together, i.e., after bonding, both faces
2891 // are pointing to each other.
2892 
2893 inline void tetgenmesh::sbond(face& s1, face& s2) {
2894  s1.sh[Orient(s1.shver)] = sencode(s2);
2895  s2.sh[Orient(s2.shver)] = sencode(s1);
2896 }
2897 
2898 // sbond1() only bonds s2 to s1, i.e., after bonding, s1 is pointing to s2,
2899 // but s2 is not pointing to s1.
2900 
2901 inline void tetgenmesh::sbond1(face& s1, face& s2) {
2902  s1.sh[Orient(s1.shver)] = sencode(s2);
2903 }
2904 
2905 // Dissolve a subface bond (from one side). Note that the other subface
2906 // will still think it's connected to this subface.
2907 
2909  s.sh[Orient(s.shver)] = (shellface) dummysh;
2910 }
2911 
2912 // These primitives determine or set the origin, destination, or apex
2913 // of a subface with respect to the edge version.
2914 
2916  return (point) s.sh[3 + vo[s.shver]];
2917 }
2918 
2920  return (point) s.sh[3 + vd[s.shver]];
2921 }
2922 
2924  return (point) s.sh[3 + va[s.shver]];
2925 }
2926 
2927 inline void tetgenmesh::setsorg(face& s, point pointptr) {
2928  s.sh[3 + vo[s.shver]] = (shellface) pointptr;
2929 }
2930 
2931 inline void tetgenmesh::setsdest(face& s, point pointptr) {
2932  s.sh[3 + vd[s.shver]] = (shellface) pointptr;
2933 }
2934 
2935 inline void tetgenmesh::setsapex(face& s, point pointptr) {
2936  s.sh[3 + va[s.shver]] = (shellface) pointptr;
2937 }
2938 
2939 // These primitives were drived from Mucke[2]'s triangle-edge data structure
2940 // to change face-edge relation in a subface (sesym, senext and senext2).
2941 
2942 inline void tetgenmesh::sesym(face& s1, face& s2) {
2943  s2.sh = s1.sh;
2944  s2.shver = s1.shver + (EdgeRing(s1.shver) ? -1 : 1);
2945 }
2946 
2948  s.shver += (EdgeRing(s.shver) ? -1 : 1);
2949 }
2950 
2951 inline void tetgenmesh::senext(face& s1, face& s2) {
2952  s2.sh = s1.sh;
2953  s2.shver = ve[s1.shver];
2954 }
2955 
2957  s.shver = ve[s.shver];
2958 }
2959 
2960 inline void tetgenmesh::senext2(face& s1, face& s2) {
2961  s2.sh = s1.sh;
2962  s2.shver = ve[ve[s1.shver]];
2963 }
2964 
2966  s.shver = ve[ve[s.shver]];
2967 }
2968 
2969 // If f0 and f1 are both in the same face ring, then f1 = f0.fnext(),
2970 
2971 inline void tetgenmesh::sfnext(face& s1, face& s2) {
2972  getnextsface(&s1, &s2);
2973 }
2974 
2976  getnextsface(&s, NULL);
2977 }
2978 
2979 // These primitives read or set a pointer of the badface structure. The
2980 // pointer is stored sh[11].
2981 
2983  return (badface*) s.sh[11];
2984 }
2985 
2987  s.sh[11] = (shellface) value;
2988 }
2989 
2990 // Check or set a subface's maximum area bound.
2991 
2993  return ((REAL *) (s.sh))[areaboundindex];
2994 }
2995 
2997  ((REAL *) (s.sh))[areaboundindex] = value;
2998 }
2999 
3000 // These two primitives read or set a shell marker. Shell markers are used
3001 // to hold user boundary information.
3002 // The last two bits of the int ((int *) ((s).sh))[shmarkindex] are used
3003 // by sinfect() and smarktest().
3004 
3006  return (((int *) ((s).sh))[shmarkindex]) >> (int) 2;
3007  // return ((int *) (s.sh))[shmarkindex];
3008 }
3009 
3010 inline void tetgenmesh::setshellmark(face& s, int value) {
3011  ((int *) ((s).sh))[shmarkindex] = (value << (int) 2) +
3012  ((((int *) ((s).sh))[shmarkindex]) & (int) 3);
3013  // ((int *) (s.sh))[shmarkindex] = value;
3014 }
3015 
3016 // These two primitives set or read the type of the subface or subsegment.
3017 
3018 inline enum tetgenmesh::shestype tetgenmesh::shelltype(face& s) {
3019  return (enum shestype) ((int *) (s.sh))[shmarkindex + 1];
3020 }
3021 
3023  ((int *) (s.sh))[shmarkindex + 1] = (int) value;
3024 }
3025 
3026 // These two primitives set or read the pbc group of the subface.
3027 
3029  return ((int *) (s.sh))[shmarkindex + 2];
3030 }
3031 
3033  ((int *) (s.sh))[shmarkindex + 2] = value;
3034 }
3035 
3036 // sinfect(), sinfected(), suninfect() -- primitives to flag or unflag a
3037 // subface. The last bit of ((int *) ((s).sh))[shmarkindex] is flaged.
3038 
3039 inline void tetgenmesh::sinfect(face& s) {
3040  ((int *) ((s).sh))[shmarkindex] =
3041  (((int *) ((s).sh))[shmarkindex] | (int) 1);
3042  // s.sh[6] = (shellface) ((unsigned long) s.sh[6] | (unsigned long) 4l);
3043 }
3044 
3046  ((int *) ((s).sh))[shmarkindex] =
3047  (((int *) ((s).sh))[shmarkindex] & ~(int) 1);
3048  // s.sh[6] = (shellface)((unsigned long) s.sh[6] & ~(unsigned long) 4l);
3049 }
3050 
3051 // Test a subface for viral infection.
3052 
3054  return (((int *) ((s).sh))[shmarkindex] & (int) 1) != 0;
3055 }
3056 
3057 // smarktest(), smarktested(), sunmarktest() -- primitives to flag or unflag
3058 // a subface. The last 2nd bit of ((int *) ((s).sh))[shmarkindex] is flaged.
3059 
3060 #define smarktest(s) \
3061  ((int *) ((s).sh))[shmarkindex] = (((int *)((s).sh))[shmarkindex] | (int) 2)
3062 
3063 #define sunmarktest(s) \
3064  ((int *) ((s).sh))[shmarkindex] = (((int *)((s).sh))[shmarkindex] & ~(int) 2)
3065 
3066 #define smarktested(s) ((((int *) ((s).sh))[shmarkindex] & (int) 2) != 0)
3067 
3068 //
3069 // End of primitives for subfaces/subsegments
3070 //
3071 
3072 //
3073 // Begin of primitives for interacting between tetrahedra and subfaces
3074 //
3075 
3076 // tspivot() finds a subface abutting on this tetrahdera.
3077 
3079  if ((t).tet[9] != NULL) {
3080  sdecode(((shellface *) (t).tet[9])[(t).loc], s);
3081  } else {
3082  (s).sh = dummysh;
3083  }
3084  //shellface sptr = (shellface) t.tet[8 + t.loc];
3085  //sdecode(sptr, s);
3086 }
3087 
3088 // stpivot() finds a tetrahedron abutting a subface.
3089 
3091  tetrahedron ptr = (tetrahedron) s.sh[6 + EdgeRing(s.shver)];
3092  decode(ptr, t);
3093 }
3094 
3095 // tsbond() bond a tetrahedron to a subface.
3096 
3097 inline void tetgenmesh::tsbond(triface& t, face& s) {
3098  if ((t).tet[9] == NULL) {
3099  // Allocate space for this tet.
3100  (t).tet[9] = (tetrahedron) tet2subpool->alloc();
3101  // NULL all fields in this space.
3102  for (int i = 0; i < 4; i++) {
3103  ((shellface *) (t).tet[9])[i] = (shellface) dummysh;
3104  }
3105  }
3106  // Bond t <==> s.
3107  ((shellface *) (t).tet[9])[(t).loc] = sencode(s);
3108  //t.tet[8 + t.loc] = (tetrahedron) sencode(s);
3109  s.sh[6 + EdgeRing(s.shver)] = (shellface) encode(t);
3110 }
3111 
3112 // tsdissolve() dissolve a bond (from the tetrahedron side).
3113 
3115  if ((t).tet[9] != NULL) {
3116  ((shellface *) (t).tet[9])[(t).loc] = (shellface) dummysh;
3117  }
3118  // t.tet[8 + t.loc] = (tetrahedron) dummysh;
3119 }
3120 
3121 // stdissolve() dissolve a bond (from the subface side).
3122 
3124  s.sh[6 + EdgeRing(s.shver)] = (shellface) dummytet;
3125 }
3126 
3127 //
3128 // End of primitives for interacting between tetrahedra and subfaces
3129 //
3130 
3131 //
3132 // Begin of primitives for interacting between subfaces and subsegs
3133 //
3134 
3135 // sspivot() finds a subsegment abutting a subface.
3136 
3137 inline void tetgenmesh::sspivot(face& s, face& edge) {
3138  shellface sptr = (shellface) s.sh[8 + Orient(s.shver)];
3139  sdecode(sptr, edge);
3140 }
3141 
3142 // ssbond() bond a subface to a subsegment.
3143 
3144 inline void tetgenmesh::ssbond(face& s, face& edge) {
3145  s.sh[8 + Orient(s.shver)] = sencode(edge);
3146  edge.sh[0] = sencode(s);
3147 }
3148 
3149 // ssdisolve() dissolve a bond (from the subface side)
3150 
3152  s.sh[8 + Orient(s.shver)] = (shellface) dummysh;
3153 }
3154 
3155 //
3156 // End of primitives for interacting between subfaces and subsegs
3157 //
3158 
3159 //
3160 // Begin of primitives for interacting between tet and subsegs.
3161 //
3162 
3164 {
3165  if ((t).tet[8] != NULL) {
3166  sdecode(((shellface *) (t).tet[8])[locver2edge[(t).loc][(t).ver]], s);
3167  } else {
3168  (s).sh = dummysh;
3169  }
3170  // shellface sptr = (shellface) t.tet[8 + locver2edge[t.loc][t.ver]];
3171  // sdecode(sptr, seg);
3172 }
3173 
3174 // Only bond/dissolve at tet's side, but not vice versa.
3175 
3177 {
3178  if ((t).tet[8] == NULL) {
3179  // Allocate space for this tet.
3180  (t).tet[8] = (tetrahedron) tet2segpool->alloc();
3181  // NULL all fields in this space.
3182  for (int i = 0; i < 6; i++) {
3183  ((shellface *) (t).tet[8])[i] = (shellface) dummysh;
3184  }
3185  }
3186  // Bond the segment.
3187  ((shellface *) (t).tet[8])[locver2edge[(t).loc][(t).ver]] = sencode((s));
3188  // t.tet[8 + locver2edge[t.loc][t.ver]] = (tetrahedron) sencode(seg);
3189 }
3190 
3192 {
3193  if ((t).tet[8] != NULL) {
3194  ((shellface *) (t).tet[8])[locver2edge[(t).loc][(t).ver]]
3195  = (shellface) dummysh;
3196  }
3197  // t.tet[8 + locver2edge[t.loc][t.ver]] = (tetrahedron) dummysh;
3198 }
3199 
3200 //
3201 // End of primitives for interacting between tet and subsegs.
3202 //
3203 
3204 //
3205 // Begin of primitives for points
3206 //
3207 
3208 inline int tetgenmesh::pointmark(point pt) {
3209  return ((int *) (pt))[pointmarkindex];
3210 }
3211 
3212 inline void tetgenmesh::setpointmark(point pt, int value) {
3213  ((int *) (pt))[pointmarkindex] = value;
3214 }
3215 
3216 // These two primitives set and read the type of the point.
3217 // The last significant bit of this integer is used by pinfect/puninfect.
3218 
3219 inline enum tetgenmesh::verttype tetgenmesh::pointtype(point pt) {
3220  return (enum verttype) (((int *) (pt))[pointmarkindex + 1] >> (int) 1);
3221 }
3222 
3224  ((int *) (pt))[pointmarkindex + 1] =
3225  ((int) value << 1) + (((int *) (pt))[pointmarkindex + 1] & (int) 1);
3226 }
3227 
3228 // pinfect(), puninfect(), pinfected() -- primitives to flag or unflag
3229 // a point. The last bit of the integer '[pointindex+1]' is flaged.
3230 
3231 inline void tetgenmesh::pinfect(point pt) {
3232  ((int *) (pt))[pointmarkindex + 1] |= (int) 1;
3233 }
3234 
3235 inline void tetgenmesh::puninfect(point pt) {
3236  ((int *) (pt))[pointmarkindex + 1] &= ~(int) 1;
3237 }
3238 
3239 inline bool tetgenmesh::pinfected(point pt) {
3240  return (((int *) (pt))[pointmarkindex + 1] & (int) 1) != 0;
3241 }
3242 
3243 // These following primitives set and read a pointer to a tetrahedron
3244 // a subface/subsegment, a point, or a tet of background mesh.
3245 
3247  return ((tetrahedron *) (pt))[point2simindex];
3248 }
3249 
3251  ((tetrahedron *) (pt))[point2simindex] = value;
3252 }
3253 
3255  return (shellface) ((tetrahedron *) (pt))[point2simindex + 1];
3256 }
3257 
3259  ((tetrahedron *) (pt))[point2simindex + 1] = (tetrahedron) value;
3260 }
3261 
3263  return (shellface) ((tetrahedron *) (pt))[point2simindex + 2];
3264 }
3265 
3267  ((tetrahedron *) (pt))[point2simindex + 2] = (tetrahedron) value;
3268 }
3269 
3271  return (point) ((tetrahedron *) (pt))[point2simindex + 3];
3272 }
3273 
3275  ((tetrahedron *) (pt))[point2simindex + 3] = (tetrahedron) value;
3276 }
3277 
3279  return ((tetrahedron *) (pt))[point2simindex + 4];
3280 }
3281 
3283  ((tetrahedron *) (pt))[point2simindex + 4] = value;
3284 }
3285 
3286 // These primitives set and read a pointer to its pbc point.
3287 
3289  return (point) ((tetrahedron *) (pt))[point2pbcptindex];
3290 }
3291 
3294 }
3295 
3296 //
3297 // End of primitives for points
3298 //
3299 
3300 //
3301 // Begin of advanced primitives
3302 //
3303 
3304 // adjustedgering() adjusts the edge version so that it belongs to the
3305 // indicated edge ring. The 'direction' only can be 0(CCW) or 1(CW).
3306 // If the edge is not in the wanted edge ring, reverse it.
3307 
3308 inline void tetgenmesh::adjustedgering(triface& t, int direction) {
3309  if (EdgeRing(t.ver) != direction) {
3310  esymself(t);
3311  }
3312 }
3313 
3314 inline void tetgenmesh::adjustedgering(face& s, int direction) {
3315  if (EdgeRing(s.shver) != direction) {
3316  sesymself(s);
3317  }
3318 }
3319 
3320 // isdead() returns TRUE if the tetrahedron or subface has been dealloced.
3321 
3323  if (t->tet == (tetrahedron *) NULL) return true;
3324  else return t->tet[4] == (tetrahedron) NULL;
3325 }
3326 
3327 inline bool tetgenmesh::isdead(face* s) {
3328  if (s->sh == (shellface *) NULL) return true;
3329  else return s->sh[3] == (shellface) NULL;
3330 }
3331 
3332 // isfacehaspoint() returns TRUE if the 'testpoint' is one of the vertices
3333 // of the tetface 't' subface 's'.
3334 
3335 inline bool tetgenmesh::isfacehaspoint(triface* t, point testpoint) {
3336  return ((org(*t) == testpoint) || (dest(*t) == testpoint) ||
3337  (apex(*t) == testpoint));
3338 }
3339 
3340 inline bool tetgenmesh::isfacehaspoint(face* s, point testpoint) {
3341  return (s->sh[3] == (shellface) testpoint) ||
3342  (s->sh[4] == (shellface) testpoint) ||
3343  (s->sh[5] == (shellface) testpoint);
3344 }
3345 
3346 // isfacehasedge() returns TRUE if the edge (given by its two endpoints) is
3347 // one of the three edges of the subface 's'.
3348 
3349 inline bool tetgenmesh::isfacehasedge(face* s, point tend1, point tend2) {
3350  return (isfacehaspoint(s, tend1) && isfacehaspoint(s, tend2));
3351 }
3352 
3353 // issymexist() returns TRUE if the adjoining tetrahedron is not 'duumytet'.
3354 
3356  tetrahedron *ptr = (tetrahedron *)
3357  ((unsigned long)(t->tet[t->loc]) & ~(unsigned long)7l);
3358  return ptr != dummytet;
3359 }
3360 
3361 // dot() returns the dot product: v1 dot v2.
3362 
3364 {
3365  return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
3366 }
3367 
3368 // cross() computes the cross product: n = v1 cross v2.
3369 
3370 inline void tetgenmesh::cross(REAL* v1, REAL* v2, REAL* n)
3371 {
3372  n[0] = v1[1] * v2[2] - v2[1] * v1[2];
3373  n[1] = -(v1[0] * v2[2] - v2[0] * v1[2]);
3374  n[2] = v1[0] * v2[1] - v2[0] * v1[1];
3375 }
3376 
3377 // distance() computs the Euclidean distance between two points.
3379 {
3380  return sqrt((p2[0] - p1[0]) * (p2[0] - p1[0]) +
3381  (p2[1] - p1[1]) * (p2[1] - p1[1]) +
3382  (p2[2] - p1[2]) * (p2[2] - p1[2]));
3383 }
3384 
3385 // Linear algebra operators.
3386 
3387 #define NORM2(x, y, z) ((x) * (x) + (y) * (y) + (z) * (z))
3388 
3389 #define DIST(p1, p2) \
3390  sqrt(NORM2((p2)[0] - (p1)[0], (p2)[1] - (p1)[1], (p2)[2] - (p1)[2]))
3391 
3392 #define TETGEN_DOT(v1, v2) \
3393  ((v1)[0] * (v2)[0] + (v1)[1] * (v2)[1] + (v1)[2] * (v2)[2])
3394 
3395 #define CROSS(v1, v2, n) \
3396  (n)[0] = (v1)[1] * (v2)[2] - (v2)[1] * (v1)[2];\
3397  (n)[1] = -((v1)[0] * (v2)[2] - (v2)[0] * (v1)[2]);\
3398  (n)[2] = (v1)[0] * (v2)[1] - (v2)[0] * (v1)[1]
3399 
3400 #define SETVECTOR3(V, a0, a1, a2) (V)[0] = (a0); (V)[1] = (a1); (V)[2] = (a2)
3401 
3402 #define SWAP2(a0, a1, tmp) (tmp) = (a0); (a0) = (a1); (a1) = (tmp)
3403 
3405 // //
3406 // Two inline functions used in read/write VTK files. //
3407 // //
3409 
3410 inline void swapBytes(unsigned char* var, int size)
3411 {
3412  int i = 0;
3413  int j = size - 1;
3414  char c;
3415 
3416  while (i < j) {
3417  c = var[i]; var[i] = var[j]; var[j] = c;
3418  i++, j--;
3419  }
3420 }
3421 
3422 inline bool testIsBigEndian()
3423 {
3424  short word = 0x4321;
3425  if((*(char *)& word) != 0x21)
3426  return true;
3427  else
3428  return false;
3429 }
3430 
3431 #endif // #ifndef tetgenH
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
#define assert(e,...)
Definition: Logger.h:744
Vector3f p1
Definition: MatrixBase_all.cpp:2
Tridiagonalization< MatrixXf > tri
Definition: Tridiagonalization_compute.cpp:1
float * p
Definition: Tutorial_Map_using.cpp:9
Map< RowVectorXf > v2(M2.data(), M2.size())
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
cout<< "Here is the matrix m:"<< endl<< m<< endl;Eigen::FullPivLU< Matrix5x3 > lu(m)
Definition: tetgen.h:630
int nomerge
Definition: tetgen.h:681
int verbose
Definition: tetgen.h:690
int nobisect
Definition: tetgen.h:682
REAL goodratio
Definition: tetgen.h:694
REAL minratio
Definition: tetgen.h:693
int refine
Definition: tetgen.h:653
int nobound
Definition: tetgen.h:676
bool parse_commandline(int argc, char **argv)
int useshelles
Definition: tetgen.h:691
enum objecttype object
Definition: tetgen.h:705
REAL alpha1
Definition: tetgen.h:700
REAL goodangle
Definition: tetgen.h:696
int optpasses
Definition: tetgen.h:666
int noflip
Definition: tetgen.h:683
int plc
Definition: tetgen.h:651
int diagnose
Definition: tetgen.h:661
int fixedvolume
Definition: tetgen.h:657
int order
Definition: tetgen.h:667
int neighout
Definition: tetgen.h:670
char commandline[1024]
Definition: tetgen.h:708
int coarse
Definition: tetgen.h:654
int varvolume
Definition: tetgen.h:656
REAL maxdihedral
Definition: tetgen.h:699
char addinfilename[1024]
Definition: tetgen.h:711
REAL epsilon
Definition: tetgen.h:703
int insertaddpoints
Definition: tetgen.h:658
int conformdel
Definition: tetgen.h:660
REAL minangle
Definition: tetgen.h:695
int nojettison
Definition: tetgen.h:684
int steiner
Definition: tetgen.h:685
int geomview
Definition: tetgen.h:674
int voroout
Definition: tetgen.h:671
REAL alpha3
Definition: tetgen.h:702
int vtkview
Definition: tetgen.h:675
REAL maxvolume
Definition: tetgen.h:697
int zeroindex
Definition: tetgen.h:662
int quiet
Definition: tetgen.h:689
int docheck
Definition: tetgen.h:688
int regionattrib
Definition: tetgen.h:659
int max_btreenode_size
Definition: tetgen.h:664
~tetgenbehavior()
Definition: tetgen.h:789
char outfilename[1024]
Definition: tetgen.h:710
REAL mindihedral
Definition: tetgen.h:698
tetgenbehavior()
Definition: tetgen.h:724
REAL alpha2
Definition: tetgen.h:701
int nofacewritten
Definition: tetgen.h:679
int offcenter
Definition: tetgen.h:687
int fliprepair
Definition: tetgen.h:686
int gidview
Definition: tetgen.h:673
int noiterationnum
Definition: tetgen.h:680
int edgesout
Definition: tetgen.h:669
int maxflipedgelinksize
Definition: tetgen.h:692
bool parse_commandline(char *switches)
Definition: tetgen.h:719
int quality
Definition: tetgen.h:652
REAL epsilon2
Definition: tetgen.h:704
char infilename[1024]
Definition: tetgen.h:709
int nonodewritten
Definition: tetgen.h:677
int metric
Definition: tetgen.h:655
int btree
Definition: tetgen.h:663
int facesout
Definition: tetgen.h:668
int optlevel
Definition: tetgen.h:665
char bgmeshfilename[1024]
Definition: tetgen.h:712
objecttype
Definition: tetgen.h:646
@ MEDIT
Definition: tetgen.h:646
@ NODES
Definition: tetgen.h:646
@ VTK
Definition: tetgen.h:646
@ POLY
Definition: tetgen.h:646
@ STL
Definition: tetgen.h:646
@ MESH
Definition: tetgen.h:646
@ NONE
Definition: tetgen.h:646
@ OFF
Definition: tetgen.h:646
@ PLY
Definition: tetgen.h:646
int meditview
Definition: tetgen.h:672
int noelewritten
Definition: tetgen.h:678
Definition: tetgen.h:201
int numberofregions
Definition: tetgen.h:349
int numberofvfacets
Definition: tetgen.h:403
bool useindex
Definition: tetgen.h:291
int * facetmarkerlist
Definition: tetgen.h:332
vorofacet * vfacetlist
Definition: tetgen.h:399
int numberofpointmtrs
Definition: tetgen.h:308
void save_neighbors(char *)
pbcgroup * pbcgrouplist
Definition: tetgen.h:366
REAL * tetrahedronvolumelist
Definition: tetgen.h:323
int * trifacemarkerlist
Definition: tetgen.h:380
int * trifacelist
Definition: tetgen.h:378
bool load_mtr(char *)
char * readline(char *string, FILE *infile, int *linenumber)
int * edgemarkerlist
Definition: tetgen.h:388
REAL * holelist
Definition: tetgen.h:338
void save_faces(char *)
int numberofpointattributes
Definition: tetgen.h:307
char * findnextnumber(char *string)
@ FILENAMESIZE
Definition: tetgen.h:206
int numberofvpoints
Definition: tetgen.h:401
REAL * pointattributelist
Definition: tetgen.h:303
bool load_var(char *)
int * adjtetlist
Definition: tetgen.h:379
int numberofvedges
Definition: tetgen.h:402
int numberofpoints
Definition: tetgen.h:306
static void init(facet *f)
Definition: tetgen.h:236
int numberofsegmentconstraints
Definition: tetgen.h:363
bool load_vtk(char *)
int numberofedges
Definition: tetgen.h:389
REAL * pointlist
Definition: tetgen.h:302
bool load_off(char *)
REAL * regionlist
Definition: tetgen.h:348
bool load_node(char *filebasename)
int mesh_dim
Definition: tetgen.h:288
int numberofcorners
Definition: tetgen.h:326
void save_nodes(char *)
@ INPUTLINESIZE
Definition: tetgen.h:209
bool load_poly(char *)
char * readnumberline(char *string, FILE *infile, char *infilename)
bool load_stl(char *)
void save_elements(char *)
bool load_tetmesh(char *)
bool load_ply(char *)
bool load_pbc(char *)
REAL * facetconstraintlist
Definition: tetgen.h:355
REAL * segmentconstraintlist
Definition: tetgen.h:362
int * neighborlist
Definition: tetgen.h:324
voroedge * vedgelist
Definition: tetgen.h:398
bool(* TetSizeFunc)(REAL *, REAL *, REAL *, REAL *, REAL *, REAL)
Definition: tetgen.h:282
int numberoftrifaces
Definition: tetgen.h:381
int numberofpbcgroups
Definition: tetgen.h:367
void initialize()
Definition: tetgen.h:437
int numberoftetrahedronattributes
Definition: tetgen.h:327
int ** vcelllist
Definition: tetgen.h:400
bool load_plc(char *, int)
void save_poly(char *)
bool load_node_call(FILE *infile, int markers, char *nodefilename)
static void init(polygon *p)
Definition: tetgen.h:222
int numberoffacetconstraints
Definition: tetgen.h:356
int firstnumber
Definition: tetgen.h:285
int numberofholes
Definition: tetgen.h:339
tetgenio()
Definition: tetgen.h:612
int * edgelist
Definition: tetgen.h:387
TetSizeFunc tetunsuitable
Definition: tetgen.h:407
facet * facetlist
Definition: tetgen.h:331
int numberoftetrahedra
Definition: tetgen.h:325
REAL * pointmtrlist
Definition: tetgen.h:304
bool load_medit(char *)
int * tetrahedronlist
Definition: tetgen.h:321
REAL * tetrahedronattributelist
Definition: tetgen.h:322
char * findnextfield(char *string)
void save_edges(char *)
int numberoffacets
Definition: tetgen.h:333
~tetgenio()
Definition: tetgen.h:613
int numberofvcells
Definition: tetgen.h:404
int * pointmarkerlist
Definition: tetgen.h:305
void deinitialize()
Definition: tetgen.h:499
REAL * vpointlist
Definition: tetgen.h:397
Definition: tetgen.h:1397
char * getblock(int objectindex)
long objects
Definition: tetgen.h:1406
int objectsperblock
Definition: tetgen.h:1402
void * lookup(int objectindex)
void poolinit(int sizeofobject, int log2objperblk)
char ** toparray
Definition: tetgen.h:1405
int objectbytes
Definition: tetgen.h:1401
arraypool(int sizeofobject, int log2objperblk)
int toparraylen
Definition: tetgen.h:1404
int log2objectsperblock
Definition: tetgen.h:1403
unsigned long totalmemory
Definition: tetgen.h:1407
int newindex(void **newptr)
Definition: tetgen.h:1123
point pset1[3]
Definition: tetgen.h:1128
enum fliptype ft
Definition: tetgen.h:1127
point pset2[3]
Definition: tetgen.h:1129
elemflip()
Definition: tetgen.h:1131
Definition: tetgen.h:1062
shellface * sh
Definition: tetgen.h:1066
face & operator=(const face &s)
Definition: tetgen.h:1072
face()
Definition: tetgen.h:1070
int shver
Definition: tetgen.h:1067
bool operator!=(face &s)
Definition: tetgen.h:1077
bool operator==(face &s)
Definition: tetgen.h:1076
Definition: tetgen.h:1456
compfunc comp
Definition: tetgen.h:1463
void clear()
Definition: tetgen.h:1474
int expandsize
Definition: tetgen.h:1462
int maxitems
Definition: tetgen.h:1462
char * base
Definition: tetgen.h:1460
void setcomp(compfunc compf)
Definition: tetgen.h:1473
void * operator[](int i)
Definition: tetgen.h:1470
int hasitem(void *checkitem)
int items
Definition: tetgen.h:1462
int len()
Definition: tetgen.h:1475
void del(int pos, int order)
void * insert(int pos, void *insitem)
~list()
Definition: tetgen.h:1468
list(int itbytes, compfunc pcomp, int mitems=256, int exsize=128)
Definition: tetgen.h:1465
void * append(void *appitem)
int itembytes
Definition: tetgen.h:1461
void listinit(int itbytes, compfunc pcomp, int mitems, int exsize)
Definition: tetgen.h:1513
int itemsperblock
Definition: tetgen.h:1525
void poolinit(int, int, enum wordtype, int)
int itemwords
Definition: tetgen.h:1524
void * pathitem
Definition: tetgen.h:1521
memorypool(int, int, enum wordtype, int)
void * deaditemstack
Definition: tetgen.h:1519
void ** firstblock
Definition: tetgen.h:1517
void ** nowblock
Definition: tetgen.h:1517
void ** pathblock
Definition: tetgen.h:1520
int alignbytes
Definition: tetgen.h:1523
wordtype itemwordtype
Definition: tetgen.h:1522
int unallocateditems
Definition: tetgen.h:1527
void * nextitem
Definition: tetgen.h:1518
int pathitemsleft
Definition: tetgen.h:1528
int itembytes
Definition: tetgen.h:1524
long maxitems
Definition: tetgen.h:1526
long items
Definition: tetgen.h:1526
Definition: tetgen.h:1550
queue(int bytecount, int itemcount=256)
Definition: tetgen.h:1558
int linkitembytes
Definition: tetgen.h:1555
void clear()
Definition: tetgen.h:1568
int linkitems
Definition: tetgen.h:1556
bool empty()
Definition: tetgen.h:1580
void ** head
Definition: tetgen.h:1554
void * push(void *newitem)
Definition: tetgen.h:1582
long len()
Definition: tetgen.h:1579
void * pop()
Definition: tetgen.h:1594
void ** tail
Definition: tetgen.h:1554
Definition: tetgen.h:1040
bool operator!=(triface &t)
Definition: tetgen.h:1057
triface()
Definition: tetgen.h:1048
int ver
Definition: tetgen.h:1045
int loc
Definition: tetgen.h:1045
bool operator==(triface &t)
Definition: tetgen.h:1054
tetrahedron * tet
Definition: tetgen.h:1044
triface & operator=(const triface &t)
Definition: tetgen.h:1050
Definition: tetgen.h:805
interresult
Definition: tetgen.h:839
@ INTERSUBFACE
Definition: tetgen.h:841
@ TOUCHEDGE
Definition: tetgen.h:840
@ TOUCHFACE
Definition: tetgen.h:840
@ INTERVERT
Definition: tetgen.h:840
@ SHAREFACE
Definition: tetgen.h:839
@ SHAREEDGE
Definition: tetgen.h:839
@ DISJOINT
Definition: tetgen.h:839
@ COLLISIONFACE
Definition: tetgen.h:841
@ INTERFACE
Definition: tetgen.h:840
@ INTERTET
Definition: tetgen.h:840
@ SHAREVERTEX
Definition: tetgen.h:839
@ INTEREDGE
Definition: tetgen.h:840
@ BELOWHULL2
Definition: tetgen.h:842
@ INTERSECT
Definition: tetgen.h:839
@ TRIEDGEINT
Definition: tetgen.h:841
@ EDGETRIINT
Definition: tetgen.h:841
@ INTERSUBSEG
Definition: tetgen.h:841
enum locateresult sinsertvertex(point insertpt, face *splitsh, face *splitseg, bool bwflag, bool cflag)
bool fillcavity(arraypool *, arraypool *, arraypool *, arraypool *)
void setpointtype(point pt, enum verttype value)
Definition: tetgen.h:3223
long updvolcount
Definition: tetgen.h:2167
bool iscospheric(REAL *, REAL *, REAL *, REAL *, REAL *, REAL vol24, REAL eps)
int recentq
Definition: tetgen.h:2107
void ordervertices(point *vertexarray, int arraysize)
void btree_sort(point *, int, int, REAL, REAL, REAL, REAL, REAL, REAL, int)
enum locateresult adjustlocatesub(point, face *, enum locateresult, REAL)
memorypool * badtetrahedrons
Definition: tetgen.h:2047
int(* compfunc)(const void *, const void *)
Definition: tetgen.h:1436
void algorithmicstatistics()
void setdest(triface &t, point pointptr)
Definition: tetgen.h:2517
void sstpivot(face *, triface *)
void detachauxsubfaces(list *newtetlist)
REAL xmax
Definition: tetgen.h:2113
enum locateresult adjustlocateseg(point, face *, enum locateresult, REAL)
void removeholetets(memorypool *viri)
enum locateresult locateseg(point searchpt, face *searchseg)
void flipedgerecursive(face *flipedge, queue *flipqueue)
void spivotself(face &s)
Definition: tetgen.h:2885
void outneighbors(tetgenio *)
void makeindex2pointmap(point *&)
void setelemattribute(tetrahedron *ptr, int attnum, REAL value)
Definition: tetgen.h:2754
void restorepolyhedron(list *oldtetlist)
unsigned long randomnation(unsigned int choices)
void outmesh2vtk(char *)
enum interresult tri_edge_cop_inter(REAL *, REAL *, REAL *, REAL *, REAL *, REAL *)
point * highordertable
Definition: tetgen.h:2087
void sspivot(face &s, face &edge)
Definition: tetgen.h:3137
void checkconforming()
void orientnewsubs(list *newshlist, face *orientsh, REAL *norm)
int pointmarkindex
Definition: tetgen.h:2123
REAL cosmindihed
Definition: tetgen.h:2147
int shellpbcgroup(face &s)
Definition: tetgen.h:3028
void initializepools()
long samples
Definition: tetgen.h:2144
void setareabound(face &s, REAL value)
Definition: tetgen.h:2996
long totaldeadtets
Definition: tetgen.h:2159
int highorderindex
Definition: tetgen.h:2125
int * idx2segpglist
Definition: tetgen.h:2098
@ ELEPERBLOCK
Definition: tetgen.h:815
@ VERPERBLOCK
Definition: tetgen.h:815
@ SUBPERBLOCK
Definition: tetgen.h:815
void enforcequality()
long rejsubpts
Definition: tetgen.h:2172
void setshell2badface(face &s, badface *value)
Definition: tetgen.h:2986
enum interresult finddirection2(triface *searchtet, point)
static int locver2dest[4][6]
Definition: tetgen.h:1192
void formbowatcavityquad(point, list *, list *)
badface * subquefront[3]
Definition: tetgen.h:2104
memorypool * tet2segpool
Definition: tetgen.h:2048
enum locateresult locate2(point searchpt, triface *searchtet, arraypool *)
void sfnextself(face &)
Definition: tetgen.h:2975
void setpoint2ppt(point pt, point value)
Definition: tetgen.h:3274
void tallslivers(bool optflag)
long r2count
Definition: tetgen.h:2170
shellface * shellfacetraverse(memorypool *)
void setshelltype(face &s, enum shestype value)
Definition: tetgen.h:3022
void sesym(face &s1, face &s2)
Definition: tetgen.h:2942
memorypool * subsegs
Definition: tetgen.h:2043
long outbowatcircumcount
Definition: tetgen.h:2169
void enextself(triface &t)
Definition: tetgen.h:2554
void removesteiners2()
locateresult
Definition: tetgen.h:845
@ ONVERTEX
Definition: tetgen.h:845
@ ONEDGE
Definition: tetgen.h:845
@ ENCSEGMENT
Definition: tetgen.h:846
@ ONFACE
Definition: tetgen.h:845
@ OUTSIDE
Definition: tetgen.h:845
@ INTETRAHEDRON
Definition: tetgen.h:845
void bowatinsertsite(point bp, face *splitseg, int n, list **sublists, list **subceillists, list **tetlists, list **ceillists, list *verlist, queue *flipque, bool chkencseg, bool chkencsub, bool chkbadtet)
void tetallnormal(point, point, point, point, REAL N[4][3], REAL *volume)
int checkshells()
void numberedges()
bool removeedgebycombNM(REAL *, int, triface *, int *, triface *, triface *, queue *)
long meshedges
Definition: tetgen.h:2118
long across_edge_count
Definition: tetgen.h:2160
void constrainedfacets2()
bool p1interpolatebgm(point pt, triface *bgmtet, long *scount)
bool incrflipdelaunaysub(int shmark, REAL eps, list *, int, REAL *, queue *)
long insphere_sos_count
Definition: tetgen.h:2155
long opt_edge_flips
Definition: tetgen.h:2163
void insertsubseg(face *tri)
void getsegmentsplitpoint2(face *sseg, point refpt, REAL *vt)
void point2segorg(point, face &)
void highorder()
void outmesh2medit(char *)
triface firstbotface
Definition: tetgen.h:2073
void tfnextself(triface &t)
Definition: tetgen.h:2705
bool infected(triface &t)
Definition: tetgen.h:2792
point sapex(face &s)
Definition: tetgen.h:2923
void printsh(face *)
void splittetrahedron(point, triface *, queue *)
int collapverts
Definition: tetgen.h:2140
bool trimbowatcavity(point bp, face *bpseg, int n, list **sublists, list **subceillists, list **tetlists, list **ceillists, REAL maxcosd)
static int locver2nextf[4][6][2]
Definition: tetgen.h:1201
enum locateresult locatesub(point searchpt, face *searchsh, int, REAL)
void optimizemesh2(bool optflag)
void setpoint2bgmtet(point pt, tetrahedron value)
Definition: tetgen.h:3282
void projpt2face(REAL *p, REAL *f1, REAL *f2, REAL *f3, REAL *prj)
void tetrahedrondealloc(tetrahedron *)
long inspherecount
Definition: tetgen.h:2155
bool smoothpoint(point smthpt, point, point, list *, bool, REAL *)
void assignsegmentmarkers()
void replacepolygonsubs(list *oldshlist, list *newshlist)
bool findrelocatepoint2(point sp, point np, REAL *n, list *, list *)
void jettisonnodes()
point getsubsegfarorg(face *sseg)
bool fnextself(triface &t)
Definition: tetgen.h:2605
void stpivot(face &s, triface &t)
Definition: tetgen.h:3090
void setapex(triface &t, point pointptr)
Definition: tetgen.h:2521
void statistics()
long r1count
Definition: tetgen.h:2170
void repairencsegs(bool chkencsub, bool chkbadtet)
int point2pbcptindex
Definition: tetgen.h:2124
long bowatsubcount
Definition: tetgen.h:2166
point oppo(triface &t)
Definition: tetgen.h:2509
void makepoint2tetmap()
void edgeorthonormal(REAL *e1, REAL *e2, REAL *op, REAL *n)
pbcdata * subpbcgrouptable
Definition: tetgen.h:2094
void setvolumebound(tetrahedron *ptr, REAL value)
Definition: tetgen.h:2764
void dequeuebadtet()
void maketetrahedronmap(int *&, tetrahedron **&)
void ssbond(face &s, face &edge)
Definition: tetgen.h:3144
bool splittetedge(point, triface *, queue *)
void duplicatebgmesh()
void plaguesub(memorypool *viri)
void outsubfaces(tetgenio *)
int pointmtrindex
Definition: tetgen.h:2121
enum finddirectionresult finddirection(triface *searchtet, point, long)
bool relocatepoint(point steinpt, triface *oldtet, list *, list *, queue *)
void sfnext(face &, face &)
Definition: tetgen.h:2971
int checkdelaunay(REAL, queue *)
arraypool * elemfliplist
Definition: tetgen.h:2076
bool incrflipdelaunay(triface *, point *, long, bool, bool, REAL, queue *)
bool recoveredgebyflips(triface *searchtet, point pb, int *)
void repairbadtets()
long ptloc_count
Definition: tetgen.h:2153
shellface * dummyshbase
Definition: tetgen.h:2057
void enqueueflipedge(face &, queue *)
arraypool * btreenode_list
Definition: tetgen.h:2060
tetrahedron point2bgmtet(point pt)
Definition: tetgen.h:3278
void printtet(triface *)
long opt_face_flips
Definition: tetgen.h:2163
REAL facedihedral(REAL *pa, REAL *pb, REAL *pc1, REAL *pc2)
long flip22count
Definition: tetgen.h:2157
void pinfect(point pt)
Definition: tetgen.h:3231
void uninfect(triface &t)
Definition: tetgen.h:2786
void inscribedsphere(REAL *, REAL *, REAL *, REAL *, REAL *cent, REAL *radius)
void retrievenewsubs(list *newshlist, bool removeseg)
REAL shortdistance(REAL *p, REAL *e1, REAL *e2)
void decidefeaturepointsizes()
int relverts
Definition: tetgen.h:2138
bool marktested(triface &t)
Definition: tetgen.h:2810
void collapseedge(point suppt, point conpt, list *oldtetlist, list *)
long abovecount
Definition: tetgen.h:2165
memorypool * tet2subpool
Definition: tetgen.h:2048
int maxcavfaces
Definition: tetgen.h:2149
long rejsegpts
Definition: tetgen.h:2172
arraypool * subsegstack
Definition: tetgen.h:2070
memorypool * subfaces
Definition: tetgen.h:2042
static int locver2org[4][6]
Definition: tetgen.h:1191
long maxcavsize
Definition: tetgen.h:2161
bool scoutfront(triface *front, triface *idfront)
~tetgenmesh()
Definition: tetgen.h:2278
bool removeedgebyflips(triface *remedge, int *)
void outmesh2off(char *)
void getfacetabovepoint(face *facetsh)
long flip44s
Definition: tetgen.h:2174
long flip23s
Definition: tetgen.h:2174
int pointmark(point pt)
Definition: tetgen.h:3208
long maxregionsize
Definition: tetgen.h:2161
void qualitystatistics()
@ CCW
Definition: tetgen.h:822
@ CW
Definition: tetgen.h:822
bool removeedgebyflip32(REAL *key, triface *, triface *, queue *)
REAL shortdistance(REAL *p, REAL *e1, REAL *e2, REAL *e3)
bool splitencseg(point, face *, list *, list *, list *, queue *, bool, bool, bool)
void marktest(triface &t)
Definition: tetgen.h:2802
static int loc2oppo[4]
Definition: tetgen.h:1196
bool suppressfacetpoint(face *supsh, list *frontlist, list *misfrontlist, list *ptlist, list *conlist, memorypool *viri, queue *flipque, bool noreloc, bool optflag)
enum locateresult hullwalk(point searchpt, triface *hulltet)
void interecursive(shellface **subfacearray, int arraysize, int axis, REAL bxmin, REAL bxmax, REAL bymin, REAL bymax, REAL bzmin, REAL bzmax, int *internum)
void formbowatcavitysegquad(point, list *, list *)
bool isfacehaspoint(triface *t, point testpoint)
Definition: tetgen.h:3335
REAL distance(REAL *p1, REAL *p2)
Definition: tetgen.h:3378
@ FILENAMESIZE
Definition: tetgen.h:810
badface * tetquefront[64]
Definition: tetgen.h:2105
void spivot(face &s1, face &s2)
Definition: tetgen.h:2880
long failsegcount
Definition: tetgen.h:2168
void suninfect(face &s)
Definition: tetgen.h:3045
bool suppresssegpoint(face *supseg, list *spinshlist, list *newsegshlist, list *frontlist, list *misfrontlist, list *ptlist, list *conlist, memorypool *viri, queue *flipque, bool noreloc, bool optflag)
void esym(triface &t1, triface &t2)
Definition: tetgen.h:2536
int elemattribindex
Definition: tetgen.h:2126
void getsplitpoint(point e1, point e2, point refpt, point newpt)
long flip22s
Definition: tetgen.h:2174
bool registerelemflip(enum fliptype ft, point pa1, point pb1, point pc1, point pa2, point pb2, point pc2)
bool tallencsegs(point testpt, int n, list **ceillists)
point sorg(face &s)
Definition: tetgen.h:2915
REAL xmin
Definition: tetgen.h:2113
void gluefronts(triface *front, triface *front1, list *gluetetlist, list *glueshlist)
long orient3dcount
Definition: tetgen.h:2154
bool removeedge(badface *remedge, bool optflag)
arraypool * caveshbdlist
Definition: tetgen.h:2068
REAL areabound(face &s)
Definition: tetgen.h:2992
long flip32s
Definition: tetgen.h:2174
long flip26count
Definition: tetgen.h:2156
point dummypoint
Definition: tetgen.h:2083
void outelements(tetgenio *)
void senext(face &s1, face &s2)
Definition: tetgen.h:2951
void symedge(triface &t1, triface &t2)
Definition: tetgen.h:2642
bool sinfected(face &s)
Definition: tetgen.h:3053
tetrahedron * tetrahedrontraverse()
void retrievenewtets(list *newtetlist)
void recoversegment(point tstart, point tend, queue *flipqueue)
wordtype
Definition: tetgen.h:826
@ POINTER
Definition: tetgen.h:826
@ FLOATINGPOINT
Definition: tetgen.h:826
bool removetetbypeeloff(triface *striptet, triface *)
long across_face_count
Definition: tetgen.h:2160
badface * badfacetraverse(memorypool *)
void puninfect(point pt)
Definition: tetgen.h:3235
void regionplague(memorypool *viri, REAL attribute, REAL volume)
long reconstructmesh()
void getnextsface(face *, face *)
int * segpglist
Definition: tetgen.h:2098
void facenormal2(point pa, point pb, point pc, REAL *n, int pivot)
void flip32(triface *, queue *)
void tssbond1(triface &t, face &seg)
Definition: tetgen.h:3176
void enext2fnextself(triface &t)
Definition: tetgen.h:2742
void flip22(triface *, queue *)
int jettisoninverts
Definition: tetgen.h:2143
void outfaces(tetgenio *)
void ssdissolve(face &s)
Definition: tetgen.h:3151
@ SAMPLEFACTOR
Definition: tetgen.h:819
void outsmesh(char *)
badface * topbadtetra()
void findedge(triface *t, point eorg, point edest)
void outvoronoi(tetgenio *)
void initializecavity(list *floorlist, list *ceillist, list *frontlist, list *ptlist, list *gluelist)
long maxbowatcavsize
Definition: tetgen.h:2159
REAL ** tetrahedron
Definition: tetgen.h:972
void lu_solve(REAL lu[4][4], int n, int *ps, REAL *b, int N)
bool issymexist(triface *t)
Definition: tetgen.h:3355
long across_max_count
Definition: tetgen.h:2160
REAL minfaceang
Definition: tetgen.h:2148
tetrahedron point2tet(point pt)
Definition: tetgen.h:3246
void senext2self(face &s)
Definition: tetgen.h:2965
int tri_edge_2d(point, point, point, point, point, point, int, int *, int *)
point point2pbcpt(point pt)
Definition: tetgen.h:3288
bool acceptsegpt(point segpt, point refpt, face *splitseg)
void makepoint2segmap()
shellface sencode(face &s)
Definition: tetgen.h:2873
bool checktet4ill(triface *testtet, bool enqflag)
tetrahedron * dummytet
Definition: tetgen.h:2051
bool checkseg4encroach(face *testseg, point testpt, point *, bool enqflag)
int checksubsegs
Definition: tetgen.h:2132
long failsubcount
Definition: tetgen.h:2168
void setsapex(face &s, point pointptr)
Definition: tetgen.h:2935
bool checktet4opt(triface *testtet, bool enqflag)
void facenormal(REAL *pa, REAL *pb, REAL *pc, REAL *n, REAL *nlen)
void sbond(face &s1, face &s2)
Definition: tetgen.h:2893
void delaunizesegments2()
shellface point2sh(point pt)
Definition: tetgen.h:3254
enum interresult tri_edge_inter_tail(REAL *, REAL *, REAL *, REAL *, REAL *, REAL, REAL)
void setshellpbcgroup(face &s, int value)
Definition: tetgen.h:3032
bool checktet4badqual(triface *testtet, bool enqflag)
long ptloc_max_count
Definition: tetgen.h:2153
void adjustedgering(triface &t, int direction)
Definition: tetgen.h:3308
void mergefacets(queue *flipqueue)
void splittetface(point, triface *, queue *)
long optcount[10]
Definition: tetgen.h:2173
enum interresult edge_vert_col_inter(REAL *, REAL *, REAL *)
bool isfacehasedge(face *s, point tend1, point tend2)
Definition: tetgen.h:3349
void outhullfaces(tetgenio *)
shestype
Definition: tetgen.h:833
@ SHARP
Definition: tetgen.h:833
@ NSHARP
Definition: tetgen.h:833
point getsubsegfardest(face *sseg)
void setsorg(face &s, point pointptr)
Definition: tetgen.h:2927
void outnodes(tetgenio *)
void sym(triface &t1, triface &t2)
Definition: tetgen.h:2468
void tssdissolve1(triface &t)
Definition: tetgen.h:3191
void assignregionattribs()
void sdissolve(face &s)
Definition: tetgen.h:2908
memorypool * badsubsegs
Definition: tetgen.h:2045
long flipn2ncount
Definition: tetgen.h:2156
long totalbowatcavsize
Definition: tetgen.h:2159
void formstarpolyhedron(point pt, list *tetlist, list *verlist, bool)
unsigned long randomseed
Definition: tetgen.h:2145
int elemmarkerindex
Definition: tetgen.h:2128
void btree_search(point searchpt, triface *searchtet)
void flip22sub(face *, queue *)
int sizeoftensor
Definition: tetgen.h:2120
void tsdissolve(triface &t)
Definition: tetgen.h:3114
point pointtraverse()
void tallbadtetrahedrons()
tetrahedron encode(triface &t)
Definition: tetgen.h:2462
arraypool * fixededgelist
Definition: tetgen.h:2079
bool b_steinerflag
Definition: tetgen.h:2150
void formstarpolygon(point pt, list *trilist, list *verlist)
tetgenmesh * bgm
Definition: tetgen.h:2036
void triangulate(int shmark, REAL eps, list *ptlist, list *conlist, int holes, REAL *holelist, memorypool *viri, queue *)
void setpoint2sh(point pt, shellface value)
Definition: tetgen.h:3258
void outmetrics(tetgenio *)
static int va[6]
Definition: tetgen.h:1187
void decode(tetrahedron ptr, triface &t)
Definition: tetgen.h:2457
static int vd[6]
Definition: tetgen.h:1187
long cdtenforcesegpts
Definition: tetgen.h:2171
REAL interiorangle(REAL *o, REAL *p1, REAL *p2, REAL *n)
bool acceptvolpt(point volpt, list *ceillist, list *verlist)
void carvecavity(arraypool *, arraypool *, arraypool *)
long hullsize
Definition: tetgen.h:2116
void getseghasorg(face *sseg, point dorg)
void marksharpsegments(REAL sharpangle)
void markedge(triface &t)
Definition: tetgen.h:2837
static int vo[6]
Definition: tetgen.h:1187
int firstnonemptyq
Definition: tetgen.h:2107
void detectinterfaces()
void sesymself(face &s)
Definition: tetgen.h:2947
bool recoverfacebyflips(triface *front, int *)
enum verttype pointtype(point pt)
Definition: tetgen.h:3219
void interpolatesizemap()
shellface point2seg(point pt)
Definition: tetgen.h:3262
long rejtetpts
Definition: tetgen.h:2172
void planelineint(REAL *, REAL *, REAL *, REAL *, REAL *, REAL *, REAL *)
REAL tetaspectratio(point, point, point, point)
void formskeleton(clock_t &)
void flip23(triface *, queue *)
bool removeedgebyflip22(REAL *key, int, triface *, queue *)
long updsegcount
Definition: tetgen.h:2167
bool constrainedcavity(triface *oldtet, list *floorlist, list *ceillist, list *ptlist, list *frontlist, list *misfrontlist, list *newtetlist, list *gluetetlist, list *glueshlist, queue *flipque)
bool fnext(triface &t1, triface &t2)
Definition: tetgen.h:2574
void splitsubface(point, face *, queue *)
enum finddirectionresult finddirectionsub(face *searchsh, point tend)
void enext2self(triface &t)
Definition: tetgen.h:2566
void unmarkedge(triface &t)
Definition: tetgen.h:2842
void tsspivot(triface *, face *)
void enextfnextself(triface &t)
Definition: tetgen.h:2732
void outsubsegments(tetgenio *)
enum interresult finddirection3(triface *searchtet, point)
static int locver2apex[4][6]
Definition: tetgen.h:1193
point apex(triface &t)
Definition: tetgen.h:2505
void setnewpointsize(point newpt, point e1, point e2)
int shmarkindex
Definition: tetgen.h:2129
list * segpbcgrouptable
Definition: tetgen.h:2095
REAL macheps
Definition: tetgen.h:2146
void makeshellface(memorypool *, face *)
bool removefacebyflips(triface *remface, int *)
void constrainededge(face *startsh, point tend, queue *flipqueue)
bool findorg(triface *t, point dorg)
void cross(REAL *v1, REAL *v2, REAL *n)
Definition: tetgen.h:3370
int checksubfaces
Definition: tetgen.h:2131
bool findorg(face *s, point dorg)
void esymself(triface &t)
Definition: tetgen.h:2542
enum locateresult adjustlocate(point, triface *, enum locateresult, REAL)
void senext2(face &s1, face &s2)
Definition: tetgen.h:2960
void formbowatcavity(point bp, face *bpseg, face *bpsh, int *n, int *nmax, list **sublists, list **subceillists, list **tetlists, list **ceillists)
void releasebowatcavity(face *, int, list **, list **, list **, list **)
void point2tetorg(point, triface &)
void tspivot(triface &t, face &s)
Definition: tetgen.h:3078
int checkmesh()
REAL cosmaxdihed
Definition: tetgen.h:2147
void randomsample(point searchpt, triface *searchtet)
void makepoint(point *)
void splitsubedge(point, face *, queue *)
void restorecavity(arraypool *, arraypool *, arraypool *)
void maketetrahedron(triface *)
long ndelaunayedgecount
Definition: tetgen.h:2162
void tetalldihedral(point, point, point, point, REAL *, REAL *, REAL *)
long lawson3d(queue *flipqueue)
void sinfect(face &s)
Definition: tetgen.h:3039
void formcavity(face *, arraypool *, arraypool *, arraypool *, arraypool *, arraypool *, arraypool *, arraypool *)
void stdissolve(face &s)
Definition: tetgen.h:3123
void carveholessub(int holes, REAL *holelist, memorypool *viri)
finddirectionresult
Definition: tetgen.h:853
@ TOPCOLLINEAR
Definition: tetgen.h:854
@ RIGHTCOLLINEAR
Definition: tetgen.h:854
@ ACROSSEDGE
Definition: tetgen.h:853
@ LEFTCOLLINEAR
Definition: tetgen.h:853
@ BELOWHULL
Definition: tetgen.h:854
@ ACROSSFACE
Definition: tetgen.h:853
void setpoint2pbcpt(point pt, point value)
Definition: tetgen.h:3292
void setsdest(face &s, point pointptr)
Definition: tetgen.h:2931
point sdest(face &s)
Definition: tetgen.h:2919
bool circumsphere(REAL *, REAL *, REAL *, REAL *, REAL *cent, REAL *radius)
bool acceptfacpt(point facpt, list *subceillist, list *verlist)
void enqueuebadtet(triface *tt, REAL key, REAL *cent)
void setpoint2seg(point pt, shellface value)
Definition: tetgen.h:3266
badface * shell2badface(face &s)
Definition: tetgen.h:2982
void point2shorg(point, face &)
long delaunizevertices()
memorypool * badsubfaces
Definition: tetgen.h:2046
void dummyinit(int, int)
void getonextseg(face *s, face *lseg)
void tsspivot1(triface &t, face &seg)
Definition: tetgen.h:3163
bool validatebowatcavityquad(point bp, list *ceillist, REAL maxcosd)
void badfacedealloc(memorypool *, badface *)
void markacutevertices(REAL acuteangle)
void tsbond(triface &t, face &s)
Definition: tetgen.h:3097
bool check4fixededge(point pa, point pb)
int suprelverts
Definition: tetgen.h:2139
void enqueueflipface(triface &, queue *)
bool checksub4encroach(face *testsub, point testpt, bool enqflag)
void shellfacedealloc(memorypool *, shellface *)
int maxcavverts
Definition: tetgen.h:2149
void infecthull(memorypool *viri)
bool suppressvolpoint(triface *suptet, list *frontlist, list *misfrontlist, list *ptlist, queue *flipque, bool optflag)
int shellmark(face &s)
Definition: tetgen.h:3005
bool iscollinear(REAL *, REAL *, REAL *, REAL eps)
int unsupverts
Definition: tetgen.h:2141
void enqueueencsub(face *ss, point encpt, int quenumber, REAL *cent)
shellface * dummysh
Definition: tetgen.h:2056
enum locateresult locate(point searchpt, triface *searchtet)
fliptype
Definition: tetgen.h:836
@ N32
Definition: tetgen.h:836
@ T44
Definition: tetgen.h:836
@ T22
Definition: tetgen.h:836
@ FORBIDDENFACE
Definition: tetgen.h:836
@ T23
Definition: tetgen.h:836
@ T32
Definition: tetgen.h:836
@ FORBIDDENEDGE
Definition: tetgen.h:836
@ N40
Definition: tetgen.h:836
void insertconstrainedpoints(tetgenio *addio)
void sbond1(face &s1, face &s2)
Definition: tetgen.h:2901
int nonconvex
Definition: tetgen.h:2135
point abovepoint
Definition: tetgen.h:2083
void pointdealloc(point)
void deallocfaketets(list *frontlist)
void infecthullsub(memorypool *viri)
bool lu_decmp(REAL lu[4][4], int n, int *ps, REAL *d, int N)
static int locpivot[4][3]
Definition: tetgen.h:1211
void getsegmentsplitpoint3(face *sseg, point refpt, REAL *vt)
bool carvecavity(list *newtetlist, list *outtetlist, list *gluetetlist, queue *flipque)
bool facemarked(triface &t)
Definition: tetgen.h:2828
int smoothsegverts
Definition: tetgen.h:2142
void unmarkface(triface &t)
Definition: tetgen.h:2824
bool tallencsubs(point testpt, int n, list **ceillists)
int areaboundindex
Definition: tetgen.h:2130
long r3count
Definition: tetgen.h:2170
REAL elemattribute(tetrahedron *ptr, int attnum)
Definition: tetgen.h:2749
void dissolve(triface &t)
Definition: tetgen.h:2490
long cavityexpcount
Definition: tetgen.h:2162
bool smoothsliver(badface *remedge, list *starlist)
void tfnext(triface &t1, triface &t2)
Definition: tetgen.h:2685
void symself(triface &t)
Definition: tetgen.h:2473
bool findcollapseedge(point suppt, point *conpt, list *oldtetlist, list *)
void projpt2edge(REAL *p, REAL *e1, REAL *e2, REAL *prj)
REAL zmax
Definition: tetgen.h:2113
void insertauxsubface(triface *front, triface *idfront)
void sdecode(shellface sptr, face &s)
Definition: tetgen.h:2868
long bowatvolcount
Definition: tetgen.h:2166
REAL ymax
Definition: tetgen.h:2113
long insegments
Definition: tetgen.h:2117
bool isdead(triface *t)
Definition: tetgen.h:3322
arraypool * cavebdrylist
Definition: tetgen.h:2067
void transfernodes()
void setelemmarker(tetrahedron *ptr, int value)
Definition: tetgen.h:2774
REAL volumebound(tetrahedron *ptr)
Definition: tetgen.h:2760
bool pinfected(point pt)
Definition: tetgen.h:3239
static int minus1mod3[3]
Definition: tetgen.h:1216
REAL * point
Definition: tetgen.h:998
static int locver2edge[4][6]
Definition: tetgen.h:1204
int max_btreenode_size
Definition: tetgen.h:2062
void enext(triface &t1, triface &t2)
Definition: tetgen.h:2548
verttype
Definition: tetgen.h:829
@ ACUTEVERTEX
Definition: tetgen.h:829
@ FREESEGVERTEX
Definition: tetgen.h:830
@ DUPLICATEDVERTEX
Definition: tetgen.h:829
@ UNUSEDVERTEX
Definition: tetgen.h:829
@ FREEVOLVERTEX
Definition: tetgen.h:830
@ NACUTEVERTEX
Definition: tetgen.h:829
@ DEADVERTEX
Definition: tetgen.h:830
@ FREESUBVERTEX
Definition: tetgen.h:830
void infect(triface &t)
Definition: tetgen.h:2782
arraypool * caveoldtetlist
Definition: tetgen.h:2067
void symedgeself(triface &t)
Definition: tetgen.h:2659
tetgenio * in
Definition: tetgen.h:2030
void setpointmark(point pt, int value)
Definition: tetgen.h:3212
void outedges(tetgenio *)
REAL ** shellface
Definition: tetgen.h:985
long bowatsegcount
Definition: tetgen.h:2166
point dest(triface &t)
Definition: tetgen.h:2501
long opt_tet_peels
Definition: tetgen.h:2163
void setorg(triface &t, point pointptr)
Definition: tetgen.h:2513
REAL zmin
Definition: tetgen.h:2113
static REAL PI
Definition: tetgen.h:1641
static int edge2locver[6][2]
Definition: tetgen.h:1205
int getelemmarker(tetrahedron *ptr)
Definition: tetgen.h:2770
void carveholes()
void unmarktest(triface &t)
Definition: tetgen.h:2806
int tri_edge_test(point, point, point, point, point, point, int, int *, int *)
void bond(triface &t1, triface &t2)
Definition: tetgen.h:2480
bool delaunizecavity(arraypool *, arraypool *, arraypool *, arraypool *, arraypool *, arraypool *)
REAL distance2(tetrahedron *tetptr, point p)
enum locateresult insertvertexbw(point insertpt, triface *searchtet, bool bwflag, bool visflag, bool noencsegflag, bool noencsubflag)
void makesegmentmap(int *&, shellface **&)
tetgenmesh()
Definition: tetgen.h:2182
int max_btree_depth
Definition: tetgen.h:2064
long flip14count
Definition: tetgen.h:2156
long meshsurface()
static int ve[6]
Definition: tetgen.h:1184
bool removefacebyflip23(REAL *key, triface *, triface *, queue *)
badface * tetquetail[64]
Definition: tetgen.h:2105
void unifysegments()
void setpoint2tet(point pt, tetrahedron value)
Definition: tetgen.h:3250
REAL lengthlimit
Definition: tetgen.h:2115
void setoppo(triface &t, point pointptr)
Definition: tetgen.h:2525
void makesubfacemap(int *&, shellface **&)
enum interresult tri_edge_inter(REAL *, REAL *, REAL *, REAL *, REAL *)
REAL incircle3d(point pa, point pb, point pc, point pd)
REAL insphere_s(REAL *, REAL *, REAL *, REAL *, REAL *)
triface recenttet
Definition: tetgen.h:2111
bool scoutsegmentsub(face *searchsh, point tend)
tetgenbehavior * b
Definition: tetgen.h:2033
triface firsttopface
Definition: tetgen.h:2073
int checksegments()
point org(triface &t)
Definition: tetgen.h:2497
memorypool * tetrahedrons
Definition: tetgen.h:2041
tetrahedron * dummytetbase
Definition: tetgen.h:2052
void formbowatcavitysub(point, face *, list *, list *)
void findedge(face *s, point eorg, point edest)
enum interresult edge_edge_cop_inter(REAL *, REAL *, REAL *, REAL *, REAL *)
bool edgemarked(triface &t)
Definition: tetgen.h:2847
void splitsubedge(point, face *, arraypool *, arraypool *)
int dupverts
Definition: tetgen.h:2136
enum shestype shelltype(face &s)
Definition: tetgen.h:3018
int nextnonemptyq[64]
Definition: tetgen.h:2106
long lawson(queue *flipqueue)
enum locateresult preciselocate(point searchpt, triface *searchtet, long)
enum interresult tri_vert_cop_inter(REAL *, REAL *, REAL *, REAL *, REAL *)
void updatebowatcavityquad(list *tetlist, list *ceillist)
int point2simindex
Definition: tetgen.h:2122
REAL ymin
Definition: tetgen.h:2113
badface * dequeueencsub(int *quenumber)
void setshellmark(face &s, int value)
Definition: tetgen.h:3010
void senextself(face &s)
Definition: tetgen.h:2956
point point2ppt(point pt)
Definition: tetgen.h:3270
bool splitsliver(badface *remedge, list *tetlist, list *ceillist)
void btree_insert(point insertpt)
bool removeedgebytranNM(REAL *, int, triface *, triface *, point, point, queue *)
void repairencsubs(bool chkbadtet)
bool delaunizecavvertices(triface *, list *, list *, list *, queue *)
bool identifyfronts(list *frontlist, list *misfrontlist, list *gluetetlist, list *glueshlist)
void markface(triface &t)
Definition: tetgen.h:2820
insertsiteresult
Definition: tetgen.h:849
@ SUCCESSONEDGE
Definition: tetgen.h:849
@ SUCCESSINTET
Definition: tetgen.h:849
@ DUPLICATEPOINT
Definition: tetgen.h:850
@ OUTSIDEPOINT
Definition: tetgen.h:850
@ SUCCESSONFACE
Definition: tetgen.h:849
REAL minfacetdihed
Definition: tetgen.h:2148
void enextfnext(triface &t1, triface &t2)
Definition: tetgen.h:2727
void enext2(triface &t1, triface &t2)
Definition: tetgen.h:2560
int steinerleft
Definition: tetgen.h:2119
void plague(memorypool *viri)
point * facetabovepointarray
Definition: tetgen.h:2083
static int plus1mod3[3]
Definition: tetgen.h:1215
int checkpbcs
Definition: tetgen.h:2133
void outmesh2gid(char *)
int varconstraint
Definition: tetgen.h:2134
void updatebowatcavitysub(list *sublist, list *subceillist, int *cutcount)
bool unifypoint(point testpt, triface *, enum locateresult, REAL)
enum interresult scoutcrosstet(face *ssub, triface *searchtet, arraypool *)
bool iscoplanar(REAL *, REAL *, REAL *, REAL *, REAL vol6, REAL eps)
void recoversubfacebyflips(face *pssub, triface *crossface, arraypool *)
REAL longest
Definition: tetgen.h:2114
int unuverts
Definition: tetgen.h:2137
enum interresult scoutsegment2(face *, triface *, point *)
static int locverpivot[4][6][2]
Definition: tetgen.h:1212
long inserthullcount
Definition: tetgen.h:2158
badface ** subquetail[3]
Definition: tetgen.h:2104
void enext2fnext(triface &t1, triface &t2)
Definition: tetgen.h:2737
REAL dot(REAL *v1, REAL *v2)
Definition: tetgen.h:3363
memorypool * points
Definition: tetgen.h:2044
long updsubcount
Definition: tetgen.h:2167
arraypool * caveshlist
Definition: tetgen.h:2068
int volumeboundindex
Definition: tetgen.h:2127
void rotatepoint(REAL *p, REAL rotangle, REAL *p1, REAL *p2)
enum interresult tri_tri_inter(REAL *, REAL *, REAL *, REAL *, REAL *, REAL *)
enum interresult scoutsubface(face *ssub, triface *searchtet, int)
long failvolcount
Definition: tetgen.h:2168
arraypool * cavetetlist
Definition: tetgen.h:2067
arraypool * subfacstack
Definition: tetgen.h:2070
@ N
Definition: constructor.cpp:22
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
RealScalar s
Definition: level1_cplx_impl.h:130
return int(ret)+1
int RealScalar int RealScalar int RealScalar RealScalar * ps
Definition: level1_cplx_impl.h:124
int RealScalar int RealScalar int RealScalar * pc
Definition: level1_cplx_impl.h:124
const char const int const RealScalar const RealScalar * pa
Definition: level2_cplx_impl.h:20
const char const int const int const RealScalar const RealScalar const int const RealScalar * pb
Definition: level2_impl.h:28
char char * op
Definition: level2_impl.h:374
double eps
Definition: crbond_bessel.cc:24
squared absolute value
Definition: GlobalFunctions.h:87
double f2(const Vector< double > &coord)
f2 function, in front of the C2 unknown
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:233
double f1(const Vector< double > &coord)
f1 function, in front of the C1 unknown
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:147
radius
Definition: UniformPSDSelfTest.py:15
int c
Definition: calibrate.py:100
const double & pe() const
Peclet number.
Definition: gen_axisym_advection_diffusion_elements.h:284
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36
Definition: tetgen.h:229
int numberofpolygons
Definition: tetgen.h:231
int numberofholes
Definition: tetgen.h:233
polygon * polygonlist
Definition: tetgen.h:230
REAL * holelist
Definition: tetgen.h:232
Definition: tetgen.h:274
int * pointpairlist
Definition: tetgen.h:278
int numberofpointpairs
Definition: tetgen.h:277
int fmark1
Definition: tetgen.h:275
Definition: tetgen.h:217
int numberofvertices
Definition: tetgen.h:219
int * vertexlist
Definition: tetgen.h:218
Definition: tetgen.h:250
int v1
Definition: tetgen.h:251
Definition: tetgen.h:262
int c1
Definition: tetgen.h:263
int * elist
Definition: tetgen.h:264
Definition: tetgen.h:1104
triface tt
Definition: tetgen.h:1105
point fapex
Definition: tetgen.h:1109
point forg
Definition: tetgen.h:1109
point fdest
Definition: tetgen.h:1109
point foppo
Definition: tetgen.h:1109
REAL cent[3]
Definition: tetgen.h:1108
struct badface * previtem
Definition: tetgen.h:1111
REAL key
Definition: tetgen.h:1107
face ss
Definition: tetgen.h:1106
point noppo
Definition: tetgen.h:1110
struct badface * nextitem
Definition: tetgen.h:1111
Definition: tetgen.h:1154
REAL transmat[2][4][4]
Definition: tetgen.h:1158
int segid[2]
Definition: tetgen.h:1156
face ss[2]
Definition: tetgen.h:1157
int fmark[2]
Definition: tetgen.h:1155
std::ofstream out("Result.txt")
void terminatetetgen(int x)
Definition: tetgen.h:2370
#define REAL
Definition: tetgen.h:146
REAL insphere(REAL *pa, REAL *pb, REAL *pc, REAL *pd, REAL *pe)
REAL orient3d(REAL *pa, REAL *pb, REAL *pc, REAL *pd)
void swapBytes(unsigned char *var, int size)
Definition: tetgen.h:3410
bool testIsBigEndian()
Definition: tetgen.h:3422
void tetrahedralize(tetgenbehavior *b, tetgenio *in, tetgenio *out, tetgenio *addin=NULL, tetgenio *bgmin=NULL)
#define EdgeRing(V)
Definition: tetgen.h:2442
REAL exactinit()
#define Orient(V)
Definition: tetgen.h:2438
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2