qdelaun_r.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_r/libqhull_r.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  qhT qh_qh;
261  qhT *qh= &qh_qh;
262 
263  QHULL_LIB_CHECK /* Check for compatible library */
264 
265  if ((argc == 1) && isatty( 0 /*stdin*/)) {
266  fprintf(stdout, qh_prompt2, qh_version);
267  exit(qh_ERRnone);
268  }
269  if (argc > 1 && *argv[1] == '-' && !*(argv[1]+1)) {
270  fprintf(stdout, qh_prompta, qh_version,
272  exit(qh_ERRnone);
273  }
274  if (argc > 1 && *argv[1] == '.' && !*(argv[1]+1)) {
275  fprintf(stdout, qh_prompt3, qh_version);
276  exit(qh_ERRnone);
277  }
278  if (argc > 1 && *argv[1] == '-' && *(argv[1]+1)=='V') {
279  fprintf(stdout, "%s\n", qh_version2);
280  exit(qh_ERRnone);
281  }
282  qh_init_A(qh, stdin, stdout, stderr, argc, argv); /* sets qh->qhull_command */
283  exitcode= setjmp(qh->errexit); /* simple statement for CRAY J916 */
284  if (!exitcode) {
285  qh->NOerrexit = False;
286  qh_option(qh, "delaunay Qbbound-last", NULL, NULL);
287  qh->DELAUNAY= True; /* 'd' */
288  qh->SCALElast= True; /* 'Qbb' */
289  qh->KEEPcoplanar= True; /* 'Qc', to keep coplanars in 'p' */
291  qh_initflags(qh, qh->qhull_command);
292  points= qh_readpoints(qh, &numpoints, &dim, &ismalloc);
293  if (dim >= 5) {
294  qh_option(qh, "Qxact_merge", NULL, NULL);
295  qh->MERGEexact= True; /* 'Qx' always */
296  }
297  qh_init_B(qh, points, numpoints, dim, ismalloc);
298  qh_qhull(qh);
299  qh_check_output(qh);
300  qh_produce_output(qh);
301  if (qh->VERIFYoutput && !qh->FORCEoutput && !qh->STOPpoint && !qh->STOPcone)
302  qh_check_points(qh);
303  exitcode= qh_ERRnone;
304  }
305  qh->NOerrexit= True; /* no more setjmp */
306 #ifdef qh_NOmem
307  qh_freeqhull(qh, qh_ALL);
308 #else
309  qh_freeqhull(qh, !qh_ALL);
310  qh_memfreeshort(qh, &curlong, &totlong);
311  if (curlong || totlong)
312  qh_fprintf_stderr(6263, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n",
313  totlong, curlong);
314 #endif
315  return exitcode;
316 } /* main */
317 
Definition: libqhull.h:465
char qh_prompte[]
Definition: qdelaun_r.c:135
void qh_fprintf_stderr(int msgcode, const char *fmt,...)
Definition: usermem.c:57
#define boolT
Definition: libqhull.h:121
int STOPpoint
Definition: libqhull.h:567
const char qh_version2[]
Definition: global.c:51
char qh_prompt2[]
Definition: qdelaun_r.c:172
jmp_buf errexit
Definition: libqhull.h:656
const char qh_version[]
Definition: global.c:50
void qh_check_output(void)
Definition: poly2.c:302
char hidden_options[]
Definition: qdelaun_r.c:50
boolT KEEPcoplanar
Definition: libqhull.h:505
qhT qh_qh
Definition: global.c:26
boolT DELAUNAY
Definition: libqhull.h:491
void qh_init_A(FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[])
Definition: global.c:487
int dim
#define coordT
Definition: libqhull.h:80
#define True
Definition: libqhull.h:129
boolT FORCEoutput
Definition: libqhull.h:494
void qh_check_points(void)
Definition: poly2.c:365
int main(int argc, char *argv[])
Definition: qdelaun_r.c:255
#define qh
Definition: libqhull.h:457
int isatty(int)
void qh_produce_output(void)
Definition: io.c:39
void qh_freeqhull(boolT allmem)
Definition: global.c:425
void qh_option(const char *option, int *i, realT *r)
Definition: global.c:2115
boolT NOerrexit
Definition: libqhull.h:737
boolT VERIFYoutput
Definition: libqhull.h:580
int STOPcone
Definition: libqhull.h:565
void qh_init_B(coordT *points, int numpoints, int dim, boolT ismalloc)
Definition: global.c:534
char qh_promptb[]
Definition: qdelaun_r.c:69
#define qh_ERRnone
Definition: libqhull.h:193
#define QHULL_LIB_CHECK
Definition: libqhull.h:462
void qh_memfreeshort(int *curlong, int *totlong)
Definition: mem.c:288
char qh_promptd[]
Definition: qdelaun_r.c:109
boolT MERGEexact
Definition: libqhull.h:511
coordT * qh_readpoints(int *numpoints, int *dimension, boolT *ismalloc)
Definition: io.c:3673
char qh_prompta[]
Definition: qdelaun_r.c:52
void qh_initflags(char *command)
Definition: global.c:615
#define False
Definition: libqhull.h:128
#define qh_ALL
Definition: libqhull.h:180
boolT SCALElast
Definition: libqhull.h:559
char qhull_command[256]
Definition: libqhull.h:598
char qh_prompt3[]
Definition: qdelaun_r.c:211
char qh_promptc[]
Definition: qdelaun_r.c:76
void qh_checkflags(char *command, char *hiddenflags)
Definition: global.c:86
void qh_qhull(void)
Definition: libqhull.c:60


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:01