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

upgrade triangle to version 1.6
parent 94e1d1d5
Branches
Tags
No related merge requests found
// $Id: 2D_Mesh_Triangle.cpp,v 1.12 2005-01-01 19:35:30 geuzaine Exp $ // $Id: 2D_Mesh_Triangle.cpp,v 1.13 2005-11-25 23:49:04 geuzaine Exp $
// //
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
// //
...@@ -36,6 +36,7 @@ int Mesh_Triangle(Surface * s) ...@@ -36,6 +36,7 @@ int Mesh_Triangle(Surface * s)
#define ANSI_DECLARATORS #define ANSI_DECLARATORS
#define REAL double #define REAL double
#define VOID void
extern "C" extern "C"
{ {
......
// $Id: Triangulate.cpp,v 1.28 2005-03-02 08:14:29 geuzaine Exp $ // $Id: Triangulate.cpp,v 1.29 2005-11-25 23:49:05 geuzaine Exp $
// //
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
// //
...@@ -98,6 +98,7 @@ void Triangulate(int nbIn, List_T *inList, int *nbOut, List_T *outList, ...@@ -98,6 +98,7 @@ void Triangulate(int nbIn, List_T *inList, int *nbOut, List_T *outList,
#define ANSI_DECLARATORS #define ANSI_DECLARATORS
#define REAL double #define REAL double
#define VOID void
extern "C" extern "C"
{ {
......
...@@ -13,24 +13,28 @@ Gmsh if no compensation is received. ...@@ -13,24 +13,28 @@ 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.5 Version 1.6
Copyright 1993, 1995, 1997, 1998, 2002, 2004 Jonathan Richard Shewchuk Show Me
A Display Program for Meshes and More.
Version 1.6
Copyright 1993, 1995, 1997, 1998, 2002, 2005 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
Created as part of the Archimedes project (tools for parallel FEM). Created as part of the Quake project (tools for earthquake simulation).
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, constrained Delaunay Triangle generates exact Delaunay triangulations, constrained Delaunay
triangulations, Voronoi diagrams, and quality conforming Delaunay triangulations, conforming Delaunay triangulations, Voronoi diagrams, and
triangulations. The latter can be generated with no small angles, and are high-quality triangular meshes. The latter can be generated with no small
thus suitable for finite element analysis. Show Me graphically displays or large angles, and are thus suitable for finite element analysis.
the contents of the geometric files used by Triangle. Show Me can also Show Me graphically displays the contents of the geometric files used by
write images in PostScript form. 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
...@@ -57,18 +61,151 @@ free, then you are not required to make any arrangement with me.) ...@@ -57,18 +61,151 @@ free, then you are not required to make any arrangement with me.)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
If you use Triangle, and especially if you use it to accomplish real The files included in this distribution are:
work, I would like very much to hear from you. A short letter or email
(to jrs@cs.cmu.edu) describing how you use Triangle will mean a lot to README The file you're reading now.
me. The more people I know are using this program, the more easily I can triangle.c Complete C source code for Triangle.
showme.c Complete C source code for Show Me.
triangle.h Include file for calling Triangle from another program.
tricall.c Sample program that calls Triangle.
makefile Makefile for compiling Triangle and Show Me.
A.poly A sample input file.
Each of Triangle and Show Me is a single portable C file. The easiest way
to compile them is to edit and use the included makefile. Before
compiling, read the makefile, which describes your options, and edit it
accordingly. You should specify:
The source and binary directories.
The C compiler and level of optimization.
The "correct" directories for include files (especially X include files),
if necessary.
Do you want single precision or double? (The default is double.) Do you
want to leave out some of Triangle's features to reduce the size of the
executable file? Investigate the SINGLE, REDUCED, and CDT_ONLY symbols.
If yours is not a Unix system, define the NO_TIMER symbol to remove the
Unix-specific timing code. Also, don't try to compile Show Me; it only
works with X Windows.
If you are compiling on an Intel x86 CPU and using gcc w/Linux or
Microsoft C, be sure to define the LINUX or CPU86 (for Microsoft) symbol
during compilation so that the exact arithmetic works right.
Once you've done this, type "make" to compile the programs. Alternatively,
the files are usually easy to compile without a makefile:
cc -O -o triangle triangle.c -lm
cc -O -o showme showme.c -lX11
On some systems, the C compiler won't be able to find the X include files
or libraries, and you'll need to specify an include path or library path:
cc -O -I/usr/local/include -o showme showme.c -L/usr/local/lib -lX11
Some processors, including Intel x86 family and possibly Motorola 68xxx
family chips, are IEEE conformant but have extended length internal
floating-point registers that may defeat Triangle's exact arithmetic
routines by failing to cause enough roundoff error! Typically, there is a
way to set these internal registers so that they are rounded off to IEEE
single or double precision format. I believe (but I'm not certain) that
Triangle has the right incantations for x86 chips, if you have gcc running
under Linux (define the LINUX compiler symbol) or Microsoft C (define the
CPU86 compiler symbol).
If you have a different processor or operating system, or if I got the
incantations wrong, you should check your C compiler or system manuals to
find out how to configure these internal registers to the precision you are
using. Otherwise, the exact arithmetic routines won't be exact at all.
See http://www.cs.cmu.edu/~quake/robust.pc.html for details. Triangle's
exact arithmetic hasn't a hope of working on machines like the Cray C90 or
Y-MP, which are not IEEE conformant and have inaccurate rounding.
Triangle and Show Me have both text and HTML documentation. The latter is
illustrated. Find it on the Web at
http://www.cs.cmu.edu/~quake/triangle.html
http://www.cs.cmu.edu/~quake/showme.html
Complete text instructions are printed by invoking each program with the
`-h' switch:
triangle -h
showme -h
The instructions are long; you'll probably want to pipe the output to
`more' or `lpr' or redirect it to a file.
Both programs give a short list of command line options if they are invoked
without arguments (that is, just type `triangle' or `showme').
Try out Triangle on the enclosed sample file, A.poly:
triangle -p A
showme A.poly &
Triangle will read the Planar Straight Line Graph defined by A.poly, and
write its constrained Delaunay triangulation to A.1.node and A.1.ele.
Show Me will display the figure defined by A.poly. There are two buttons
marked "ele" in the Show Me window; click on the top one. This will cause
Show Me to load and display the triangulation.
For contrast, try running
triangle -pq A
Now, click on the same "ele" button. A new triangulation will be loaded;
this one having no angles smaller than 20 degrees.
To see a Voronoi diagram, try this:
cp A.poly A.node
triangle -v A
Click the "ele" button again. You will see the Delaunay triangulation of
the points in A.poly, without the segments. Now click the top "voro" button.
You will see the Voronoi diagram corresponding to that Delaunay triangulation.
Click the "Reset" button to see the full extent of the diagram.
------------------------------------------------------------------------------
If you wish to call Triangle from another program, instructions for doing
so are contained in the file `triangle.h' (but read Triangle's regular
instructions first!). Also look at `tricall.c', which provides an example
of how to call Triangle.
Type "make trilibrary" to create triangle.o, a callable object file.
Alternatively, the object file is usually easy to compile without a
makefile:
cc -DTRILIBRARY -O -c triangle.c
Type "make distclean" to remove all the object and executable files created
by make.
------------------------------------------------------------------------------
If you use Triangle, and especially if you use it to accomplish real work,
I would like very much to hear from you. A short letter or email (to
jrs@cs.berkeley.edu) describing how you use Triangle will mean a lot to me.
The more people I know are using this program, the more easily I can
justify spending time on improvements and on the three-dimensional justify spending time on improvements and on the three-dimensional
successor to Triangle, which in turn will benefit you. Also, I can put successor to Triangle, which in turn will benefit you. Also, I can put you
you on a list to receive email whenever a new version of Triangle is on a list to receive email whenever a new version of Triangle is available.
available.
If you use a mesh generated by Triangle or plotted by Show Me in a If you use a mesh generated by Triangle or plotted by Show Me in a
publication, please include an acknowledgment as well. publication, please include an acknowledgment as well. And please spell
Triangle with a capital `T'! If you want to include a citation, use
`Jonathan Richard Shewchuk, ``Triangle: Engineering a 2D Quality Mesh
Generator and Delaunay Triangulator,'' in Applied Computational Geometry:
Towards Geometric Engineering (Ming C. Lin and Dinesh Manocha, editors),
volume 1148 of Lecture Notes in Computer Science, pages 203-222,
Springer-Verlag, Berlin, May 1996. (From the First ACM Workshop on Applied
Computational Geometry.)'
Jonathan Richard Shewchuk Jonathan Richard Shewchuk
April 27, 2004 July 27, 2005
This diff is collapsed.
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
/* */ /* */
/* Include file for programs that call Triangle. */ /* Include file for programs that call Triangle. */
/* */ /* */
/* Accompanies Triangle Versions 1.3 and 1.4 */ /* Accompanies Triangle Version 1.6 */
/* July 19, 1996 */ /* July 28, 2005 */
/* */ /* */
/* Copyright 1996 */ /* Copyright 1996, 2005 */
/* Jonathan Richard Shewchuk */ /* Jonathan Richard Shewchuk */
/* 2360 Woolsey #H */ /* 2360 Woolsey #H */
/* Berkeley, California 94705-1927 */ /* Berkeley, California 94705-1927 */
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
/* them), you won't understand what follows. */ /* them), you won't understand what follows. */
/* */ /* */
/* Triangle must be compiled into an object file (triangle.o) with the */ /* Triangle must be compiled into an object file (triangle.o) with the */
/* TRILIBRARY symbol defined (preferably by using the -DTRILIBRARY compiler */ /* TRILIBRARY symbol defined (generally by using the -DTRILIBRARY compiler */
/* switch). The makefile included with Triangle will do this for you if */ /* switch). The makefile included with Triangle will do this for you if */
/* you run "make trilibrary". The resulting object file can be called via */ /* you run "make trilibrary". The resulting object file can be called via */
/* the procedure triangulate(). */ /* the procedure triangulate(). */
...@@ -35,11 +35,11 @@ ...@@ -35,11 +35,11 @@
/* the -DREDUCED switch eliminates Triangle's -i, -F, -s, and -C switches. */ /* the -DREDUCED switch eliminates Triangle's -i, -F, -s, and -C switches. */
/* The CDT_ONLY symbol gets rid of all meshing algorithms above and beyond */ /* The CDT_ONLY symbol gets rid of all meshing algorithms above and beyond */
/* constrained Delaunay triangulation. Specifically, the -DCDT_ONLY switch */ /* constrained Delaunay triangulation. Specifically, the -DCDT_ONLY switch */
/* eliminates Triangle's -r, -q, -a, -S, and -s switches. */ /* eliminates Triangle's -r, -q, -a, -u, -D, -Y, -S, and -s switches. */
/* */ /* */
/* IMPORTANT: These definitions (TRILIBRARY, REDUCED, CDT_ONLY) must be */ /* IMPORTANT: These definitions (TRILIBRARY, REDUCED, CDT_ONLY) must be */
/* made in the makefile or in triangle.c itself. Putting these definitions */ /* made in the makefile or in triangle.c itself. Putting these definitions */
/* in this file will not create the desired effect. */ /* in this file (triangle.h) will not create the desired effect. */
/* */ /* */
/* */ /* */
/* The calling convention for triangulate() follows. */ /* The calling convention for triangulate() follows. */
...@@ -61,13 +61,14 @@ ...@@ -61,13 +61,14 @@
/* - You'll probably want to use the `Q' (quiet) switch in your final code, */ /* - You'll probably want to use the `Q' (quiet) switch in your final code, */
/* but you can take advantage of Triangle's printed output (including the */ /* but you can take advantage of Triangle's printed output (including the */
/* `V' switch) while debugging. */ /* `V' switch) while debugging. */
/* - If you are not using the `q' or `a' switches, then the output points */ /* - If you are not using the `q', `a', `u', `D', `j', or `s' switches, */
/* will be identical to the input points, except possibly for the */ /* then the output points will be identical to the input points, except */
/* boundary markers. If you don't need the boundary markers, you should */ /* possibly for the boundary markers. If you don't need the boundary */
/* use the `N' (no nodes output) switch to save memory. (If you do need */ /* markers, you should use the `N' (no nodes output) switch to save */
/* boundary markers, but need to save memory, a good nasty trick is to */ /* memory. (If you do need boundary markers, but need to save memory, a */
/* set out->pointlist equal to in->pointlist before calling triangulate(),*/ /* good nasty trick is to set out->pointlist equal to in->pointlist */
/* so that Triangle overwrites the input points with identical copies.) */ /* before calling triangulate(), so that Triangle overwrites the input */
/* points with identical copies.) */
/* - The `I' (no iteration numbers) and `g' (.off file output) switches */ /* - The `I' (no iteration numbers) and `g' (.off file output) switches */
/* have no effect when Triangle is compiled with TRILIBRARY defined. */ /* have no effect when Triangle is compiled with TRILIBRARY defined. */
/* */ /* */
...@@ -129,7 +130,7 @@ ...@@ -129,7 +130,7 @@
/* */ /* */
/* `regionlist': An array of regional attributes and area constraints. */ /* `regionlist': An array of regional attributes and area constraints. */
/* The first constraint's x and y coordinates are at indices [0] and [1], */ /* The first constraint's x and y coordinates are at indices [0] and [1], */
/* followed by the regional attribute and index [2], followed by the */ /* followed by the regional attribute at index [2], followed by the */
/* maximum area at index [3], followed by the remaining area constraints. */ /* maximum area at index [3], followed by the remaining area constraints. */
/* Four REALs per area constraint. Note that each regional attribute is */ /* Four REALs per area constraint. Note that each regional attribute is */
/* used only if you select the `A' switch, and each area constraint is */ /* used only if you select the `A' switch, and each area constraint is */
...@@ -162,7 +163,11 @@ ...@@ -162,7 +163,11 @@
/* same arrays as the input. */ /* same arrays as the input. */
/* */ /* */
/* Triangle will not free() any input or output arrays, including those it */ /* Triangle will not free() any input or output arrays, including those it */
/* allocates itself; that's up to you. */ /* allocates itself; that's up to you. You should free arrays allocated by */
/* Triangle by calling the trifree() procedure defined below. (By default, */
/* trifree() just calls the standard free() library procedure, but */
/* applications that call triangulate() may replace trimalloc() and */
/* trifree() in triangle.c to use specialized memory allocators.) */
/* */ /* */
/* Here's a guide to help you decide which fields you must initialize */ /* Here's a guide to help you decide which fields you must initialize */
/* before you call triangulate(). */ /* before you call triangulate(). */
...@@ -277,6 +282,8 @@ struct triangulateio { ...@@ -277,6 +282,8 @@ struct triangulateio {
#ifdef ANSI_DECLARATORS #ifdef ANSI_DECLARATORS
void triangulate(char *, struct triangulateio *, struct triangulateio *, void triangulate(char *, struct triangulateio *, struct triangulateio *,
struct triangulateio *); struct triangulateio *);
void trifree(VOID *memptr);
#else /* not ANSI_DECLARATORS */ #else /* not ANSI_DECLARATORS */
void triangulate(); void triangulate();
void trifree();
#endif /* not ANSI_DECLARATORS */ #endif /* not ANSI_DECLARATORS */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment