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


libviso2
Author(s): Andreas Geiger, Stephan Wirth
autogenerated on Fri Aug 28 2015 13:37:45