Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
triangle.h
Go to the documentation of this file.
1/*****************************************************************************/
2/* */
3/* (triangle.h) */
4/* */
5/* Include file for programs that call Triangle. */
6/* */
7/* Accompanies Triangle Version 1.6 */
8/* July 28, 2005 */
9/* */
10/* Jonathan Richard Shewchuk */
11/* 2360 Woolsey #H */
12/* Berkeley, California 94705-1927 */
13/* jrs@cs.berkeley.edu */
14/* */
15/*****************************************************************************/
16
17/*****************************************************************************/
18/* */
19/* How to call Triangle from another program */
20/* */
21/* */
22/* If you haven't read Triangle's instructions (run "triangle -h" to read */
23/* them), you won't understand what follows. */
24/* */
25/* Triangle must be compiled into an object file (triangle.o) with the */
26/* TRILIBRARY symbol defined (generally by using the -DTRILIBRARY compiler */
27/* switch). The makefile included with Triangle will do this for you if */
28/* you run "make trilibrary". The resulting object file can be called via */
29/* the procedure triangulate(). */
30/* */
31/* If the size of the object file is important to you, you may wish to */
32/* generate a reduced version of triangle.o. The REDUCED symbol gets rid */
33/* of all features that are primarily of research interest. Specifically, */
34/* the -DREDUCED switch eliminates Triangle's -i, -F, -s, and -C switches. */
35/* The CDT_ONLY symbol gets rid of all meshing algorithms above and beyond */
36/* constrained Delaunay triangulation. Specifically, the -DCDT_ONLY switch */
37/* eliminates Triangle's -r, -q, -a, -u, -D, -Y, -S, and -s switches. */
38/* */
39/* IMPORTANT: These definitions (TRILIBRARY, REDUCED, CDT_ONLY) must be */
40/* made in the makefile or in triangle.c itself. Putting these definitions */
41/* in this file (triangle.h) will not create the desired effect. */
42/* */
43/* */
44/* The calling convention for triangulate() follows. */
45/* */
46/* void triangulate(triswitches, in, out, vorout) */
47/* char *triswitches; */
48/* struct triangulateio *in; */
49/* struct triangulateio *out; */
50/* struct triangulateio *vorout; */
51/* */
52/* `triswitches' is a string containing the command line switches you wish */
53/* to invoke. No initial dash is required. Some suggestions: */
54/* */
55/* - You'll probably find it convenient to use the `z' switch so that */
56/* points (and other items) are numbered from zero. This simplifies */
57/* indexing, because the first item of any type always starts at index */
58/* [0] of the corresponding array, whether that item's number is zero or */
59/* one. */
60/* - You'll probably want to use the `Q' (quiet) switch in your final code, */
61/* but you can take advantage of Triangle's printed output (including the */
62/* `V' switch) while debugging. */
63/* - If you are not using the `q', `a', `u', `D', `j', or `s' switches, */
64/* then the output points will be identical to the input points, except */
65/* possibly for the boundary markers. If you don't need the boundary */
66/* markers, you should use the `N' (no nodes output) switch to save */
67/* memory. (If you do need boundary markers, but need to save memory, a */
68/* good nasty trick is to set out->pointlist equal to in->pointlist */
69/* before calling triangulate(), so that Triangle overwrites the input */
70/* points with identical copies.) */
71/* - The `I' (no iteration numbers) and `g' (.off file output) switches */
72/* have no effect when Triangle is compiled with TRILIBRARY defined. */
73/* */
74/* `in', `out', and `vorout' are descriptions of the input, the output, */
75/* and the Voronoi output. If the `v' (Voronoi output) switch is not used, */
76/* `vorout' may be NULL. `in' and `out' may never be NULL. */
77/* */
78/* Certain fields of the input and output structures must be initialized, */
79/* as described below. */
80/* */
81/*****************************************************************************/
82
83/*****************************************************************************/
84/* */
85/* The `triangulateio' structure. */
86/* */
87/* Used to pass data into and out of the triangulate() procedure. */
88/* */
89/* */
90/* Arrays are used to store points, triangles, markers, and so forth. In */
91/* all cases, the first item in any array is stored starting at index [0]. */
92/* However, that item is item number `1' unless the `z' switch is used, in */
93/* which case it is item number `0'. Hence, you may find it easier to */
94/* index points (and triangles in the neighbor list) if you use the `z' */
95/* switch. Unless, of course, you're calling Triangle from a Fortran */
96/* program. */
97/* */
98/* Description of fields (except the `numberof' fields, which are obvious): */
99/* */
100/* `pointlist': An array of point coordinates. The first point's x */
101/* coordinate is at index [0] and its y coordinate at index [1], followed */
102/* by the coordinates of the remaining points. Each point occupies two */
103/* REALs. */
104/* `pointattributelist': An array of point attributes. Each point's */
105/* attributes occupy `numberofpointattributes' REALs. */
106/* `pointmarkerlist': An array of point markers; one int per point. */
107/* */
108/* `trianglelist': An array of triangle corners. The first triangle's */
109/* first corner is at index [0], followed by its other two corners in */
110/* counterclockwise order, followed by any other nodes if the triangle */
111/* represents a nonlinear element. Each triangle occupies */
112/* `numberofcorners' ints. */
113/* `triangleattributelist': An array of triangle attributes. Each */
114/* triangle's attributes occupy `numberoftriangleattributes' REALs. */
115/* `trianglearealist': An array of triangle area constraints; one REAL per */
116/* triangle. Input only. */
117/* `neighborlist': An array of triangle neighbors; three ints per */
118/* triangle. Output only. */
119/* */
120/* `segmentlist': An array of segment endpoints. The first segment's */
121/* endpoints are at indices [0] and [1], followed by the remaining */
122/* segments. Two ints per segment. */
123/* `segmentmarkerlist': An array of segment markers; one int per segment. */
124/* */
125/* `holelist': An array of holes. The first hole's x and y coordinates */
126/* are at indices [0] and [1], followed by the remaining holes. Two */
127/* REALs per hole. Input only, although the pointer is copied to the */
128/* output structure for your convenience. */
129/* */
130/* `regionlist': An array of regional attributes and area constraints. */
131/* The first constraint's x and y coordinates are at indices [0] and [1], */
132/* followed by the regional attribute at index [2], followed by the */
133/* maximum area at index [3], followed by the remaining area constraints. */
134/* Four REALs per area constraint. Note that each regional attribute is */
135/* used only if you select the `A' switch, and each area constraint is */
136/* used only if you select the `a' switch (with no number following), but */
137/* omitting one of these switches does not change the memory layout. */
138/* Input only, although the pointer is copied to the output structure for */
139/* your convenience. */
140/* */
141/* `edgelist': An array of edge endpoints. The first edge's endpoints are */
142/* at indices [0] and [1], followed by the remaining edges. Two ints per */
143/* edge. Output only. */
144/* `edgemarkerlist': An array of edge markers; one int per edge. Output */
145/* only. */
146/* `normlist': An array of normal vectors, used for infinite rays in */
147/* Voronoi diagrams. The first normal vector's x and y magnitudes are */
148/* at indices [0] and [1], followed by the remaining vectors. For each */
149/* finite edge in a Voronoi diagram, the normal vector written is the */
150/* zero vector. Two REALs per edge. Output only. */
151/* */
152/* */
153/* Any input fields that Triangle will examine must be initialized. */
154/* Furthermore, for each output array that Triangle will write to, you */
155/* must either provide space by setting the appropriate pointer to point */
156/* to the space you want the data written to, or you must initialize the */
157/* pointer to NULL, which tells Triangle to allocate space for the results. */
158/* The latter option is preferable, because Triangle always knows exactly */
159/* how much space to allocate. The former option is provided mainly for */
160/* people who need to call Triangle from Fortran code, though it also makes */
161/* possible some nasty space-saving tricks, like writing the output to the */
162/* same arrays as the input. */
163/* */
164/* Triangle will not free() any input or output arrays, including those it */
165/* allocates itself; that's up to you. You should free arrays allocated by */
166/* Triangle by calling the trifree() procedure defined below. (By default, */
167/* trifree() just calls the standard free() library procedure, but */
168/* applications that call triangulate() may replace trimalloc() and */
169/* trifree() in triangle.c to use specialized memory allocators.) */
170/* */
171/* Here's a guide to help you decide which fields you must initialize */
172/* before you call triangulate(). */
173/* */
174/* `in': */
175/* */
176/* - `pointlist' must always point to a list of points; `numberofpoints' */
177/* and `numberofpointattributes' must be properly set. */
178/* `pointmarkerlist' must either be set to NULL (in which case all */
179/* markers default to zero), or must point to a list of markers. If */
180/* `numberofpointattributes' is not zero, `pointattributelist' must */
181/* point to a list of point attributes. */
182/* - If the `r' switch is used, `trianglelist' must point to a list of */
183/* triangles, and `numberoftriangles', `numberofcorners', and */
184/* `numberoftriangleattributes' must be properly set. If */
185/* `numberoftriangleattributes' is not zero, `triangleattributelist' */
186/* must point to a list of triangle attributes. If the `a' switch is */
187/* used (with no number following), `trianglearealist' must point to a */
188/* list of triangle area constraints. `neighborlist' may be ignored. */
189/* - If the `p' switch is used, `segmentlist' must point to a list of */
190/* segments, `numberofsegments' must be properly set, and */
191/* `segmentmarkerlist' must either be set to NULL (in which case all */
192/* markers default to zero), or must point to a list of markers. */
193/* - If the `p' switch is used without the `r' switch, then */
194/* `numberofholes' and `numberofregions' must be properly set. If */
195/* `numberofholes' is not zero, `holelist' must point to a list of */
196/* holes. If `numberofregions' is not zero, `regionlist' must point to */
197/* a list of region constraints. */
198/* - If the `p' switch is used, `holelist', `numberofholes', */
199/* `regionlist', and `numberofregions' is copied to `out'. (You can */
200/* nonetheless get away with not initializing them if the `r' switch is */
201/* used.) */
202/* - `edgelist', `edgemarkerlist', `normlist', and `numberofedges' may be */
203/* ignored. */
204/* */
205/* `out': */
206/* */
207/* - `pointlist' must be initialized (NULL or pointing to memory) unless */
208/* the `N' switch is used. `pointmarkerlist' must be initialized */
209/* unless the `N' or `B' switch is used. If `N' is not used and */
210/* `in->numberofpointattributes' is not zero, `pointattributelist' must */
211/* be initialized. */
212/* - `trianglelist' must be initialized unless the `E' switch is used. */
213/* `neighborlist' must be initialized if the `n' switch is used. If */
214/* the `E' switch is not used and (`in->numberofelementattributes' is */
215/* not zero or the `A' switch is used), `elementattributelist' must be */
216/* initialized. `trianglearealist' may be ignored. */
217/* - `segmentlist' must be initialized if the `p' or `c' switch is used, */
218/* and the `P' switch is not used. `segmentmarkerlist' must also be */
219/* initialized under these circumstances unless the `B' switch is used. */
220/* - `edgelist' must be initialized if the `e' switch is used. */
221/* `edgemarkerlist' must be initialized if the `e' switch is used and */
222/* the `B' switch is not. */
223/* - `holelist', `regionlist', `normlist', and all scalars may be ignored.*/
224/* */
225/* `vorout' (only needed if `v' switch is used): */
226/* */
227/* - `pointlist' must be initialized. If `in->numberofpointattributes' */
228/* is not zero, `pointattributelist' must be initialized. */
229/* `pointmarkerlist' may be ignored. */
230/* - `edgelist' and `normlist' must both be initialized. */
231/* `edgemarkerlist' may be ignored. */
232/* - Everything else may be ignored. */
233/* */
234/* After a call to triangulate(), the valid fields of `out' and `vorout' */
235/* will depend, in an obvious way, on the choice of switches used. Note */
236/* that when the `p' switch is used, the pointers `holelist' and */
237/* `regionlist' are copied from `in' to `out', but no new space is */
238/* allocated; be careful that you don't free() the same array twice. On */
239/* the other hand, Triangle will never copy the `pointlist' pointer (or any */
240/* others); new space is allocated for `out->pointlist', or if the `N' */
241/* switch is used, `out->pointlist' remains uninitialized. */
242/* */
243/* All of the meaningful `numberof' fields will be properly set; for */
244/* instance, `numberofedges' will represent the number of edges in the */
245/* triangulation whether or not the edges were written. If segments are */
246/* not used, `numberofsegments' will indicate the number of boundary edges. */
247/* */
248/*****************************************************************************/
249
250#ifdef SINGLE
251#define REAL float
252#else /* not SINGLE */
253#define REAL double
254#endif /* not SINGLE */
255//# define TRILIBRARY // use Triangle as a library
256# define ANSI_DECLARATORS // use ANSI_DECLARATORS
257
259 REAL *pointlist; /* In / out */
260 REAL *pointattributelist; /* In / out */
261 int *pointmarkerlist; /* In / out */
262 int numberofpoints; /* In / out */
263 int numberofpointattributes; /* In / out */
264
265 int *trianglelist; /* In / out */
266 REAL *triangleattributelist; /* In / out */
267 REAL *trianglearealist; /* In only */
268 int *neighborlist; /* Out only */
269 int numberoftriangles; /* In / out */
270 int numberofcorners; /* In / out */
271 int numberoftriangleattributes; /* In / out */
272
273 int *segmentlist; /* In / out */
274 int *segmentmarkerlist; /* In / out */
275 int numberofsegments; /* In / out */
276
277 REAL *holelist; /* In / pointer to array copied out */
278 int numberofholes; /* In / copied out */
279
280 REAL *regionlist; /* In / pointer to array copied out */
281 int numberofregions; /* In / copied out */
282
283 int *edgelist; /* Out only */
284 int *edgemarkerlist; /* Not used with Voronoi diagram; out only */
285 REAL *normlist; /* Used only with Voronoi diagram; out only */
286 int numberofedges; /* Out only */
287};
288
289#ifdef ANSI_DECLARATORS
290void triangulate(const char *, struct triangulateio *, struct triangulateio *,
291 struct triangulateio *);
292void trifree(void *memptr);
293#else /* not ANSI_DECLARATORS */
295void trifree();
296#endif /* not ANSI_DECLARATORS */
REAL * pointattributelist
Definition triangle.h:260
int * neighborlist
Definition triangle.h:268
int numberoftriangleattributes
Definition triangle.h:271
int numberofpoints
Definition triangle.h:262
int * edgemarkerlist
Definition triangle.h:284
int numberofsegments
Definition triangle.h:275
REAL * normlist
Definition triangle.h:285
int numberoftriangles
Definition triangle.h:269
REAL * trianglearealist
Definition triangle.h:267
int * trianglelist
Definition triangle.h:265
REAL * pointlist
Definition triangle.h:259
int * segmentmarkerlist
Definition triangle.h:274
int numberofholes
Definition triangle.h:278
REAL * regionlist
Definition triangle.h:280
int numberofpointattributes
Definition triangle.h:263
int numberofcorners
Definition triangle.h:270
int numberofregions
Definition triangle.h:281
int numberofedges
Definition triangle.h:286
int * pointmarkerlist
Definition triangle.h:261
int * segmentlist
Definition triangle.h:273
REAL * triangleattributelist
Definition triangle.h:266
REAL * holelist
Definition triangle.h:277
int * edgelist
Definition triangle.h:283
memptr
void triangulate()
void trifree()