triangle.h

00001 /*****************************************************************************/
00002 /*                                                                           */
00003 /*  (triangle.h)                                                             */
00004 /*                                                                           */
00005 /*  Include file for programs that call Triangle.                            */
00006 /*                                                                           */
00007 /*  Accompanies Triangle Version 1.6                                         */
00008 /*  July 28, 2005                                                            */
00009 /*                                                                           */
00010 /*  Copyright 1996, 2005                                                     */
00011 /*  Jonathan Richard Shewchuk                                                */
00012 /*  2360 Woolsey #H                                                          */
00013 /*  Berkeley, California  94705-1927                                         */
00014 /*  jrs@cs.berkeley.edu                                                      */
00015 /*                                                                           */
00016 /*****************************************************************************/
00017 
00018 /*****************************************************************************/
00019 /*                                                                           */
00020 /*  How to call Triangle from another program                                */
00021 /*                                                                           */
00022 /*                                                                           */
00023 /*  If you haven't read Triangle's instructions (run "triangle -h" to read   */
00024 /*  them), you won't understand what follows.                                */
00025 /*                                                                           */
00026 /*  Triangle must be compiled into an object file (triangle.o) with the      */
00027 /*  TRILIBRARY symbol defined (generally by using the -DTRILIBRARY compiler  */
00028 /*  switch).  The makefile included with Triangle will do this for you if    */
00029 /*  you run "make trilibrary".  The resulting object file can be called via  */
00030 /*  the procedure triangulate().                                             */
00031 /*                                                                           */
00032 /*  If the size of the object file is important to you, you may wish to      */
00033 /*  generate a reduced version of triangle.o.  The REDUCED symbol gets rid   */
00034 /*  of all features that are primarily of research interest.  Specifically,  */
00035 /*  the -DREDUCED switch eliminates Triangle's -i, -F, -s, and -C switches.  */
00036 /*  The CDT_ONLY symbol gets rid of all meshing algorithms above and beyond  */
00037 /*  constrained Delaunay triangulation.  Specifically, the -DCDT_ONLY switch */
00038 /*  eliminates Triangle's -r, -q, -a, -u, -D, -Y, -S, and -s switches.       */
00039 /*                                                                           */
00040 /*  IMPORTANT:  These definitions (TRILIBRARY, REDUCED, CDT_ONLY) must be    */
00041 /*  made in the makefile or in triangle.c itself.  Putting these definitions */
00042 /*  in this file (triangle.h) will not create the desired effect.            */
00043 /*                                                                           */
00044 /*                                                                           */
00045 /*  The calling convention for triangulate() follows.                        */
00046 /*                                                                           */
00047 /*      void triangulate(triswitches, in, out, vorout)                       */
00048 /*      char *triswitches;                                                   */
00049 /*      struct triangulateio *in;                                            */
00050 /*      struct triangulateio *out;                                           */
00051 /*      struct triangulateio *vorout;                                        */
00052 /*                                                                           */
00053 /*  `triswitches' is a string containing the command line switches you wish  */
00054 /*  to invoke.  No initial dash is required.  Some suggestions:              */
00055 /*                                                                           */
00056 /*  - You'll probably find it convenient to use the `z' switch so that       */
00057 /*    points (and other items) are numbered from zero.  This simplifies      */
00058 /*    indexing, because the first item of any type always starts at index    */
00059 /*    [0] of the corresponding array, whether that item's number is zero or  */
00060 /*    one.                                                                   */
00061 /*  - You'll probably want to use the `Q' (quiet) switch in your final code, */
00062 /*    but you can take advantage of Triangle's printed output (including the */
00063 /*    `V' switch) while debugging.                                           */
00064 /*  - If you are not using the `q', `a', `u', `D', `j', or `s' switches,     */
00065 /*    then the output points will be identical to the input points, except   */
00066 /*    possibly for the boundary markers.  If you don't need the boundary     */
00067 /*    markers, you should use the `N' (no nodes output) switch to save       */
00068 /*    memory.  (If you do need boundary markers, but need to save memory, a  */
00069 /*    good nasty trick is to set out->pointlist equal to in->pointlist       */
00070 /*    before calling triangulate(), so that Triangle overwrites the input    */
00071 /*    points with identical copies.)                                         */
00072 /*  - The `I' (no iteration numbers) and `g' (.off file output) switches     */
00073 /*    have no effect when Triangle is compiled with TRILIBRARY defined.      */
00074 /*                                                                           */
00075 /*  `in', `out', and `vorout' are descriptions of the input, the output,     */
00076 /*  and the Voronoi output.  If the `v' (Voronoi output) switch is not used, */
00077 /*  `vorout' may be NULL.  `in' and `out' may never be NULL.                 */
00078 /*                                                                           */
00079 /*  Certain fields of the input and output structures must be initialized,   */
00080 /*  as described below.                                                      */
00081 /*                                                                           */
00082 /*****************************************************************************/
00083 
00084 /*****************************************************************************/
00085 /*                                                                           */
00086 /*  The `triangulateio' structure.                                           */
00087 /*                                                                           */
00088 /*  Used to pass data into and out of the triangulate() procedure.           */
00089 /*                                                                           */
00090 /*                                                                           */
00091 /*  Arrays are used to store points, triangles, markers, and so forth.  In   */
00092 /*  all cases, the first item in any array is stored starting at index [0].  */
00093 /*  However, that item is item number `1' unless the `z' switch is used, in  */
00094 /*  which case it is item number `0'.  Hence, you may find it easier to      */
00095 /*  index points (and triangles in the neighbor list) if you use the `z'     */
00096 /*  switch.  Unless, of course, you're calling Triangle from a Fortran       */
00097 /*  program.                                                                 */
00098 /*                                                                           */
00099 /*  Description of fields (except the `numberof' fields, which are obvious): */
00100 /*                                                                           */
00101 /*  `pointlist':  An array of point coordinates.  The first point's x        */
00102 /*    coordinate is at index [0] and its y coordinate at index [1], followed */
00103 /*    by the coordinates of the remaining points.  Each point occupies two   */
00104 /*    REALs.                                                                 */
00105 /*  `pointattributelist':  An array of point attributes.  Each point's       */
00106 /*    attributes occupy `numberofpointattributes' REALs.                     */
00107 /*  `pointmarkerlist':  An array of point markers; one int per point.        */
00108 /*                                                                           */
00109 /*  `trianglelist':  An array of triangle corners.  The first triangle's     */
00110 /*    first corner is at index [0], followed by its other two corners in     */
00111 /*    counterclockwise order, followed by any other nodes if the triangle    */
00112 /*    represents a nonlinear element.  Each triangle occupies                */
00113 /*    `numberofcorners' ints.                                                */
00114 /*  `triangleattributelist':  An array of triangle attributes.  Each         */
00115 /*    triangle's attributes occupy `numberoftriangleattributes' REALs.       */
00116 /*  `trianglearealist':  An array of triangle area constraints; one REAL per */
00117 /*    triangle.  Input only.                                                 */
00118 /*  `neighborlist':  An array of triangle neighbors; three ints per          */
00119 /*    triangle.  Output only.                                                */
00120 /*                                                                           */
00121 /*  `segmentlist':  An array of segment endpoints.  The first segment's      */
00122 /*    endpoints are at indices [0] and [1], followed by the remaining        */
00123 /*    segments.  Two ints per segment.                                       */
00124 /*  `segmentmarkerlist':  An array of segment markers; one int per segment.  */
00125 /*                                                                           */
00126 /*  `holelist':  An array of holes.  The first hole's x and y coordinates    */
00127 /*    are at indices [0] and [1], followed by the remaining holes.  Two      */
00128 /*    REALs per hole.  Input only, although the pointer is copied to the     */
00129 /*    output structure for your convenience.                                 */
00130 /*                                                                           */
00131 /*  `regionlist':  An array of regional attributes and area constraints.     */
00132 /*    The first constraint's x and y coordinates are at indices [0] and [1], */
00133 /*    followed by the regional attribute at index [2], followed by the       */
00134 /*    maximum area at index [3], followed by the remaining area constraints. */
00135 /*    Four REALs per area constraint.  Note that each regional attribute is  */
00136 /*    used only if you select the `A' switch, and each area constraint is    */
00137 /*    used only if you select the `a' switch (with no number following), but */
00138 /*    omitting one of these switches does not change the memory layout.      */
00139 /*    Input only, although the pointer is copied to the output structure for */
00140 /*    your convenience.                                                      */
00141 /*                                                                           */
00142 /*  `edgelist':  An array of edge endpoints.  The first edge's endpoints are */
00143 /*    at indices [0] and [1], followed by the remaining edges.  Two ints per */
00144 /*    edge.  Output only.                                                    */
00145 /*  `edgemarkerlist':  An array of edge markers; one int per edge.  Output   */
00146 /*    only.                                                                  */
00147 /*  `normlist':  An array of normal vectors, used for infinite rays in       */
00148 /*    Voronoi diagrams.  The first normal vector's x and y magnitudes are    */
00149 /*    at indices [0] and [1], followed by the remaining vectors.  For each   */
00150 /*    finite edge in a Voronoi diagram, the normal vector written is the     */
00151 /*    zero vector.  Two REALs per edge.  Output only.                        */
00152 /*                                                                           */
00153 /*                                                                           */
00154 /*  Any input fields that Triangle will examine must be initialized.         */
00155 /*  Furthermore, for each output array that Triangle will write to, you      */
00156 /*  must either provide space by setting the appropriate pointer to point    */
00157 /*  to the space you want the data written to, or you must initialize the    */
00158 /*  pointer to NULL, which tells Triangle to allocate space for the results. */
00159 /*  The latter option is preferable, because Triangle always knows exactly   */
00160 /*  how much space to allocate.  The former option is provided mainly for    */
00161 /*  people who need to call Triangle from Fortran code, though it also makes */
00162 /*  possible some nasty space-saving tricks, like writing the output to the  */
00163 /*  same arrays as the input.                                                */
00164 /*                                                                           */
00165 /*  Triangle will not free() any input or output arrays, including those it  */
00166 /*  allocates itself; that's up to you.  You should free arrays allocated by */
00167 /*  Triangle by calling the trifree() procedure defined below.  (By default, */
00168 /*  trifree() just calls the standard free() library procedure, but          */
00169 /*  applications that call triangulate() may replace trimalloc() and         */
00170 /*  trifree() in triangle.c to use specialized memory allocators.)           */
00171 /*                                                                           */
00172 /*  Here's a guide to help you decide which fields you must initialize       */
00173 /*  before you call triangulate().                                           */
00174 /*                                                                           */
00175 /*  `in':                                                                    */
00176 /*                                                                           */
00177 /*    - `pointlist' must always point to a list of points; `numberofpoints'  */
00178 /*      and `numberofpointattributes' must be properly set.                  */
00179 /*      `pointmarkerlist' must either be set to NULL (in which case all      */
00180 /*      markers default to zero), or must point to a list of markers.  If    */
00181 /*      `numberofpointattributes' is not zero, `pointattributelist' must     */
00182 /*      point to a list of point attributes.                                 */
00183 /*    - If the `r' switch is used, `trianglelist' must point to a list of    */
00184 /*      triangles, and `numberoftriangles', `numberofcorners', and           */
00185 /*      `numberoftriangleattributes' must be properly set.  If               */
00186 /*      `numberoftriangleattributes' is not zero, `triangleattributelist'    */
00187 /*      must point to a list of triangle attributes.  If the `a' switch is   */
00188 /*      used (with no number following), `trianglearealist' must point to a  */
00189 /*      list of triangle area constraints.  `neighborlist' may be ignored.   */
00190 /*    - If the `p' switch is used, `segmentlist' must point to a list of     */
00191 /*      segments, `numberofsegments' must be properly set, and               */
00192 /*      `segmentmarkerlist' must either be set to NULL (in which case all    */
00193 /*      markers default to zero), or must point to a list of markers.        */
00194 /*    - If the `p' switch is used without the `r' switch, then               */
00195 /*      `numberofholes' and `numberofregions' must be properly set.  If      */
00196 /*      `numberofholes' is not zero, `holelist' must point to a list of      */
00197 /*      holes.  If `numberofregions' is not zero, `regionlist' must point to */
00198 /*      a list of region constraints.                                        */
00199 /*    - If the `p' switch is used, `holelist', `numberofholes',              */
00200 /*      `regionlist', and `numberofregions' is copied to `out'.  (You can    */
00201 /*      nonetheless get away with not initializing them if the `r' switch is */
00202 /*      used.)                                                               */
00203 /*    - `edgelist', `edgemarkerlist', `normlist', and `numberofedges' may be */
00204 /*      ignored.                                                             */
00205 /*                                                                           */
00206 /*  `out':                                                                   */
00207 /*                                                                           */
00208 /*    - `pointlist' must be initialized (NULL or pointing to memory) unless  */
00209 /*      the `N' switch is used.  `pointmarkerlist' must be initialized       */
00210 /*      unless the `N' or `B' switch is used.  If `N' is not used and        */
00211 /*      `in->numberofpointattributes' is not zero, `pointattributelist' must */
00212 /*      be initialized.                                                      */
00213 /*    - `trianglelist' must be initialized unless the `E' switch is used.    */
00214 /*      `neighborlist' must be initialized if the `n' switch is used.  If    */
00215 /*      the `E' switch is not used and (`in->numberofelementattributes' is   */
00216 /*      not zero or the `A' switch is used), `elementattributelist' must be  */
00217 /*      initialized.  `trianglearealist' may be ignored.                     */
00218 /*    - `segmentlist' must be initialized if the `p' or `c' switch is used,  */
00219 /*      and the `P' switch is not used.  `segmentmarkerlist' must also be    */
00220 /*      initialized under these circumstances unless the `B' switch is used. */
00221 /*    - `edgelist' must be initialized if the `e' switch is used.            */
00222 /*      `edgemarkerlist' must be initialized if the `e' switch is used and   */
00223 /*      the `B' switch is not.                                               */
00224 /*    - `holelist', `regionlist', `normlist', and all scalars may be ignored.*/
00225 /*                                                                           */
00226 /*  `vorout' (only needed if `v' switch is used):                            */
00227 /*                                                                           */
00228 /*    - `pointlist' must be initialized.  If `in->numberofpointattributes'   */
00229 /*      is not zero, `pointattributelist' must be initialized.               */
00230 /*      `pointmarkerlist' may be ignored.                                    */
00231 /*    - `edgelist' and `normlist' must both be initialized.                  */
00232 /*      `edgemarkerlist' may be ignored.                                     */
00233 /*    - Everything else may be ignored.                                      */
00234 /*                                                                           */
00235 /*  After a call to triangulate(), the valid fields of `out' and `vorout'    */
00236 /*  will depend, in an obvious way, on the choice of switches used.  Note    */
00237 /*  that when the `p' switch is used, the pointers `holelist' and            */
00238 /*  `regionlist' are copied from `in' to `out', but no new space is          */
00239 /*  allocated; be careful that you don't free() the same array twice.  On    */
00240 /*  the other hand, Triangle will never copy the `pointlist' pointer (or any */
00241 /*  others); new space is allocated for `out->pointlist', or if the `N'      */
00242 /*  switch is used, `out->pointlist' remains uninitialized.                  */
00243 /*                                                                           */
00244 /*  All of the meaningful `numberof' fields will be properly set; for        */
00245 /*  instance, `numberofedges' will represent the number of edges in the      */
00246 /*  triangulation whether or not the edges were written.  If segments are    */
00247 /*  not used, `numberofsegments' will indicate the number of boundary edges. */
00248 /*                                                                           */
00249 /*****************************************************************************/
00250 
00251 struct triangulateio {
00252   REAL *pointlist;                                               /* In / out */
00253   REAL *pointattributelist;                                      /* In / out */
00254   int *pointmarkerlist;                                          /* In / out */
00255   int numberofpoints;                                            /* In / out */
00256   int numberofpointattributes;                                   /* In / out */
00257 
00258   int *trianglelist;                                             /* In / out */
00259   REAL *triangleattributelist;                                   /* In / out */
00260   REAL *trianglearealist;                                         /* In only */
00261   int *neighborlist;                                             /* Out only */
00262   int numberoftriangles;                                         /* In / out */
00263   int numberofcorners;                                           /* In / out */
00264   int numberoftriangleattributes;                                /* In / out */
00265 
00266   int *segmentlist;                                              /* In / out */
00267   int *segmentmarkerlist;                                        /* In / out */
00268   int numberofsegments;                                          /* In / out */
00269 
00270   REAL *holelist;                        /* In / pointer to array copied out */
00271   int numberofholes;                                      /* In / copied out */
00272 
00273   REAL *regionlist;                      /* In / pointer to array copied out */
00274   int numberofregions;                                    /* In / copied out */
00275 
00276   int *edgelist;                                                 /* Out only */
00277   int *edgemarkerlist;            /* Not used with Voronoi diagram; out only */
00278   REAL *normlist;                /* Used only with Voronoi diagram; out only */
00279   int numberofedges;                                             /* Out only */
00280 };
00281 
00282 #ifdef ANSI_DECLARATORS
00283 void triangulate(char *, struct triangulateio *, struct triangulateio *,
00284                  struct triangulateio *);
00285 void trifree(VOID *memptr);
00286 #else /* not ANSI_DECLARATORS */
00287 void triangulate();
00288 void trifree();
00289 #endif /* not ANSI_DECLARATORS */

Generated on Wed Mar 18 12:51:54 2009 for Chaste by  doxygen 1.5.5