qdelaun.c
Go to the documentation of this file.
1 /*<html><pre> -<a href="../libqhull/qh-qhull.htm"
2  >-------------------------------</a><a name="TOP">-</a>
3 
4  qdelaun.c
5  compute Delaunay triangulations and furthest-point Delaunay
6  triangulations using qhull
7 
8  see unix.c for full interface
9 
10  Copyright (c) 1993-2015, The Geometry Center
11 */
12 
13 #include "libqhull/libqhull.h"
14 
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <ctype.h>
19 #include <math.h>
20 
21 #if __cplusplus
22 extern "C" {
23  int isatty(int);
24 }
25 
26 #elif _MSC_VER
27 #include <io.h>
28 #define isatty _isatty
29 /* int _isatty(int); */
30 
31 #else
32 int isatty(int); /* returns 1 if stdin is a tty
33  if "Undefined symbol" this can be deleted along with call in main() */
34 #endif
35 
36 /*-<a href="../libqhull/qh-qhull.htm#TOC"
37  >-------------------------------</a><a name="prompt">-</a>
38 
39  qh_prompt
40  long prompt for qhull
41 
42  notes:
43  restricted version of libqhull.c
44 
45  see:
46  concise prompt below
47 */
48 
49 /* duplicated in qdelau_f.htm and qdelaun.htm */
50 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 ";
51 
52 char qh_prompta[]= "\n\
53 qdelaunay- compute the Delaunay triangulation\n\
54  http://www.qhull.org %s\n\
55 \n\
56 input (stdin):\n\
57  first lines: dimension and number of points (or vice-versa).\n\
58  other lines: point coordinates, best if one point per line\n\
59  comments: start with a non-numeric character\n\
60 \n\
61 options:\n\
62  Qu - compute furthest-site Delaunay triangulation\n\
63  Qt - triangulated output\n\
64  QJ - joggled input instead of merged facets\n\
65 \n\
66 Qhull control options:\n\
67  QJn - randomly joggle input in range [-n,n]\n\
68 %s%s%s%s"; /* split up qh_prompt for Visual C++ */
69 char qh_promptb[]= "\
70  Qs - search all points for the initial simplex\n\
71  Qz - add point-at-infinity to Delaunay triangulation\n\
72  QGn - print Delaunay region if visible from point n, -n if not\n\
73  QVn - print Delaunay regions that include point n, -n if not\n\
74 \n\
75 ";
76 char qh_promptc[]= "\
77 Trace options:\n\
78  T4 - trace at level n, 4=all, 5=mem/gauss, -1= events\n\
79  Tc - check frequently during execution\n\
80  Ts - print statistics\n\
81  Tv - verify result: structure, convexity, and in-circle test\n\
82  Tz - send all output to stdout\n\
83  TFn - report summary when n or more facets created\n\
84  TI file - input data from file, no spaces or single quotes\n\
85  TO file - output results to file, may be enclosed in single quotes\n\
86  TPn - turn on tracing when point n added to hull\n\
87  TMn - turn on tracing at merge n\n\
88  TWn - trace merge facets when width > n\n\
89  TVn - stop qhull after adding point n, -n for before (see TCn)\n\
90  TCn - stop qhull after building cone for point n (see TVn)\n\
91 \n\
92 Precision options:\n\
93  Cn - radius of centrum (roundoff added). Merge facets if non-convex\n\
94  An - cosine of maximum angle. Merge facets if cosine > n or non-convex\n\
95  C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge\n\
96  Rn - randomly perturb computations by a factor of [1-n,1+n]\n\
97  Wn - min facet width for outside point (before roundoff)\n\
98 \n\
99 Output formats (may be combined; if none, produces a summary to stdout):\n\
100  f - facet dump\n\
101  G - Geomview output (see below)\n\
102  i - vertices incident to each Delaunay region\n\
103  m - Mathematica output (2-d only, lifted to a paraboloid)\n\
104  o - OFF format (dim, points, and facets as a paraboloid)\n\
105  p - point coordinates (lifted to a paraboloid)\n\
106  s - summary (stderr)\n\
107 \n\
108 ";
109 char qh_promptd[]= "\
110 More formats:\n\
111  Fa - area for each Delaunay region\n\
112  FA - compute total area for option 's'\n\
113  Fc - count plus coincident points for each Delaunay region\n\
114  Fd - use cdd format for input (homogeneous with offset first)\n\
115  FD - use cdd format for numeric output (offset first)\n\
116  FF - facet dump without ridges\n\
117  FI - ID of each Delaunay region\n\
118  Fm - merge count for each Delaunay region (511 max)\n\
119  FM - Maple output (2-d only, lifted to a paraboloid)\n\
120  Fn - count plus neighboring region for each Delaunay region\n\
121  FN - count plus neighboring region for each point\n\
122  FO - options and precision constants\n\
123  FP - nearest point and distance for each coincident point\n\
124  FQ - command used for qdelaunay\n\
125  Fs - summary: #int (8), dimension, #points, tot vertices, tot facets,\n\
126  for output: #vertices, #Delaunay regions,\n\
127  #coincident points, #non-simplicial regions\n\
128  #real (2), max outer plane, min vertex\n\
129  FS - sizes: #int (0)\n\
130  #real (2), tot area, 0\n\
131  Fv - count plus vertices for each Delaunay region\n\
132  Fx - extreme points of Delaunay triangulation (on convex hull)\n\
133 \n\
134 ";
135 char qh_prompte[]= "\
136 Geomview options (2-d and 3-d)\n\
137  Ga - all points as dots\n\
138  Gp - coplanar points and vertices as radii\n\
139  Gv - vertices as spheres\n\
140  Gi - inner planes only\n\
141  Gn - no planes\n\
142  Go - outer planes only\n\
143  Gc - centrums\n\
144  Gh - hyperplane intersections\n\
145  Gr - ridges\n\
146  GDn - drop dimension n in 3-d and 4-d output\n\
147  Gt - transparent outer ridges to view 3-d Delaunay\n\
148 \n\
149 Print options:\n\
150  PAn - keep n largest Delaunay regions by area\n\
151  Pdk:n - drop facet if normal[k] <= n (default 0.0)\n\
152  PDk:n - drop facet if normal[k] >= n\n\
153  Pg - print good Delaunay regions (needs 'QGn' or 'QVn')\n\
154  PFn - keep Delaunay regions whose area is at least n\n\
155  PG - print neighbors of good regions (needs 'QGn' or 'QVn')\n\
156  PMn - keep n Delaunay regions with most merges\n\
157  Po - force output. If error, output neighborhood of facet\n\
158  Pp - do not report precision problems\n\
159 \n\
160  . - list of all options\n\
161  - - one line descriptions of all options\n\
162  -V - version\n\
163 ";
164 /* for opts, don't assign 'e' or 'E' to a flag (already used for exponent) */
165 
166 /*-<a href="../libqhull/qh-qhull.htm#TOC"
167  >-------------------------------</a><a name="prompt2">-</a>
168 
169  qh_prompt2
170  synopsis for qhull
171 */
172 char qh_prompt2[]= "\n\
173 qdelaunay- compute the Delaunay triangulation. Qhull %s\n\
174  input (stdin): dimension, number of points, point coordinates\n\
175  comments start with a non-numeric character\n\
176 \n\
177 options (qdelaun.htm):\n\
178  Qu - furthest-site Delaunay triangulation\n\
179  Qt - triangulated output\n\
180  QJ - joggled input instead of merged facets\n\
181  Tv - verify result: structure, convexity, and in-circle test\n\
182  . - concise list of all options\n\
183  - - one-line description of all options\n\
184  -V - version\n\
185 \n\
186 output options (subset):\n\
187  s - summary of results (default)\n\
188  i - vertices incident to each Delaunay region\n\
189  Fx - extreme points (vertices of the convex hull)\n\
190  o - OFF format (shows the points lifted to a paraboloid)\n\
191  G - Geomview output (2-d and 3-d points lifted to a paraboloid)\n\
192  m - Mathematica output (2-d inputs lifted to a paraboloid)\n\
193  QVn - print Delaunay regions that include point n, -n if not\n\
194  TO file- output results to file, may be enclosed in single quotes\n\
195 \n\
196 examples:\n\
197  rbox c P0 D2 | qdelaunay s o rbox c P0 D2 | qdelaunay i\n\
198  rbox c P0 D2 | qdelaunay Fv rbox c P0 D2 | qdelaunay s Qu Fv\n\
199  rbox c G1 d D2 | qdelaunay s i rbox c G1 d D2 | qdelaunay Qt\n\
200  rbox M3,4 z 100 D2 | qdelaunay s rbox M3,4 z 100 D2 | qdelaunay s Qt\n\
201 \n\
202 ";
203 /* for opts, don't assign 'e' or 'E' to a flag (already used for exponent) */
204 
205 /*-<a href="../libqhull/qh-qhull.htm#TOC"
206  >-------------------------------</a><a name="prompt3">-</a>
207 
208  qh_prompt3
209  concise prompt for qhull
210 */
211 char qh_prompt3[]= "\n\
212 Qhull %s.\n\
213 Except for 'F.' and 'PG', upper-case options take an argument.\n\
214 \n\
215  incidences mathematica OFF_format points_lifted summary\n\
216  facet_dump\n\
217 \n\
218  Farea FArea_total Fcoincident Fd_cdd_in FD_cdd_out\n\
219  FF_dump_xridge FIDs Fmerges Fneighbors FNeigh_vertex\n\
220  FOptions FPoint_near FQdelaun Fsummary FSize\n\
221  Fvertices Fxtremes FMaple\n\
222 \n\
223  Gvertices Gpoints Gall_points Gno_planes Ginner\n\
224  Gcentrums Ghyperplanes Gridges Gouter GDrop_dim\n\
225  Gtransparent\n\
226 \n\
227  PArea_keep Pdrop d0:0D0 Pgood PFacet_area_keep\n\
228  PGood_neighbors PMerge_keep Poutput_forced Pprecision_not\n\
229 \n\
230  QGood_point QJoggle Qsearch_1st Qtriangulate QupperDelaunay\n\
231  QVertex_good Qzinfinite\n\
232 \n\
233  T4_trace Tcheck_often Tstatistics Tverify Tz_stdout\n\
234  TFacet_log TInput_file TPoint_trace TMerge_trace TOutput_file\n\
235  TWide_trace TVertex_stop TCone_stop\n\
236 \n\
237  Angle_max Centrum_size Random_dist Wide_outside\n\
238 ";
239 
240 /*-<a href="../libqhull/qh-qhull.htm#TOC"
241  >-------------------------------</a><a name="main">-</a>
242 
243  main( argc, argv )
244  processes the command line, calls qhull() to do the work, and exits
245 
246  design:
247  initializes data structures
248  reads points
249  finishes initialization
250  computes convex hull and other structures
251  checks the result
252  writes the output
253  frees memory
254 */
255 int main(int argc, char *argv[]) {
256  int curlong, totlong; /* used !qh_NOmem */
257  int exitcode, numpoints, dim;
258  coordT *points;
259  boolT ismalloc;
260 
261  QHULL_LIB_CHECK /* Check for compatible library */
262 
263  if ((argc == 1) && isatty( 0 /*stdin*/)) {
264  fprintf(stdout, qh_prompt2, qh_version);
265  exit(qh_ERRnone);
266  }
267  if (argc > 1 && *argv[1] == '-' && !*(argv[1]+1)) {
268  fprintf(stdout, qh_prompta, qh_version,
270  exit(qh_ERRnone);
271  }
272  if (argc > 1 && *argv[1] == '.' && !*(argv[1]+1)) {
273  fprintf(stdout, qh_prompt3, qh_version);
274  exit(qh_ERRnone);
275  }
276  if (argc > 1 && *argv[1] == '-' && *(argv[1]+1)=='V') {
277  fprintf(stdout, "%s\n", qh_version2);
278  exit(qh_ERRnone);
279  }
280  qh_init_A(stdin, stdout, stderr, argc, argv); /* sets qh qhull_command */
281  exitcode= setjmp(qh errexit); /* simple statement for CRAY J916 */
282  if (!exitcode) {
283  qh NOerrexit = False;
284  qh_option("delaunay Qbbound-last", NULL, NULL);
285  qh DELAUNAY= True; /* 'd' */
286  qh SCALElast= True; /* 'Qbb' */
287  qh KEEPcoplanar= True; /* 'Qc', to keep coplanars in 'p' */
288  qh_checkflags(qh qhull_command, hidden_options);
289  qh_initflags(qh qhull_command);
290  points= qh_readpoints(&numpoints, &dim, &ismalloc);
291  if (dim >= 5) {
292  qh_option("Qxact_merge", NULL, NULL);
293  qh MERGEexact= True; /* 'Qx' always */
294  }
295  qh_init_B(points, numpoints, dim, ismalloc);
296  qh_qhull();
297  qh_check_output();
299  if (qh VERIFYoutput && !qh FORCEoutput && !qh STOPpoint && !qh STOPcone)
300  qh_check_points();
301  exitcode= qh_ERRnone;
302  }
303  qh NOerrexit= True; /* no more setjmp */
304 #ifdef qh_NOmem
306 #else
308  qh_memfreeshort(&curlong, &totlong);
309  if (curlong || totlong)
310  qh_fprintf_stderr(6263, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n",
311  totlong, curlong);
312 #endif
313  return exitcode;
314 } /* main */
315 
qh_version
const char qh_version[]
Definition: global.c:50
QHULL_LIB_CHECK
#define QHULL_LIB_CHECK
Definition: libqhull.h:462
coordT
#define coordT
Definition: libqhull.h:80
qh_fprintf_stderr
void qh_fprintf_stderr(int msgcode, const char *fmt,...)
Definition: usermem.c:57
qh_ALL
#define qh_ALL
Definition: libqhull.h:180
isatty
int isatty(int)
qh_promptd
char qh_promptd[]
Definition: qdelaun.c:109
qh_check_output
void qh_check_output(void)
Definition: poly2.c:302
qh_checkflags
void qh_checkflags(char *command, char *hiddenflags)
Definition: global.c:86
qh_prompt3
char qh_prompt3[]
Definition: qdelaun.c:211
qh_version2
const char qh_version2[]
Definition: global.c:51
qh_prompta
char qh_prompta[]
Definition: qdelaun.c:52
libqhull.h
hidden_options
char hidden_options[]
Definition: qdelaun.c:50
main
int main(int argc, char *argv[])
Definition: qdelaun.c:255
boolT
#define boolT
Definition: libqhull.h:121
qh_check_points
void qh_check_points(void)
Definition: poly2.c:365
qh_ERRnone
#define qh_ERRnone
Definition: libqhull.h:193
False
#define False
Definition: libqhull.h:128
qh_prompte
char qh_prompte[]
Definition: qdelaun.c:135
qh_init_A
void qh_init_A(FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[])
Definition: global.c:487
qh_promptb
char qh_promptb[]
Definition: qdelaun.c:69
qh
#define qh
Definition: libqhull.h:457
qh_freeqhull
void qh_freeqhull(boolT allmem)
Definition: global.c:425
qh_option
void qh_option(const char *option, int *i, realT *r)
Definition: global.c:2115
qh_promptc
char qh_promptc[]
Definition: qdelaun.c:76
qh_readpoints
coordT * qh_readpoints(int *numpoints, int *dimension, boolT *ismalloc)
Definition: io.c:3673
qh_produce_output
void qh_produce_output(void)
Definition: io.c:39
qh_qhull
void qh_qhull(void)
Definition: libqhull.c:60
qh_memfreeshort
void qh_memfreeshort(int *curlong, int *totlong)
Definition: mem.c:288
qh_initflags
void qh_initflags(char *command)
Definition: global.c:615
io.h
qh_prompt2
char qh_prompt2[]
Definition: qdelaun.c:172
dim
int dim
qh_init_B
void qh_init_B(coordT *points, int numpoints, int dim, boolT ismalloc)
Definition: global.c:534
True
#define True
Definition: libqhull.h:129


hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:14