Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gmsh
gmsh
Commits
dc5baebc
Commit
dc5baebc
authored
21 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
upgraded Triangle to version 1.5
parent
2745138a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Triangle/README
+10
-7
10 additions, 7 deletions
Triangle/README
Triangle/triangle.c
+155
-75
155 additions, 75 deletions
Triangle/triangle.c
doc/gmsh.html
+2
-3
2 additions, 3 deletions
doc/gmsh.html
with
167 additions
and
85 deletions
Triangle/README
+
10
−
7
View file @
dc5baebc
...
@@ -13,9 +13,9 @@ Gmsh if no compensation is received.
...
@@ -13,9 +13,9 @@ Gmsh if no compensation is received.
Triangle
Triangle
A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.
A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.
Version 1.
4
Version 1.
5
Copyright 1993, 1995, 1997, 1998, 2002 Jonathan Richard Shewchuk
Copyright 1993, 1995, 1997, 1998, 2002
, 2004
Jonathan Richard Shewchuk
2360 Woolsey #H
2360 Woolsey #H
Berkeley, California 94705-1927
Berkeley, California 94705-1927
Please send bugs and comments to jrs@cs.berkeley.edu
Please send bugs and comments to jrs@cs.berkeley.edu
...
@@ -24,10 +24,13 @@ Created as part of the Archimedes project (tools for parallel FEM).
...
@@ -24,10 +24,13 @@ Created as part of the Archimedes project (tools for parallel FEM).
Supported in part by NSF Grant CMS-9318163 and an NSERC 1967 Scholarship.
Supported in part by NSF Grant CMS-9318163 and an NSERC 1967 Scholarship.
There is no warranty whatsoever. Use at your own risk.
There is no warranty whatsoever. Use at your own risk.
Triangle generates exact Delaunay triangulations, exact constrained
Delaunay triangulations, Voronoi diagrams, and quality conforming Delaunay
Triangle generates exact Delaunay triangulations, constrained Delaunay
triangulations. The latter can be generated with no small angles or large,
triangulations, Voronoi diagrams, and quality conforming Delaunay
and are thus suitable for finite element analysis.
triangulations. The latter can be generated with no small angles, and are
thus suitable for finite element analysis. Show Me graphically displays
the contents of the geometric files used by Triangle. Show Me can also
write images in PostScript form.
Information on the algorithms used by Triangle, including complete
Information on the algorithms used by Triangle, including complete
references, can be found in the comments at the beginning of the triangle.c
references, can be found in the comments at the beginning of the triangle.c
...
@@ -68,4 +71,4 @@ publication, please include an acknowledgment as well.
...
@@ -68,4 +71,4 @@ publication, please include an acknowledgment as well.
Jonathan Richard Shewchuk
Jonathan Richard Shewchuk
November
2, 200
2
April
2
7
, 200
4
This diff is collapsed.
Click to expand it.
Triangle/triangle.c
+
155
−
75
View file @
dc5baebc
...
@@ -11,10 +11,10 @@
...
@@ -11,10 +11,10 @@
/* A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator. */
/* A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator. */
/* (triangle.c) */
/* (triangle.c) */
/* */
/* */
/* Version 1.
4
*/
/* Version 1.
5
*/
/*
November 1
, 200
2
*/
/*
April 27
, 200
4
*/
/* */
/* */
/* Copyright 1993, 1995, 1997, 1998, 2002
*/
/* Copyright 1993, 1995, 1997, 1998, 2002
, 2004
*/
/* Jonathan Richard Shewchuk */
/* Jonathan Richard Shewchuk */
/* 2360 Woolsey #H */
/* 2360 Woolsey #H */
/* Berkeley, California 94705-1927 */
/* Berkeley, California 94705-1927 */
...
@@ -149,6 +149,12 @@
...
@@ -149,6 +149,12 @@
/* lations," International Journal of Computational Geometry & Applica- */
/* lations," International Journal of Computational Geometry & Applica- */
/* tions 5(1-2):193-213, March-June 1995. */
/* tions 5(1-2):193-213, March-June 1995. */
/* */
/* */
/* The method of inserting new vertices off-center (not precisely at the */
/* circumcenter of every poor-quality triangle) is from Alper Ungor, */
/* "Off-centers: A New Type of Steiner Points for Computing Size-Optimal */
/* quality-guaranteed Delaunay triangulations," Proceedings of LATIN */
/* 2004 (Buenos Aires, Argentina), April 2004. */
/* */
/* For definitions of and results involving Delaunay triangulations, */
/* For definitions of and results involving Delaunay triangulations, */
/* constrained and conforming versions thereof, and other aspects of */
/* constrained and conforming versions thereof, and other aspects of */
/* triangular mesh generation, see the excellent survey by Marshall Bern */
/* triangular mesh generation, see the excellent survey by Marshall Bern */
...
@@ -623,10 +629,11 @@ struct splaynode {
...
@@ -623,10 +629,11 @@ struct splaynode {
/* determines how new records should be aligned in memory. itembytes and */
/* determines how new records should be aligned in memory. itembytes and */
/* itemwords are the length of a record in bytes (after rounding up) and */
/* itemwords are the length of a record in bytes (after rounding up) and */
/* words. itemsperblock is the number of items allocated at once in a */
/* words. itemsperblock is the number of items allocated at once in a */
/* single block. items is the number of currently allocated items. */
/* single block. itemsfirstblock is the number of items in the first */
/* maxitems is the maximum number of items that have been allocated at */
/* block, which can vary from the others. items is the number of */
/* once; it is the current number of items plus the number of records kept */
/* currently allocated items. maxitems is the maximum number of items */
/* on deaditemstack. */
/* that have been allocated at once; it is the current number of items */
/* plus the number of records kept on deaditemstack. */
struct memorypool {
struct memorypool {
VOID **firstblock, **nowblock;
VOID **firstblock, **nowblock;
...
@@ -638,6 +645,7 @@ struct memorypool {
...
@@ -638,6 +645,7 @@ struct memorypool {
int alignbytes;
int alignbytes;
int itembytes, itemwords;
int itembytes, itemwords;
int itemsperblock;
int itemsperblock;
int itemsfirstblock;
long items, maxitems;
long items, maxitems;
int unallocateditems;
int unallocateditems;
int pathitemsleft;
int pathitemsleft;
...
@@ -755,6 +763,7 @@ struct behavior {
...
@@ -755,6 +763,7 @@ struct behavior {
/* quality: -q switch. */
/* quality: -q switch. */
/* minangle: minimum angle bound, specified after -q switch. */
/* minangle: minimum angle bound, specified after -q switch. */
/* goodangle: cosine squared of minangle. */
/* goodangle: cosine squared of minangle. */
/* offconstant: constant used to place off-center Steiner points. */
/* vararea: -a switch without number. */
/* vararea: -a switch without number. */
/* fixedarea: -a switch with number. */
/* fixedarea: -a switch with number. */
/* maxarea: maximum area bound, specified after -a switch. */
/* maxarea: maximum area bound, specified after -a switch. */
...
@@ -796,7 +805,7 @@ struct behavior {
...
@@ -796,7 +805,7 @@ struct behavior {
int order;
int order;
int nobisect;
int nobisect;
int steiner;
int steiner;
REAL minangle, goodangle;
REAL minangle, goodangle
, offconstant
;
REAL maxarea;
REAL maxarea;
/* Variables for file names. */
/* Variables for file names. */
...
@@ -1348,25 +1357,15 @@ int minus1mod3[3] = {2, 0, 1};
...
@@ -1348,25 +1357,15 @@ int minus1mod3[3] = {2, 0, 1};
#ifdef EXTERNAL_TEST
#ifdef EXTERNAL_TEST
#ifdef ANSI_DECLARATORS
int triunsuitable();
extern int triunsuitable(vertex triorg, vertex tridest, vertex triapex,
REAL area);
#else /* not ANSI_DECLARATORS */
extern int triunsuitable();
#endif /* not ANSI_DECLARATORS */
#else /* not EXTERNAL_TEST */
#else /* not EXTERNAL_TEST */
#ifdef ANSI_DECLARATORS
int triunsuitable(vertex triorg, vertex tridest, vertex triapex, REAL area)
#else /* not ANSI_DECLARATORS */
int triunsuitable(triorg, tridest, triapex, area)
int triunsuitable(triorg, tridest, triapex, area)
vertex triorg; /* The triangle's origin vertex. */
vertex triorg; /* The triangle's origin vertex. */
vertex tridest; /* The triangle's destination vertex. */
vertex tridest; /* The triangle's destination vertex. */
vertex triapex; /* The triangle's apex vertex. */
vertex triapex; /* The triangle's apex vertex. */
REAL area; /* The area of the triangle. */
REAL area; /* The area of the triangle. */
#endif /* not ANSI_DECLARATORS */
{
{
REAL dxoa, dxda, dxod;
REAL dxoa, dxda, dxod;
REAL dyoa, dyda, dyod;
REAL dyoa, dyda, dyod;
...
@@ -1414,7 +1413,7 @@ int size;
...
@@ -1414,7 +1413,7 @@ int size;
{
{
VOID *memptr;
VOID *memptr;
memptr = malloc(size);
memptr = malloc(
(unsigned int)
size);
if (memptr == (VOID *) NULL) {
if (memptr == (VOID *) NULL) {
printf("Error: Out of memory.\n");
printf("Error: Out of memory.\n");
exit(1);
exit(1);
...
@@ -1531,8 +1530,9 @@ void info()
...
@@ -1531,8 +1530,9 @@ void info()
printf("Triangle\n");
printf("Triangle\n");
printf(
printf(
"A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.\n");
"A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.\n");
printf("Version 1.4\n\n");
printf("Version 1.5\n\n");
printf("Copyright 1993, 1995, 1997, 1998, 2002 Jonathan Richard Shewchuk\n");
printf(
"Copyright 1993, 1995, 1997, 1998, 2002, 2004 Jonathan Richard Shewchuk\n");
printf("2360 Woolsey #H / Berkeley, California 94705-1927\n");
printf("2360 Woolsey #H / Berkeley, California 94705-1927\n");
printf("Bugs/comments to jrs@cs.berkeley.edu\n");
printf("Bugs/comments to jrs@cs.berkeley.edu\n");
printf(
printf(
...
@@ -3111,15 +3111,17 @@ void info()
...
@@ -3111,15 +3111,17 @@ void info()
printf(
printf(
" Marshall Bern, L. Paul Chew, Boris Delaunay, Rex A. Dwyer, David\n");
" Marshall Bern, L. Paul Chew, Boris Delaunay, Rex A. Dwyer, David\n");
printf(
printf(
" Eppstein, Steven Fortune, Leonidas J. Guibas, Donald E. Knuth, C. L.\n");
" Eppstein, Steven Fortune, Leonidas J. Guibas, Donald E. Knuth, Charles L.\n"
);
printf(
printf(
" Lawson, Der-Tsai Lee, Ernst P. Mucke, Douglas M. Priest, Jim Ruppert,\n");
" Lawson, Der-Tsai Lee, Ernst P. Mucke, Douglas M. Priest, Jim Ruppert,\n");
printf(
printf(
" Isaac Saias, Bruce J. Schachter, Micha Sharir, Daniel D. Sleator, Jorge\n");
" Isaac Saias, Bruce J. Schachter, Micha Sharir, Daniel D. Sleator, Jorge\n");
printf(
printf(
" Stolfi, Robert E. Tarjan, Christopher J. Van Wyk, and Binhai Zhu. See\n");
" Stolfi, Robert E. Tarjan, Alper Ungor, Christopher J. Van Wyk, and Binhai\n"
printf(
);
" the comments at the beginning of the source code for references.\n");
printf(" Zhu. See the comments at the beginning of the source code for\n");
printf(" references.\n\n");
exit(0);
exit(0);
}
}
...
@@ -3386,6 +3388,11 @@ struct behavior *b;
...
@@ -3386,6 +3388,11 @@ struct behavior *b;
#endif /* not TRILIBRARY */
#endif /* not TRILIBRARY */
b->usesegments = b->poly || b->refine || b->quality || b->convex;
b->usesegments = b->poly || b->refine || b->quality || b->convex;
b->goodangle = cos(b->minangle * PI / 180.0);
b->goodangle = cos(b->minangle * PI / 180.0);
if (b->goodangle == 1.0) {
b->offconstant = 0.0;
} else {
b->offconstant = 0.475 * sqrt((1.0 + b->goodangle) / (1.0 - b->goodangle));
}
b->goodangle *= b->goodangle;
b->goodangle *= b->goodangle;
if (b->refine && b->noiterationnum) {
if (b->refine && b->noiterationnum) {
printf(
printf(
...
@@ -3718,7 +3725,7 @@ struct memorypool *pool;
...
@@ -3718,7 +3725,7 @@ struct memorypool *pool;
(alignptr + (unsigned long) pool->alignbytes -
(alignptr + (unsigned long) pool->alignbytes -
(alignptr % (unsigned long) pool->alignbytes));
(alignptr % (unsigned long) pool->alignbytes));
/* There are lots of unallocated items left in this block. */
/* There are lots of unallocated items left in this block. */
pool->unallocateditems = pool->items
per
block;
pool->unallocateditems = pool->items
first
block;
/* The stack of deallocated items is empty. */
/* The stack of deallocated items is empty. */
pool->deaditemstack = (VOID *) NULL;
pool->deaditemstack = (VOID *) NULL;
}
}
...
@@ -3744,12 +3751,13 @@ struct memorypool *pool;
...
@@ -3744,12 +3751,13 @@ struct memorypool *pool;
#ifdef ANSI_DECLARATORS
#ifdef ANSI_DECLARATORS
void poolinit(struct memorypool *pool, int bytecount, int itemcount,
void poolinit(struct memorypool *pool, int bytecount, int itemcount,
enum wordtype wtype, int alignment)
int firstitemcount,
enum wordtype wtype, int alignment)
#else /* not ANSI_DECLARATORS */
#else /* not ANSI_DECLARATORS */
void poolinit(pool, bytecount, itemcount, wtype, alignment)
void poolinit(pool, bytecount, itemcount,
firstitemcount,
wtype, alignment)
struct memorypool *pool;
struct memorypool *pool;
int bytecount;
int bytecount;
int itemcount;
int itemcount;
int firstitemcount;
enum wordtype wtype;
enum wordtype wtype;
int alignment;
int alignment;
#endif /* not ANSI_DECLARATORS */
#endif /* not ANSI_DECLARATORS */
...
@@ -3777,12 +3785,18 @@ int alignment;
...
@@ -3777,12 +3785,18 @@ int alignment;
* (pool->alignbytes / wordsize);
* (pool->alignbytes / wordsize);
pool->itembytes = pool->itemwords * wordsize;
pool->itembytes = pool->itemwords * wordsize;
pool->itemsperblock = itemcount;
pool->itemsperblock = itemcount;
if (firstitemcount == 0) {
pool->itemsfirstblock = itemcount;
} else {
pool->itemsfirstblock = firstitemcount;
}
/* Allocate a block of items. Space for `items
per
block' items and one
*/
/* Allocate a block of items. Space for `items
first
block' items and one */
/* pointer (to point to the next block) are allocated, as well as space */
/* pointer (to point to the next block) are allocated, as well as space */
/* to ensure alignment of the items. */
/* to ensure alignment of the items. */
pool->firstblock = (VOID **) trimalloc(pool->itemsperblock * pool->itembytes
pool->firstblock = (VOID **)
+ sizeof(VOID *) + pool->alignbytes);
trimalloc(pool->itemsfirstblock * pool->itembytes + (int) sizeof(VOID *) +
pool->alignbytes);
/* Set the next block pointer to NULL. */
/* Set the next block pointer to NULL. */
*(pool->firstblock) = (VOID *) NULL;
*(pool->firstblock) = (VOID *) NULL;
poolrestart(pool);
poolrestart(pool);
...
@@ -3839,11 +3853,13 @@ struct memorypool *pool;
...
@@ -3839,11 +3853,13 @@ struct memorypool *pool;
if (*(pool->nowblock) == (VOID *) NULL) {
if (*(pool->nowblock) == (VOID *) NULL) {
/* Allocate a new block of items, pointed to by the previous block. */
/* Allocate a new block of items, pointed to by the previous block. */
newblock = (VOID **) trimalloc(pool->itemsperblock * pool->itembytes +
newblock = (VOID **) trimalloc(pool->itemsperblock * pool->itembytes +
sizeof(VOID *) + pool->alignbytes);
(int) sizeof(VOID *) +
pool->alignbytes);
*(pool->nowblock) = (VOID *) newblock;
*(pool->nowblock) = (VOID *) newblock;
/* The next block pointer is NULL. */
/* The next block pointer is NULL. */
*newblock = (VOID *) NULL;
*newblock = (VOID *) NULL;
}
}
/* Move to the new block. */
/* Move to the new block. */
pool->nowblock = (VOID **) *(pool->nowblock);
pool->nowblock = (VOID **) *(pool->nowblock);
/* Find the first item in the block. */
/* Find the first item in the block. */
...
@@ -3856,6 +3872,7 @@ struct memorypool *pool;
...
@@ -3856,6 +3872,7 @@ struct memorypool *pool;
/* There are lots of unallocated items left in this block. */
/* There are lots of unallocated items left in this block. */
pool->unallocateditems = pool->itemsperblock;
pool->unallocateditems = pool->itemsperblock;
}
}
/* Allocate a new item. */
/* Allocate a new item. */
newitem = pool->nextitem;
newitem = pool->nextitem;
/* Advance `nextitem' pointer to next free item in block. */
/* Advance `nextitem' pointer to next free item in block. */
...
@@ -3921,7 +3938,7 @@ struct memorypool *pool;
...
@@ -3921,7 +3938,7 @@ struct memorypool *pool;
(alignptr + (unsigned long) pool->alignbytes -
(alignptr + (unsigned long) pool->alignbytes -
(alignptr % (unsigned long) pool->alignbytes));
(alignptr % (unsigned long) pool->alignbytes));
/* Set the number of items left in the current block. */
/* Set the number of items left in the current block. */
pool->pathitemsleft = pool->items
per
block;
pool->pathitemsleft = pool->items
first
block;
}
}
/*****************************************************************************/
/*****************************************************************************/
...
@@ -3953,6 +3970,7 @@ struct memorypool *pool;
...
@@ -3953,6 +3970,7 @@ struct memorypool *pool;
if (pool->pathitem == pool->nextitem) {
if (pool->pathitem == pool->nextitem) {
return (VOID *) NULL;
return (VOID *) NULL;
}
}
/* Check whether any untraversed items remain in the current block. */
/* Check whether any untraversed items remain in the current block. */
if (pool->pathitemsleft == 0) {
if (pool->pathitemsleft == 0) {
/* Find the next block. */
/* Find the next block. */
...
@@ -3966,6 +3984,7 @@ struct memorypool *pool;
...
@@ -3966,6 +3984,7 @@ struct memorypool *pool;
/* Set the number of items left in the current block. */
/* Set the number of items left in the current block. */
pool->pathitemsleft = pool->itemsperblock;
pool->pathitemsleft = pool->itemsperblock;
}
}
newitem = pool->pathitem;
newitem = pool->pathitem;
/* Find the next item in the block. */
/* Find the next item in the block. */
if (pool->itemwordtype == POINTER) {
if (pool->itemwordtype == POINTER) {
...
@@ -4020,7 +4039,8 @@ int subsegwords;
...
@@ -4020,7 +4039,8 @@ int subsegwords;
unsigned long alignptr;
unsigned long alignptr;
/* Set up `dummytri', the `triangle' that occupies "outer space." */
/* Set up `dummytri', the `triangle' that occupies "outer space." */
m->dummytribase = (triangle *) trimalloc(trianglewords * sizeof(triangle) +
m->dummytribase = (triangle *)
trimalloc(trianglewords * (int) sizeof(triangle) +
m->triangles.alignbytes);
m->triangles.alignbytes);
/* Align `dummytri' on a `triangles.alignbytes'-byte boundary. */
/* Align `dummytri' on a `triangles.alignbytes'-byte boundary. */
alignptr = (unsigned long) m->dummytribase;
alignptr = (unsigned long) m->dummytribase;
...
@@ -4043,7 +4063,7 @@ int subsegwords;
...
@@ -4043,7 +4063,7 @@ int subsegwords;
/* Set up `dummysub', the omnipresent subsegment pointed to by any */
/* Set up `dummysub', the omnipresent subsegment pointed to by any */
/* triangle side or subsegment end that isn't attached to a real */
/* triangle side or subsegment end that isn't attached to a real */
/* subsegment. */
/* subsegment. */
m->dummysubbase = (subseg *) trimalloc(subsegwords * sizeof(subseg) +
m->dummysubbase = (subseg *) trimalloc(subsegwords *
(int)
sizeof(subseg) +
m->subsegs.alignbytes);
m->subsegs.alignbytes);
/* Align `dummysub' on a `subsegs.alignbytes'-byte boundary. */
/* Align `dummysub' on a `subsegs.alignbytes'-byte boundary. */
alignptr = (unsigned long) m->dummysubbase;
alignptr = (unsigned long) m->dummysubbase;
...
@@ -4108,8 +4128,10 @@ struct behavior *b;
...
@@ -4108,8 +4128,10 @@ struct behavior *b;
sizeof(triangle);
sizeof(triangle);
vertexsize = (m->vertex2triindex + 1) * sizeof(triangle);
vertexsize = (m->vertex2triindex + 1) * sizeof(triangle);
}
}
/* Initialize the pool of vertices. */
/* Initialize the pool of vertices. */
poolinit(&m->vertices, vertexsize, VERTEXPERBLOCK,
poolinit(&m->vertices, vertexsize, VERTEXPERBLOCK,
m->invertices > VERTEXPERBLOCK ? m->invertices : VERTEXPERBLOCK,
(sizeof(REAL) >= sizeof(triangle)) ? FLOATINGPOINT : POINTER, 0);
(sizeof(REAL) >= sizeof(triangle)) ? FLOATINGPOINT : POINTER, 0);
}
}
...
@@ -4165,14 +4187,17 @@ struct behavior *b;
...
@@ -4165,14 +4187,17 @@ struct behavior *b;
(trisize < 6 * sizeof(triangle) + sizeof(int))) {
(trisize < 6 * sizeof(triangle) + sizeof(int))) {
trisize = 6 * sizeof(triangle) + sizeof(int);
trisize = 6 * sizeof(triangle) + sizeof(int);
}
}
/* Having determined the memory size of a triangle, initialize the pool. */
/* Having determined the memory size of a triangle, initialize the pool. */
poolinit(&m->triangles, trisize, TRIPERBLOCK, POINTER, 4);
poolinit(&m->triangles, trisize, TRIPERBLOCK,
(2 * m->invertices - 2) > TRIPERBLOCK ? (2 * m->invertices - 2) :
TRIPERBLOCK, POINTER, 4);
if (b->usesegments) {
if (b->usesegments) {
/* Initialize the pool of subsegments. Take into account all six */
/* Initialize the pool of subsegments. Take into account all six */
/* pointers and one boundary marker. */
/* pointers and one boundary marker. */
poolinit(&m->subsegs, 6 * sizeof(triangle) + sizeof(int), SUBSEGPERBLOCK,
poolinit(&m->subsegs, 6 * sizeof(triangle) + sizeof(int), SUBSEGPERBLOCK,
POINTER, 4);
SUBSEGPERBLOCK,
POINTER, 4);
/* Initialize the "outer space" triangle and omnipresent subsegment. */
/* Initialize the "outer space" triangle and omnipresent subsegment. */
dummyinit(m, b, m->triangles.itemwords, m->subsegs.itemwords);
dummyinit(m, b, m->triangles.itemwords, m->subsegs.itemwords);
...
@@ -4404,11 +4429,17 @@ int number;
...
@@ -4404,11 +4429,17 @@ int number;
getblock = m->vertices.firstblock;
getblock = m->vertices.firstblock;
current = b->firstnumber;
current = b->firstnumber;
/* Find the right block. */
/* Find the right block. */
if (current + m->vertices.itemsfirstblock <= number) {
getblock = (VOID **) *getblock;
current += m->vertices.itemsfirstblock;
while (current + m->vertices.itemsperblock <= number) {
while (current + m->vertices.itemsperblock <= number) {
getblock = (VOID **) *getblock;
getblock = (VOID **) *getblock;
current += m->vertices.itemsperblock;
current += m->vertices.itemsperblock;
}
}
}
/* Now find the right vertex. */
/* Now find the right vertex. */
alignptr = (unsigned long) (getblock + 1);
alignptr = (unsigned long) (getblock + 1);
foundvertex = (vertex) (alignptr + (unsigned long) m->vertices.alignbytes -
foundvertex = (vertex) (alignptr + (unsigned long) m->vertices.alignbytes -
...
@@ -6325,9 +6356,11 @@ vertex pd;
...
@@ -6325,9 +6356,11 @@ vertex pd;
#ifdef ANSI_DECLARATORS
#ifdef ANSI_DECLARATORS
void findcircumcenter(struct mesh *m, struct behavior *b,
void findcircumcenter(struct mesh *m, struct behavior *b,
vertex torg, vertex tdest, vertex tapex,
vertex torg, vertex tdest, vertex tapex,
vertex circumcenter, REAL *xi, REAL *eta, REAL *minedge)
vertex circumcenter, REAL *xi, REAL *eta, REAL *minedge,
int offcenter)
#else /* not ANSI_DECLARATORS */
#else /* not ANSI_DECLARATORS */
void findcircumcenter(m, b, torg, tdest, tapex, circumcenter, xi, eta, minedge)
void findcircumcenter(m, b, torg, tdest, tapex, circumcenter, xi, eta, minedge,
offcenter)
struct mesh *m;
struct mesh *m;
struct behavior *b;
struct behavior *b;
vertex torg;
vertex torg;
...
@@ -6337,13 +6370,14 @@ vertex circumcenter;
...
@@ -6337,13 +6370,14 @@ vertex circumcenter;
REAL *xi;
REAL *xi;
REAL *eta;
REAL *eta;
REAL *minedge;
REAL *minedge;
int offcenter;
#endif /* not ANSI_DECLARATORS */
#endif /* not ANSI_DECLARATORS */
{
{
REAL xdo, ydo, xao, yao;
REAL xdo, ydo, xao, yao;
REAL dodist, aodist, dadist;
REAL dodist, aodist, dadist;
REAL denominator;
REAL denominator;
REAL dx, dy;
REAL dx, dy
, dxoff, dyoff
;
m->circumcentercount++;
m->circumcentercount++;
...
@@ -6366,26 +6400,66 @@ REAL *minedge;
...
@@ -6366,26 +6400,66 @@ REAL *minedge;
/* Don't count the above as an orientation test. */
/* Don't count the above as an orientation test. */
m->counterclockcount--;
m->counterclockcount--;
}
}
circumcenter[0] = torg[0] - (ydo * aodist - yao * dodist) * denominator;
dx = (yao * dodist - ydo * aodist) * denominator;
circumcenter[1] = torg[1] + (xdo * aodist - xao * dodist) * denominator;
dy = (xdo * aodist - xao * dodist) * denominator;
/* Find the (squared) length of the triangle's shortest edge. This */
/* serves as a conservative estimate of the insertion radius of the */
/* circumcenter's parent. The estimate is used to ensure that */
/* the algorithm terminates even if very small angles appear in */
/* the input PSLG. */
if ((dodist < aodist) && (dodist < dadist)) {
*minedge = dodist;
if (offcenter && (b->offconstant > 0.0)) {
/* Find the position of the off-center, as described by Alper Ungor. */
dxoff = 0.5 * xdo - b->offconstant * ydo;
dyoff = 0.5 * ydo + b->offconstant * xdo;
/* If the off-center is closer to the origin than the */
/* circumcenter, use the off-center instead. */
if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy) {
dx = dxoff;
dy = dyoff;
}
}
} else if (aodist < dadist) {
*minedge = aodist;
if (offcenter && (b->offconstant > 0.0)) {
dxoff = 0.5 * xao + b->offconstant * yao;
dyoff = 0.5 * yao - b->offconstant * xao;
/* If the off-center is closer to the origin than the */
/* circumcenter, use the off-center instead. */
if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy) {
dx = dxoff;
dy = dyoff;
}
}
} else {
*minedge = dadist;
if (offcenter && (b->offconstant > 0.0)) {
dxoff = 0.5 * (tapex[0] - tdest[0]) -
b->offconstant * (tapex[1] - tdest[1]);
dyoff = 0.5 * (tapex[1] - tdest[1]) +
b->offconstant * (tapex[0] - tdest[0]);
/* If the off-center is closer to the destination than the */
/* circumcenter, use the off-center instead. */
if (dxoff * dxoff + dyoff * dyoff <
(dx - xdo) * (dx - xdo) + (dy - ydo) * (dy - ydo)) {
dx = xdo + dxoff;
dy = ydo + dyoff;
}
}
}
circumcenter[0] = torg[0] + dx;
circumcenter[1] = torg[1] + dy;
/* To interpolate vertex attributes for the new vertex inserted at */
/* To interpolate vertex attributes for the new vertex inserted at */
/* the circumcenter, define a coordinate system with a xi-axis, */
/* the circumcenter, define a coordinate system with a xi-axis, */
/* directed from the triangle's origin to its destination, and */
/* directed from the triangle's origin to its destination, and */
/* an eta-axis, directed from its origin to its apex. */
/* an eta-axis, directed from its origin to its apex. */
/* Calculate the xi and eta coordinates of the circumcenter. */
/* Calculate the xi and eta coordinates of the circumcenter. */
dx = circumcenter[0] - torg[0];
*xi = (yao * dx - xao * dy) * (2.0 * denominator);
dy = circumcenter[1] - torg[1];
*eta = (xdo * dy - ydo * dx) * (2.0 * denominator);
*xi = (dx * yao - xao * dy) * (2.0 * denominator);
*eta = (xdo * dy - dx * ydo) * (2.0 * denominator);
/* Find the length of the triangle's shortest edge. This serves as */
/* a conservative estimate of the insertion radius of the */
/* circumcenter's parent. The estimate is used to ensure that */
/* the algorithm terminates even if very small angles appear in */
/* the input PSLG. */
*minedge = ((dodist < aodist) && (dodist < dadist)) ? dodist :
(aodist < dadist) ? aodist : dadist;
}
}
/** **/
/** **/
...
@@ -7692,7 +7766,7 @@ struct otri *searchtri;
...
@@ -7692,7 +7766,7 @@ struct otri *searchtri;
- (alignptr % (unsigned long) m->triangles.alignbytes));
- (alignptr % (unsigned long) m->triangles.alignbytes));
for (j = 0; j < samplesperblock; j++) {
for (j = 0; j < samplesperblock; j++) {
if (i == triblocks - 1) {
if (i == triblocks - 1) {
samplenum = randomnation((int)
samplenum = randomnation((
unsigned
int)
(m->triangles.maxitems - (i * TRIPERBLOCK)));
(m->triangles.maxitems - (i * TRIPERBLOCK)));
} else {
} else {
samplenum = randomnation(TRIPERBLOCK);
samplenum = randomnation(TRIPERBLOCK);
...
@@ -9184,7 +9258,7 @@ int arraysize;
...
@@ -9184,7 +9258,7 @@ int arraysize;
return;
return;
}
}
/* Choose a random pivot to split the array. */
/* Choose a random pivot to split the array. */
pivot = (int) randomnation(arraysize);
pivot = (int) randomnation(
(unsigned int)
arraysize);
pivotx = sortarray[pivot][0];
pivotx = sortarray[pivot][0];
pivoty = sortarray[pivot][1];
pivoty = sortarray[pivot][1];
/* Split the array. */
/* Split the array. */
...
@@ -9260,7 +9334,7 @@ int axis;
...
@@ -9260,7 +9334,7 @@ int axis;
return;
return;
}
}
/* Choose a random pivot to split the array. */
/* Choose a random pivot to split the array. */
pivot = (int) randomnation(arraysize);
pivot = (int) randomnation(
(unsigned int)
arraysize);
pivot1 = sortarray[pivot][axis];
pivot1 = sortarray[pivot][axis];
pivot2 = sortarray[pivot][1 - axis];
pivot2 = sortarray[pivot][1 - axis];
/* Split the array. */
/* Split the array. */
...
@@ -9947,7 +10021,7 @@ struct behavior *b;
...
@@ -9947,7 +10021,7 @@ struct behavior *b;
}
}
/* Allocate an array of pointers to vertices for sorting. */
/* Allocate an array of pointers to vertices for sorting. */
sortarray = (vertex *) trimalloc(m->invertices * sizeof(vertex));
sortarray = (vertex *) trimalloc(m->invertices *
(int)
sizeof(vertex));
traversalinit(&m->vertices);
traversalinit(&m->vertices);
for (i = 0; i < m->invertices; i++) {
for (i = 0; i < m->invertices; i++) {
sortarray[i] = vertextraverse(m);
sortarray[i] = vertextraverse(m);
...
@@ -10386,8 +10460,9 @@ struct event **freeevents;
...
@@ -10386,8 +10460,9 @@ struct event **freeevents;
int i;
int i;
maxevents = (3 * m->invertices) / 2;
maxevents = (3 * m->invertices) / 2;
*eventheap = (struct event **) trimalloc(maxevents * sizeof(struct event *));
*eventheap = (struct event **)
*events = (struct event *) trimalloc(maxevents * sizeof(struct event));
trimalloc(maxevents * (int) sizeof(struct event *));
*events = (struct event *) trimalloc(maxevents * (int) sizeof(struct event));
traversalinit(&m->vertices);
traversalinit(&m->vertices);
for (i = 0; i < m->invertices; i++) {
for (i = 0; i < m->invertices; i++) {
thisvertex = vertextraverse(m);
thisvertex = vertextraverse(m);
...
@@ -10773,7 +10848,7 @@ struct behavior *b;
...
@@ -10773,7 +10848,7 @@ struct behavior *b;
triangle ptr; /* Temporary variable used by sym(), onext(), and oprev(). */
triangle ptr; /* Temporary variable used by sym(), onext(), and oprev(). */
poolinit(&m->splaynodes, sizeof(struct splaynode), SPLAYNODEPERBLOCK,
poolinit(&m->splaynodes, sizeof(struct splaynode), SPLAYNODEPERBLOCK,
POINTER, 0);
SPLAYNODEPERBLOCK,
POINTER, 0);
splayroot = (struct splaynode *) NULL;
splayroot = (struct splaynode *) NULL;
if (b->verbose) {
if (b->verbose) {
...
@@ -11230,7 +11305,8 @@ FILE *polyfile;
...
@@ -11230,7 +11305,8 @@ FILE *polyfile;
/* Allocate a temporary array that maps each vertex to some adjacent */
/* Allocate a temporary array that maps each vertex to some adjacent */
/* triangle. I took care to allocate all the permanent memory for */
/* triangle. I took care to allocate all the permanent memory for */
/* triangles and subsegments first. */
/* triangles and subsegments first. */
vertexarray = (triangle *) trimalloc(m->vertices.items * sizeof(triangle));
vertexarray = (triangle *)
trimalloc(m->vertices.items * (int) sizeof(triangle));
/* Each vertex is initially unrepresented. */
/* Each vertex is initially unrepresented. */
for (i = 0; i < m->vertices.items; i++) {
for (i = 0; i < m->vertices.items; i++) {
vertexarray[i] = (triangle) m->dummytri;
vertexarray[i] = (triangle) m->dummytri;
...
@@ -12944,13 +13020,15 @@ int regions;
...
@@ -12944,13 +13020,15 @@ int regions;
if (regions > 0) {
if (regions > 0) {
/* Allocate storage for the triangles in which region points fall. */
/* Allocate storage for the triangles in which region points fall. */
regiontris = (struct otri *) trimalloc(regions * sizeof(struct otri));
regiontris = (struct otri *)
trimalloc(regions * (int) sizeof(struct otri));
}
}
if (((holes > 0) && !b->noholes) || !b->convex || (regions > 0)) {
if (((holes > 0) && !b->noholes) || !b->convex || (regions > 0)) {
/* Initialize a pool of viri to be used for holes, concavities, */
/* Initialize a pool of viri to be used for holes, concavities, */
/* regional attributes, and/or regional area constraints. */
/* regional attributes, and/or regional area constraints. */
poolinit(&m->viri, sizeof(triangle *), VIRUSPERBLOCK, POINTER, 0);
poolinit(&m->viri, sizeof(triangle *), VIRUSPERBLOCK, VIRUSPERBLOCK,
POINTER, 0);
}
}
if (!b->convex) {
if (!b->convex) {
...
@@ -13449,7 +13527,8 @@ struct badtriang *badtri;
...
@@ -13449,7 +13527,8 @@ struct badtriang *badtri;
errorflag = 0;
errorflag = 0;
/* Create a new vertex at the triangle's circumcenter. */
/* Create a new vertex at the triangle's circumcenter. */
newvertex = (vertex) poolalloc(&m->vertices);
newvertex = (vertex) poolalloc(&m->vertices);
findcircumcenter(m, b, borg, bdest, bapex, newvertex, &xi, &eta, &minedge);
findcircumcenter(m, b, borg, bdest, bapex, newvertex, &xi, &eta, &minedge,
1);
/* Check whether the new vertex lies on a triangle vertex. */
/* Check whether the new vertex lies on a triangle vertex. */
if (((newvertex[0] == borg[0]) && (newvertex[1] == borg[1])) ||
if (((newvertex[0] == borg[0]) && (newvertex[1] == borg[1])) ||
...
@@ -13558,7 +13637,7 @@ struct behavior *b;
...
@@ -13558,7 +13637,7 @@ struct behavior *b;
}
}
/* Initialize the pool of encroached subsegments. */
/* Initialize the pool of encroached subsegments. */
poolinit(&m->badsubsegs, sizeof(struct badsubseg), BADSUBSEGPERBLOCK,
poolinit(&m->badsubsegs, sizeof(struct badsubseg), BADSUBSEGPERBLOCK,
POINTER, 0);
BADSUBSEGPERBLOCK,
POINTER, 0);
if (b->verbose) {
if (b->verbose) {
printf(" Looking for encroached subsegments.\n");
printf(" Looking for encroached subsegments.\n");
}
}
...
@@ -13576,7 +13655,7 @@ struct behavior *b;
...
@@ -13576,7 +13655,7 @@ struct behavior *b;
if ((b->minangle > 0.0) || b->vararea || b->fixedarea || b->usertest) {
if ((b->minangle > 0.0) || b->vararea || b->fixedarea || b->usertest) {
/* Initialize the pool of bad triangles. */
/* Initialize the pool of bad triangles. */
poolinit(&m->badtriangles, sizeof(struct badtriang), BADTRIPERBLOCK,
poolinit(&m->badtriangles, sizeof(struct badtriang), BADTRIPERBLOCK,
POINTER, 0);
BADTRIPERBLOCK,
POINTER, 0);
/* Initialize the queues of bad triangles. */
/* Initialize the queues of bad triangles. */
for (i = 0; i < 64; i++) {
for (i = 0; i < 64; i++) {
m->queuefront[i] = (struct badtriang *) NULL;
m->queuefront[i] = (struct badtriang *) NULL;
...
@@ -13586,7 +13665,7 @@ struct behavior *b;
...
@@ -13586,7 +13665,7 @@ struct behavior *b;
tallyfaces(m, b);
tallyfaces(m, b);
/* Initialize the pool of recently flipped triangles. */
/* Initialize the pool of recently flipped triangles. */
poolinit(&m->flipstackers, sizeof(struct flipstacker), FLIPSTACKERPERBLOCK,
poolinit(&m->flipstackers, sizeof(struct flipstacker), FLIPSTACKERPERBLOCK,
POINTER, 0);
FLIPSTACKERPERBLOCK,
POINTER, 0);
m->checkquality = 1;
m->checkquality = 1;
if (b->verbose) {
if (b->verbose) {
printf(" Splitting bad triangles.\n");
printf(" Splitting bad triangles.\n");
...
@@ -14124,7 +14203,7 @@ int *regions;
...
@@ -14124,7 +14203,7 @@ int *regions;
stringptr = readline(inputline, polyfile, polyfilename);
stringptr = readline(inputline, polyfile, polyfilename);
*holes = (int) strtol(stringptr, &stringptr, 0);
*holes = (int) strtol(stringptr, &stringptr, 0);
if (*holes > 0) {
if (*holes > 0) {
holelist = (REAL *) trimalloc(2 * *holes * sizeof(REAL));
holelist = (REAL *) trimalloc(2 * *holes *
(int)
sizeof(REAL));
*hlist = holelist;
*hlist = holelist;
for (i = 0; i < 2 * *holes; i += 2) {
for (i = 0; i < 2 * *holes; i += 2) {
stringptr = readline(inputline, polyfile, polyfilename);
stringptr = readline(inputline, polyfile, polyfilename);
...
@@ -14155,7 +14234,7 @@ int *regions;
...
@@ -14155,7 +14234,7 @@ int *regions;
stringptr = readline(inputline, polyfile, polyfilename);
stringptr = readline(inputline, polyfile, polyfilename);
*regions = (int) strtol(stringptr, &stringptr, 0);
*regions = (int) strtol(stringptr, &stringptr, 0);
if (*regions > 0) {
if (*regions > 0) {
regionlist = (REAL *) trimalloc(4 * *regions * sizeof(REAL));
regionlist = (REAL *) trimalloc(4 * *regions *
(int)
sizeof(REAL));
*rlist = regionlist;
*rlist = regionlist;
index = 0;
index = 0;
for (i = 0; i < *regions; i++) {
for (i = 0; i < *regions; i++) {
...
@@ -14954,7 +15033,8 @@ char **argv;
...
@@ -14954,7 +15033,8 @@ char **argv;
org(triangleloop, torg);
org(triangleloop, torg);
dest(triangleloop, tdest);
dest(triangleloop, tdest);
apex(triangleloop, tapex);
apex(triangleloop, tapex);
findcircumcenter(m, b, torg, tdest, tapex, circumcenter, &xi, &eta, &dum);
findcircumcenter(m, b, torg, tdest, tapex, circumcenter, &xi, &eta, &dum,
0);
#ifdef TRILIBRARY
#ifdef TRILIBRARY
/* X and y coordinates. */
/* X and y coordinates. */
plist[coordindex++] = circumcenter[0];
plist[coordindex++] = circumcenter[0];
...
...
This diff is collapsed.
Click to expand it.
doc/gmsh.html
+
2
−
3
View file @
dc5baebc
...
@@ -257,9 +257,8 @@ the Algorithm Oriented Mesh Database</a>.
...
@@ -257,9 +257,8 @@ the Algorithm Oriented Mesh Database</a>.
<p>
<p>
Gmsh can use Jonathan Shewchuk's
<a
Gmsh can use Jonathan Shewchuk's
<a
href=
"http://www-2.cs.cmu.edu/~quake/triangle.html"
>
Triangle
</a>
(
<a
href=
"http://www-2.cs.cmu.edu/~quake/triangle.html"
>
Triangle
</a>
as an
href=
"http://www.cs.berkeley.edu/~jrs/triangle.shar.gz"
>
download
</a>
)
alternative 2D mesh generator and Joachim Sch
ö
berl's
as an alternative 2D mesh generator and Joachim Sch
ö
berl's
<a
href=
"http://www.hpfem.jku.at/netgen"
>
Netgen
</a>
as an alternative
<a
href=
"http://www.hpfem.jku.at/netgen"
>
Netgen
</a>
as an alternative
3D mesh generator/optimizer.
3D mesh generator/optimizer.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment