rbox.c
Go to the documentation of this file.
00001 /*<html><pre>  -<a                             href="../libqhull/index.htm#TOC"
00002   >-------------------------------</a><a name="TOP">-</a>
00003 
00004    rbox.c
00005      rbox program for generating input points for qhull.
00006 
00007    notes:
00008      50 points generated for 'rbox D4'
00009 
00010 */
00011 
00012 #include "random.h"
00013 #include "libqhull.h"
00014 
00015 #include <stdarg.h>
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 
00019 #if __MWERKS__ && __POWERPC__
00020 #include <SIOUX.h>
00021 #include <Files.h>
00022 #include <console.h>
00023 #include <Desk.h>
00024 #endif
00025 
00026 #ifdef _MSC_VER  /* Microsoft Visual C++ -- warning level 4 */
00027 #pragma warning( disable : 4706)  /* assignment within conditional function */
00028 #endif
00029 
00030 char prompt[]= "\n\
00031 -rbox- generate various point distributions.  Default is random in cube.\n\
00032 \n\
00033 args (any order, space separated):                    Version: 2001/06/24\n\
00034   3000    number of random points in cube, lens, spiral, sphere or grid\n\
00035   D3      dimension 3-d\n\
00036   c       add a unit cube to the output ('c G2.0' sets size)\n\
00037   d       add a unit diamond to the output ('d G2.0' sets size)\n\
00038   l       generate a regular 3-d spiral\n\
00039   r       generate a regular polygon, ('r s Z1 G0.1' makes a cone)\n\
00040   s       generate cospherical points\n\
00041   x       generate random points in simplex, may use 'r' or 'Wn'\n\
00042   y       same as 'x', plus simplex\n\
00043   Pn,m,r  add point [n,m,r] first, pads with 0\n\
00044 \n\
00045   Ln      lens distribution of radius n.  Also 's', 'r', 'G', 'W'.\n\
00046   Mn,m,r  lattice(Mesh) rotated by [n,-m,0], [m,n,0], [0,0,r], ...\n\
00047           '27 M1,0,1' is {0,1,2} x {0,1,2} x {0,1,2}.  Try 'M3,4 z'.\n\
00048   W0.1    random distribution within 0.1 of the cube's or sphere's surface\n\
00049   Z0.5 s  random points in a 0.5 disk projected to a sphere\n\
00050   Z0.5 s G0.6 same as Z0.5 within a 0.6 gap\n\
00051 \n\
00052   Bn      bounding box coordinates, default %2.2g\n\
00053   h       output as homogeneous coordinates for cdd\n\
00054   n       remove command line from the first line of output\n\
00055   On      offset coordinates by n\n\
00056   t       use time as the random number seed(default is command line)\n\
00057   tn      use n as the random number seed\n\
00058   z       print integer coordinates, default 'Bn' is %2.2g\n\
00059 ";
00060 
00061 /*--------------------------------------------
00062 -rbox-  main procedure of rbox application
00063 */
00064 int main(int argc, char **argv) {
00065   char *command;
00066   int command_size;
00067   int return_status;
00068 
00069 #if __MWERKS__ && __POWERPC__
00070   char inBuf[BUFSIZ], outBuf[BUFSIZ], errBuf[BUFSIZ];
00071   SIOUXSettings.showstatusline= False;
00072   SIOUXSettings.tabspaces= 1;
00073   SIOUXSettings.rows= 40;
00074   if (setvbuf(stdin, inBuf, _IOFBF, sizeof(inBuf)) < 0   /* w/o, SIOUX I/O is slow*/
00075   || setvbuf(stdout, outBuf, _IOFBF, sizeof(outBuf)) < 0
00076   || (stdout != stderr && setvbuf(stderr, errBuf, _IOFBF, sizeof(errBuf)) < 0))
00077     fprintf(stderr, "qhull internal warning (main): could not change stdio to fully buffered.\n");
00078   argc= ccommand(&argv);
00079 #endif
00080 
00081   if (argc == 1) {
00082     printf(prompt, qh_DEFAULTbox, qh_DEFAULTzbox);
00083     return 1;
00084   }
00085 
00086   command_size= qh_argv_to_command_size(argc, argv);
00087   if ((command= (char *)qh_malloc((size_t)command_size))) {
00088     if (!qh_argv_to_command(argc, argv, command, command_size)) {
00089       fprintf(stderr, "rbox internal error: allocated insufficient memory (%d) for arguments\n", command_size);
00090       return_status= qh_ERRinput;
00091     }else{
00092       return_status= qh_rboxpoints(stdout, stderr, command);
00093     }
00094     qh_free(command);
00095   }else {
00096     fprintf(stderr, "rbox error: insufficient memory for %d bytes\n", command_size);
00097     return_status= qh_ERRmem;
00098   }
00099   return return_status;
00100 }/*main*/
00101 


libqhull-ours
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:11