Skip to content
Snippets Groups Projects
Commit eb687991 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

*** empty log message ***

parent 2ec51ef3
No related branches found
No related tags found
No related merge requests found
...@@ -10,19 +10,8 @@ LIB = ../../lib/libGmshTetgen${LIBEXT} ...@@ -10,19 +10,8 @@ LIB = ../../lib/libGmshTetgen${LIBEXT}
# Don't optimize Tetgen # Don't optimize Tetgen
CFLAGS = ${FLAGS} ${DASH}DTETLIBRARY CFLAGS = ${FLAGS} ${DASH}DTETLIBRARY
SRC = behavior.cxx\ SRC = tetgen.cxx \
constrain.cxx\ predicates.cxx
delaunay.cxx\
flip.cxx\
geom.cxx\
io.cxx\
main.cxx\
memorypool.cxx\
meshio.cxx\
meshstat.cxx\
predicates.cxx\
refine.cxx\
surface.cxx
OBJ = ${SRC:.cxx=${OBJEXT}} OBJ = ${SRC:.cxx=${OBJEXT}}
...@@ -50,16 +39,3 @@ depend: ...@@ -50,16 +39,3 @@ depend:
rm -f Makefile.new rm -f Makefile.new
# DO NOT DELETE THIS LINE # DO NOT DELETE THIS LINE
behavior${OBJEXT}: behavior.cxx tetgen.h
constrain${OBJEXT}: constrain.cxx tetgen.h
delaunay${OBJEXT}: delaunay.cxx tetgen.h
flip${OBJEXT}: flip.cxx tetgen.h
geom${OBJEXT}: geom.cxx tetgen.h
io${OBJEXT}: io.cxx tetgen.h
main${OBJEXT}: main.cxx tetgen.h
memorypool${OBJEXT}: memorypool.cxx tetgen.h
meshio${OBJEXT}: meshio.cxx tetgen.h
meshstat${OBJEXT}: meshstat.cxx tetgen.h
predicates${OBJEXT}: predicates.cxx tetgen.h
refine${OBJEXT}: refine.cxx tetgen.h
surface${OBJEXT}: surface.cxx tetgen.h
This is an EXPERIMENTAL version of TetGen provided by Hang Si for Gmsh This is TetGen version 1.4.2 (released on April 16, 2007)
Please see the documentation of TetGen (available at the following link) for Please see the documentation of TetGen (available at the following link) for
compiling and using TetGen. compiling and using TetGen.
...@@ -13,4 +13,4 @@ Please send bugs/comments to Hang Si <si@wias-berlin.de> ...@@ -13,4 +13,4 @@ Please send bugs/comments to Hang Si <si@wias-berlin.de>
Thank you and enjoy! Thank you and enjoy!
Hang Si Hang Si
April 16, 2007
File moved
#ifndef refineCXX
#define refineCXX
#include "tetgen.h"
///////////////////////////////////////////////////////////////////////////////
// //
// checkedge4encroach() Check a subsegment to see if it is encroached. //
// //
// If 'testpt' != NULL, only test if the segment is encroached by this point.//
// Otherwise, test all apexes of faces containing this segment. //
// //
// If 'enqflag' > 0, add the segment into list (badsegpool) if it is encroa- //
// ched. //
// //
///////////////////////////////////////////////////////////////////////////////
bool tetgenmesh::checkedge4encroach(face& seg, point testpt, int enqflag)
{
badface *encseg;
triface neightet, spintet;
point pa, pb, pc, encpt;
REAL midpt[3], r, d, diff;
int encroached;
int i;
seg.shver = 0;
pa = sorg(seg);
pb = sdest(seg);
for (i = 0; i < 3; i++) {
midpt[i] = 0.5 * (pa[i] + pb[i]);
}
r = DIST(midpt, pa);
encroached = 0;
encpt = NULL;
if (testpt == NULL) {
// Check all apexes of faces containing [pa, pb].
stpivot(seg, neightet); // sstpivot(seg, neightet);
spintet = neightet;
while (1) {
pc = apex(spintet);
if (pc != dummypoint) {
d = DIST(midpt, pc);
diff = fabs(r - d);
if ((diff / r) < b->epsilon) {
// testpt is on the diametric ball of [pa, pb].
encroached = 0;
} else {
encroached = (d < r ? 1 : 0);
}
if (encroached) {
encpt = pc; // pc is encroached [pa. pb].
break;
}
}
fnextself(spintet);
if (spintet.tet == neightet.tet) break;
}
} else {
d = DIST(midpt, testpt);
diff = fabs(r - d);
if ((diff / r) < b->epsilon) {
// testpt is on the diametric ball of [pa, pb].
encroached = 0;
} else {
encroached = (d < r ? 1 : 0);
if (encroached) {
encpt = testpt;
}
}
}
if (encroached && enqflag) {
if (b->verbose > 1) {
printf(" Queuing encroaching segment (%d, %d) ref (%d).\n",
pointmark(pa), pointmark(pb), pointmark(encpt));
}
encseg = (badface *) badsegpool->alloc();
encseg->ss = seg;
encseg->forg = pa;
encseg->fdest = pb;
encseg->foppo = encpt; // The encroaching point.
smarktest(seg); // Flag it to avoid multiple testing.
}
return encroached > 0;
}
///////////////////////////////////////////////////////////////////////////////
// //
// repairencsegs() Repair all queued encroached subsegments. //
// //
// Encroached segments are repaired by inserting a vertex inside them. Each //
// newly inserted vertex may encroach other segments, or makeing them non- //
// Delaunay, these segments are also repaired. //
// //
///////////////////////////////////////////////////////////////////////////////
void tetgenmesh::repairencsegs()
{
badface *encloop;
triface searchtet;
face splitsh;
point newpt, refpt;
point pa, pb;
while ((badsegpool->items > 0) && (b->steinerleft != 0)) {
badsegpool->traversalinit();
encloop = badfacetraverse(badsegpool);
while ((encloop != NULL) && (b->steinerleft != 0)) {
// assert(smarktested(encloop->ss));
sunmarktest(encloop->ss);
// Check if it is still the same segment when it is tested.
pa = sorg(encloop->ss);
pb = sdest(encloop->ss);
if ((encloop->forg == pa) && (encloop->fdest == pb)) {
refpt = encloop->foppo;
if ((refpt == NULL) || getpointtype(refpt) == DEADVERTEX) {
// Check if this segment can be split.
assert(0); // Not handled yet.
}
// Create a new point in the segment.
makepoint(&newpt);
// getsegmentsplitpoint2(&(encloop->ss), refpt, newpt);
getsegmentsplitpoint3(&(encloop->ss), refpt, newpt);
setpointtype(newpt, STEINERVERTEX);
// Decrease the number of allocated Steiner points (-S option).
if (b->steinerleft != -1) {
b->steinerleft--;
}
// Get an adjacent tet for point location.
stpivot(encloop->ss, searchtet);
// Split the segment by newpt. Two new subsegments and new subfaces
// are queued in subsegstack and subfacstack for recovery.
spivot(encloop->ss, splitsh);
sinsertvertex(newpt, &splitsh, &(encloop->ss), true, false);
// Insert newpt into the DT. Since the mesh may be a CDT, always
// set visflag be true. Some existing egments and subfaces may be
// non-Delaunay due to this new vertex, they will be removed from
// the mesh, and are queued in subsegstack and subfacstack for
// recovery.
// Newly encroached segments, subfaces, and badly-shaped tets are
// queued in badsegpool, badsubpool, and badtetpool, resp.
insertvertex(newpt, &searchtet, true, true, false, false);
// Recover missing subsegments.
assert(subsegstack->objects > 0);
delaunizesegments();
// Recover missing subfaces.
assert(subfacstack->objects > 0);
constrainedfacets();
}
// Deallocate the badface.
badfacedealloc(badsegpool, encloop);
// Get the next badface.
encloop = badfacetraverse(badsegpool);
} // while (encloop != NULL)
} // while (badsegpool->items > 0)
}
///////////////////////////////////////////////////////////////////////////////
// //
// enforcequality() Create quality conforming Delaunay mesh. //
// //
///////////////////////////////////////////////////////////////////////////////
void tetgenmesh::enforcequality()
{
face shloop;
REAL bakeps;
long bakptcount;
if (!b->quiet) {
printf("Conforming Delaunay meshing.\n");
}
bakeps = b->epsilon; // Bakup the epsilon.
b->epsilon = 0;
// Initialize the pool for storing encroched segments.
badsegpool = new memorypool(sizeof(badface), SUBPERBLOCK, POINTER, 0);
// Initialize arrays.
tg_crosstets = new arraypool(sizeof(triface), 10);
tg_topnewtets = new arraypool(sizeof(triface), 10);
tg_botnewtets = new arraypool(sizeof(triface), 10);
tg_topfaces = new arraypool(sizeof(triface), 10);
tg_botfaces = new arraypool(sizeof(triface), 10);
tg_midfaces = new arraypool(sizeof(triface), 10);
tg_toppoints = new arraypool(sizeof(point), 8);
tg_botpoints = new arraypool(sizeof(point), 8);
tg_facpoints = new arraypool(sizeof(point), 8);
tg_facfaces = new arraypool(sizeof(face), 10);
tg_topshells = new arraypool(sizeof(face), 10);
tg_botshells = new arraypool(sizeof(face), 10);
// Find all encroached segments.
subsegpool->traversalinit();
shloop.sh = shellfacetraverse(subsegpool);
while (shloop.sh != NULL) {
checkedge4encroach(shloop, NULL, 1);
shloop.sh = shellfacetraverse(subsegpool);
}
if (b->verbose && (badsegpool->items > 0)) {
printf(" Splitting encroached segments.\n");
}
bakptcount = pointpool->items;
// Fix encroached segments.
repairencsegs();
// At this point, no segments should be encroached.
if (b->verbose && ((pointpool->items - bakptcount) > 0)) {
printf(" %ld Steiner points.\n", pointpool->items - bakptcount);
}
// Delete arrays.
delete tg_crosstets;
delete tg_topnewtets;
delete tg_botnewtets;
delete tg_topfaces;
delete tg_botfaces;
delete tg_midfaces;
delete tg_toppoints;
delete tg_botpoints;
delete tg_facpoints;
delete tg_facfaces;
delete tg_topshells;
delete tg_botshells;
delete badsegpool;
b->epsilon = bakeps; // Restore the epsilon.
}
#endif // #ifndef refineCXX
This diff is collapsed.
File moved
This diff is collapsed.
TetGen License
--------------
The software (TetGen) is licensed under the terms of the MIT license
with the following exceptions:
Distribution of modified versions of this code is permissible UNDER
THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE
SAME SOURCE FILES tetgen.h AND tetgen.cxx REMAIN UNDER COPYRIGHT OF
THE ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE MADE FREELY
AVAILABLE WITHOUT CHARGE, AND CLEAR NOTICE IS GIVEN OF THE
MODIFICATIONS.
Distribution of this code for any commercial purpose is permissible
ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNER.
The full license text is reproduced below.
This means that TetGen is no free software, but for private, research,
and educational purposes it can be used at absolutely no cost and
without further arrangements.
For details, see http://tetgen.berlios.de
==============================================================================
TetGen
A Quality Tetrahedral Mesh Generator and 3D Delaunay Triangulator
Version 1.4 (Released on January 14, 2006).
Copyright 2002, 2004, 2005, 2006
Hang Si
Rathausstr. 9, 10178 Berlin, Germany
si@wias-berlin.de
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Distribution of modified versions of this code is permissible UNDER
THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE
SAME SOURCE FILES tetgen.h AND tetgen.cxx REMAIN UNDER COPYRIGHT OF
THE ORIGINAL AUTHOR, BOTH SOURCE AND OBJECT CODE ARE MADE FREELY
AVAILABLE WITHOUT CHARGE, AND CLEAR NOTICE IS GIVEN OF THE
MODIFICATIONS.
Distribution of this code for any commercial purpose is permissible
ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNER.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==============================================================================
\ No newline at end of file
# Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
#
# See the LICENSE.txt file for license information. Please report all
# bugs and problems to <gmsh@geuz.org>.
include ../../variables
LIB = ../../lib/libGmshTetgen${LIBEXT}
# Don't optimize Tetgen
CFLAGS = ${FLAGS} ${DASH}DTETLIBRARY
SRC = tetgen.cxx \
predicates.cxx
OBJ = ${SRC:.cxx=${OBJEXT}}
.SUFFIXES: ${OBJEXT} .cxx
${LIB}: ${OBJ}
${AR} ${ARFLAGS}${LIB} ${OBJ}
${RANLIB} ${LIB}
cpobj: ${OBJ}
cp -f ${OBJ} ../../lib/
.cxx${OBJEXT}:
${CXX} ${CFLAGS} ${DASH}c $<
clean:
${RM} *.o *.obj
depend:
(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
${CXX} -MM ${CFLAGS} ${SRC} | sed 's/.o:/$${OBJEXT}:/g' \
) > Makefile.new
cp Makefile Makefile.bak
cp Makefile.new Makefile
rm -f Makefile.new
# DO NOT DELETE THIS LINE
This is TetGen version 1.4.2 (released on April 16, 2007)
Please see the documentation of TetGen (available at the following link) for
compiling and using TetGen.
http://tetgen.berlios.de/index.html
TetGen may be freely copied, modified, and redistributed under the
copyright notices stated in the file LICENSE.
Please send bugs/comments to Hang Si <si@wias-berlin.de>
Thank you and enjoy!
Hang Si
April 16, 2007
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment