Skip to content

Commit

Permalink
Upgrade tetgen to 1.4.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Oct 4, 2013
1 parent 2e28cc0 commit c96c09a
Show file tree
Hide file tree
Showing 4 changed files with 19,582 additions and 18,023 deletions.
214 changes: 214 additions & 0 deletions patches/tetgen-1.4.3.patch
@@ -0,0 +1,214 @@
--- /home/andreas/pack/tetgen1.4.3/tetgen.h 2009-12-13 16:20:33.000000000 -0500
+++ ../src/cpp/tetgen.h 2010-01-22 19:41:28.590818901 -0500
@@ -87,6 +87,7 @@
#include <math.h>
#include <time.h>
#include <assert.h>
+#include <boost/noncopyable.hpp>

// The types 'intptr_t' and 'uintptr_t' are signed and unsigned integer types,
// respectively. They are guaranteed to be the same width as a pointer.
@@ -213,10 +214,13 @@
// Note that the points of the polygon must be given in either counter-
// clockwise or clockwise order and they form a ring, so every two
// consective points forms an edge of the polygon.
- typedef struct {
+ struct polygon : public boost::noncopyable {
int *vertexlist;
int numberofvertices;
- } polygon;
+
+ polygon();
+ ~polygon();
+ };

static void init(polygon* p) {
p->vertexlist = (int *) NULL;
@@ -225,12 +229,15 @@

// The facet data structure. A "facet" describes a facet. Each facet is
// a polygonal region possibly with holes, edges, and points in it.
- typedef struct {
+ struct facet {
polygon *polygonlist;
int numberofpolygons;
REAL *holelist;
int numberofholes;
- } facet;
+
+ facet();
+ ~facet();
+ };

static void init(facet* f) {
f->polygonlist = (polygon *) NULL;
@@ -270,12 +277,15 @@
// maps a point in f1 into f2. An array of pbc point pairs are saved
// in 'pointpairlist'. The first point pair is at indices [0] and [1],
// followed by remaining pairs. Two integers per pair.
- typedef struct {
+ struct pbcgroup {
int fmark1, fmark2;
REAL transmat[4][4];
int numberofpointpairs;
int *pointpairlist;
- } pbcgroup;
+
+ pbcgroup();
+ ~pbcgroup();
+ };

// A callback function for mesh refinement.
typedef bool (* TetSizeFunc)(REAL*, REAL*, REAL*, REAL*, REAL*, REAL);
@@ -549,17 +559,6 @@
}

if (facetlist != (facet *) NULL) {
- for (i = 0; i < numberoffacets; i++) {
- f = &facetlist[i];
- for (j = 0; j < f->numberofpolygons; j++) {
- p = &f->polygonlist[j];
- delete [] p->vertexlist;
- }
- delete [] f->polygonlist;
- if (f->holelist != (REAL *) NULL) {
- delete [] f->holelist;
- }
- }
delete [] facetlist;
}
if (facetmarkerlist != (int *) NULL) {
@@ -579,12 +578,6 @@
delete [] segmentconstraintlist;
}
if (pbcgrouplist != (pbcgroup *) NULL) {
- for (i = 0; i < numberofpbcgroups; i++) {
- pg = &(pbcgrouplist[i]);
- if (pg->pointpairlist != (int *) NULL) {
- delete [] pg->pointpairlist;
- }
- }
delete [] pbcgrouplist;
}
if (vpointlist != (REAL *) NULL) {
@@ -2381,6 +2374,7 @@
///////////////////////////////////////////////////////////////////////////////

REAL exactinit();
+void exactdeinit();
REAL orient3d(REAL *pa, REAL *pb, REAL *pc, REAL *pd);
REAL insphere(REAL *pa, REAL *pb, REAL *pc, REAL *pd, REAL *pe);

--- /home/andreas/pack/tetgen1.4.3/tetgen.cxx 2009-12-13 16:21:08.000000000 -0500
+++ ../src/cpp/tetgen.cpp 2010-01-22 19:41:28.590818901 -0500
@@ -34,6 +34,45 @@
//// ////
//// ////

+tetgenio::polygon::polygon()
+{
+ vertexlist = 0;
+ numberofvertices = 0;
+}
+
+tetgenio::polygon::~polygon()
+{
+ if (vertexlist)
+ delete [] vertexlist;
+}
+
+tetgenio::facet::facet()
+{
+ polygonlist = 0;
+ numberofpolygons = 0;
+ holelist = 0;
+ numberofholes = 0;
+}
+
+tetgenio::facet::~facet()
+{
+ if (polygonlist)
+ delete[] polygonlist;
+ if (holelist)
+ delete[] holelist;
+}
+
+tetgenio::pbcgroup::pbcgroup()
+{
+ numberofpointpairs = 0;
+ pointpairlist = 0;
+}
+
+tetgenio::pbcgroup::~pbcgroup()
+{
+ delete[] pointpairlist;
+}
+
///////////////////////////////////////////////////////////////////////////////
// //
// load_node_call() Read a list of points from a file. //
@@ -34751,6 +34790,7 @@
if (b->metric) {
delete m.bgm;
}
+ exactdeinit();
}

#ifndef TETLIBRARY
--- /home/andreas/pack/tetgen1.4.3/predicates.cxx 2009-12-13 16:18:56.000000000 -0500
+++ ../src/cpp/predicates.cpp 2010-01-22 19:41:28.576309963 -0500
@@ -113,6 +113,10 @@
/* */
/*****************************************************************************/

+#if defined(__linux__) && defined(__i386__)
+ #define LINUX 1
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -149,8 +153,8 @@
/* which is disastrously slow. A faster way on IEEE machines might be to */
/* mask the appropriate bit, but that's difficult to do in C. */

-#define Absolute(a) ((a) >= 0.0 ? (a) : -(a))
-/* #define Absolute(a) fabs(a) */
+/* #define Absolute(a) ((a) >= 0.0 ? (a) : -(a))*/
+#define Absolute(a) fabs(a)

/* Many of the operations are broken up into two pieces, a main part that */
/* performs an approximate operation, and a "tail" that computes the */
@@ -660,6 +664,8 @@
/* */
/*****************************************************************************/

+static int previous_cword;
+
REAL exactinit()
{
REAL half;
@@ -676,7 +682,9 @@
_control87(_PC_53, _MCW_PC); /* Set FPU control word for double precision. */
#endif /* not SINGLE */
#endif /* CPU86 */
+
#ifdef LINUX
+ _FPU_GETCW(previous_cword);
#ifdef SINGLE
/* cword = 4223; */
cword = 4210; /* set FPU control word for single precision */
@@ -725,6 +733,13 @@
return epsilon; /* Added by H. Si 30 Juli, 2004. */
}

+void exactdeinit()
+{
+#ifdef LINUX
+ _FPU_SETCW(previous_cword);
+#endif /* LINUX */
+}
+
/*****************************************************************************/
/* */
/* grow_expansion() Add a scalar to an expansion. */

0 comments on commit c96c09a

Please sign in to comment.