rbox.c
Go to the documentation of this file.
1 /*<html><pre> -<a href="../libqhull/index.htm#TOC"
2  >-------------------------------</a><a name="TOP">-</a>
3 
4  rbox.c
5  rbox program for generating input points for qhull.
6 
7  notes:
8  50 points generated for 'rbox D4'
9 
10 */
11 
12 #include "libqhull/libqhull.h"
13 #include "libqhull/random.h"
14 
15 #include <stdarg.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 
20 #ifdef _MSC_VER /* Microsoft Visual C++ -- warning level 4 */
21 #pragma warning( disable : 4706) /* assignment within conditional function */
22 #endif
23 
24 char prompt[]= "\n\
25 -rbox- generate various point distributions. Default is random in cube.\n\
26 \n\
27 args (any order, space separated): Version: 2016/01/18\n\
28  3000 number of random points in cube, lens, spiral, sphere or grid\n\
29  D3 dimension 3-d\n\
30  c add a unit cube to the output ('c G2.0' sets size)\n\
31  d add a unit diamond to the output ('d G2.0' sets size)\n\
32  l generate a regular 3-d spiral\n\
33  r generate a regular polygon, ('r s Z1 G0.1' makes a cone)\n\
34  s generate cospherical points\n\
35  x generate random points in simplex, may use 'r' or 'Wn'\n\
36  y same as 'x', plus simplex\n\
37  Cn,r,m add n nearly coincident points within radius r of m points\n\
38  Pn,m,r add point [n,m,r] first, pads with 0, maybe repeated\n\
39 \n\
40  Ln lens distribution of radius n. Also 's', 'r', 'G', 'W'.\n\
41  Mn,m,r lattice(Mesh) rotated by [n,-m,0], [m,n,0], [0,0,r], ...\n\
42  '27 M1,0,1' is {0,1,2} x {0,1,2} x {0,1,2}. Try 'M3,4 z'.\n\
43  W0.1 random distribution within 0.1 of the cube's or sphere's surface\n\
44  Z0.5 s random points in a 0.5 disk projected to a sphere\n\
45  Z0.5 s G0.6 same as Z0.5 within a 0.6 gap\n\
46 \n\
47  Bn bounding box coordinates, default %2.2g\n\
48  h output as homogeneous coordinates for cdd\n\
49  n remove command line from the first line of output\n\
50  On offset coordinates by n\n\
51  t use time as the random number seed(default is command line)\n\
52  tn use n as the random number seed\n\
53  z print integer coordinates, default 'Bn' is %2.2g\n\
54 ";
55 
56 /*--------------------------------------------
57 -rbox- main procedure of rbox application
58 */
59 int main(int argc, char **argv) {
60  char *command;
61  int command_size;
62  int return_status;
63 
65 
66  if (argc == 1) {
68  return 1;
69  }
70  if (argc == 2 && strcmp(argv[1], "D4")==0)
71  qh_fprintf_stderr(0, "\nStarting the rbox smoketest for qhull. An immediate failure indicates\nthat non-reentrant rbox was linked to reentrant routines. An immediate\nfailure of qhull may indicate that qhull was linked to the wrong\nqhull library. Also try 'rbox D4 | qhull T1'\n");
72 
73  command_size= qh_argv_to_command_size(argc, argv);
74  if ((command= (char *)qh_malloc((size_t)command_size))) {
75  if (!qh_argv_to_command(argc, argv, command, command_size)) {
76  qh_fprintf_stderr(6264, "rbox internal error: allocated insufficient memory (%d) for arguments\n", command_size);
77  return_status= qh_ERRinput;
78  }else{
79  return_status= qh_rboxpoints(stdout, stderr, command);
80  }
81  qh_free(command);
82  }else {
83  qh_fprintf_stderr(6265, "rbox error: insufficient memory for %d bytes\n", command_size);
84  return_status= qh_ERRmem;
85  }
86  return return_status;
87 }/*main*/
88 
qh_ERRinput
#define qh_ERRinput
Definition: libqhull.h:194
qh_DEFAULTbox
#define qh_DEFAULTbox
Definition: user.h:486
qh_fprintf_stderr
void qh_fprintf_stderr(int msgcode, const char *fmt,...)
Definition: usermem.c:57
qh_argv_to_command
int qh_argv_to_command(int argc, char *argv[], char *command, int max_size)
Definition: random.c:42
qh_argv_to_command_size
int qh_argv_to_command_size(int argc, char *argv[])
Definition: random.c:105
qh_malloc
void * qh_malloc(size_t size)
Definition: usermem.c:90
libqhull.h
qh_rboxpoints
int qh_rboxpoints(FILE *fout, FILE *ferr, char *rbox_command)
Definition: rboxlib.c:90
random.h
qh_DEFAULTzbox
#define qh_DEFAULTzbox
Definition: user.h:487
QHULL_LIB_CHECK_RBOX
#define QHULL_LIB_CHECK_RBOX
Definition: libqhull.h:463
qh_ERRmem
#define qh_ERRmem
Definition: libqhull.h:197
main
int main(int argc, char **argv)
Definition: rbox.c:59
qh_free
void qh_free(void *mem)
Definition: usermem.c:77
prompt
char prompt[]
Definition: rbox.c:24


hpp-fcl
Author(s):
autogenerated on Fri Jan 26 2024 03:46:15