From ec66468a72aa1c6459b016efc18045945da822dd Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 19 Aug 2007 03:11:50 -0400 Subject: [PATCH] Add constructor/destructor to tetgen's pbcgroup. Update patch against 1.4.2. --- patches/mk-patch | 5 + patches/tetgen-1.4.2.patch | 273 +++++++++++++++++++++---------------- src/cpp/tetgen.cpp | 24 ++-- src/cpp/tetgen.h | 7 +- src/python/tet.py | 1 - 5 files changed, 180 insertions(+), 130 deletions(-) create mode 100755 patches/mk-patch diff --git a/patches/mk-patch b/patches/mk-patch new file mode 100755 index 0000000..218f2ce --- /dev/null +++ b/patches/mk-patch @@ -0,0 +1,5 @@ +#! /bin/sh + +diff -u $1/tetgen.h ../src/cpp/tetgen.h +diff -u $1/tetgen.cxx ../src/cpp/tetgen.cpp +diff -u $1/predicates.cxx ../src/cpp/predicates.cpp diff --git a/patches/tetgen-1.4.2.patch b/patches/tetgen-1.4.2.patch index 45ee71f..d47ba72 100644 --- a/patches/tetgen-1.4.2.patch +++ b/patches/tetgen-1.4.2.patch @@ -1,77 +1,82 @@ -Nur in tetgen1.4.2-hacked: headerpatch. -Nur in tetgen1.4.2-hacked: headerpatch~. -Nur in tetgen1.4.2-hacked: meshpy. -diff -u tetgen1.4.2/predicates.cxx tetgen1.4.2-hacked/predicates.cxx ---- tetgen1.4.2/predicates.cxx 2007-04-16 09:45:04.000000000 -0500 -+++ tetgen1.4.2-hacked/predicates.cxx 2007-07-19 18:59:39.000000000 -0500 -@@ -113,6 +113,10 @@ - /* */ - /*****************************************************************************/ +--- /home/andreas/tetgen1.4.2/tetgen.h 2007-04-16 10:45:13.000000000 -0400 ++++ ../src/cpp/tetgen.h 2007-08-19 03:03:45.000000000 -0400 +@@ -87,6 +87,7 @@ + #include // Math lib: sin(), sqrt(), pow(), ... + #include // Defined type clock_t, constant CLOCKS_PER_SEC. + #include ++#include -+#if defined(__linux__) && defined(__i386__) -+ #define LINUX 1 -+#endif + /////////////////////////////////////////////////////////////////////////////// + // // +@@ -194,10 +195,13 @@ + // 'vertexlist' is a list of vertex indices (integers), its length is + // indicated by 'numberofvertices'. The vertex indices are odered in + // either counterclockwise or clockwise way. +- typedef struct { ++ struct polygon : public boost::noncopyable { + int *vertexlist; + int numberofvertices; +- } polygon; + - #include - #include - #include -@@ -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 @@ - /* */ - /*****************************************************************************/ ++ polygon(); ++ ~polygon(); ++ }; -+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 */ + static void init(polygon* p) { + p->vertexlist = (int *) NULL; +@@ -208,12 +212,15 @@ + // to represent a planar straight line graph (PSLG) in two dimension. + // A PSLG contains a list of polygons. It also may conatin holes in it, + // indicated by a list of hole points (their coordinates). +- typedef struct { ++ struct facet { + polygon *polygonlist; + int numberofpolygons; + REAL *holelist; + int numberofholes; +- } facet; + - #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. */ - } ++ facet(); ++ ~facet(); ++ }; -+void exactdeinit() -+{ -+#ifdef LINUX -+ _FPU_SETCW(previous_cword); -+#endif /* LINUX */ -+} + static void init(facet* f) { + f->polygonlist = (polygon *) NULL; +@@ -253,12 +260,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; + - /*****************************************************************************/ - /* */ - /* grow_expansion() Add a scalar to an expansion. */ -Nur in tetgen1.4.2-hacked: predicates.patch. -Nur in tetgen1.4.2-hacked: predicates.patch~. -Nur in tetgen1.4.2-hacked: sourcepatch. -diff -u tetgen1.4.2/tetgen.cxx tetgen1.4.2-hacked/tetgen.cxx ---- tetgen1.4.2/tetgen.cxx 2007-04-16 09:45:11.000000000 -0500 -+++ tetgen1.4.2-hacked/tetgen.cxx 2007-07-19 19:02:15.000000000 -0500 -@@ -49,6 +49,34 @@ ++ pbcgroup(); ++ ~pbcgroup(); ++ }; + + public: + +@@ -568,6 +578,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/tetgen1.4.2/tetgen.cxx 2007-04-16 10:45:11.000000000 -0400 ++++ ../src/cpp/tetgen.cpp 2007-08-19 03:05:28.000000000 -0400 +@@ -49,6 +49,45 @@ // Begin of class 'tetgenio' implementation // +tetgenio::polygon::polygon() +{ -+ vertexlist = (int *) NULL; ++ vertexlist = 0; + numberofvertices = 0; +} + @@ -83,9 +88,9 @@ diff -u tetgen1.4.2/tetgen.cxx tetgen1.4.2-hacked/tetgen.cxx + +tetgenio::facet::facet() +{ -+ polygonlist = (polygon *) NULL; ++ polygonlist = 0; + numberofpolygons = 0; -+ holelist = (REAL *) NULL; ++ holelist = 0; + numberofholes = 0; +} + @@ -96,11 +101,30 @@ diff -u tetgen1.4.2/tetgen.cxx tetgen1.4.2-hacked/tetgen.cxx + if (holelist) + delete[] holelist; +} ++ ++tetgenio::pbcgroup::pbcgroup() ++{ ++ numberofpointpairs = 0; ++ pointpairlist = 0; ++} ++ ++tetgenio::pbcgroup::~pbcgroup() ++{ ++ delete[] pointpairlist; ++} + /////////////////////////////////////////////////////////////////////////////// // // // initialize() Initialize all variables of 'tetgenio'. // -@@ -187,19 +215,9 @@ +@@ -143,6 +182,7 @@ + pbcgroup *pg; + int i, j; + ++ using namespace std; + if (pointlist != (REAL *) NULL) { + delete [] pointlist; + } +@@ -187,19 +227,9 @@ } if (facetlist != (facet *) NULL) { @@ -121,7 +145,20 @@ diff -u tetgen1.4.2/tetgen.cxx tetgen1.4.2-hacked/tetgen.cxx if (facetmarkerlist != (int *) NULL) { delete [] facetmarkerlist; } -@@ -34887,6 +34905,7 @@ +@@ -217,12 +247,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) { +@@ -34887,6 +34911,7 @@ if (b->metric) { delete m.bgm; } @@ -129,60 +166,60 @@ diff -u tetgen1.4.2/tetgen.cxx tetgen1.4.2-hacked/tetgen.cxx } #ifndef TETLIBRARY -Nur in tetgen1.4.2-hacked: tetgen.cxx.orig. -diff -u tetgen1.4.2/tetgen.h tetgen1.4.2-hacked/tetgen.h ---- tetgen1.4.2/tetgen.h 2007-04-16 09:45:13.000000000 -0500 -+++ tetgen1.4.2-hacked/tetgen.h 2007-07-19 19:02:06.000000000 -0500 -@@ -87,6 +87,7 @@ - #include // Math lib: sin(), sqrt(), pow(), ... - #include // Defined type clock_t, constant CLOCKS_PER_SEC. - #include -+#include +--- /home/andreas/tetgen1.4.2/predicates.cxx 2007-04-16 10:45:04.000000000 -0400 ++++ ../src/cpp/predicates.cpp 2007-07-19 20:55:24.000000000 -0400 +@@ -113,6 +113,10 @@ + /* */ + /*****************************************************************************/ - /////////////////////////////////////////////////////////////////////////////// - // // -@@ -194,10 +195,13 @@ - // 'vertexlist' is a list of vertex indices (integers), its length is - // indicated by 'numberofvertices'. The vertex indices are odered in - // either counterclockwise or clockwise way. -- typedef struct { -+ struct polygon : public boost::noncopyable { - int *vertexlist; - int numberofvertices; -- } polygon; ++#if defined(__linux__) && defined(__i386__) ++ #define LINUX 1 ++#endif + -+ polygon(); -+ ~polygon(); -+ }; + #include + #include + #include +@@ -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. */ - static void init(polygon* p) { - p->vertexlist = (int *) NULL; -@@ -208,12 +212,15 @@ - // to represent a planar straight line graph (PSLG) in two dimension. - // A PSLG contains a list of polygons. It also may conatin holes in it, - // indicated by a list of hole points (their coordinates). -- typedef struct { -+ struct facet : public boost::noncopyable { - polygon *polygonlist; - int numberofpolygons; - REAL *holelist; - int numberofholes; -- } facet; -+ -+ facet(); -+ ~facet(); -+ }; +-#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) - static void init(facet* f) { - f->polygonlist = (polygon *) NULL; -@@ -568,6 +575,7 @@ - /////////////////////////////////////////////////////////////////////////////// + /* 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 @@ + /* */ + /*****************************************************************************/ - 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); ++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. */ + } -Nur in tetgen1.4.2-hacked: tetgen.h~. -Nur in tetgen1.4.2-hacked: tetgen.h.orig. -Nur in tetgen1.4.2-hacked: tetgen.h.rej. ++void exactdeinit() ++{ ++#ifdef LINUX ++ _FPU_SETCW(previous_cword); ++#endif /* LINUX */ ++} ++ + /*****************************************************************************/ + /* */ + /* grow_expansion() Add a scalar to an expansion. */ diff --git a/src/cpp/tetgen.cpp b/src/cpp/tetgen.cpp index 2886e49..79006bf 100644 --- a/src/cpp/tetgen.cpp +++ b/src/cpp/tetgen.cpp @@ -51,7 +51,7 @@ void terminatetetgen(int x) tetgenio::polygon::polygon() { - vertexlist = (int *) NULL; + vertexlist = 0; numberofvertices = 0; } @@ -63,9 +63,9 @@ tetgenio::polygon::~polygon() tetgenio::facet::facet() { - polygonlist = (polygon *) NULL; + polygonlist = 0; numberofpolygons = 0; - holelist = (REAL *) NULL; + holelist = 0; numberofholes = 0; } @@ -77,6 +77,17 @@ tetgenio::facet::~facet() delete[] holelist; } +tetgenio::pbcgroup::pbcgroup() +{ + numberofpointpairs = 0; + pointpairlist = 0; +} + +tetgenio::pbcgroup::~pbcgroup() +{ + delete[] pointpairlist; +} + /////////////////////////////////////////////////////////////////////////////// // // // initialize() Initialize all variables of 'tetgenio'. // @@ -171,6 +182,7 @@ void tetgenio::deinitialize() pbcgroup *pg; int i, j; + using namespace std; if (pointlist != (REAL *) NULL) { delete [] pointlist; } @@ -235,12 +247,6 @@ void tetgenio::deinitialize() 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) { diff --git a/src/cpp/tetgen.h b/src/cpp/tetgen.h index 63edac9..47ac535 100644 --- a/src/cpp/tetgen.h +++ b/src/cpp/tetgen.h @@ -260,12 +260,15 @@ class tetgenio { // 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(); + }; public: diff --git a/src/python/tet.py b/src/python/tet.py index 8752e0e..8a22b63 100644 --- a/src/python/tet.py +++ b/src/python/tet.py @@ -60,7 +60,6 @@ class MeshInfo(internals.MeshInfo, MeshInfoBase): - class Options(internals.Options): def __init__(self, switches="pq"): internals.Options.__init__(self) -- GitLab