qdelaun.c
Go to the documentation of this file.
00001 /*<html><pre>  -<a                             href="../libqhull/qh-qhull.htm"
00002   >-------------------------------</a><a name="TOP">-</a>
00003 
00004    qdelaun.c
00005      compute Delaunay triangulations and furthest-point Delaunay
00006      triangulations using qhull
00007 
00008    see unix.c for full interface
00009 
00010    Copyright (c) 1993-2011, The Geometry Center
00011 */
00012 
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include <string.h>
00016 #include <ctype.h>
00017 #include <math.h>
00018 #include "libqhull.h"
00019 #include "mem.h"
00020 #include "qset.h"
00021 
00022 #if __MWERKS__ && __POWERPC__
00023 #include <SIOUX.h>
00024 #include <Files.h>
00025 #include <console.h>
00026 #include <Desk.h>
00027 
00028 #elif __cplusplus
00029 extern "C" {
00030   int isatty(int);
00031 }
00032 
00033 #elif _MSC_VER
00034 #include <io.h>
00035 #define isatty _isatty
00036 int _isatty(int);
00037 
00038 #else
00039 int isatty(int);  /* returns 1 if stdin is a tty
00040                    if "Undefined symbol" this can be deleted along with call in main() */
00041 #endif
00042 
00043 /*-<a                             href="../libqhull/qh-qhull.htm#TOC"
00044   >-------------------------------</a><a name="prompt">-</a>
00045 
00046   qh_prompt
00047     long prompt for qhull
00048 
00049   notes:
00050     restricted version of libqhull.c
00051 
00052   see:
00053     concise prompt below
00054 */
00055 
00056 /* duplicated in qdelau_f.htm and qdelaun.htm */
00057 char hidden_options[]=" d n v H U Qb QB Qc Qf Qg Qi Qm Qr QR Qv Qx TR E V FC Fi Fo Ft Fp FV Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 ";
00058 
00059 char qh_prompta[]= "\n\
00060 qdelaunay- compute the Delaunay triangulation\n\
00061     http://www.qhull.org  %s\n\
00062 \n\
00063 input (stdin):\n\
00064     first lines: dimension and number of points (or vice-versa).\n\
00065     other lines: point coordinates, best if one point per line\n\
00066     comments:    start with a non-numeric character\n\
00067 \n\
00068 options:\n\
00069     Qu   - compute furthest-site Delaunay triangulation\n\
00070     Qt   - triangulated output\n\
00071     QJ   - joggled input instead of merged facets\n\
00072 \n\
00073 Qhull control options:\n\
00074     QJn  - randomly joggle input in range [-n,n]\n\
00075 %s%s%s%s";  /* split up qh_prompt for Visual C++ */
00076 char qh_promptb[]= "\
00077     Qs   - search all points for the initial simplex\n\
00078     Qz   - add point-at-infinity to Delaunay triangulation\n\
00079     QGn  - print Delaunay region if visible from point n, -n if not\n\
00080     QVn  - print Delaunay regions that include point n, -n if not\n\
00081 \n\
00082 ";
00083 char qh_promptc[]= "\
00084 Trace options:\n\
00085     T4   - trace at level n, 4=all, 5=mem/gauss, -1= events\n\
00086     Tc   - check frequently during execution\n\
00087     Ts   - print statistics\n\
00088     Tv   - verify result: structure, convexity, and in-circle test\n\
00089     Tz   - send all output to stdout\n\
00090     TFn  - report summary when n or more facets created\n\
00091     TI file - input data from file, no spaces or single quotes\n\
00092     TO file - output results to file, may be enclosed in single quotes\n\
00093     TPn  - turn on tracing when point n added to hull\n\
00094      TMn - turn on tracing at merge n\n\
00095      TWn - trace merge facets when width > n\n\
00096     TVn  - stop qhull after adding point n, -n for before (see TCn)\n\
00097      TCn - stop qhull after building cone for point n (see TVn)\n\
00098 \n\
00099 Precision options:\n\
00100     Cn   - radius of centrum (roundoff added).  Merge facets if non-convex\n\
00101      An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex\n\
00102            C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge\n\
00103     Rn   - randomly perturb computations by a factor of [1-n,1+n]\n\
00104     Wn   - min facet width for outside point (before roundoff)\n\
00105 \n\
00106 Output formats (may be combined; if none, produces a summary to stdout):\n\
00107     f    - facet dump\n\
00108     G    - Geomview output (see below)\n\
00109     i    - vertices incident to each Delaunay region\n\
00110     m    - Mathematica output (2-d only, lifted to a paraboloid)\n\
00111     o    - OFF format (dim, points, and facets as a paraboloid)\n\
00112     p    - point coordinates (lifted to a paraboloid)\n\
00113     s    - summary (stderr)\n\
00114 \n\
00115 ";
00116 char qh_promptd[]= "\
00117 More formats:\n\
00118     Fa   - area for each Delaunay region\n\
00119     FA   - compute total area for option 's'\n\
00120     Fc   - count plus coincident points for each Delaunay region\n\
00121     Fd   - use cdd format for input (homogeneous with offset first)\n\
00122     FD   - use cdd format for numeric output (offset first)\n\
00123     FF   - facet dump without ridges\n\
00124     FI   - ID of each Delaunay region\n\
00125     Fm   - merge count for each Delaunay region (511 max)\n\
00126     FM   - Maple output (2-d only, lifted to a paraboloid)\n\
00127     Fn   - count plus neighboring region for each Delaunay region\n\
00128     FN   - count plus neighboring region for each point\n\
00129     FO   - options and precision constants\n\
00130     FP   - nearest point and distance for each coincident point\n\
00131     FQ   - command used for qdelaunay\n\
00132     Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,\n\
00133                     for output: #vertices, #Delaunay regions,\n\
00134                                 #coincident points, #non-simplicial regions\n\
00135                     #real (2), max outer plane, min vertex\n\
00136     FS   - sizes:   #int (0)\n\
00137                     #real (2), tot area, 0\n\
00138     Fv   - count plus vertices for each Delaunay region\n\
00139     Fx   - extreme points of Delaunay triangulation (on convex hull)\n\
00140 \n\
00141 ";
00142 char qh_prompte[]= "\
00143 Geomview options (2-d and 3-d)\n\
00144     Ga   - all points as dots\n\
00145      Gp  -  coplanar points and vertices as radii\n\
00146      Gv  -  vertices as spheres\n\
00147     Gi   - inner planes only\n\
00148      Gn  -  no planes\n\
00149      Go  -  outer planes only\n\
00150     Gc     - centrums\n\
00151     Gh   - hyperplane intersections\n\
00152     Gr   - ridges\n\
00153     GDn  - drop dimension n in 3-d and 4-d output\n\
00154     Gt   - transparent outer ridges to view 3-d Delaunay\n\
00155 \n\
00156 Print options:\n\
00157     PAn  - keep n largest Delaunay regions by area\n\
00158     Pdk:n - drop facet if normal[k] <= n (default 0.0)\n\
00159     PDk:n - drop facet if normal[k] >= n\n\
00160     Pg   - print good Delaunay regions (needs 'QGn' or 'QVn')\n\
00161     PFn  - keep Delaunay regions whose area is at least n\n\
00162     PG   - print neighbors of good regions (needs 'QGn' or 'QVn')\n\
00163     PMn  - keep n Delaunay regions with most merges\n\
00164     Po   - force output.  If error, output neighborhood of facet\n\
00165     Pp   - do not report precision problems\n\
00166 \n\
00167     .    - list of all options\n\
00168     -    - one line descriptions of all options\n\
00169 ";
00170 /* for opts, don't assign 'e' or 'E' to a flag (already used for exponent) */
00171 
00172 /*-<a                             href="../libqhull/qh-qhull.htm#TOC"
00173   >-------------------------------</a><a name="prompt2">-</a>
00174 
00175   qh_prompt2
00176     synopsis for qhull
00177 */
00178 char qh_prompt2[]= "\n\
00179 qdelaunay- compute the Delaunay triangulation.  Qhull %s\n\
00180     input (stdin): dimension, number of points, point coordinates\n\
00181     comments start with a non-numeric character\n\
00182 \n\
00183 options (qdelaun.htm):\n\
00184     Qu   - furthest-site Delaunay triangulation\n\
00185     Qt   - triangulated output\n\
00186     QJ   - joggled input instead of merged facets\n\
00187     Tv   - verify result: structure, convexity, and in-circle test\n\
00188     .    - concise list of all options\n\
00189     -    - one-line description of all options\n\
00190 \n\
00191 output options (subset):\n\
00192     s    - summary of results (default)\n\
00193     i    - vertices incident to each Delaunay region\n\
00194     Fx   - extreme points (vertices of the convex hull)\n\
00195     o    - OFF format (shows the points lifted to a paraboloid)\n\
00196     G    - Geomview output (2-d and 3-d points lifted to a paraboloid)\n\
00197     m    - Mathematica output (2-d inputs lifted to a paraboloid)\n\
00198     QVn  - print Delaunay regions that include point n, -n if not\n\
00199     TO file- output results to file, may be enclosed in single quotes\n\
00200 \n\
00201 examples:\n\
00202     rbox c P0 D2 | qdelaunay s o          rbox c P0 D2 | qdelaunay i\n\
00203     rbox c P0 D2 | qdelaunay Fv           rbox c P0 D2 | qdelaunay s Qu Fv\n\
00204     rbox c G1 d D2 | qdelaunay s i        rbox c G1 d D2 | qdelaunay Qt\n\
00205     rbox M3,4 z 100 D2 | qdelaunay s      rbox M3,4 z 100 D2 | qdelaunay s Qt\n\
00206 \n\
00207 ";
00208 /* for opts, don't assign 'e' or 'E' to a flag (already used for exponent) */
00209 
00210 /*-<a                             href="../libqhull/qh-qhull.htm#TOC"
00211   >-------------------------------</a><a name="prompt3">-</a>
00212 
00213   qh_prompt3
00214     concise prompt for qhull
00215 */
00216 char qh_prompt3[]= "\n\
00217 Qhull %s.\n\
00218 Except for 'F.' and 'PG', upper-case options take an argument.\n\
00219 \n\
00220  incidences     mathematica    OFF_format     points_lifted  summary\n\
00221  facet_dump\n\
00222 \n\
00223  Farea          FArea_total    Fcoincident    Fd_cdd_in      FD_cdd_out\n\
00224  FF_dump_xridge FIDs           Fmerges        Fneighbors     FNeigh_vertex\n\
00225  FOptions       FPoint_near    FQdelaun       Fsummary       FSize\n\
00226  Fvertices      Fxtremes       FMaple\n\
00227 \n\
00228  Gvertices      Gpoints        Gall_points    Gno_planes     Ginner\n\
00229  Gcentrums      Ghyperplanes   Gridges        Gouter         GDrop_dim\n\
00230  Gtransparent\n\
00231 \n\
00232  PArea_keep     Pdrop d0:0D0   Pgood          PFacet_area_keep\n\
00233  PGood_neighbors PMerge_keep   Poutput_forced Pprecision_not\n\
00234 \n\
00235  QGood_point    QJoggle        Qsearch_1st    Qtriangulate   QupperDelaunay\n\
00236  QVertex_good   Qzinfinite\n\
00237 \n\
00238  T4_trace       Tcheck_often   Tstatistics    Tverify        Tz_stdout\n\
00239  TFacet_log     TInput_file    TPoint_trace   TMerge_trace   TOutput_file\n\
00240  TWide_trace    TVertex_stop   TCone_stop\n\
00241 \n\
00242  Angle_max      Centrum_size   Random_dist    Wide_outside\n\
00243 ";
00244 
00245 /*-<a                             href="../libqhull/qh-qhull.htm#TOC"
00246   >-------------------------------</a><a name="main">-</a>
00247 
00248   main( argc, argv )
00249     processes the command line, calls qhull() to do the work, and exits
00250 
00251   design:
00252     initializes data structures
00253     reads points
00254     finishes initialization
00255     computes convex hull and other structures
00256     checks the result
00257     writes the output
00258     frees memory
00259 */
00260 int main(int argc, char *argv[]) {
00261   int curlong, totlong; /* used !qh_NOmem */
00262   int exitcode, numpoints, dim;
00263   coordT *points;
00264   boolT ismalloc;
00265 
00266 #if __MWERKS__ && __POWERPC__
00267   char inBuf[BUFSIZ], outBuf[BUFSIZ], errBuf[BUFSIZ];
00268   SIOUXSettings.showstatusline= false;
00269   SIOUXSettings.tabspaces= 1;
00270   SIOUXSettings.rows= 40;
00271   if (setvbuf(stdin, inBuf, _IOFBF, sizeof(inBuf)) < 0   /* w/o, SIOUX I/O is slow*/
00272   || setvbuf(stdout, outBuf, _IOFBF, sizeof(outBuf)) < 0
00273   || (stdout != stderr && setvbuf(stderr, errBuf, _IOFBF, sizeof(errBuf)) < 0))
00274     fprintf(stderr, "qhull internal warning (main): could not change stdio to fully buffered.\n");
00275   argc= ccommand(&argv);
00276 #endif
00277 
00278   if ((argc == 1) && isatty( 0 /*stdin*/)) {
00279     fprintf(stdout, qh_prompt2, qh_version);
00280     exit(qh_ERRnone);
00281   }
00282   if (argc > 1 && *argv[1] == '-' && !*(argv[1]+1)) {
00283     fprintf(stdout, qh_prompta, qh_version,
00284                 qh_promptb, qh_promptc, qh_promptd, qh_prompte);
00285     exit(qh_ERRnone);
00286   }
00287   if (argc >1 && *argv[1] == '.' && !*(argv[1]+1)) {
00288     fprintf(stdout, qh_prompt3, qh_version);
00289     exit(qh_ERRnone);
00290   }
00291   qh_init_A(stdin, stdout, stderr, argc, argv);  /* sets qh qhull_command */
00292   exitcode= setjmp(qh errexit); /* simple statement for CRAY J916 */
00293   if (!exitcode) {
00294     qh_option("delaunay  Qbbound-last", NULL, NULL);
00295     qh DELAUNAY= True;     /* 'd'   */
00296     qh SCALElast= True;    /* 'Qbb' */
00297     qh KEEPcoplanar= True; /* 'Qc', to keep coplanars in 'p' */
00298     qh_checkflags(qh qhull_command, hidden_options);
00299     qh_initflags(qh qhull_command);
00300     points= qh_readpoints(&numpoints, &dim, &ismalloc);
00301     if (dim >= 5) {
00302       qh_option("Qxact_merge", NULL, NULL);
00303       qh MERGEexact= True; /* 'Qx' always */
00304     }
00305     qh_init_B(points, numpoints, dim, ismalloc);
00306     qh_qhull();
00307     qh_check_output();
00308     qh_produce_output();
00309     if (qh VERIFYoutput && !qh FORCEoutput && !qh STOPpoint && !qh STOPcone)
00310       qh_check_points();
00311     exitcode= qh_ERRnone;
00312   }
00313   qh NOerrexit= True;  /* no more setjmp */
00314 #ifdef qh_NOmem
00315   qh_freeqhull( True);
00316 #else
00317   qh_freeqhull( False);
00318   qh_memfreeshort(&curlong, &totlong);
00319   if (curlong || totlong)
00320     fprintf(stderr, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n",
00321        totlong, curlong);
00322 #endif
00323   return exitcode;
00324 } /* main */
00325 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


libqhull
Author(s): Robert Krug
autogenerated on Tue Jun 18 2013 12:38:49