[Scipy-svn] r6902 - in trunk/scipy/spatial: . qhull qhull/src

scipy-svn@scip... scipy-svn@scip...
Tue Nov 16 15:18:39 CST 2010


Author: ptvirtan
Date: 2010-11-16 15:18:37 -0600 (Tue, 16 Nov 2010)
New Revision: 6902

Added:
   trunk/scipy/spatial/qhull/src/libqhull.c
   trunk/scipy/spatial/qhull/src/libqhull.h
   trunk/scipy/spatial/qhull/src/random.c
   trunk/scipy/spatial/qhull/src/random.h
   trunk/scipy/spatial/qhull/src/rboxlib.c
   trunk/scipy/spatial/qhull/src/usermem.c
   trunk/scipy/spatial/qhull/src/userprintf.c
Removed:
   trunk/scipy/spatial/qhull/REGISTER.txt
   trunk/scipy/spatial/qhull/index.htm
   trunk/scipy/spatial/qhull/src/qconvex.c
   trunk/scipy/spatial/qhull/src/qdelaun.c
   trunk/scipy/spatial/qhull/src/qhalf.c
   trunk/scipy/spatial/qhull/src/qhull.c
   trunk/scipy/spatial/qhull/src/qhull_interface.cpp
   trunk/scipy/spatial/qhull/src/qvoronoi.c
   trunk/scipy/spatial/qhull/src/rbox.c
   trunk/scipy/spatial/qhull/src/unix.c
   trunk/scipy/spatial/qhull/src/user_eg.c
   trunk/scipy/spatial/qhull/src/user_eg2.c
Modified:
   trunk/scipy/spatial/SConscript
   trunk/scipy/spatial/qhull/Announce.txt
   trunk/scipy/spatial/qhull/COPYING.txt
   trunk/scipy/spatial/qhull/README.txt
   trunk/scipy/spatial/qhull/src/Changes.txt
   trunk/scipy/spatial/qhull/src/geom.c
   trunk/scipy/spatial/qhull/src/geom.h
   trunk/scipy/spatial/qhull/src/geom2.c
   trunk/scipy/spatial/qhull/src/global.c
   trunk/scipy/spatial/qhull/src/io.c
   trunk/scipy/spatial/qhull/src/io.h
   trunk/scipy/spatial/qhull/src/mem.c
   trunk/scipy/spatial/qhull/src/mem.h
   trunk/scipy/spatial/qhull/src/merge.c
   trunk/scipy/spatial/qhull/src/merge.h
   trunk/scipy/spatial/qhull/src/poly.c
   trunk/scipy/spatial/qhull/src/poly.h
   trunk/scipy/spatial/qhull/src/poly2.c
   trunk/scipy/spatial/qhull/src/qhull.h
   trunk/scipy/spatial/qhull/src/qhull_a.h
   trunk/scipy/spatial/qhull/src/qset.c
   trunk/scipy/spatial/qhull/src/qset.h
   trunk/scipy/spatial/qhull/src/stat.c
   trunk/scipy/spatial/qhull/src/stat.h
   trunk/scipy/spatial/qhull/src/user.c
   trunk/scipy/spatial/qhull/src/user.h
   trunk/scipy/spatial/setup.py
Log:
ENH: spatial: upgrade bundled Qhull to version 2010.1

Modified: trunk/scipy/spatial/SConscript
===================================================================
--- trunk/scipy/spatial/SConscript	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/SConscript	2010-11-16 21:18:37 UTC (rev 6902)
@@ -36,8 +36,9 @@
 
 # Build qhull
 src = [join('qhull', 'src', s) for s in [
-    'geom.c', 'geom2.c', 'global.c', 'io.c', 'mem.c',
-    'merge.c', 'poly.c', 'poly2.c', 'qset.c', 'user.c',
-    'stat.c', 'qhull.c']]
+    'geom2.c', 'geom.c', 'global.c', 'io.c', 'libqhull.c', 
+    'mem.c', 'merge.c', 'poly2.c', 'poly.c', 'qset.c', 
+    'random.c', 'rboxlib.c', 'stat.c', 'user.c', 'usermem.c',
+    'userprintf.c']]
 
 env.NumpyPythonExtension('qhull', source = ['qhull.c'] + src)

Modified: trunk/scipy/spatial/qhull/Announce.txt
===================================================================
--- trunk/scipy/spatial/qhull/Announce.txt	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/Announce.txt	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,16 +1,17 @@
 
- Qhull 2003.1 2003/12/30
+ Qhull 2010.1  2010/01/14
 
         http://www.qhull.org
-        http://savannah.nongnu.org/projects/qhull/
+        git@gitorious.org:qhull/qhull.git
+        http://packages.debian.org/sid/libqhull5        
         http://www6.uniovi.es/ftp/pub/mirrors/geom.umn.edu/software/ghindex.html
         http://www.geomview.org
         http://www.geom.uiuc.edu
 
-Qhull computes convex hulls, Delaunay triangulations, Voronoi diagrams, 
-furthest-site Voronoi diagrams, and halfspace intersections about a point. 
-It runs in 2-d, 3-d, 4-d, or higher.  It implements the Quickhull algorithm 
-for computing convex hulls.   Qhull handles round-off errors from floating 
+Qhull computes convex hulls, Delaunay triangulations, Voronoi diagrams,
+furthest-site Voronoi diagrams, and halfspace intersections about a point.
+It runs in 2-d, 3-d, 4-d, or higher.  It implements the Quickhull algorithm
+for computing convex hulls.   Qhull handles round-off errors from floating
 point arithmetic.  It can approximate a convex hull.
 
 The program includes options for hull volume, facet area, partial hulls,
@@ -20,7 +21,8 @@
 
 To download Qhull:
         http://www.qhull.org/download
-        http://savannah.nongnu.org/files/?group=qhull
+        git@gitorious.org:qhull/qhull.git
+        http://packages.debian.org/sid/libqhull5        
 
 Download qhull-96.ps for:
 
@@ -28,7 +30,7 @@
         Quickhull Algorithm for Convex Hulls," ACM Trans. on
         Mathematical Software, 22(4):469-483, Dec. 1996.
         http://www.acm.org/pubs/citations/journals/toms/1996-22-4/p469-barber/
-        http://citeseer.nj.nec.com/83502.html
+        http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.117.405
 
 Abstract:
 
@@ -38,7 +40,7 @@
 Beneath-Beyond Algorithm.  It is similar to the randomized, incremental
 algorithms for convex hull and Delaunay triangulation.  We provide empirical
 evidence that the algorithm runs faster when the input contains non-extreme
-points, and that it uses less memory. 
+points, and that it uses less memory.
 
 Computational geometry algorithms have traditionally assumed that input sets
 are well behaved.  When an algorithm is implemented with floating point
@@ -46,5 +48,5 @@
 a solution to this problem when computing the convex hull in two, three, or
 four dimensions.  The output is a set of "thick" facets that contain all
 possible exact convex hulls of the input.   A variation is effective in five
-or more dimensions.  
+or more dimensions.
 

Modified: trunk/scipy/spatial/qhull/COPYING.txt
===================================================================
--- trunk/scipy/spatial/qhull/COPYING.txt	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/COPYING.txt	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,4 +1,9 @@
-                    Qhull, Copyright (c) 1993-2003
+                    Qhull, Copyright (c) 1993-2010
+                    
+                            C.B. Barber
+                           Arlington, MA 
+                          
+                               and
 
        The National Science and Technology Research Center for
         Computation and Visualization of Geometric Structures
@@ -7,9 +12,9 @@
 
                        email: qhull@qhull.org
 
-This software includes Qhull from The Geometry Center.  Qhull is 
-copyrighted as noted above.  Qhull is free software and may be obtained 
-via http from www.qhull.org.  It may be freely copied, modified, 
+This software includes Qhull from C.B. Barber and The Geometry Center.  
+Qhull is copyrighted as noted above.  Qhull is free software and may 
+be obtained via http from www.qhull.org.  It may be freely copied, modified, 
 and redistributed under the following conditions:
 
 1. All copyright notices must remain intact in all files.
@@ -31,4 +36,3 @@
    provided solely "as is".  Bug reports or fixes may be sent to 
    qhull_bug@qhull.org; the authors may or may not act on them as 
    they desire.
-

Modified: trunk/scipy/spatial/qhull/README.txt
===================================================================
--- trunk/scipy/spatial/qhull/README.txt	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/README.txt	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,23 +1,25 @@
 Name
 
-      qhull, rbox         2003.1           2003/12/30
+      qhull, rbox         2010.1     2010/01/14
   
 Convex hull, Delaunay triangulation, Voronoi diagrams, Halfspace intersection
  
       Documentation:
         html/index.htm
+        http://www.qhull.org/html
 
       Available from:
         <http://www.qhull.org>
-	<http://savannah.nongnu.org/projects/qhull>
+        <git@gitorious.org:qhull/qhull.git>
+        <http://packages.debian.org/sid/libqhull5>
  
+      News and a paper:
+        <http://www.qhull.org/news>
+        <http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.117.405>
+
      Version 1 (simplicial only):
         <http://www.qhull.org/download/qhull-1.0.tar.gz>
-        <http://www.qhull.org/download/qhull.sit.hqx>
        
-      News and a paper:
-        <http://www.qhull.org/news>
-        <http://citeseer.nj.nec.com/83502.html>
 
 Purpose
 
@@ -34,13 +36,16 @@
   Qhull produces graphical output for Geomview.  This helps with
   understanding the output. <http://www.geomview.org>
 
-    
 Environment requirements
 
   Qhull and rbox should run on all 32-bit and 64-bit computers.  Use
   an ANSI C or C++ compiler to compile the program.  The software is 
-  self-contained.  
+  self-contained.  It comes with examples and test scripts.
   
+  Qhull's C++ interface uses the STL.  The C++ test program uses QTestLib 
+  from Nokia's Qt Framework.  For 2010, Qhull's C++ interface 
+  may change without notice.
+  
   Qhull is copyrighted software.  Please read COPYING.txt and REGISTER.txt
   before using or distributing Qhull.
 
@@ -52,49 +57,95 @@
 
 To contribute to Qhull
 
-  Qhull is on Savannah at http://savannah.nongnu.org/projects/qhull/
+  Qhull is on Gitorious (http://gitorious.org:qhull, git@gitorious.org:qhull/qhull.git)
+  
+  For internal documentation, see html/qh-code.htm
 
-Qhull on Windows 95, 98, ME, NT, 2000, XP
+-----------------
+Installing Qhull on Windows
 
   The zip file contains rbox.exe, qhull.exe, qconvex.exe, qdelaunay.exe, 
-  qhalf.exe, qvoronoi.exe, documentation files, and source files.
+  qhalf.exe, qvoronoi.exe, user_eg3.exe, documentation files, and source files.
   
   To install Qhull:
   - Unzip the files into a directory.  You may use WinZip32 <www.hotfiles.com>
   - Click on QHULL-GO
     
+  - If you use qhull a lot, consider using 
+    Road Bash (www.qhull.org/bash) or Cygwin (www.cygwin.com),
   - In Windows 95, the DOS window needs improvement.
       - Increase the size of the screen font to 8x12.
       - If the text is too dim, fix the screen colors with shareware (e.g., crt.exe)
-  - If you use qhull a lot, consider using the Cygwin Unix shell (www.cygwin.com),
 
   To learn about Qhull:
   - Execute 'qconvex' for a synopsis and examples.
   - Execute 'rbox 10 | qconvex' to compute the convex hull of 10 random points.
   - Execute 'rbox 10 | qconvex i TO file' to write results to 'file'. 
-  - If an error occurs, Windows 95 sends the error to stdout instead of stderr 
-      - use 'TO xxx' to send normal output to xxx and error output to stdout
   - Browse the documentation: qhull\html\index.htm
+  - If an error occurs, Windows sends the error to stdout instead of stderr. 
+    Use 'TO xxx' to send normal output to xxx and error output to stdout
 
-Compiling with cygwin on Windows NT, 2000, XP
-  - install cygwin [www.cygwin.com] with gcc, make, ar, and ln
+-----------------
+Installing Qhull on Unix with gcc
+
+  The tgz tarball contains documentation and source files.
+  
+  To install Qhull
+  - Extract the files
   - cd qhull/src
-  - make -f Makefile.txt
+  - make
+  - or, make -f Makefile.txt
 
-Qhull on Unix (Debian)
+-----------------
+Installing Qhull with Autoconf
 
-  The gzip file, qhull.tar.gz, contains documentation and source files for
-  qhull and rbox.  It should compile on all Unix systems, including Debian.
-  You may also use the source instructions below.
+  The tar.gz tarball contains documentation, source files, 
+  and a config directory [R. Laboissiere].
   
-  To unpack the gzip file
-  - tar zxf qhull.tar.gz
-  - cd qhull
-  
-  Compile with the configure Makefile [R. Laboissiere]:
+  To install Qhull
+  - Extract the files
   - ./configure
   - make
+  - make install
 
+-----------------
+Compiling Qhull with Qt 
+
+  Qt is a C++ framework for Windows, Linux, and Macintosh
+
+  Qhull includes a C++ test using Qt's QTestLib
+
+  To compile Qhull  
+  - Download the Qt SDK from Nokia (http://qt.nokia.com/downloads)
+  - Start Qt Creator
+  - Load project/qhull-all.pro
+  - Build all
+
+-----------------
+Compiling Qhull on Windows.
+
+  To compile Qhull with Visual C++
+  - Load solution project/qhull.sln
+  - For project qhulltest, 
+    install Qt for DevStudio (http://qt.nokia.com/downloads)
+  - Build->Build all
+
+  To compile Qhull with MINGW
+  - Install Road Bash (http://www.qhull.org/bash)
+  - or install MSYS (http://www.mingw.org/wiki/msys)
+  - Install MINGW (http://www.mingw.org/)
+  - cd src
+  - make 
+  - or, make -f Makefile.txt
+
+  To compile Qhull with cygwin
+  - Install cygwin (http://www.cygwin.com)
+  - Include packages for gcc, make, ar, and ln
+  - cd src
+  - make
+  - or, make -f Makefile.txt
+
+-----------------
 Compiling the source distribution
 
   The gzip file, qhull-src.tgz, contains documentation and source files for
@@ -104,7 +155,7 @@
   - tar zxf qhull-src.tgz
   - cd qhull
   
-  Compiling with Makefile (i.e., Makefile.txt)   
+  Compiling qhull and rbox with Makefile (i.e., Makefile.txt)   
   - cd src
   - in Makefile, check the CC, CCOPTS1, PRINTMAN, and PRINTC defines
       - the defaults are gcc and enscript
@@ -122,8 +173,10 @@
       - this is ok, your compiler should have these in stdio.h
   - if your compiler warns about missing prototypes for memset() etc.
       - include memory.h in qhull_a.h
-  - if your compiler is gcc-2.95.1, you need to set flag -fno-strict-aliasing.  
-      - This flag is set by default for other versions [Karas, Krishnaswami]
+  - if your compiler is gcc-4.3, 4.2, 4.1 or 2.95.1, set flag -fno-strict-aliasing.  
+      - This flag is set by default for other versions up to 4.0 [Karas, Krishnaswami]
+      - strict-aliasing appears to work ok for gcc-4.4
+      - See news/qhull-news.html#bugs for details
   - if your compiler reports "global.c: storage size of 'qh_qh' isn't known"
       - delete the initializer "={0}" in global.c, stat.c and mem.c
   - if your compiler warns about "stat.c: improper initializer"
@@ -133,7 +186,7 @@
   - if the code compiles, the qhull test case will automatically execute
   - if an error occurs, there's an incompatibility between machines
       - For gcc-2.95.1, you need to set flag -fno-strict-aliasing.
-	    It is set by default for other versions of gcc [Karas, Krishnaswami]
+            It is set by default for other versions of gcc [Karas, Krishnaswami]
       - If you can, try a different compiler 
       - You can turn off the Qhull memory manager with qh_NOmem in mem.h
       - You can turn off compiler optimization (-O2 in Makefile)
@@ -145,52 +198,86 @@
       - define MANDIR and BINDIR
       - type 'make install'
 
-Compiling on Windows 95, 98, NT, 2000, XP
+If you need to create a custom build, create projects as follows.
+These instructions assume Visual C++, but similar ones apply to other
+build systems.
 
-  Qhull compiles as a console application in Visual C++ 5.0 at warning 
-  level 3.
+  For qhull.exe and rbox.exe only:
+    - create a "console application" called "qhull"
+        - add the following files:
+            geom.c geom2.c global.c io.c libqhull.c mem.c merge.c 
+            poly.c poly2.c qset.c random.c stat.c unix.c 
+            user.c usermem.c userprintf.c
+    - create a "console application" called "rbox" 
+        - add rbox.c rboxlib.c
 
-  Visual C++ quickstart for qhull.exe only:
-    - create a "Win32 console application" called "qhull"
-	- add the following files:
-	    geom.c geom2.c global.c io.c mem.c merge.c poly.c poly2.c qhull.c
-		qset.c stat.c unix.c user.c
-    - create a "Win32 console application" called "rbox" 
-	- add rbox.c
-
-  Visual C++ quickstart for qhull library, qhull.exe, qconvex.exe, etc.
+  For all projects
     - To simplify setting up lots of projects, 
-	- create a temporary "Win32 console application" called "source"
-	- add all .c files from .../src/...
-	- In Tools::Options::Tab
-	  Set tab size to 8 and indent size to 2
+        - create a temporary "Win32 console application" called "source"
+        - add all .c files from .../src/...
+        - add all .cpp files from .../cpp/...
+        - In Tools::Options::Tab
+          Set tab size to 8 and indent size to 2
 
     - create a "Win32 console application" called "rbox"
-	- move rbox.c from "qhull source"
-	- for Project:Settings..., Link
-	  you only need the default libraries
-	- build the project
+        - move rbox.c rboxlib.c from "qhull source"
+        - for Project:Settings..., Link
+          you only need the default libraries
+        - build the project
 
-    - create a "Win32 static library" called "library"
-	- move these files from "qhull source"
-	    geom.c geom2.c global.c io.c mem.c merge.c poly.c poly2.c qhull.c
-		qset.c stat.c user.c
-	- set the library file (use the same for debug and release)
-	- build the project
+    - create a "Win32 static library" called "libqhull"
+        - move these files from "qhull source"
+            geom.c geom2.c global.c io.c mem.c merge.c poly.c poly2.c libqhull.c
+                qset.c random.c rboxlib.c stat.c user.c usermem.c userprintf.c
+        - set the library file (use the same for debug and release)
+        - build the project
 
-    - create a "Win32 console application" called "qhull"
-	- Move unix.c from "qhull source"
-	- Add the library file created by "library"
-	- Qhull does not use other libraries
+    - create a "Win32 static library" called "libqhullp"
+        - move these files from "qhull source"
+            geom.c geom2.c global.c io.c mem.c merge.c poly.c poly2.c libqhull.c
+                qset.c random.c rboxlib.c stat.c user.c usermem.c userprintf.c
+        - define qh_QHpointer=1
+        - set the library file (use the same for debug and release)
+        - build the project
 
-    - create a "Win32 console application" called "qconvex"
-	- Move qconvex.c from "qhull source"
-	- Copy the library file from "qhull"
+    - create a "Win32 console application, empty project" called "qhull"
+        - Move unix.c from "qhull source"
+        - Project Dependency on libqhull (or copy the library file)
+        - Linker->Input->Ignore LIBCMT
+        - Qhull does not use other libraries
 
+    - create a "Win32 console application, empty project" called "qconvex"
+        - Move qconvex.c from "qhull source"
+        - Project Dependency on libqhull (or copy the library file)
+        - Linker->Input->Ignore LIBCMT
+        - build the project
+
     - do the same for qdelaun.c, qhalf, qvoronoi.c, user_eg.c, user_eg2.c
-	- delete "qhull sources" since it is no longer needed
-	- use Project:Settings to make any changes
-	- use batch build to rebuild everything
+
+    - create a "Win32 dynamic library" called "libqhullcpp"
+        - Move cpp sources in cpp/*.cpp from "qhull source"
+          Do not move cpp/qhulltest, road/RoadTest.cpp, or user_eg3.cpp
+        - define qh_QHpointer=1
+        - Add the library file created by "libqhullp"
+        - build the project
+    
+    - create a "Win32 console application" called "user_eg3"
+        - Move user_eg3 from "qhull source"
+        - define qh_QHpointer=1
+        - Add the library file created by "libqhullcpp"
+        - build the project
+
+    - create a "Win32 console application" called "qhulltest"
+        - Install Qt for DevStudio (http://qt.nokia.com/downloads)
+        - Add everything in cpp/qhulltest
+        - Add road/RoadTest.cpp
+        - define qh_QHpointer=1
+        - Add the library file created by "libqhullcpp"
+        - build the project
+
+    - use Project:Settings to make any changes
+    - use batch build to rebuild everything
+    - delete "qhull sources" since it is no longer needed
   
   Qhull compiles with Borland C++ 5.0 bcc32.  A Makefile is included.
   Execute 'make -f Mborland'.  If you use the Borland IDE, set the ANSI
@@ -216,11 +303,6 @@
   Windows 95'.  Instead of using SIOUX, Qhull may be embedded within an 
   application.  
 
-  Version 1 is available for Macintosh computers by download of qhull.sit.hqx
-  It reads point coordinates from a standard file and returns output
-  to a standard file.  There is no graphical output.
-
-
 Compiling on other machines
  
   Some users have reported problems with compiling Qhull under Irix 5.1.  It
@@ -232,23 +314,35 @@
   You may compile Qhull with a C++ compiler.  
 
 
+-----------------
 Distributed files
 
   README.txt           // instructions for installing Qhull 
   REGISTER.txt         // Qhull registration 
   COPYING.txt          // copyright notice 
-  QHULL-GO.pif	       // Windows icon for qhull-go.bat
+  QHULL-GO.pif         // Windows icon for qhull-go.bat
   Announce.txt         // announcement 
-  Changes.txt          // change history for Qhull and rbox 
-  File_id.diz	       // package descriptor
+  CMakeLists.txt       // CMake file
+  File_id.diz          // package descriptor
   index.htm            // Home page 
+  qhull*.md5sum        // md5sum for all files
   html/qh-faq.htm      // Frequently asked questions
   html/qh-get.htm      // Download page
   html/index.htm       // Manual
+  src/Changes.txt      // change history for Qhull and rbox 
+  src/CMakeLists.txt   // CMake file
   src/Makefile.txt     // Makefile for Unix or cygwin 'make' 
   src/Mborland         // Makefile for Borland C++/Win32
   src/Make-config.sh   // Create Debian configure and automake
- 
+  project/qhull-all.pro  // Qt project with Visual C++ vcproj files
+
+eg/ 
+  q_eg                 // shell script for Geomview examples
+  q_egtest             // shell script for Geomview test examples
+  q_test               // shell script to test qhull
+  q_test-ok.txt        // output from q_test
+  qhulltest-ok.txt     // output from qhulltest (Qt only)
+
 src/      
   rbox consists of:
      rbox.exe          // Win32 executable (.zip only) 
@@ -256,6 +350,7 @@
      rbox.man          // Unix man page 
      rbox.txt
      rbox.c            // source program 
+     rboxlib.c
      
   qhull consists of:
      qhull.exe         // Win32 executables (.zip only) 
@@ -263,7 +358,7 @@
      qdelaunay.exe
      qhalf.exe
      qvoronoi.exe
-     qhull-go.bat      // DOS window
+     eg/qhull-go.bat   // DOS window
      qconvex.htm       // html manuals
      qdelaun.htm
      qdelau_f.htm        
@@ -271,35 +366,37 @@
      qvoronoi.htm
      qvoron_f.htm
      qh-eg.htm
+     qh-code.htm
      qh-impre.htm
-     qh-in.htm
      index.htm
      qh-opt*.htm
      qh-quick.htm
      qh--4d.gif,etc.   // images for manual 
      qhull.man         // Unix man page 
      qhull.txt
-     q_eg              // shell script for Geomview examples
-     q_egtest          // shell script for Geomview test examples
-     q_test            // shell script to test qhull
   
   top-level source files:
      src/index.htm     // index to source files 
      qh-...htm         //   specific files
      user.h            // header file of user definable constants 
-     qhull.h           // header file for qhull 
+     libqhull.h        // header file for qhull
      unix.c            // Unix front end to qhull 
-     qhull.c           // Quickhull algorithm with partitioning 
+     qconvex.c    
+     qhalf.c
+     qdelaunay.c
+     qvoronoi.c
+     libqhull.c        // Quickhull algorithm with partitioning
      user.c            // user re-definable functions 
+     usermem.c
+     userprintf.c
      user_eg.c         // example of incorporating qhull into a user program 
      user_eg2.c        // more complex example 
-     qhull_interface.cpp // call Qhull from C++
 
   other source files:
      qhull_a.h         // include file for *.c 
      geom.c            // geometric routines 
      geom2.c
-     geom.h	
+     geom.h     
      global.c          // global variables 
      io.c              // input-output routines 
      io.h
@@ -315,14 +412,105 @@
      stat.c            // statistics 
      stat.h
 
+project/
+  projects for building Qhull
+     qhull.sln          // Solution for Visual C++ 2005 and higher
+     qhull-all.pro      // Project for Qt
+     */*.pro            // Qt projects for each component
+     *.vcproj           // Visual C++ projects 
+     
+cpp/      
+  cpp interface to Qhull
+    Qhull.cpp           // calls libqhull.c
+    Qhull.h
+    user_eg3.cpp        // sample program
+    
+  input classes
+    Coordinates.cpp
+    Coordinates.h
+    PointCoordinates.cpp
+    PointCoordinates.h
+    PointIterator.h
+    RboxPoints.cpp      // calls rboxlib.c
+    RboxPoints.h
+
+  data structure classes  
+    QhullFacet.cpp
+    QhullFacet.h
+    QhullHyperplane.cpp
+    QhullHyperplane.h
+    QhullPoint.cpp
+    QhullPoint.h
+    QhullQh.cpp
+    QhullQh.h
+    QhullStat.cpp
+    QhullStat.h
+    
+  collection classes
+    QhullFacetList.cpp
+    QhullFacetList.h
+    QhullFacetSet.cpp
+    QhullFacetSet.h
+    QhullIterator.h
+    QhullLinkedList.h
+    QhullPoints.cpp
+    QhullPoints.h
+    QhullPointSet.cpp
+    QhullPointSet.h
+    QhullRidge.cpp
+    QhullRidge.h
+    QhullSet.cpp
+    QhullSet.h
+    QhullSets.h
+
+  supporting classes
+    functionObjects.h
+    QhullError.cpp
+    QhullError.h
+    QhullEvent.cpp
+    QhullEvent.h
+    QhullLog.cpp
+    QhullLog.h
+    UsingLibQhull.cpp
+    UsingLibQhull.h
+
+cpp/qhulltest/
+  Tests for each class
+    Coordinates_test.cpp
+    PointCoordinates_test.cpp
+    Point_test.cpp
+    QhullFacetList_test.cpp
+    QhullFacetSet_test.cpp
+    QhullFacet_test.cpp
+    QhullHyperplane_test.cpp
+    QhullLinkedList_test.cpp
+    QhullPointSet_test.cpp
+    QhullPoints_test.cpp
+    QhullPoint_test.cpp
+    QhullRidge_test.cpp
+    QhullSet_test.cpp
+    qhulltest.cpp
+    QhullVertexSet_test.cpp
+    QhullVertex_test.cpp
+    Qhull_test.cpp
+    RboxPoints_test.cpp
+    UsingLibQhull_test.cpp
+
+cpp/road/
+  Supporting base classes
+    RoadError.cpp
+    RoadError.h
+    RoadLogEvent.cpp
+    RoadLogEvent.h
+    RoadTest.cpp
+    RoadTest.h
+
+-----------------
 Authors:
 
   C. Bradford Barber                    Hannu Huhdanpaa
-  bradb@qhull.org                       hannu@qhull.org
+  bradb@shore.net                       hannu@qhull.org
   
-                    The Geometry Center
-                    University of Minnesota
-  
   Qhull 1.0 and 2.0 were developed under NSF grants NSF/DMS-8920161 
   and NSF-CCR-91-15793 750-7504 at the Geometry Center and Harvard 
   University.  If you find Qhull useful, please let us know.

Deleted: trunk/scipy/spatial/qhull/REGISTER.txt
===================================================================
--- trunk/scipy/spatial/qhull/REGISTER.txt	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/REGISTER.txt	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,37 +0,0 @@
-Dear User of Geometry Center Software:
-
-We would like to find out how you are using our software.  Think of
-Geometry Center software as a new kind of shareware: you share your
-science and successes with us, and we share our software and support
-with you. 
-
-If you use Geometry Center software, please send us a note telling
-us what you are doing with it.
-
-We need to know:
-
-  (1) What you are working on - an abstract of your work would be
-      fine.
-
-  (2) What Geometry Center software you use.
-
-  (3) How that software has helped you, for example, by increasing
-      your productivity or allowing you to do things you could not do
-      before.  In particular, if you feel that Geometry Center
-      software has had a direct bearing on your work, please tell us
-      about this.
-
-We encourage you to cite the use of any Geometry Center software you
-have used in your publications.  
-
-To cite Qhull, please use
-
-        Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull 
-	algorithm for convex hulls," ACM Trans. on Mathematical Software,
-	22(4):469-483, Dec 1996, http://www.qhull.org.
-
-Please send e-mail to
-
-    qhull@qhull.org
-
-Thank you!

Deleted: trunk/scipy/spatial/qhull/index.htm
===================================================================
--- trunk/scipy/spatial/qhull/index.htm	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/index.htm	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,252 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-
-<head>
-<title>Qhull for Convex Hull, Delaunay Triangulation, Voronoi Diagram, and Halfspace Intersection about a Point</title>
-</head>
-
-<body>
-<!-- Navigation links -->
-<b>URL:</b> <a href="http://www.qhull.org">http://www.qhull.org</a>
-<br><b>To:</b>
-<a href="http://www.qhull.org/news">News</a>
-&#149; <a href="http://www.qhull.org/download">Download</a>
-&#149; <a href="http://citeseer.nj.nec.com/83502.html">CiteSeer</a>
-&#149; <a href=http://images.google.com/images?q=qhull&num=100>Images</a>
-&#149; <a href="html/index.htm#TOC">Manual</a>
-&#149; <a href="http://www.qhull.org/html/qh-faq.htm">FAQ</a>
-&#149; <a href="html/qh-quick.htm#programs">Programs</a>
-&#149; <a href="html/qh-quick.htm#options">Options</a> 
-</p>
-
-<hr>
-<!-- Main text of document -->
-<table>
-<tr><td valign=top>
-	<h1>Qhull</h1>
-	<a
-	href="http://www.geom.uiuc.edu/graphics/pix/Special_Topics/Computational_Geometry/cone.html"><img
-	src="html/qh--cone.gif" alt="[CONE]" align="middle" width="100"
-	height="100"></a>
-</td><td>
-Qhull computes convex hulls, Delaunay triangulations,
-halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay
-triangulations, and furthest-site Voronoi diagrams. It runs in
-2-d, 3-d, 4-d, and higher dimensions. It implements the Quickhull
-algorithm for computing the convex hull. Qhull handles roundoff
-errors from floating point arithmetic. It computes volumes,
-surface areas, and approximations to the convex hull.</p>
-
-<!-- duplicated in index.htm and html/index.htm -->
-<p>Qhull does <i>not</i> support constrained Delaunay
-triangulations, triangulation of non-convex surfaces, mesh
-generation of non-convex objects, or medium-sized inputs in 9-D
-and higher. </p>
-</td></tr></table>
-
-<hr>
-<form method=get action=http://www.google.com/search>
-<input type=hidden name=as_q value=site:www.qhull.org>
-<input type=hidden name=num value=100>
-<ul>
-    <li><a href="http://www.qhull.org/news">News</a> and
-	<a href="http://www.qhull.org/news/qhull-news.html#bugs">Bugs</a>
-	about Qhull 2003.1 2003/12/30</li>
-    <li><a href="http://www.qhull.org/download">Download</a>
-        Qhull</li>
-    <li><a
-        href="http://www.geom.uiuc.edu/graphics/pix/Special_Topics/Computational_Geometry/welcome.html">Examples
-        </a>of Qhull output </li>
-	<li><a href=http://savannah.nongnu.org/projects/qhull/>Development</a> at Savannah
-	<li><input name=as_q size=10> search www.qhull.org 
-	<p>
-    <li><a href="http://www.qhull.org/news/qhull-news.html#users">How</a> is Qhull used?</li>
-	<li><a href="http://citeseer.nj.nec.com/context/86585/83502">CiteSeer</a> references to Qhull
-</p>
- 	<li><a href=http://www.google.com/search?as_q=qhull+-debian+-cvs+-gentoo+-pool+-mirrors&num=100>Google</a> Qhull, 
-	Qhull <a href=http://images.google.com/images?q=qhull&num=100>Images</a>,
-	Qhull in <a href=http://groups.google.com/groups?as_q=qhull&num=100&as_scoring=d>Newsgroups</a>,
-	and <a href=http://www.googlism.com/who_is/q/qhull/>Who is</a> Qhull?
-
-	<p>
-	<li><a href=http://www.mathworks.com/>MATLAB</a> uses Qhull for their computational geometry functions: <a href=http://www.mathworks.com/access/helpdesk/help/techdoc/ref/convhulln.shtml>convhulln</a>
-	<a href=http://www.mathworks.com/access/helpdesk/help/techdoc/ref/delaunayn.shtml>delaunayn</a>
-	<a href=http://www.mathworks.com/access/helpdesk/help/techdoc/ref/griddata3.shtml>griddata3</a>
-	<a href=http://www.mathworks.com/access/helpdesk/help/techdoc/ref/griddatan.shtml>griddatan</a>
-	<a href=http://www.mathworks.com/access/helpdesk/help/techdoc/ref/tsearch.shtml>tsearch</a>
-	<a href=http://www.mathworks.com/access/helpdesk/help/techdoc/ref/tsearchn.shtml>tsearchn</a>
-    <a href=http://www.mathworks.com/access/helpdesk/help/techdoc/ref/voronoin.shtml>voronoin</a>.  MATLAB R14 will upgrade to
-	Qhull 2003.1 and triangulated output ('Qt').
-    </li>
-	<li><a href=http://www.octave.org/>GNU Octave</a> uses Qhull for their
-	<a href=http://octave.sourceforge.net/index/analysis.html#Geometry>computational geometry functions</a>.  Octave has partially upgraded
-	to Qhull 2002.1 and triangulated output ('Qt').
-	<li><a href=http://www.wolfram.com/products/mathematica/>Mathematica</a>'s Delaunay interface: <a href=http://www.mathsource.com/Content/Enhancements/Geometry/0211-251>qh-math</a>
-	<li><a href=http://www.geomview.org>Geomview</a> for 3-D and 4-D visualization of Qhull output
-</ul>
-</form>
-
-<p><b>Introduction</b>
-<ul>
-    <li><a
-        href="http://www.ifor.math.ethz.ch/staff/fukuda/polyfaq/polyfaq.html">Fukuda's
-        introduction</a> to convex hulls, Delaunay
-        triangulations, Voronoi diagrams, and linear programming</li>
-    <li><a
-        href="http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html">Lambert's
-        Java</a> visualization of convex hull algorithms </li>
-    <li><a
-        href="http://www.cs.sunysb.edu/~algorith/major_section/1.6.shtml">Stony
-        Brook</a> Algorithm Repository, computational geometry</li>
-</ul>
-
-<p><b>Qhull Documentation and Support</b>
-<ul>
-   <li><a href="html/index.htm">Manual</a> for Qhull and rbox
-	<ul>
-		<li><a href="html/qconvex.htm">qconvex</a> -- convex hull
-		<li><a href="html/qdelaun.htm">qdelaunay</a> -- Delaunay triangulation
-		<li><a href="html/qvoronoi.htm">qvoronoi</a> -- Voronoi diagram
-		<li><a href="html/qhalf.htm">qhalf</a> -- halfspace intersection about a point
-		<li><a href="html/rbox.htm">rbox</a> -- generate point distributions
-	    <li><a href=src/index.htm>Qhull functions</a>, macros, and data structures with source
-	</ul>
-    <li><a href="http://www.qhull.org/html/qh-faq.htm">Frequently</a> asked
-        questions about Qhull</li>
-    <li>Send e-mail to <a href=mailto:qhull@qhull.org>qhull@qhull.org</a> </li>
-    <li>Report bugs to <a
-        href="mailto:qhull_bug@qhull.org">qhull_bug@qhull.org</a>
-</ul>
-
-<p><b>Related URLs</b>
-<ul>
-    <li><a href="http://www.geom.uiuc.edu/software/cglist">Amenta's directory</a> of
-        computational geometry software </li>
-
-	<li><a href=http://www.boost.org/libs/graph/doc/table_of_contents.html>BGL</a> 
-	Boost Graph Library provides C++ classes for graph data structures
-and algorithms,
-    <li><a
-        href="http://netlib.bell-labs.com/netlib/voronoi/hull.html">Clarkson's
-        hull </a>program with exact arithmetic for convex hulls, Delaunay triangulations,
-		Voronoi volumes, and alpha shapes. </li>
-	<li><a href="http://compgeom.cs.uiuc.edu/~jeffe/compgeom/compgeom.html">Erickson's 
-	    Computational</a> Geometry Pages and 
-		<a href="http://compgeom.cs.uiuc.edu/~jeffe/compgeom/code.html">Software</a>
-    <li><a
-        href="http://www.cs.mcgill.ca/~fukuda/soft/cdd_home/cdd.html">Fukuda's
-        cdd</a> program for halfspace intersection and convex hulls</li>
-	<li><a href="http://www.inf.ethz.ch/personal/gaertner/miniball.html">Gartner's 
-	Miniball</a> for fast and robust smallest enclosing balls (up to 20-d)
-
-	<li><a href=http://directory.google.com/Top/Science/Math/Geometry/Computational_Geometry/Software/>Google's directory</a> for 
-	Science > Math > Geometry > Computational Geometry > Software
-    <li><a href=http://www.algorithmic-solutions.com/enleda.htm>Leda</a>  
-and <a href=http://www.cgal.org/>CGAL</a> libraries for writing computational
-geometry programs and other combinatorial algorithms
-	<li><a href=http://www.magic-software.com>Magic Software</a> source code for computer
-	graphics, image analysis, and numerical methods
-	<li><a href=http://www.mathtools.net/>Mathtools.net</a> of scientific and engineering
-	software
-    <li><a href="http://www.andrew.cmu.edu/user/sowen/mesh.html">Owen's Meshing</a> Research Corner
-    <li><a
-        href="http://www-users.informatik.rwth-aachen.de/~roberts/meshgeneration.html">Schneiders'
-        Finite Element</a> Mesh Generation page</li>
-    <li><a href="http://www.cs.cmu.edu/~quake/triangle.html">Shewchuk's
-        triangle </a>program for 2-d Delaunay</li>
-	<li><a href=ftp://ftp.zib.de/pub/Packages/mathprog/index.html>Skorobohatyj's Mathprog@ZIB</a> for  
-	mathematical software
-	<li><a href=http://www.voronoi.com>Voronoi Web Site</a> for all things Voronoi
-</ul>
-
-<p><b>FAQs and Newsgroups</b>
-<ul>
-    <li><a
-        href="http://exaflop.org/docs/cgafaq/">FAQ</a>
-        for computer graphics algorithms 
-		(<a href="http://exaflop.org/docs/cgafaq/cga6.html">geometric</a> structures)
- </li>
-    <li><a
-        href="http://www-unix.mcs.anl.gov/otc/Guide/faq/linear-programming-faq.html">FAQ
-        </a>for linear programming </li>
-    <li><a href="news:comp.graphics.algorithms">Newsgroup</a>:
-        comp.graphics.algorithms </li>
-	<li><a href="news:comp.soft-sys.matlab">Newsgroup</a>:
-	    comp.soft-sys.matlab</li>
-    <li><a href="news:sci.math.num-analysis">Newsgroup</a>:
-        sci.math.num-analysis </li>
-    <li><a href="news:sci.op-research">Newsgroup</a>:
-        sci.op-research </li>
-</ul>
-</blockquote>
-<hr>
-
-<p>The program includes options for input transformations,
-randomization, tracing, multiple output formats, and execution
-statistics. The program can be called from within your
-application. </p>
-
-<p>You can view the results in 2-d, 3-d and 4-d with <a
-href="http://www.geomview.org">Geomview</a>.   An alternative
-is <a href=http://www.kitware.com/vtk.html>VTK</a>.</p>
-
-<p>For an article about Qhull, download from <a
-href="http://citeseer.nj.nec.com/83502.html">CiteSeer</a> or <a
-    href="http://www.acm.org/pubs/citations/journals/toms/1996-22-4/p469-barber/">www.acm.org</a>:
-</p>
-
-<blockquote>
-    <p>Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., &quot;The
-    Quickhull algorithm for convex hulls,&quot; <i>ACM Trans. on
-    Mathematical Software</i>, 22(4):469-483, Dec 1996, http://www.qhull.org. </p>
-</blockquote>
-
-<p>Abstract: </p>
-
-<blockquote>
-    <p>The convex hull of a set of points is the smallest convex
-    set that contains the points. This article presents a
-    practical convex hull algorithm that combines the
-    two-dimensional Quickhull Algorithm with the general
-    dimension Beneath-Beyond Algorithm. It is similar to the
-    randomized, incremental algorithms for convex hull and
-    Delaunay triangulation. We provide empirical evidence that
-    the algorithm runs faster when the input contains non-extreme
-    points, and that it uses less memory. </p>
-    <p>Computational geometry algorithms have traditionally
-    assumed that input sets are well behaved. When an algorithm
-    is implemented with floating point arithmetic, this
-    assumption can lead to serious errors. We briefly describe a
-    solution to this problem when computing the convex hull in
-    two, three, or four dimensions. The output is a set of
-    "thick" facets that contain all possible exact convex hulls
-    of the input. A variation is effective in five or more
-    dimensions. </p>
-</blockquote>
-<!-- Navigation links -->
-<hr>
-
-<p><b>Up:</b> <a href="http://www.geom.uiuc.edu/software/past-projects.html"><i>Past Software
-Projects of the Geometry Center</i></a> <br>
-<b>URL:</b> <a href="http://www.qhull.org">http://www.qhull.org</a>
-<br><b>To:</b> 
-<a href="http://www.qhull.org/news">News</a>
-&#149; <a href="http://www.qhull.org/download">Download</a>
-&#149; <a href="http://citeseer.nj.nec.com/83502.html">CiteSeer</a>
-&#149; <a href=http://images.google.com/images?q=qhull&num=100>Images</a>
-&#149; <a href="html/index.htm#TOC">Manual</a>
-&#149; <a href="http://www.qhull.org/html/qh-faq.htm">FAQ</a>
-&#149; <a href="html/qh-quick.htm#programs">Programs</a>
-&#149; <a href="html/qh-quick.htm#options">Options</a> 
-<!-- GC common information --></p>
-
-<hr>
-
-<p><a href="http://www.geom.uiuc.edu/"><img src="html/qh--geom.gif" alt="[HOME]"
-align="middle"></a> <i>The Geometry Center Home Page</i> </p>
-
-<p>Comments to: <a href="mailto:qhull@qhull.org">qhull@qhull.org</a>
-<br>
-Created: May 17 1995 --- <!-- hhmts start --> 
-</body>
-</html>

Modified: trunk/scipy/spatial/qhull/src/Changes.txt
===================================================================
--- trunk/scipy/spatial/qhull/src/Changes.txt	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/Changes.txt	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,24 +1,278 @@
 
 .............This file lists all changes to qhull and rbox.....................
 
+------------
+Need help
+ - The C++ interface needs work.  Give it a try and make it better.
+   http://gitorious.org/qhull/
+ - Produce conformant triangulations for merged facets using option 'Qt' 
+ - Add CMakeLists.txt for qhullcpp, user_eg3, cpp/, and cpp/road
+   If practical, please move to project/
+ - Verify -fno-strict-aliasing needed for gcc 4.1, 4.2, and 4.3 (qset segfault)
+ - Set up debian build [Pkg-octave-devel]
+   Please keep debian files in config/ and project/debian/
+   Branch 'debian' is from http://savannah.nongnu.org/cvs/?group=qhull
+   project/debian needs updating for its new location.  It was at qhull's level.
+
+To do
+ - Review email for doc changes
+ - RMP build of Qhull
+
+------------
+qhull 2010.1 2010/01/14
+- Fixed quote for #include in qhull.h [U.Hergenhahn, K.Roland]
+- Add qt-qhull.cpp with Qt conditional code
+- Add libqhullp.proj
+- Add libqhull5 to Readme, Announce, download
+- Reviewed #pragma
+- Reviewed FIXUP and assigned QH tags
+- All projects compile with warnings enabled
+- Replaced 'up' glyphs with &#187;
+- Moved cpp questions to qh-code.htm#questions-cpp 
+- Moved suggestions to qh-code.htm#enhance 
+- Moved documentation requests to qh-code.htm#enhance
+- Add md5sum file to distributions
+- Switched to DevStudio builds to avoid dependent libraries, 10% slower
+  Removed user_eg3.exe and qhullcpp.dll from Windows build 
+  Fix qhull.sln and project files for qh_QHpointer
+- Add eg/qhull-zip.sh to build qhull distribution files
+
+------------
+qhull 2010.1 2010/01/10
+- Test for NULL fp in qh_eachvoronoi [D. Szczerba]
+
+qhull 2010.1 2010/01/09
+
+Changes to build and distribution
+- Use qh_QHpointer=0 for libqhull.a, qhull, rbox, etc.
+  Use -Dqh_QHpointer for libqhullp.a, qhullcpp.dll, etc.
+  qh_QHpointer costs: [2010, gcc] 4% time 4% space, [2003, msvc] 8% time 2% space
+- Add config/ and project/debian/ for Autoconf build [R. Laboissiere]
+  from debian branch in git and http://savannah.nongnu.org/cvs/?group=qhull
+- Add CMakeLists.txt [kwilliams]
+- Fix tabs in Makefile.txt [mschamschula]
+- Add -fno-strict-aliasing to Makefile for gcc 4.1, 4.2, and 4.3 qset segfault
+- Remove user_eg.exe and user_eg2.exe from Windows distribution
+- Order object files by frequency of execution for better locality.
+
+Changes to source
+- Remove ptr_intT from qh_matchvertices.  It was int since the beginning.
+- user.h requires <time.h> for CLOCKS_PER_SEC
+- Move ostream<<QhullFacetList from inline to compiled.
+- Removed ConvexHull/ from git.  Not used.
+
+------------
+qhull 2009.1.1 2010/01/09
+- Patch release of 2009.1.
+  qh_gethash allowed a negative result, causing overwrite or segfault
+  See git:qhull/project/patch/qhull-2003.1/poly.c-qh_gethash.patch
+  Compared results of q_test, q_eg, and q_egtest with patched poly.c, qhull-2003.1
+
+------------
+qhull 2010.1 2010/01/07
+- Assign type to qh.old_qhstat and memT.tempstack [amorilia]
+- Replace tabs with spaces.
+- Fix qh_pointid in case ptr_intT is unsigned
+
+qhull 2010.1 2010/01/06
+- Fixed serious bug in qh_gethash [poly.c]
+- Documentation and build system are incomplete (see above)
+- First release of C++ interface [qh-code.htm]
+- Development moved to http://gitorious.org/qhull
+  git clone git@gitorious.org:qhull/qhull.git
+- Did not fix conformant tesselations for 'Qt'.
+  For details, see http://www.qhull.org/news#bugs of May 2007 and Dec 2006.
+- Use g++ builds for Windows distribution (10% faster than msvc2005)
+  Combined vcproj/ and qtproj/ into project/
+  vcproj will be replaced by qmake generated files
+
+------------
+qhull 2010.0.3 2010/01/05
+Fixed bugs
+- 'QJn' (joggle): Fix qh.STOPcone in qh_build_withrestart().  It was not cleared.
+- qh_initqhull_outputflags [global.c]: warn about Qc only if QHULLfinished, otherwise set if needed
+
+qhull 2010.0.2 2010/01/04
+
+Fixed bugs
+- qh_gethash [poly.c]: fix sign conversion.
+    Previously, the result may be negative, leading to a segfault.
+    The bug is more likely with large address spaces
+    Reviewed all uses of %(modulo) for remainder with negative arguments
+- Reviewed output of q_test and compared to results from 2003.1
+
+Breaking code changes
+- Return type of qh_gethash changed from unsigned to int.  Matches 'size'
+- addhash takes a signed hash
+  qh_addhash( newelem, hashtable, hashsize, hash )
+
+Code changes
+- Test for qh_qh in qh_printf
+- Makefile.txt corrected for libqhull build [amorilia]
+- Renamed index to idx to avoid shadowing BSD strings.h [kwilliams]
+
+qhull 2010.0.1  2010/01/03
+
+New Features:
+ - Added option 'Ta' to annotate output with message codes
+
+Preliminary C++ support:
+ - C++ declarations may change without warning
+ - Preliminary documentation for Qhull's C++ interface [qh-code.htm#cpp, qhull-cpp.xml]
+ - Added user_eg3 as an example of Qhull.cpp
+ - Removed qhull_interface.cpp
+
+Changes to qhull options and results
+ - Allow 'd' and 'v' as the filename for 'TO ..' and 'TI ...' in qdelaunay [M. Jambon]
+ - 'rbox tN' requires an integer (previously allowed floats)
+ - Allow quoted filenames for 'TO ...' and 'TI ...'
+ - Prefix error messages and warnings with a message code (e.g., QH6012)
+ - Fixed rbox ignoring flags that were not separated by spaces
+ - Report all hidden options before exiting in qh_checkflags()
+ - Defined qh_OPTIONline [user.h] as max length of option line ('FO')
+ - Report error if negative arguments to rbox 'G', 'L', 'Z'
+ - Unknown rbox flag changed from a warning to an error
+ - Set error status 4 qh_ERRmem if rbox runs out of memory
+ - Removed extra spaces at end of line
+
+Breaking Code Changes:
+ - Renamed qh.coplanarset to coplanarfacetset.  Avoids conflict with facetT.coplanarset
+ - qh_restore_qhull() zeroes out qh.old_qhstat and qh.old_tempstack.  Ownership moved.
+ - Rewrote save_qhull/restore_qhull
+ - Add Ztotcheck to zzdef_ [R. Gardener]
+ - Changed qh_malloc to size_t (was unsigned long)
+ - Declare qh_PRINT instead of int [kwilliams]
+ - In qh_printafacet(), changed error output to 'qh ferr'
+
+Bug fixes to C code:
+ - Use gcc 4.4.0 or later.  gcc 4.2.1, 4.2.2, and 4.3.2 -O2 segfaults in qset.c .  gcc 4.1.1 was OK
+   See bug report http://gcc.gnu.org/ml/gcc-bugs/2007-09/msg00474.html
+ - Rewrite qh_setappend to avoid g++ 4.1, 4.2, and 4.3 strict_aliasing error.
+     Orion Poplawski (orion@cora.nwra.com)
+     http://www.rpmfind.net/linux/RPM/fedora/12/ppc/qhull-devel-2003.1-13.fc12.ppc64.html
+ - Fixed qh_findfacet_all(), "REALmin" should be "-REALmax" [L.A. Taylor].
+     Effects library users for convex hulls and halfspace intersections.
+ - qh_printfacet [io.c] Removed extra space for neighboring facets
+ - Report error if d points, Delaunay, and not Qz
+ - Fixed double-free of facet->centrum for triangulated facets
+ - Fixed mindist initialization if !testcentrum in io.c findbest_test [Ratcliff]
+ - Fixed parentheses around warning for missing 'Qc' [qh_initqhull_outputflags]
+ - Fixed rbox buffer overflow of 'command' when appending seedbuf
+ - Fixed option string for 'rbox t t999'.  Although seed was correctly set to 999,
+   a random seed was appended to the rbox comment (e.g., 'rbox t t999 t32343')
+ - Fixed upper bound of sanity check for qh_RANDOMmax in qh_initqhull_globals()
+
+Changes to C code
+ - Reordered #include from specific to general.  Move up .h for module.
+ - Removed qh.old_stat -- never used
+ - Removed qh_clearcenters from qh_freeqhull.  Duplicated by qh_delfacet
+ - qh_printcenter [io.c] removed unreachable fprintf argument
+ - qh_getarea() [geom2.c] ignored on multiple calls (qh.hasAreaVolume)
+ - qh_getarea() [geom2.c] checks facet->isarea. Set by QhullFacet.facetArea()
+ - qh_triangulate() [poly2.c] ignored on multiple calls (qh.hasTriangulation)
+ - Add statistics for vertex_visit and visit_id to buildtracing
+ - Defined scale and offset parameters for qh_randomfactor
+
+Bug fixes and changes to mem.c/mem.h
+ - Fixed qhmem.totshort (total short memory in use)
+ - Memory tracing (T5) redone for sort order by object
+ - Added full tracing for short memory allocations.
+ - Added qhmem.totfree (total short memory on freelists)
+     Increases size of qh_memalloc_ and qh_memfree_
+ - Added qhmem.totdropped (leftover freesize at end of each short buffer)
+ - Added qhmem.totunused (short size - request size)
+ - Added qhmem.totbuffer (total short memory buffer w/o links)
+ - Added memory statistics to qh_NOmem;
+ - Added qh_memtotal to track allocated memory
+ - Renamed qh_memfree parameter to 'insize' for consistency with qh_memalloc
+ - Removed qhmem.curlong.  qa_memfreeshort computes curlong from cntlong and cntfree
+ - In mem.h, changed ptr_intT to long.  qh_meminit() checks that it holds a 'void*'
+
+Fixed g++ and devstudio warnings
+ - Except for bit field conversions, compiles cleanly with
+   -Wall -Wextra -Wshadow -Wcast-qual -Wwrite-strings -Wno-sign-conversion -Wconversion
+ - Fixed warnings at VC8, level 4
+ - Fix data types to remove conversion warnings [kwilliams]
+ - Use size_t for calls to malloc,etc [kwilliams]
+   Retained int sizes for qset.h and mem.h.  Follows Qt convention
+   and is easier to work with.  int can be 64-bits if 2 billion facets
+ - Change literal strings to const char* [kwilliams]
+ - Added type casts to SETfirst and SETsecond [amorilia+alphax]
+ - getid_() returns an int [kwilliams]
+ - Add missing const annotations [kwilliams]
+ - Fixed 64-bit warnings (marked with "WARN64")
+ - Convert sizeof to (int) for int parameters
+ - In libqhull.c, added explicit casts from long to float,  Avoids warning
+ - In global.c, cast time() to int for QRandom-seed.  Avoids warning
+
+Changes to C code for C++ support
+ - Add sln, vcproj, and qtpro files for building Qhull -- add to README notes
+ - Added dim to vertexT for cpp interface. Reduced size of qh.vertex_visit
+ - qh_produce_output [io.c] may be called multiple times (C++ interface)
+ - Moved SETsizeaddr_() to qset.h for use by QhullSet.cpp
+ - Option 'Tz' sets flag qh.USEstdout for QhullPoints.cpp
+ - Added support for multiple output runs from QhullPoints.outputQhull
+ -   qh_clear_outputflags() resets the output flags
+ -   qh_initqhull_outputflags split from qh_initqhull_globals
+ - Added qh.run_id, a random identifier for this instance of Qhull (QhullPoints)
+ -   For qh.run_id, initqhull_start initializes qh_RANDOMseed to time instead of 1
+ - Extracted qh_argv_to_command (random.c) from qh_init_qhull_command and fixed a buffer overflow
+ - Moved qh_strtod/qh_strtol from global.c to random.c for use in rboxlib.c
+ - Split out random functions into random.c
+ - Added message codes to qh_fprintf().  See its definition in user.c
+ - Replaced exit, malloc, free, fprintf, and fputs with qh_malloc,...[J.W. Ratcliff]
+ - Added qh_fprintf, qh_malloc, qh_free, ph_printhelp_narrowhull to user.c
+ - Moved qh_printhelp_degenerate and qh_printhelp_singular from io.c to user.c
+ - Clear qh.ERREXITcalled at end of qh_errexit().
+
+Documentation:
+ - Fixed out-of-date CiteSeer references
+ - Renamed html/qh-in.htm to html/qh-code.htm
+ - Add reference to 'Qt' to 'i'
+ - Add reference to 'FS' to 'FA'
+ - qh-impre.htm discusses precision issues for halfspace intersection
+ - Add cross references between options 'FA' and 'FS'
+ - Added link to Wolfram Research's MathWorld site
+ - Updated Fukuda's links
+ - Changed copyright to C.B. Barber for C++, documentation, and merge.c
  - Updated Qhull citation with page numbers.
- - Project: constructing Voronoi diagram
- - Project: computing Voronoi volumes
- - identity function may drop points.  The following lens distribution drops 52 of 102 points of its points
-     rbox 100 L1e5 | tee r | qconvex FV n | qhalf Fp | cat - r | /bin/sort -n > x
- - offsetted points will add intersection points
-     rbox 1000 s O2 t | tee r | qconvex FV n | qhalf Fp | cat - r | /bin/sort -n | tail
+ - Proposed project: constructing Voronoi diagram
+ - Proposed project: computing Voronoi volumes
+ - Replaced tabs with spaces in qhull.txt and rbox.txt
 
+------------
+qhull 2009.1  2009/6/11
+
+This is a maintenance release done by Rafael Laboissiere <rafael@debian.org>.
+ - src/rbox.c (main): Avoid problems of evaluation order when
+   pre-incrementing arguments of strtod
+ - src/io.c (qh_produce_output), src/stat.c (qh_initstatistics): Use %lu
+   instead of %d in the format string for arguments of type size_t
+ - html/qhull.man, html/rbox.man: Fix several syntax, macros, and hyphen
+   problems in man pages
+ - The Autotools files have been generated with modern version of autoconf (2.63),
+   automake/aclocal (1.10.2), and libtool (2.2.6)
+ - Some character issues in the man pages are fixed
+
+------------
 qhull 2003.1  2003/12/30
 
 New Features:
  - Add Maple output ('FM') for 2-d and 3-d convex hulls [T. Abraham]
 
+Breaking Code Changes:
+ - Annotate C code with 'const'.  An ANSI compatible compiler is required.
+
 Bug Fixes and Code Changes:
  - Fixed qh_findbest() for upperdelaunay facets w/o better, lower neighbors
      For library users and some qhull users [A. Cutti, E. Milloti, K. Sun]
  - Preserved qhmem.ferr in qh_memfreeshort() for library users
  - Removed 'static' from qh_compare... for io.h and merge.h [V. Brumberg]
+ - Split out qh_initqhull_start2() to avoid allocating qh_qh
+ - Split out qh_freeqhull2() to avoid freeing qh_qh
+ - Split out qh_produce_output2() and qh_prepare_output()
+ - qh_initstatistics() frees a previously existing qh_qhstat
+ - qh_initqhull_start2() checks that qh_initstatistics() called first
 
 Documentation:
  - Add warning to findDelaunay() and qh_in.htm about tricoplanar facets
@@ -63,6 +317,7 @@
  - Fixed options for eg/eg.t23.voronoi.imprecise [B. Pearlmutter]
 
 
+------------
 qhull 2002.1  2002/8/20
 
 Changes to distribution:
@@ -77,14 +332,14 @@
  - Fixed sign of coefficients for cdd halfspaces ('FD','Fd')  [T. Abraham]
 
 Changes to code:
- - Replace qh_version with qh_VERSION in qhull.h.
+ - Replace qh_version with qh_VERSION in libqhull.h.
    Allows shared libraries and single point of definition
  - Added qh.TESTpoints for future implementation of tsearch
 
 Changes to build
  - Makefile.txt works under cygwin
  - Added Make-config.sh to create a Debian build [R. Laboissiere]
- - Added .exe to Makefile.txt#clean.  
+ - Added .exe to Makefile.txt#clean.
  - In README, use -fno-strict-aliasing with gcc-2.95.1 [Karas, Krishnaswami]
  - Fixed chmod in Makefile.txt [B. Karas]
 
@@ -103,6 +358,7 @@
  - Changed URL for locate/cglist to software/cglist
  - Used site relative links for qh-home.htm
 
+------------
 qhull 3.1 2001/10/04
 
 New features
@@ -123,16 +379,16 @@
      For non-simplicial regions, 'Ft' does not satisify the Delaunay property.
  - If 'Po' or 'TVn', qhull checks outer planes.  Use 'Q5' to turn off.
  - If 'T4', print facet lists and check polygon after adding each point
- 
+
 Corrections to code
  - rbox: allow 'c' and 'd' with 's r', meshes, etc.
  - qh_findbest: redesigned as directed search. qh_findbesthorizon for coplanar
       qh_findbest is faster for many distributions
  - qh_findbestnew: redesigned to search horizon of coplanar best newfacets
-      needed for distributions with a sharp edge, 
-	  e.g., rbox 1000 s Z1 G1e-13 | qhull Tv
+      needed for distributions with a sharp edge,
+          e.g., rbox 1000 s Z1 G1e-13 | qhull Tv
  - qh_findbest/qh_findbestnew: search neighbors of better horizon facets
-      was needed for RBOX 1000 s Z1 G1e-13 t996564279 | qhull Tv  
+      was needed for RBOX 1000 s Z1 G1e-13 t996564279 | qhull Tv
       and RBOX 1000 s W1e-13 P0 t996547055 | QHULL d Qbb Qc Tv
  - qh_findbest with noupper: could return an upperdelaunay facet if dist>qh.MINoutside.
  - qh_findbestnew: allow facet->upperdelaunay if dist > qh.MINoutside
@@ -146,7 +402,7 @@
  - For Delaunay & Voronoi, 's' reports deleted vertices due to facet merging.
    They were incorrectly reported as nearly incident points.
  - Warn if recompute centrum after constructing hull
- - Simplified narrow hull warning and print all digits of cosine.  
+ - Simplified narrow hull warning and print all digits of cosine.
      A narrow hull may lead to a point outside of the hull.
  - Print total vertices deleted instead of ave. per iteration (Zdelvertextot)
  - Improved tracing for qh_partitionpoint and qh_partitioncoplanar
@@ -158,15 +414,15 @@
  - README.txt: Added quickstart instructions for Visual C++
  - rbox: Added example of edge of narrow lens, rbox 1000 L100000 s G1e-6
  - Added cross references between options 'o' and 'p'.
- - qh-eg.html: added examples comparing 'Qt', 'QJ', and neither 'Qt' nor 'QJ' 
-	eg.15a.surface, eg.15b.triangle, eg.17a.delaunay.2, etc.
+ - qh-eg.html: added examples comparing 'Qt', 'QJ', and neither 'Qt' nor 'QJ'
+        eg.15a.surface, eg.15b.triangle, eg.17a.delaunay.2, etc.
  - Reorganized and enhanced discussion of precision problems in qh_impre.htm
  - Fixed spelling errors [K. Briggs]
  - Fixed link errors, validated HTML, and spell checked [HomeSite]
  - Removed unnecessary #TOP links
  - Added source links to the qh-quick.htm's header and footer
  - qh-geom.htm, qh-poly.htm: add links to Voronoi functions in io.c
- - src/index.htm: Added how to search qhull.h for qhull options
+ - src/index.htm: Added how to search libqhull.h for qhull options
  - qvoronoi.htm/qdelaun.htm: 'Fc' and 'FN' includes deleted vertices
 
 Changes to URLs
@@ -179,10 +435,10 @@
  - qh_checkpolygon: report qh.facet_next error if NARROWhull & dist>MINoutside
  - qh_findbest: renamed "newfacets" parameter to "isnewfacets" since it is boolT
  - qh_findbest/qh_findbestnew: testhorizon even if !MERGING
-        Otherwise qhull c D6 | qhull Q0 Tv assigns coplanar points 
+        Otherwise qhull c D6 | qhull Q0 Tv assigns coplanar points
  - qh_resetlists: add qh_RESETvisible for qh_triangulate
  - qh_findbest: search better facets first.  Rewritten.
- - qh_findbest: increased minminsearch, always check coplanar facets.  
+ - qh_findbest: increased minminsearch, always check coplanar facets.
         See: RBOX 1000 s Z1 G1e-13 t996564279 | QHULL Tv
  - qh_findbestnew: report precision error for deleted cones [rare event]
         e.g.:  RBOX 1000 s W1e-13 P0 t1001034076 | QHULL d Qbb Qc Tv
@@ -191,14 +447,14 @@
  - qh_partitionpoint, Delaunay sites can not be inside.  Otherwise points may
        be outside upperDelaunay facets yet not near-inside Delaunay facets
        See: RBOX s 1000 t993602376 | QHULL C-1e-3 d  Qbb FA Tv
- - qh_partitioncoplanar: call qh_findbest/qh_findbestnew with qh DELAUNAY 
- - qh_printlists: format long lines 
+ - qh_partitioncoplanar: call qh_findbest/qh_findbestnew with qh DELAUNAY
+ - qh_printlists: format long lines
  - qh_printvertex: format long lines
- - user.h: tightened qh_WARNnarrow and qh_MAXnarrow.  Do not see problems 
+ - user.h: tightened qh_WARNnarrow and qh_MAXnarrow.  Do not see problems
        until they are -1.0.
- - user.h: defined qh_DISToutside, qh_SEARCHdist, and qh_USEfindbestnew 
+ - user.h: defined qh_DISToutside, qh_SEARCHdist, and qh_USEfindbestnew
  - qh_checkfacet: in 3-d, allow #ridges > #vertices.  Can get a vertex twice
-   in a ridge list, e.g,  RBOX 1000 s W1e-13 t995849315 D2 | QHULL d Tc Tv 
+   in a ridge list, e.g,  RBOX 1000 s W1e-13 t995849315 D2 | QHULL d Tc Tv
 
 Changes to FAQ
  - Recommended use of triangulated output ('Qt')
@@ -209,17 +465,18 @@
 
 Changes to Qhull library
  - Added qh_triangulate() to poly2.c.  It triangulates the output.
- - Added option 'Q11' to copy normals and recompute centrums for tricoplanar facets 
+ - Added option 'Q11' to copy normals and recompute centrums for tricoplanar facets
         'FP' may not print the nearest vertex for coplanar points
         Use option 'Q11' when adding points after qh_triangulate()
 
+------------
 qhull 3.0 2001/02/11
 
 Changes to distribution
  - added qconvex, qdelaunay, qhalf, and qvoronoi
  - added qhull-interface.cpp on calling Qhull from C++ [K. Erleben]
- - renamed to qhull3.0/.   
- - added eg/, html/, and src/ directories 
+ - renamed to qhull3.0/.
+ - added eg/, html/, and src/ directories
 
 Changes to URLs
  - MathLab6 qhull: convhulln, delaunayn, griddatan, tsearchn, vororoin [Z. You]
@@ -237,7 +494,7 @@
 Corrections to code
  - fixed type of arg for error message in qh_initqhull_globals [N. Max]
  - fixed incorrect initialization of qh MINdenom_1 for scalepoints
- - fixed drop dim for 'H Qbk:0Bk:0'.  Added qh.feasible_point to qh_projectinput 
+ - fixed drop dim for 'H Qbk:0Bk:0'.  Added qh.feasible_point to qh_projectinput
  - qh_WARNnarrow is angle between facet normals.  Negate for warning message.
  -   statistics for Wangle/etc. concerns facet normals.  Reworded [E. Voth]
  - fixed error message for 'FC v'
@@ -262,8 +519,8 @@
  - ignore warning if options 'v i Pp'.  qvoronoi users may need Delaunay tri.
  - reworded warning if 'Pg' and 'QVn' is not a vertex.
  - reworded warning for 'Qx Tv', qh_check_points() in poly2.c
- - if 'Pp', turn off warning for 'Qbb' without 'd' or 'v' 
- - in qh_printsummary() of Voronoi and Delaunay, distinguish QVn, QGn, Pdn, PDn 
+ - if 'Pp', turn off warning for 'Qbb' without 'd' or 'v'
+ - in qh_printsummary() of Voronoi and Delaunay, distinguish QVn, QGn, Pdn, PDn
 
 Changes to FAQ
  - added FAQ item for nearly flat Delaunay triangles [Z. You]
@@ -278,19 +535,21 @@
  - added FAQ item on meshing non-convex objects
  - added FAQ item on MATLAB and Mathematica interface
 
+------------
 qhull 2.6 1999/04/19
  - fixed memory overwrite (no effect) in qh_initstatistics() [K. Ford]
  - added zdoc11 to qh-stat.h#ZZdef for !qh_KEEPstatistics [K. Ford]
  - enhanced qh_initqhull_globals() test of qh_RANDOMint and qh_RANDOMmax
  - added debugging option to always return qh_RANDOMmax from qh_rand()
- - fixed option 'Qr', qh_initialvertices(), to allow a broken qh_rand() 
-   fixed option 'Qr', qh_nextfurthest(), to allow narrow hulls  
+ - fixed option 'Qr', qh_initialvertices(), to allow a broken qh_rand()
+   fixed option 'Qr', qh_nextfurthest(), to allow narrow hulls
      Option 'Qr' simulates the random incremental algorithm for convex hulls
  - added note that qh.num_outside includes coplanar points for narrow hulls
  - added FAQ items for triangles/ridges of 3-d Delaunay triangulation[P. Kumar]
  - added FAQ item about on-line processing with the Qhull library [O. Skare]
  - changed name of option 'Error-roundoff' to 'Distance-roundoff'
 
+------------
 qhull 2.6 1998/12/30
  - for the unbounded rays of the Voronoi diagram, use a large box [Schmidt]
      e.g., 'rbox P4,4,4 P4,2,4 P2,4,4 P4,4,2 10 | qhull v Fv' fails for point 0
@@ -306,10 +565,11 @@
  - added link to Owen's Meshing Research Corner
  - added note to 'd' about quadratic size of 'rbox 100 l | qhull d' [Kumar]
  - added 'about a point' to mentions of halfspace intersection
- - added request to qh-in.htm to compute largest empty circle [Hase]
+ - added request to qh-code.htm to compute largest empty circle [Hase]
  - the DOS window in Windows NT is better than the DOS window in Windows 95
  - removed obsolete qh_findfacet() from qh-c.htm [Sminchisescu]
 
+------------
 qhull 2.6 1998/8/12
  new and modified features
  - rbox: added option Mn,m,r to generate a rotated lattice or mesh
@@ -319,7 +579,7 @@
  - added qh_new_qhull() to user.c for calling qhull() from a program [D. Zwick]
    rewrote user_eg.c to use qh_new_qhull().  Added qh_QHpointer example.
  - added qh_CLOCKtype 2 in user.h to call times() for CPU time [B. Hemkemeier]
- - renamed set.c/set.h to avoid conflict with STL's set.h [G. van den Bergen] 
+ - renamed set.c/set.h to avoid conflict with STL's set.h [G. van den Bergen]
    can also use '#include <qhull/qhull_a.h>' for Qhull library
 
  fixed errors
@@ -340,12 +600,13 @@
  - added .c and .h source files to web distribution and qh-c.htm [J. Sands]
  - documented qh_ZEROdelaunay.  Delaunay and Voronoi diagrams do not include
    facets that are coplanar with the convex hull of the input sites.
-  
+
  modified code
  - replaced computed minnorm in qh_sethyperplane_det with distance test
  - removed 'qh rand_seed' since random number generator is independent of qhull
  - dropt 'qhull-PPC.sit.bin' from the distribution (out-of-date) [M. Harris]
 
+------------
 qhull 2.5 1998/5/4
 
  fixed errors
@@ -362,7 +623,8 @@
  - to browse qh-c.htm, set MIME type of .c and .h files to text/html
  - added example of 3-d Delaunay triangulation to q-faq.htm
  - added Delaunay and Voronoi examples to qh-optv.htm
- 
+
+------------
 qhull 2.5 1998/2/4
  - added option 'v Fi' for separating hyperplanes of bounded Voronoi regions
  - added option 'v Fo' for separating hyperplanes of unbounded Voronoi regions
@@ -371,24 +633,24 @@
  - fixed missing statistics in qh_allstat* [T. Johnson]
  - rearranged qh_printvdiagram.  Use qh_eachvoronoi to iterate Voronoi ridges.
  - added qh_check_points to qh-math.c
- 
+
 qhull 2.5 1998/1/28
  - added option 'Fv' to print the Voronoi diagram
  - added rbox option 'x' to generate random points in a simplex
  - added rbox option 'y' to generate a simplex and random points
- - added rbox option 'On' to offset the output 
+ - added rbox option 'On' to offset the output
  - add unpacking instructions to README.txt
  - updated discussion of forced output, 'Po'
  - sorted the options alphabetically
- - removed __STDC__ check from qhull.h for VisualC++
+ - removed __STDC__ check from libqhull.h for VisualC++
  - moved qh_markvoronoi from qh_printvoronoi and cleared facet->seen flags
  - added facet->seen2 flag for 'Fv'
 
 qhull 2.5 1998/1/16
- - fixed initialization of qh.last_low on restart of 'd QJ' 
+ - fixed initialization of qh.last_low on restart of 'd QJ'
  - renamed qh_JOGGLEmax to qh_JOGGLEmaxincrease
  - updated URL for Fukuda's cdd program
-  
+
 qhull 2.5 1998/1/12
 
 New or modified features
@@ -404,14 +666,14 @@
  - for Mathematica 2.2 ('m') changed %10.8g to %16.8f [A. Zhaxybayev]
  - fixed incorrect warning for 'QV0 Qg' in qh_initbuild [B. Wythoff]
  - fixed unaccessible statistic if !qh_KEEPstatistics for Wnewvertexmax
- - fixed overestimate of qh ONEmerge for point sets outside of 
+ - fixed overestimate of qh ONEmerge for point sets outside of
      first quadrant and far from the origin
  - fixed overestimate of 'Qbb' for point sets far from the origin
  - fixed potential overestimate of qh DISTround under 'Qbb'
  - fixed 'p' printing coplanar points of unselected facets
  - fixed 'Ft' printing centrums unnecessarily in 2-d
-  
-Changes to documentation 
+
+Changes to documentation
  - wrote internal design documentation (qh-c.htm)
  - started frequently asked questions (qh-faq.htm)
  - added a section on joggled input to qh-impre.htm
@@ -421,10 +683,10 @@
  - added examples to rbox.htm
  - added examples to the synopsis
  - added a reference to Mucke, et al ['96], Fast randomized point location ...
- - added code for printing Delaunay triangles to qh-in.htm [A. Tsui]
+ - added code for printing Delaunay triangles to qh-code.htm [A. Tsui]
  - options 'Pdk' and 'PDk' do not drop on equality
 
-Improvements to the code 
+Improvements to the code
  - reviewed warning messages for Qhull options in qh_initflags
  - added warning to 's' if premature exit from 'TCn' or 'TVn'
  - 's' prints max distance above/below only if qh.MERGING
@@ -434,7 +696,7 @@
  - removed qh_check_maxout for 'Wn Q0'
  - reset tracing after 'TPn' adds point in 4-d and higher
 
-Changes for the Qhull library 
+Changes for the Qhull library
  - changed qh_setdelaunay to call qh_scalelast if used with 'Qbb' or 'QJ'
      Delaunay callers to qh_findbestfacet, qh_addpoint, or qh_findfacet_all
      should always use qh_setdelaunay as in user_eg.c
@@ -442,7 +704,7 @@
  - added header to user_eg.c to avoid its incorporation into qhull [C. Begnis]
  - added qh_nearcoplanar() calls to user_eg.c
      only needed if use 'QJ'
- - expanded __STDC__ warning message in qhull.h [C. Begnis]
+ - expanded __STDC__ warning message in libqhull.h [C. Begnis]
  - renamed qh maxmaxcoord to qh MAXabs_coord
  - replaced qh MAXlowcoord with qh MAXabs_coord
  - random seed ('QR-n') is reset in qh_initqhull_globals after testing
@@ -450,7 +712,7 @@
 
 Other changes to Qhull functions
  - report error for !bestfacet in qh_findbest (it shouldn't happen) [H. Meuret]
- - set newbest in qh_findbest only if bestfacet updated 
+ - set newbest in qh_findbest only if bestfacet updated
  - renamed facet parameter for qh_findbest
  - added maxdist argument to qh_checkpoint
  - moved 'FO' output after qh_partitionall
@@ -464,11 +726,12 @@
  - separated qh_distround and qh_detroundoff from qh_maxmin
 
 
+------------
 qhull 2.4 97/4/2
 
 New or modified features
  - made 'C-0' and 'Qx' default options.  Use 'Q0' to not handle roundoff errors
- - removed point-at-infinity from Delaunay/Voronoi.  
+ - removed point-at-infinity from Delaunay/Voronoi.
      you no longer need to use 'Qu PDk'
  - added 'Qz' to add a point-at-infinity to Delaunay and Voronoi constructions
  - added published version of qhull article in ACM Trans Math Software
@@ -478,7 +741,7 @@
  - changed definition of coplanar point in output to qh min_vertex (see 'Qc')
      it was qh MAXcoplanar ('Un') [could make vertices non-coplanar]
  - automatically set 'Qi' for options 'd Qc' and 'v Qc'.
- - reworded summary ('s') for Delaunay/Voronoi/halfspace.  
+ - reworded summary ('s') for Delaunay/Voronoi/halfspace.
      use 'Fs' and 'FS' for summary statistics.
  - for summary 's' of Delaunay/Voronoi, display number of coplanars for facets
      if none, display total number of coplanars (i.e., non-vertices)
@@ -490,23 +753,23 @@
  - fixed qh_partitioncoplanar() to not drop interior points if 'Qi' is used
  - fixed 'FP d' to report distance in point set instead of paraboloid
  - fixed qh_findbest() to search all coplanar facets for qh_check_maxout()
-  
-Changes to documentation 
+
+Changes to documentation
  - added example eg.17f.delaunay.3 to show a triangulation of cospherical sites
  - split up qh-opt.htm into multiple pieces
- - split off qh-in.htm for Qhull internals
+ - split off qh-code.htm for Qhull code
  - renamed .html files to .htm for Windows95
  - rewrote qh-optv.htm on Delaunay triangulation and Voronoi vertices
  - added 'man' pages qhull.txt and rbox.txt.  These list all the options
  - removed 'txt' versions of html files
  - added note to 'PDk' about avoiding a 'd' option immediately after a float
  - under option 'd', display the triangulation with 'GrD3', not 'GnrD3'
- 
+
 Changes to the Qhull library
  - added 'format' argument to qh_printfacetNvertex_nonsimplicial() in io.c
  - removed C++ type errors [J. Stern, S. Marino]
- -  created SETelemt, SETfirstt, etc. for specifying data types.  
- -  use SETelem,etc. for assignments. 
+ -  created SETelemt, SETfirstt, etc. for specifying data types.
+ -  use SETelem,etc. for assignments.
  -  changed setT.maxsize to 'int' to prevent type conversion warnings
  -  changed FOREACH.. to a comma expression for better code and less warning
  -  changed qh.vertex_visit and .visit_id to unsigned int to prevent warnings
@@ -523,11 +786,12 @@
  - added request for unbounded Voronoi rays to Enhancements
     please let me know if you try this
 
+------------
 qhull V2.3 96/6/5
- - fixed total area of Delaunay triangulation. [A. Enge]  
+ - fixed total area of Delaunay triangulation. [A. Enge]
       It should ignore facets on the upper-envelope.
  - if 'd Qu FA', the total area is summed over the upper-Delaunay triangles
- - fixed sign of area for Delaunay triangulations. 
+ - fixed sign of area for Delaunay triangulations.
  - fixed cdd input format for Delaunay triangulation. [A. Enge]
  - for cdd input, allow feasible point for halfspaces.
  - warning if cdd output format for centrums, halfspace intersections, or OFF.
@@ -535,7 +799,7 @@
  - option 'QR-n' sets random number seed to n without rotating input
  - fixed qh_findbest() to retest coplanar and flipped facets after a restart
  - for 'd Qu Ts' collects angle statistics for upper Delaunay facets
- 
+
  Changes to the Qhull library
  - expanded user_eg.c for incremental constructions and Delaunay triangulation
  - added discussion of incremental construction to qh_man.html#library
@@ -544,9 +808,9 @@
          Please set qh ATinfinity if you explicitly add the point "at-infinity"
          Please set qh ATinfinity if you explicitly call qh_projectinput.
          Please set qh UPPERdelaunay if you explicitly cleared qh ATinfinity.
-	 Other users do not need to change their code.         
-   Now you can build a Delaunay triangulation without creating a point 
-   "at-infinity".  This removes a potential, hard-to-understand error.  
+         Other users do not need to change their code.
+   Now you can build a Delaunay triangulation without creating a point
+   "at-infinity".  This removes a potential, hard-to-understand error.
    qh_readpoints sets qh ATinfinity for options 'd' or 'v' without 'Qu'.
    qh_initB sets qh ATinfinity for qh PROJECTdelaunay w/o qh UPPERdelaunay.
    qh_projectinput adds a point "at-infinity" only if qh ATinfinity is set.
@@ -562,6 +826,7 @@
  - fixed qh_projectinput for furthest-site Delaunay (qh PROJECTdelaunay 'd Qu')
  - added voids to procedure declarations with empty parameter lists
 
+------------
 qhull V2.3 96/3/25
  - fixed missing qh_check_maxout when coplanar points and no merged facets.
  - fixed qh_freeqhull/allmem (e.g., if qh_NOmem) [only custom code] [E. Voth]
@@ -577,9 +842,10 @@
  - moved 'FO' print of options to just before qh_buildhull
  - changed 'FO' to list difference from -1 for _narrow-hull
 
+------------
 qhull V2.2 96/2/15
  - detect narrow initial hulls (cosine of min angle < qh_MAXnarrow in user.h).
-   Write warning if cosine < qh_WARNnarrow in user.h.  If narrow (qh NARROWhull), 
+   Write warning if cosine < qh_WARNnarrow in user.h.  If narrow (qh NARROWhull),
    partition coplanar points as outside points and delay coplanar test to end.
    Needed for  RBOX 1000 L100000 s G1e-6 t995127886 | QHULL Tv
    See 'limitations' in qh-impre.html for further discussion.
@@ -596,12 +862,13 @@
  - added option 'Q9' to always process furthest of furthest outside points.
  - removed option 'Pp' from q_eg and qh-eg.html.
 
+------------
 qhull V2.2 95/12/28
  - added option 'Qbb' to scale the last coordinate to [0,m] (max prev coord).
    This reduces roundoff errors for Delaunay triangulations with integer coordinates.
  - changed option 'Qu d' to print out the furthest-site Delaunay triangulation
    Use options 'Qu d PD2' to compute the normal 2-d Delaunay triangulation without
-   the point at infinity. 
+   the point at infinity.
  - added notes to the documentation of option 'd'
  - added notes to limitations of how Qhull handles imprecision
  - added warning if options 'FP', 'Fc', or 'Gp' without option 'Qc' or 'Qi'
@@ -612,7 +879,7 @@
  - fixed option 'QbB' (qh SCALEpoints was not set)
  - fixed minor confusion between 'Gc' (print centrums) and 'Gp' (print points)
  - rewrote qh_findbestnew for upper convex hull, Delaunay facets
- - changed option name for 'Gp' from 'Gcoplanar' to 'Gpoints' 
+ - changed option name for 'Gp' from 'Gcoplanar' to 'Gpoints'
  - changed "nearest" facet for 'Pdk' to threshold - normal
  - reworked qh GOODclosest for 'Qg'
  - added note that 'Qg' does not always work
@@ -620,26 +887,26 @@
  - refined qh DISTround in qh_maxmin/geom2.c for Delaunay triangulations
 
 qhull V2.2 95/12/4
- - Version 2.2 fixes an important bug in computing Delaunay triangulations 
-   and convex hulls with edges sharper than ninety degrees.  The problem 
-   occurs when processing a point at a sharp edge.  A directed search can 
-   not be used for partitioning because one side may hide facets from the 
-   other side.  The new lens-shaped distribution for rbox demonstrates the 
+ - Version 2.2 fixes an important bug in computing Delaunay triangulations
+   and convex hulls with edges sharper than ninety degrees.  The problem
+   occurs when processing a point at a sharp edge.  A directed search can
+   not be used for partitioning because one side may hide facets from the
+   other side.  The new lens-shaped distribution for rbox demonstrates the
    problem.  For example, 'rbox 100 L3 G0.5 s | qhull Tv' fails for Version 2.1.
    O. Schramm found the bug when computing the Delaunay triangulation of points
-   near an outside edge.  
+   near an outside edge.
 
-   I rewrote qh_findbest and related functions.  Qh_findbest 
-   uses an exhaustive test for sharp edges (qh_findbest_sharp).  
+   I rewrote qh_findbest and related functions.  Qh_findbest
+   uses an exhaustive test for sharp edges (qh_findbest_sharp).
    Qh_findbest avoids the upper convex hull of Delaunay triangulations.
 
    Options 'd' and 'v' no longer assign coplanar points to the upper convex hull.
-    
+
    Qh_check_maxout tests near-inside points.  It ignores fully inside points.
    When done, it removes near-inside points from the coplanar sets.
 
-   If you use qh_addpoint or qh_findbest, please review the function headers.  
-   They do not work for lens-shaped hulls for arbitrary facets.  They do work for 
+   If you use qh_addpoint or qh_findbest, please review the function headers.
+   They do not work for lens-shaped hulls for arbitrary facets.  They do work for
    Delaunay triangulations.
 
  Changes to options for V2.2
@@ -648,7 +915,7 @@
  - added 'FP' to print nearest vertex for coplanar points
  - added coplanar count to 'Fs' and 's'
  - added number of similar points to summary for Delaunay/Voronoi
- - Option 'Qc' is no longer necessary when merging.  
+ - Option 'Qc' is no longer necessary when merging.
  - 'o' format for Voronoi vertices ('v') generates "0" lines for similar points
  - 'QRn' for Delaunay ('d' or 'v') now rotates about the Z axis (see qh_init_B).
    Otherwise Qhull does not identify the upper hull
@@ -656,7 +923,7 @@
    set for 'd'.  Even though it was a bad idea, it revealed the above bug.
  - for option list ('FO'), added version, values for one-merge, maxpos, maxneg,
    and near-inside, and flags for zero-centrum
- - optimized 'C-0' and 'Qx'.  These options ("zero-centrum") test vertices 
+ - optimized 'C-0' and 'Qx'.  These options ("zero-centrum") test vertices
    instead of centrums for adjacent simplicial facets.
  - if 'Tv', report number of points that are not verified due to qh_findbest
  - Option 'Q8' ignores near-inside points.
@@ -671,9 +938,9 @@
    and renumbered the examples for q_eg
  - described facet orientation in 'data structure' section [P. Soikkonen]
  - added notes to qh-man.html/"What to do if something goes wrong"
- - added note about using 'Tv' to verify the results [O. Schramm] 
+ - added note about using 'Tv' to verify the results [O. Schramm]
  - expanded definition of f_r in Performance section [S. Grundmann]
- - noted that Geomview display of a Voronoi diagram adds extra edges 
+ - noted that Geomview display of a Voronoi diagram adds extra edges
    for unbounded Voronoi cells
  - rewrote error "convexity constraints may be too strong" [D. Newland]
  - added limitations section to "Imprecision in Qhull"
@@ -696,7 +963,7 @@
 
  Changes for users of the Qhull library
  - user code needs to define qh_version (see user_eg.c)
- - merged initialization code into qh_init_A and qh_init_B [M. Mazzario] 
+ - merged initialization code into qh_init_A and qh_init_B [M. Mazzario]
    old code works as before.
    qh_initflags also sets qh qhull_command for qh_initthresholds
    redid initialization for user_eg.c
@@ -733,10 +1000,11 @@
  - reorganized split between poly/poly2.c and geom/geom2.c
  - reordered object files in Makefile
 
+------------
 qhull V2.1 95/9/25
  - converted qhull.man to html format, many edits
  - referenced Shewchuk's triangle program and Schneiders' Mesh Generation page
- - added option 'Qa' to force all points outside 
+ - added option 'Qa' to force all points outside
      automatically set for "precise" Delaunay or Voronoi [Salazar & Velez]
      it is turned off by merging, 'Wn', 'Qc' or 'Qi'
  - added coplanar points to option 'FN'
@@ -756,7 +1024,7 @@
 
  other documentation changes:
  - new URLs for graphics images
- - fixed comment for facetT.neighbors in qhull.h [P. Soikkonen]
+ - fixed comment for facetT.neighbors in libqhull.h [P. Soikkonen]
  - changed recommendations for precision errors in qh_printhelp_degenerate()
  -  added recommendation for 'V0' (facet is visible if distance >= 0)
  - added note about 'long double' to user.h [S. Grundmann]
@@ -764,11 +1032,12 @@
  - added note about locating Delaunay triangles to option 'd' [A. Curtis]
  - added note that coplanar vertices correspond to duplicate points for 'd'
  - added note about option 'd' automatically setting 'PDk' (lower convex hull)
- - added note about precision errors to option 'd' [many users] 
+ - added note about precision errors to option 'd' [many users]
  - added note about qh_findbest() to the Qhull library section [L. Lai]
  - 'make install' renames qhull.man to qhull.1 for Unix [M. Phillips]
  - renamed README, etc. to *.txt to match WWW conventions [D. Cervone]
 
+------------
 qhull V2.1 7/10/95
   - in 2-d, 'v o' lists the vertex at infinity in order [R. Critchlow]
   -   it used to always list the vertex at infinity ("0") first
@@ -792,7 +1061,7 @@
   - fixed cast in qh_point and qh_pointid for 64-bit architectures
   - fixed URL for Amenta's list of computational geometry software
   - fixed cast in qh_meminitbuffers for qhmem.freelists
-  - added test for !qh half_space in qh readpoints 
+  - added test for !qh half_space in qh readpoints
   - clarified options for qh_printhelp_singular()
   - discussed non-simplicial facet area under option 'Fa' in qhull.1
 
@@ -805,9 +1074,9 @@
 
 qhull V2.1 beta 5/15/95
 
-		======= main changes ========
+                ======= main changes ========
   - added halfspace intersection ('Hn,n,n')
-  - facet merging is better, especially for high dimensions 
+  - facet merging is better, especially for high dimensions
   -   added 'Qx' for exact merges of coplanar points and precision faults
   - facet merging is faster, especially for high dimensions.
       e.g., convex hull of the 8-d hypercube is seven times faster
@@ -827,12 +1096,12 @@
   - added 'Un' option to set width of facet for coplanar points.
        This replaces the previous rules for determining coplanar points.
   - changed default MINoutside ('Wn') to twice MINvisible ('Vn')
-  - Geomview output adjusts point radii for MINvisible 'Vn' 
+  - Geomview output adjusts point radii for MINvisible 'Vn'
   - the input format allows the number of points to precede the dimension
   - options 'v' 'd' 'FAn' and 'FMn' record good facets ('Pg')
   - added 'Fd' and 'FD' options for homogeneous coordinates in cdd format
   -   in rbox, added 'h' flag to generate homogeneous coordinates in cdd format
-  - option 'PAn' prints out the n facets with the largest area 
+  - option 'PAn' prints out the n facets with the largest area
   - option 'PMn' prints out the n facets with the most merges
   - option 'Po' under tracing ('Tn') no longer tries to write erroneous facets
   - option 'TCn' only prints the old 'visible' facets for 'f'
@@ -846,18 +1115,18 @@
   - added 'Q4' to avoid merges of old facets into new facets (does worse)
   - added 'Q5' to skip qh_check_maxout (faster, but less accurate)
   - added 'Q6' to skip pre-merge of concave and coplanar facets
-  - added 'Qv' for testing vertex neighbors for convexity (needs merge option) 
+  - added 'Qv' for testing vertex neighbors for convexity (needs merge option)
   - added warning if mix Geomview output with other outputs ('Po' turns off)
   - options 'o v' for 3-d and higher sort the Voronoi vertices by index
 
-		======= documentation =======
-  - rewrote the introduction and precision sections 
+                ======= documentation =======
+  - rewrote the introduction and precision sections
   - added a section on performance
   - added an example on halfspace intersection
   - installed examples of Qhull in
     <http://www.geom.uiuc.edu/graphics/pix/Special_Topics/Computational_Geometry/>
 
-		======= Makefile, user.h, and messages =======
+                ======= Makefile, user.h, and messages =======
   - Makefile calls ./qhull, ./rbox, and prints short prompt for qhull
   - added new statistics, e.g., for buildhull
   - changed default qh_RANDOMtype to RAND_MAX with rand()
@@ -868,8 +1137,8 @@
   - option in user.h (qh_NOmerge) to turn off merging in qhull.
   -   use this instead of redefining qh_merge_nonconvex in user.c
   - simplified user_eg.c.  See qh_call_qhull() in user.c for the full version
-  
-		======== bug fixes ============
+
+                ======== bug fixes ============
   - fixed error in number of points for 'rbox 100 r' (odd distribution)
   - fixed performance error in qh_degen_redundant_neighbors
   - qh_partitionpoint now sets facet->maxoutside for first outside point
@@ -879,8 +1148,8 @@
   - forcing output on error ('Po') fixed for options 'n' 'o' 'i' 's'
   - fixed optimization error on HP machines [fprintf(... *p++)]
 
-                ======== changes to qhull.h for user code =======
-  - qh_collectstatistics and qh_printstatistics removed from qhull.h.
+                ======== changes to libqhull.h for user code =======
+  - qh_collectstatistics and qh_printstatistics removed from libqhull.h.
       should use qh_printallstatistics instead
   - qh_findbest uses boolT for newfacets
   - added qh_findbestnew for non-simplicial facets.  qh_findbest is
@@ -891,8 +1160,8 @@
   - added facet->f for facet pointers while merging and for facet area
   - added dfacet/dvertex for printing facets/vertices while debugging
   - added qh_produce_output and qh_printsummary
-   
-		======== changes to code ==========
+
+                ======== changes to code ==========
   - moved qh_setfacetplane from qh_makenewfacets to qh_makenewplanes
   - added qh_setfree2, qh_setcompact, and qh_setduplicate to set.c
   - qh_findgooddist returns list of visible facets instead of setting global
@@ -904,7 +1173,7 @@
   - uses facet->dupridge to indicate duplicated ridges instead of ->seen
   - qh_buildtracing records CPU time relative to qh hulltime instead of 0
 
-		========== changes to merging =======
+                ========== changes to merging =======
   - many performance improvements, especially in high-d.
   - when merging, qh_findbest and qh_findbestnew stops search at qh_DISToutside
   - vertex neighbors delayed until first merge
@@ -923,7 +1192,7 @@
   - removed angle argument from qh_merge_degenredundant and qh_mergefacet
        only used for tracing
   - getmergeset_initial had extra test of neighbor->simplicial
-  - ridge->nonconvex is now set on only one ridge between non-convex facets 
+  - ridge->nonconvex is now set on only one ridge between non-convex facets
   - moved centrum deletion to qh_updatetested
   - qh_isnewmerge(facet) changed to facet->newmerge (removed NEWmerges)
   - qh_findbestneighbor reports correct distance even if testcentrum
@@ -931,6 +1200,7 @@
   - removed horizon preference in qh_merge_nonconvex (qh AVOIDold)
   - facet->keepcentrum if qh WIDEfacet or qh_MAXnewcentrum extra vertices
 
+------------
 qhull V2.02 1/25/95
   - rbox 'z' prints integer coordinates, use 'Bn' to change range
   - fixed rare bug in qh_check_maxout when qh_bestfacet returns NULL
@@ -947,6 +1217,7 @@
   - added options for qh_RANDOMint in qhull_a.h
   - changed time format for 'TFn' to %02d
 
+------------
 qhull V2.01 6/20/94
   - fixed bug in qh_matchnewfacets that occured when memory alignment makes
     facet->neighbors larger than necessary.
@@ -958,31 +1229,31 @@
   - added an input warning to qh_check_points ('Tv') if coplanars and no 'Qc'
   - qh_partitionpoint: always counts coplanar partitions (Zcoplanarpart)
   - rewrote qh_printhelp_degenerate to emphasize option 'C-0'
-  - For Geomview output, roundoff is not needed when printing the inner and 
+  - For Geomview output, roundoff is not needed when printing the inner and
     outer planes.  This improves Geomview output for the 'Rn' option.
-  - For Geomview output without coplanar points or vertices, qh_GEOMepislon 
+  - For Geomview output without coplanar points or vertices, qh_GEOMepislon
     is not needed.  This removes the edge gap when displaying a Voronoi cell.
-  - For Geomview output 'Gp', direct vertices to the interior point 
+  - For Geomview output 'Gp', direct vertices to the interior point
     instead of the arithmetic center of the displayed vertices.
-    
+
 qhull V2.01 6/11/94
-  - if pre-merge, 'Qf' is automatically set.  Otherwise an outside point may 
+  - if pre-merge, 'Qf' is automatically set.  Otherwise an outside point may
         be dropt by qh_findbest().  This slows down partitioning.
   - always use 'Qc' if merging and all facet->maxoutside's must be right.
         Otherwise distributions with many coplanar points may occassionally
-	miss a coplanar point for a facet.  This is because qh_findbest, when 
-	called by qh_check_maxout, can become stuck at a local maximum if 
-	the search is started at an arbitrary facet.  With 'Qc', the search 
-	is started from a coplanar facet.  For example,
-		rbox 1000 W8e-6 t | qhull C-0 Tv
-	will (rarely) report that a facet->minoutside is incorrect
+        miss a coplanar point for a facet.  This is because qh_findbest, when
+        called by qh_check_maxout, can become stuck at a local maximum if
+        the search is started at an arbitrary facet.  With 'Qc', the search
+        is started from a coplanar facet.  For example,
+                rbox 1000 W8e-6 t | qhull C-0 Tv
+        will (rarely) report that a facet->minoutside is incorrect
   - option 'Pp' turns off "Verifying" message for 'Tv'
   - added qh_copynonconvex to qh_renameridgevertex (fixes rare error)
   - 'rbox tn' sets random seed to n
   - 'rbox t' reports random seed in comment line
   - qh_errexit reports rbox_command | qhull_command and 'QR' random seed
   - added additional tracing to bestdist and setfacetplane
-  - in qh_checkconvex, need to test coplanar against 0 instead of -DISTround 
+  - in qh_checkconvex, need to test coplanar against 0 instead of -DISTround
   - in qh_checkconvex, always test centrums if merging.  The opposite
     vertex of a simplicial facet may be coplanar since a vertex of
     a simplicial facet may be above the facet's hyperplane.
@@ -993,19 +1264,19 @@
 qhull V2.01 6/2/94
   - 's' prints summary to stderr
   - multiple output formats printed in order to stdout
-  - added statistic for worst-case distance for merging simplicial facets 
-       	can not hope for a better "max distance above/below facet"
+  - added statistic for worst-case distance for merging simplicial facets
+        can not hope for a better "max distance above/below facet"
         print factor for "max distance.."/"merge simplicial" in printsummary
   - fixed error in scaling input with min/max reversed ('Qb0:1B0:-1')
   - fixed error in scaling if project & Delaunay & scale ('d Qb0:0B1:0b2:0')
   - user_eg.c: qh_delpoint removed since it does not always work
   - user_eg.c now works for either convex hull or Delaunay triangulation
   - added PROJECTdelaunay for Delaunay triangulations and Voronoi diagrams
-	with libqhull.a and user_eg.c
+        with libqhull.a and user_eg.c
   - user_eg.c: if project or scale input, need to copy points
   - user_eg.c: default just defines main, added fprintf's for qh_errprint etc.
   - qh_gausselim: a 0 pivot no longer zeros the rest of the array,
-	  need the remaining elements for area computation
+          need the remaining elements for area computation
   - qh_qhull: restore cos_max, centrum_radius at end of POSTmerging
   - qh_checkflipped with !allerror is >=0.0 instead of >0.0
   - removed -Wall from gcc due to unnecesssary "warning: implicit declaration"
@@ -1014,22 +1285,23 @@
   - updated manual on 'Qg' with coplanar facets and no merging ('rbox c D7')
       'Qg Pg' and 'Pg' produce different results because of precision problems
 
+------------
 Converting from qhull 1.01 to qhull 2.00
   - 'qhull An' is now 'qhull Wn'
-	option 'Wn Po' is faster but it doesn't check coplanars
+        option 'Wn Po' is faster but it doesn't check coplanars
   - 'qhull g' is now 'qhull G', and the output formats are different
   - 'qhull c' is now 'qhull Tc'
   - 'qhull f' is now 'qhull Qf'
   - 'qhull o' is now 'qhull Po'
   - 'qhull b' is now always done
-  - qhull and rbox now use floats, change REALfloat in qhull.h for doubles
+  - qhull and rbox now use floats, change REALfloat in libqhull.h for doubles
   - qhull 2.00 fixes several initialization errors and performanace errors
-	e.g., "singular input" on data with lots of 0 coordinates
+        e.g., "singular input" on data with lots of 0 coordinates
   - 'rbox b' is now 'rbox c G0.48'
   - all rbox distributions are now scaled to a 0.5 box (use 'Bn' to change)
   - rbox now adds a comment line.  This may be removed by 'rbox n'
   - 'rbox r s Z G' no longer includes the positive pole
-  - no changes to the Macintosh version 
+  - no changes to the Macintosh version
 
 qhull V2.00 5/23/94
   - if force output ('Po'), facet->maxoutside= 'Wn' since coplanars not updated

Modified: trunk/scipy/spatial/qhull/src/geom.c
===================================================================
--- trunk/scipy/spatial/qhull/src/geom.c	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/geom.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,40 +1,43 @@
 /*<html><pre>  -<a                             href="qh-geom.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-   geom.c 
+   geom.c
    geometric routines of qhull
 
    see qh-geom.htm and geom.h
 
-   copyright (c) 1993-2003 The Geometry Center        
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/geom.c#29 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 
    infrequent code goes into geom2.c
 */
-   
+
 #include "qhull_a.h"
-   
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="distplane">-</a>
-  
+
   qh_distplane( point, facet, dist )
     return distance from point to facet
 
   returns:
     dist
     if qh.RANDOMdist, joggles result
-  
-  notes:  
+
+  notes:
     dist > 0 if point is above facet (i.e., outside)
-    does not error (for sortfacets)
-    
+    does not error (for qh_sortfacets, qh_outerinner)
+
   see:
     qh_distnorm in geom2.c
+    qh_distplane [geom.c], QhullFacet::distance, and QhullHyperplane::distance are copies
 */
-void qh_distplane (pointT *point, facetT *facet, realT *dist) {
+void qh_distplane(pointT *point, facetT *facet, realT *dist) {
   coordT *normal= facet->normal, *coordp, randr;
   int k;
-  
-  switch(qh hull_dim){
+
+  switch (qh hull_dim){
   case 2:
     *dist= facet->offset + point[0] * normal[0] + point[1] * normal[1];
     break;
@@ -50,7 +53,7 @@
   case 6:
     *dist= facet->offset+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]+point[5]*normal[5];
     break;
-  case 7:  
+  case 7:
     *dist= facet->offset+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]+point[5]*normal[5]+point[6]*normal[6];
     break;
   case 8:
@@ -59,7 +62,7 @@
   default:
     *dist= facet->offset;
     coordp= point;
-    for (k= qh hull_dim; k--; )
+    for (k=qh hull_dim; k--; )
       *dist += *coordp++ * *normal++;
     break;
   }
@@ -72,9 +75,9 @@
       qh RANDOMfactor * qh MAXabs_coord;
   }
   if (qh IStracing >= 4) {
-    fprintf (qh ferr, "qh_distplane: ");
-    fprintf (qh ferr, qh_REAL_1, *dist);
-    fprintf (qh ferr, "from p%d to f%d\n", qh_pointid(point), facet->id);
+    qh_fprintf(qh ferr, 8001, "qh_distplane: ");
+    qh_fprintf(qh ferr, 8002, qh_REAL_1, *dist);
+    qh_fprintf(qh ferr, 8003, "from p%d to f%d\n", qh_pointid(point), facet->id);
   }
   return;
 } /* distplane */
@@ -82,15 +85,15 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="findbest">-</a>
-  
+
   qh_findbest( point, startfacet, bestoutside, qh_ISnewfacets, qh_NOupper, dist, isoutside, numpart )
-    find facet that is furthest below a point 
+    find facet that is furthest below a point
     for upperDelaunay facets
       returns facet only if !qh_NOupper and clearly above
 
   input:
     starts search at 'startfacet' (can not be flipped)
-    if !bestoutside (qh_ALL), stops at qh.MINoutside
+    if !bestoutside(qh_ALL), stops at qh.MINoutside
 
   returns:
     best facet (reports error if NULL)
@@ -101,7 +104,7 @@
 
   see also:
     qh_findbestnew()
-    
+
   notes:
     If merging (testhorizon), searches horizon facets of coplanar best facets because
     after qh_distplane, this and qh_partitionpoint are the most expensive in 3-d
@@ -116,11 +119,11 @@
     qh_findbestnew set if qh_sharpnewfacets returns True (to use qh_findbestnew)
     qh.bestfacet_notsharp set if qh_sharpnewfacets returns False
 
-  when called by qh_findfacet(), qh_partitionpoint(), qh_partitioncoplanar(), 
+  when called by qh_findfacet(), qh_partitionpoint(), qh_partitioncoplanar(),
                  qh_check_bestdist(), qh_addpoint()
     indicated by !qh_ISnewfacets
     returns best facet in neighborhood of given facet
-      this is best facet overall if dist > -   qh.MAXcoplanar 
+      this is best facet overall if dist > -   qh.MAXcoplanar
         or hull has at least a "spherical" curvature
 
   design:
@@ -128,15 +131,15 @@
     repeat while there are better facets
       for each neighbor of facet
         exit if outside facet found
-	test for better facet
+        test for better facet
     if point is inside and partitioning
       test for new facets with a "sharp" intersection
       if so, future calls go to qh_findbestnew()
     test horizon facets
 */
-facetT *qh_findbest (pointT *point, facetT *startfacet, 
-		     boolT bestoutside, boolT isnewfacets, boolT noupper,
-		     realT *dist, boolT *isoutside, int *numpart) {
+facetT *qh_findbest(pointT *point, facetT *startfacet,
+                     boolT bestoutside, boolT isnewfacets, boolT noupper,
+                     realT *dist, boolT *isoutside, int *numpart) {
   realT bestdist= -REALmax/2 /* avoid underflow */;
   facetT *facet, *neighbor, **neighborp;
   facetT *bestfacet= NULL, *lastfacet= NULL;
@@ -146,21 +149,21 @@
   boolT testhorizon = True; /* needed if precise, e.g., rbox c D6 | qhull Q0 Tv */
 
   zinc_(Zfindbest);
-  if (qh IStracing >= 3 || (qh TRACElevel && qh TRACEpoint >= 0 && qh TRACEpoint == qh_pointid (point))) {
+  if (qh IStracing >= 3 || (qh TRACElevel && qh TRACEpoint >= 0 && qh TRACEpoint == qh_pointid(point))) {
     if (qh TRACElevel > qh IStracing)
       qh IStracing= qh TRACElevel;
-    fprintf (qh ferr, "qh_findbest: point p%d starting at f%d isnewfacets? %d, unless %d exit if > %2.2g\n",
-	     qh_pointid(point), startfacet->id, isnewfacets, bestoutside, qh MINoutside);
-    fprintf(qh ferr, "  testhorizon? %d noupper? %d", testhorizon, noupper);
-    fprintf (qh ferr, "  Last point added was p%d.", qh furthest_id);
-    fprintf(qh ferr, "  Last merge was #%d.  max_outside %2.2g\n", zzval_(Ztotmerge), qh max_outside);
+    qh_fprintf(qh ferr, 8004, "qh_findbest: point p%d starting at f%d isnewfacets? %d, unless %d exit if > %2.2g\n",
+             qh_pointid(point), startfacet->id, isnewfacets, bestoutside, qh MINoutside);
+    qh_fprintf(qh ferr, 8005, "  testhorizon? %d noupper? %d", testhorizon, noupper);
+    qh_fprintf(qh ferr, 8006, "  Last point added was p%d.", qh furthest_id);
+    qh_fprintf(qh ferr, 8007, "  Last merge was #%d.  max_outside %2.2g\n", zzval_(Ztotmerge), qh max_outside);
   }
   if (isoutside)
     *isoutside= True;
   if (!startfacet->flipped) {  /* test startfacet */
     *numpart= 1;
-    qh_distplane (point, startfacet, dist);  /* this code is duplicated below */
-    if (!bestoutside && *dist >= qh MINoutside 
+    qh_distplane(point, startfacet, dist);  /* this code is duplicated below */
+    if (!bestoutside && *dist >= qh MINoutside
     && (!startfacet->upperdelaunay || !noupper)) {
       bestfacet= startfacet;
       goto LABELreturn_best;
@@ -168,63 +171,63 @@
     bestdist= *dist;
     if (!startfacet->upperdelaunay) {
       bestfacet= startfacet;
-    } 
-  }else 
+    }
+  }else
     *numpart= 0;
   startfacet->visitid= visitid;
   facet= startfacet;
   while (facet) {
-    trace4((qh ferr, "qh_findbest: neighbors of f%d, bestdist %2.2g f%d\n", 
+    trace4((qh ferr, 4001, "qh_findbest: neighbors of f%d, bestdist %2.2g f%d\n",
                 facet->id, bestdist, getid_(bestfacet)));
     lastfacet= facet;
     FOREACHneighbor_(facet) {
       if (!neighbor->newfacet && isnewfacets)
         continue;
       if (neighbor->visitid == visitid)
-	continue;
+        continue;
       neighbor->visitid= visitid;
       if (!neighbor->flipped) {  /* code duplicated above */
-	(*numpart)++;
-	qh_distplane (point, neighbor, dist);
-	if (*dist > bestdist) {
-	  if (!bestoutside && *dist >= qh MINoutside 
-	  && (!neighbor->upperdelaunay || !noupper)) {
-	    bestfacet= neighbor;
-	    goto LABELreturn_best;
-	  }
-	  if (!neighbor->upperdelaunay) {
-	    bestfacet= neighbor;
-	    bestdist= *dist;
-	    break; /* switch to neighbor */
-	  }else if (!bestfacet) { 
-	    bestdist= *dist;
-	    break; /* switch to neighbor */
-	  }
-	} /* end of *dist>bestdist */
+        (*numpart)++;
+        qh_distplane(point, neighbor, dist);
+        if (*dist > bestdist) {
+          if (!bestoutside && *dist >= qh MINoutside
+          && (!neighbor->upperdelaunay || !noupper)) {
+            bestfacet= neighbor;
+            goto LABELreturn_best;
+          }
+          if (!neighbor->upperdelaunay) {
+            bestfacet= neighbor;
+            bestdist= *dist;
+            break; /* switch to neighbor */
+          }else if (!bestfacet) {
+            bestdist= *dist;
+            break; /* switch to neighbor */
+          }
+        } /* end of *dist>bestdist */
       } /* end of !flipped */
     } /* end of FOREACHneighbor */
     facet= neighbor;  /* non-NULL only if *dist>bestdist */
   } /* end of while facet (directed search) */
-  if (isnewfacets) { 
+  if (isnewfacets) {
     if (!bestfacet) {
-      bestdist= -REALmax/2; 
-      bestfacet= qh_findbestnew (point, startfacet->next, &bestdist, bestoutside, isoutside, &numpartnew);
+      bestdist= -REALmax/2;
+      bestfacet= qh_findbestnew(point, startfacet->next, &bestdist, bestoutside, isoutside, &numpartnew);
       testhorizon= False; /* qh_findbestnew calls qh_findbesthorizon */
     }else if (!qh findbest_notsharp && bestdist < - qh DISTround) {
-      if (qh_sharpnewfacets()) { 
-	/* seldom used, qh_findbestnew will retest all facets */
-	zinc_(Zfindnewsharp);
-	bestfacet= qh_findbestnew (point, bestfacet, &bestdist, bestoutside, isoutside, &numpartnew);
-	testhorizon= False; /* qh_findbestnew calls qh_findbesthorizon */
-	qh findbestnew= True;
+      if (qh_sharpnewfacets()) {
+        /* seldom used, qh_findbestnew will retest all facets */
+        zinc_(Zfindnewsharp);
+        bestfacet= qh_findbestnew(point, bestfacet, &bestdist, bestoutside, isoutside, &numpartnew);
+        testhorizon= False; /* qh_findbestnew calls qh_findbesthorizon */
+        qh findbestnew= True;
       }else
-	qh findbest_notsharp= True;
+        qh findbest_notsharp= True;
     }
   }
-  if (!bestfacet) 
-    bestfacet= qh_findbestlower (lastfacet, point, &bestdist, numpart);
-  if (testhorizon) 
-    bestfacet= qh_findbesthorizon (!qh_IScheckmax, point, bestfacet, noupper, &bestdist, &numpartnew);
+  if (!bestfacet)
+    bestfacet= qh_findbestlower(lastfacet, point, &bestdist, numpart);
+  if (testhorizon)
+    bestfacet= qh_findbesthorizon(!qh_IScheckmax, point, bestfacet, noupper, &bestdist, &numpartnew);
   *dist= bestdist;
   if (isoutside && bestdist < qh MINoutside)
     *isoutside= False;
@@ -239,14 +242,14 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="findbesthorizon">-</a>
-  
+
   qh_findbesthorizon( qh_IScheckmax, point, startfacet, qh_NOupper, &bestdist, &numpart )
     search coplanar and better horizon facets from startfacet/bestdist
     ischeckmax turns off statistics and minsearch update
     all arguments must be initialized
-  returns (ischeckmax):
+  returns(ischeckmax):
     best facet
-  returns (!ischeckmax):
+  returns(!ischeckmax):
     best facet that is not upperdelaunay
     allows upperdelaunay that is clearly outside
   returns:
@@ -266,7 +269,7 @@
 
     searchdist is qh.max_outside + 2 * DISTround
       + max( MINvisible('Vn'), MAXcoplanar('Un'));
-    This setting is a guess.  It must be at least max_outside + 2*DISTround 
+    This setting is a guess.  It must be at least max_outside + 2*DISTround
     because a facet may have a geometric neighbor across a vertex
 
   design:
@@ -275,12 +278,12 @@
       unless upperdelaunay or clearly outside
          update best facet
 */
-facetT *qh_findbesthorizon (boolT ischeckmax, pointT* point, facetT *startfacet, boolT noupper, realT *bestdist, int *numpart) {
+facetT *qh_findbesthorizon(boolT ischeckmax, pointT* point, facetT *startfacet, boolT noupper, realT *bestdist, int *numpart) {
   facetT *bestfacet= startfacet;
   realT dist;
   facetT *neighbor, **neighborp, *facet;
-  facetT *nextfacet= NULL; /* optimize last facet of coplanarset */
-  int numpartinit= *numpart, coplanarset_size;
+  facetT *nextfacet= NULL; /* optimize last facet of coplanarfacetset */
+  int numpartinit= *numpart, coplanarfacetset_size;
   unsigned int visitid= ++qh visit_id;
   boolT newbest= False; /* for tracing */
   realT minsearch, searchdist;  /* skip facets that are too far from point */
@@ -299,73 +302,73 @@
     /* Always check coplanar facets.  Needed for RBOX 1000 s Z1 G1e-13 t996564279 | QHULL Tv */
     minimize_(minsearch, -searchdist);
   }
-  coplanarset_size= 0;
+  coplanarfacetset_size= 0;
   facet= startfacet;
   while (True) {
-    trace4((qh ferr, "qh_findbesthorizon: neighbors of f%d bestdist %2.2g f%d ischeckmax? %d noupper? %d minsearch %2.2g searchdist %2.2g\n", 
-		facet->id, *bestdist, getid_(bestfacet), ischeckmax, noupper,
-		minsearch, searchdist));
+    trace4((qh ferr, 4002, "qh_findbesthorizon: neighbors of f%d bestdist %2.2g f%d ischeckmax? %d noupper? %d minsearch %2.2g searchdist %2.2g\n",
+                facet->id, *bestdist, getid_(bestfacet), ischeckmax, noupper,
+                minsearch, searchdist));
     FOREACHneighbor_(facet) {
-      if (neighbor->visitid == visitid) 
-	continue;
+      if (neighbor->visitid == visitid)
+        continue;
       neighbor->visitid= visitid;
-      if (!neighbor->flipped) { 
-	qh_distplane (point, neighbor, &dist);
-	(*numpart)++;
-	if (dist > *bestdist) {
-	  if (!neighbor->upperdelaunay || ischeckmax || (!noupper && dist >= qh MINoutside)) {
-	    bestfacet= neighbor;
-	    *bestdist= dist;
-	    newbest= True;
-	    if (!ischeckmax) {
-	      minsearch= dist - searchdist;
-	      if (dist > *bestdist + searchdist) {
-		zinc_(Zfindjump);  /* everything in qh.coplanarset at least searchdist below */
-		coplanarset_size= 0;
-	      }
-	    }
-	  }
-	}else if (dist < minsearch) 
-	  continue;  /* if ischeckmax, dist can't be positive */
+      if (!neighbor->flipped) {
+        qh_distplane(point, neighbor, &dist);
+        (*numpart)++;
+        if (dist > *bestdist) {
+          if (!neighbor->upperdelaunay || ischeckmax || (!noupper && dist >= qh MINoutside)) {
+            bestfacet= neighbor;
+            *bestdist= dist;
+            newbest= True;
+            if (!ischeckmax) {
+              minsearch= dist - searchdist;
+              if (dist > *bestdist + searchdist) {
+                zinc_(Zfindjump);  /* everything in qh.coplanarfacetset at least searchdist below */
+                coplanarfacetset_size= 0;
+              }
+            }
+          }
+        }else if (dist < minsearch)
+          continue;  /* if ischeckmax, dist can't be positive */
 #if qh_MAXoutside
-	if (ischeckmax && dist > neighbor->maxoutside)
-	  neighbor->maxoutside= dist;
-#endif      
+        if (ischeckmax && dist > neighbor->maxoutside)
+          neighbor->maxoutside= dist;
+#endif
       } /* end of !flipped */
       if (nextfacet) {
-	if (!coplanarset_size++) {
-	  SETfirst_(qh coplanarset)= nextfacet;
-	  SETtruncate_(qh coplanarset, 1);
-	}else
-  	  qh_setappend (&qh coplanarset, nextfacet); /* Was needed for RBOX 1000 s W1e-13 P0 t996547055 | QHULL d Qbb Qc Tv
-						 and RBOX 1000 s Z1 G1e-13 t996564279 | qhull Tv  */
+        if (!coplanarfacetset_size++) {
+          SETfirst_(qh coplanarfacetset)= nextfacet;
+          SETtruncate_(qh coplanarfacetset, 1);
+        }else
+          qh_setappend(&qh coplanarfacetset, nextfacet); /* Was needed for RBOX 1000 s W1e-13 P0 t996547055 | QHULL d Qbb Qc Tv
+                                                 and RBOX 1000 s Z1 G1e-13 t996564279 | qhull Tv  */
       }
       nextfacet= neighbor;
     } /* end of EACHneighbor */
     facet= nextfacet;
-    if (facet) 
+    if (facet)
       nextfacet= NULL;
-    else if (!coplanarset_size)
-      break; 
-    else if (!--coplanarset_size) {
-      facet= SETfirst_(qh coplanarset);
-      SETtruncate_(qh coplanarset, 0);
+    else if (!coplanarfacetset_size)
+      break;
+    else if (!--coplanarfacetset_size) {
+      facet= SETfirstt_(qh coplanarfacetset, facetT);
+      SETtruncate_(qh coplanarfacetset, 0);
     }else
-      facet= (facetT*)qh_setdellast (qh coplanarset);
-  } /* while True, for each facet in qh.coplanarset */
+      facet= (facetT*)qh_setdellast(qh coplanarfacetset);
+  } /* while True, for each facet in qh.coplanarfacetset */
   if (!ischeckmax) {
     zadd_(Zfindhorizontot, *numpart - numpartinit);
     zmax_(Zfindhorizonmax, *numpart - numpartinit);
     if (newbest)
       zinc_(Zparthorizon);
   }
-  trace4((qh ferr, "qh_findbesthorizon: newbest? %d bestfacet f%d bestdist %2.2g\n", newbest, getid_(bestfacet), *bestdist));
+  trace4((qh ferr, 4003, "qh_findbesthorizon: newbest? %d bestfacet f%d bestdist %2.2g\n", newbest, getid_(bestfacet), *bestdist));
   return bestfacet;
 }  /* findbesthorizon */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="findbestnew">-</a>
-  
+
   qh_findbestnew( point, startfacet, dist, isoutside, numpart )
     find best newfacet for point
     searches all of qh.newfacet_list starting at startfacet
@@ -382,8 +385,8 @@
     Always used for merged new facets (see qh_USEfindbestnew)
     Avoids upperdelaunay facet unless (isoutside and outside)
 
-    Uses qh.visit_id, qh.coplanarset.  
-    If share visit_id with qh_findbest, coplanarset is incorrect.
+    Uses qh.visit_id, qh.coplanarfacetset.
+    If share visit_id with qh_findbest, coplanarfacetset is incorrect.
 
     If merging (testhorizon), searches horizon facets of coplanar best facets because
     a point maybe coplanar to the bestfacet, below its horizon facet,
@@ -406,8 +409,8 @@
          update best facet
     test horizon facets
 */
-facetT *qh_findbestnew (pointT *point, facetT *startfacet,
-	   realT *dist, boolT bestoutside, boolT *isoutside, int *numpart) {
+facetT *qh_findbestnew(pointT *point, facetT *startfacet,
+           realT *dist, boolT bestoutside, boolT *isoutside, int *numpart) {
   realT bestdist= -REALmax/2;
   facetT *bestfacet= NULL, *facet;
   int oldtrace= qh IStracing, i;
@@ -418,11 +421,11 @@
 
   if (!startfacet) {
     if (qh MERGING)
-      fprintf(qh ferr, "qhull precision error (qh_findbestnew): merging has formed and deleted a cone of new facets.  Can not continue.\n");
+      qh_fprintf(qh ferr, 6001, "qhull precision error (qh_findbestnew): merging has formed and deleted a cone of new facets.  Can not continue.\n");
     else
-      fprintf(qh ferr, "qhull internal error (qh_findbestnew): no new facets for point p%d\n",
-      	      qh furthest_id);      
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+      qh_fprintf(qh ferr, 6002, "qhull internal error (qh_findbestnew): no new facets for point p%d\n",
+              qh furthest_id);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   zinc_(Zfindnew);
   if (qh BESToutside || bestoutside)
@@ -434,44 +437,44 @@
   if (isoutside)
     *isoutside= True;
   *numpart= 0;
-  if (qh IStracing >= 3 || (qh TRACElevel && qh TRACEpoint >= 0 && qh TRACEpoint == qh_pointid (point))) {
+  if (qh IStracing >= 3 || (qh TRACElevel && qh TRACEpoint >= 0 && qh TRACEpoint == qh_pointid(point))) {
     if (qh TRACElevel > qh IStracing)
       qh IStracing= qh TRACElevel;
-    fprintf(qh ferr, "qh_findbestnew: point p%d facet f%d. Stop? %d if dist > %2.2g\n",
-	     qh_pointid(point), startfacet->id, isdistoutside, distoutside);
-    fprintf(qh ferr, "  Last point added p%d visitid %d.",  qh furthest_id, visitid);
-    fprintf(qh ferr, "  Last merge was #%d.\n", zzval_(Ztotmerge));
+    qh_fprintf(qh ferr, 8008, "qh_findbestnew: point p%d facet f%d. Stop? %d if dist > %2.2g\n",
+             qh_pointid(point), startfacet->id, isdistoutside, distoutside);
+    qh_fprintf(qh ferr, 8009, "  Last point added p%d visitid %d.",  qh furthest_id, visitid);
+    qh_fprintf(qh ferr, 8010, "  Last merge was #%d.\n", zzval_(Ztotmerge));
   }
   /* visit all new facets starting with startfacet, maybe qh facet_list */
-  for (i= 0, facet= startfacet; i < 2; i++, facet= qh newfacet_list) {
+  for (i=0, facet=startfacet; i < 2; i++, facet= qh newfacet_list) {
     FORALLfacet_(facet) {
       if (facet == startfacet && i)
-	break;
+        break;
       facet->visitid= visitid;
       if (!facet->flipped) {
-	qh_distplane (point, facet, dist);
-	(*numpart)++;
-	if (*dist > bestdist) {
-	  if (!facet->upperdelaunay || *dist >= qh MINoutside) {
-	    bestfacet= facet;
-	    if (isdistoutside && *dist >= distoutside)
-	      goto LABELreturn_bestnew;
-	    bestdist= *dist;
-  	  }
-	}
+        qh_distplane(point, facet, dist);
+        (*numpart)++;
+        if (*dist > bestdist) {
+          if (!facet->upperdelaunay || *dist >= qh MINoutside) {
+            bestfacet= facet;
+            if (isdistoutside && *dist >= distoutside)
+              goto LABELreturn_bestnew;
+            bestdist= *dist;
+          }
+        }
       } /* end of !flipped */
     } /* FORALLfacet from startfacet or qh newfacet_list */
   }
   if (testhorizon || !bestfacet)
-    bestfacet= qh_findbesthorizon (!qh_IScheckmax, point, bestfacet ? bestfacet : startfacet, 
-	                                !qh_NOupper, &bestdist, numpart);  
+    bestfacet= qh_findbesthorizon(!qh_IScheckmax, point, bestfacet ? bestfacet : startfacet,
+                                        !qh_NOupper, &bestdist, numpart);
   *dist= bestdist;
   if (isoutside && *dist < qh MINoutside)
     *isoutside= False;
 LABELreturn_bestnew:
   zadd_(Zfindnewtot, *numpart);
   zmax_(Zfindnewmax, *numpart);
-  trace4((qh ferr, "qh_findbestnew: bestfacet f%d bestdist %2.2g\n", getid_(bestfacet), *dist));
+  trace4((qh ferr, 4004, "qh_findbestnew: bestfacet f%d bestdist %2.2g\n", getid_(bestfacet), *dist));
   qh IStracing= oldtrace;
   return bestfacet;
 }  /* findbestnew */
@@ -480,15 +483,15 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="backnormal">-</a>
-  
+
   qh_backnormal( rows, numrow, numcol, sign, normal, nearzero )
     given an upper-triangular rows array and a sign,
     solve for normal equation x using back substitution over rows U
 
   returns:
      normal= x
-      
-     if will not be able to divzero() when normalized (qh.MINdenom_2 and qh.MINdenom_1_2),
+
+     if will not be able to divzero() when normalized(qh.MINdenom_2 and qh.MINdenom_1_2),
        if fails on last row
          this means that the hyperplane intersects [0,..,1]
          sets last coordinate of normal to sign
@@ -506,7 +509,7 @@
      last row of A= [0,...,0,1]
 
      1) Ly=Pb == y=b since P only permutes the 0's of   b
-     
+
   design:
     for each row from end
       perform back substitution
@@ -515,48 +518,48 @@
         if zero divide and not last row
           set tail of normal to 0
 */
-void qh_backnormal (realT **rows, int numrow, int numcol, boolT sign,
-  	coordT *normal, boolT *nearzero) {
+void qh_backnormal(realT **rows, int numrow, int numcol, boolT sign,
+        coordT *normal, boolT *nearzero) {
   int i, j;
   coordT *normalp, *normal_tail, *ai, *ak;
   realT diagonal;
   boolT waszero;
   int zerocol= -1;
-  
+
   normalp= normal + numcol - 1;
   *normalp--= (sign ? -1.0 : 1.0);
-  for(i= numrow; i--; ) {
+  for (i=numrow; i--; ) {
     *normalp= 0.0;
     ai= rows[i] + i + 1;
     ak= normalp+1;
-    for(j= i+1; j < numcol; j++)
+    for (j=i+1; j < numcol; j++)
       *normalp -= *ai++ * *ak++;
     diagonal= (rows[i])[i];
     if (fabs_(diagonal) > qh MINdenom_2)
       *(normalp--) /= diagonal;
     else {
       waszero= False;
-      *normalp= qh_divzero (*normalp, diagonal, qh MINdenom_1_2, &waszero);
+      *normalp= qh_divzero(*normalp, diagonal, qh MINdenom_1_2, &waszero);
       if (waszero) {
         zerocol= i;
-	*(normalp--)= (sign ? -1.0 : 1.0);
-	for (normal_tail= normalp+2; normal_tail < normal + numcol; normal_tail++)
-	  *normal_tail= 0.0;
+        *(normalp--)= (sign ? -1.0 : 1.0);
+        for (normal_tail= normalp+2; normal_tail < normal + numcol; normal_tail++)
+          *normal_tail= 0.0;
       }else
-	normalp--;
+        normalp--;
     }
   }
   if (zerocol != -1) {
     zzinc_(Zback0);
     *nearzero= True;
-    trace4((qh ferr, "qh_backnormal: zero diagonal at column %d.\n", i));
-    qh_precision ("zero diagonal on back substitution");
+    trace4((qh ferr, 4005, "qh_backnormal: zero diagonal at column %d.\n", i));
+    qh_precision("zero diagonal on back substitution");
   }
 } /* backnormal */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="gausselim">-</a>
-  
+
   qh_gausselim( rows, numrow, numcol, sign )
     Gaussian elimination with partial pivoting
 
@@ -579,57 +582,57 @@
   realT *ai, *ak, *rowp, *pivotrow;
   realT n, pivot, pivot_abs= 0.0, temp;
   int i, j, k, pivoti, flip=0;
-  
+
   *nearzero= False;
-  for(k= 0; k < numrow; k++) {
+  for (k=0; k < numrow; k++) {
     pivot_abs= fabs_((rows[k])[k]);
     pivoti= k;
-    for(i= k+1; i < numrow; i++) {
+    for (i=k+1; i < numrow; i++) {
       if ((temp= fabs_((rows[i])[k])) > pivot_abs) {
-	pivot_abs= temp;
-	pivoti= i;
+        pivot_abs= temp;
+        pivoti= i;
       }
     }
     if (pivoti != k) {
-      rowp= rows[pivoti]; 
-      rows[pivoti]= rows[k]; 
-      rows[k]= rowp; 
+      rowp= rows[pivoti];
+      rows[pivoti]= rows[k];
+      rows[k]= rowp;
       *sign ^= 1;
       flip ^= 1;
     }
     if (pivot_abs <= qh NEARzero[k]) {
       *nearzero= True;
       if (pivot_abs == 0.0) {   /* remainder of column == 0 */
-	if (qh IStracing >= 4) {
-	  fprintf (qh ferr, "qh_gausselim: 0 pivot at column %d. (%2.2g < %2.2g)\n", k, pivot_abs, qh DISTround);
-	  qh_printmatrix (qh ferr, "Matrix:", rows, numrow, numcol);
-	}
-	zzinc_(Zgauss0);
-        qh_precision ("zero pivot for Gaussian elimination");
-	goto LABELnextcol;
+        if (qh IStracing >= 4) {
+          qh_fprintf(qh ferr, 8011, "qh_gausselim: 0 pivot at column %d. (%2.2g < %2.2g)\n", k, pivot_abs, qh DISTround);
+          qh_printmatrix(qh ferr, "Matrix:", rows, numrow, numcol);
+        }
+        zzinc_(Zgauss0);
+        qh_precision("zero pivot for Gaussian elimination");
+        goto LABELnextcol;
       }
     }
     pivotrow= rows[k] + k;
     pivot= *pivotrow++;  /* signed value of pivot, and remainder of row */
-    for(i= k+1; i < numrow; i++) {
+    for (i=k+1; i < numrow; i++) {
       ai= rows[i] + k;
       ak= pivotrow;
       n= (*ai++)/pivot;   /* divzero() not needed since |pivot| >= |*ai| */
-      for(j= numcol - (k+1); j--; )
-	*ai++ -= n * *ak++;
+      for (j= numcol - (k+1); j--; )
+        *ai++ -= n * *ak++;
     }
   LABELnextcol:
     ;
   }
   wmin_(Wmindenom, pivot_abs);  /* last pivot element */
   if (qh IStracing >= 5)
-    qh_printmatrix (qh ferr, "qh_gausselem: result", rows, numrow, numcol);
+    qh_printmatrix(qh ferr, "qh_gausselem: result", rows, numrow, numcol);
 } /* gausselim */
 
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="getangle">-</a>
-  
+
   qh_getangle( vect1, vect2 )
     returns the dot product of two vectors
     if qh.RANDOMdist, joggles result
@@ -642,21 +645,21 @@
   realT angle= 0, randr;
   int k;
 
-  for(k= qh hull_dim; k--; )
+  for (k=qh hull_dim; k--; )
     angle += *vect1++ * *vect2++;
   if (qh RANDOMdist) {
     randr= qh_RANDOMint;
     angle += (2.0 * randr / qh_RANDOMmax - 1.0) *
       qh RANDOMfactor;
   }
-  trace4((qh ferr, "qh_getangle: %2.2g\n", angle));
+  trace4((qh ferr, 4006, "qh_getangle: %2.2g\n", angle));
   return(angle);
 } /* getangle */
 
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="getcenter">-</a>
-  
+
   qh_getcenter( vertices )
     returns arithmetic center of a set of vertices as a new point
 
@@ -670,8 +673,8 @@
   int count= qh_setsize(vertices);
 
   if (count < 2) {
-    fprintf (qh ferr, "qhull internal error (qh_getcenter): not defined for %d points\n", count);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_fprintf(qh ferr, 6003, "qhull internal error (qh_getcenter): not defined for %d points\n", count);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   center= (pointT *)qh_memalloc(qh normal_size);
   for (k=0; k < qh hull_dim; k++) {
@@ -687,7 +690,7 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="getcentrum">-</a>
-  
+
   qh_getcentrum( facet )
     returns the centrum for a facet as a new point
 
@@ -700,18 +703,18 @@
 
   point= qh_getcenter(facet->vertices);
   zzinc_(Zcentrumtests);
-  qh_distplane (point, facet, &dist);
+  qh_distplane(point, facet, &dist);
   centrum= qh_projectpoint(point, facet, dist);
   qh_memfree(point, qh normal_size);
-  trace4((qh ferr, "qh_getcentrum: for f%d, %d vertices dist= %2.2g\n",
-	  facet->id, qh_setsize(facet->vertices), dist));
+  trace4((qh ferr, 4007, "qh_getcentrum: for f%d, %d vertices dist= %2.2g\n",
+          facet->id, qh_setsize(facet->vertices), dist));
   return centrum;
 } /* getcentrum */
 
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="getdistance">-</a>
-  
+
   qh_getdistance( facet, neighbor, mindist, maxdist )
     returns the maxdist and mindist distance of any vertex from neighbor
 
@@ -725,7 +728,7 @@
 realT qh_getdistance(facetT *facet, facetT *neighbor, realT *mindist, realT *maxdist) {
   vertexT *vertex, **vertexp;
   realT dist, maxd, mind;
-  
+
   FOREACHvertex_(facet->vertices)
     vertex->seen= False;
   FOREACHvertex_(neighbor->vertices)
@@ -737,9 +740,9 @@
       zzinc_(Zbestdist);
       qh_distplane(vertex->point, neighbor, &dist);
       if (dist < mind)
-	mind= dist;
+        mind= dist;
       else if (dist > maxd)
-	maxd= dist;
+        maxd= dist;
     }
   }
   *mindist= mind;
@@ -758,17 +761,17 @@
   qh_normalize( normal, dim, toporient )
     normalize a vector and report if too small
     does not use min norm
-  
+
   see:
     qh_normalize2
 */
-void qh_normalize (coordT *normal, int dim, boolT toporient) {
+void qh_normalize(coordT *normal, int dim, boolT toporient) {
   qh_normalize2( normal, dim, toporient, NULL, NULL);
 } /* normalize */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="normalize2">-</a>
-  
+
   qh_normalize2( normal, dim, toporient, minnorm, ismin )
     normalize a vector and report if too small
     qh.MINdenom/MINdenom1 are the upper limits for divide overflow
@@ -776,16 +779,16 @@
   returns:
     normalized vector
     flips sign if !toporient
-    if minnorm non-NULL, 
+    if minnorm non-NULL,
       sets ismin if normal < minnorm
 
   notes:
     if zero norm
        sets all elements to sqrt(1.0/dim)
-    if divide by zero (divzero ())
+    if divide by zero (divzero())
        sets largest element to   +/-1
        bumps Znearlysingular
-      
+
   design:
     computes norm
     test for minnorm
@@ -798,7 +801,7 @@
       if nearzero
         sets norm to direction of maximum value
 */
-void qh_normalize2 (coordT *normal, int dim, boolT toporient, 
+void qh_normalize2 (coordT *normal, int dim, boolT toporient,
             realT *minnorm, boolT *ismin) {
   int k;
   realT *colp, *maxp, norm= 0, temp, *norm1, *norm2, *norm3;
@@ -812,17 +815,17 @@
   else if (dim == 3)
     norm= sqrt((*normal)*(*normal) + (*norm1)*(*norm1) + (*norm2)*(*norm2));
   else if (dim == 4) {
-    norm= sqrt((*normal)*(*normal) + (*norm1)*(*norm1) + (*norm2)*(*norm2) 
+    norm= sqrt((*normal)*(*normal) + (*norm1)*(*norm1) + (*norm2)*(*norm2)
                + (*norm3)*(*norm3));
   }else if (dim > 4) {
-    norm= (*normal)*(*normal) + (*norm1)*(*norm1) + (*norm2)*(*norm2) 
+    norm= (*normal)*(*normal) + (*norm1)*(*norm1) + (*norm2)*(*norm2)
                + (*norm3)*(*norm3);
-    for (k= dim-4, colp= normal+4; k--; colp++)
+    for (k=dim-4, colp=normal+4; k--; colp++)
       norm += (*colp) * (*colp);
     norm= sqrt(norm);
   }
   if (minnorm) {
-    if (norm < *minnorm) 
+    if (norm < *minnorm)
       *ismin= True;
     else
       *ismin= False;
@@ -843,30 +846,30 @@
     }else if (dim >4) {
       *norm2 /= norm;
       *norm3 /= norm;
-      for (k= dim-4, colp= normal+4; k--; )
+      for (k=dim-4, colp=normal+4; k--; )
         *colp++ /= norm;
     }
   }else if (norm == 0.0) {
-    temp= sqrt (1.0/dim);
-    for (k= dim, colp= normal; k--; )
+    temp= sqrt(1.0/dim);
+    for (k=dim, colp=normal; k--; )
       *colp++ = temp;
   }else {
     if (!toporient)
       norm= -norm;
-    for (k= dim, colp= normal; k--; colp++) { /* k used below */
-      temp= qh_divzero (*colp, norm, qh MINdenom_1, &zerodiv);
+    for (k=dim, colp=normal; k--; colp++) { /* k used below */
+      temp= qh_divzero(*colp, norm, qh MINdenom_1, &zerodiv);
       if (!zerodiv)
-	*colp= temp;
+        *colp= temp;
       else {
-	maxp= qh_maxabsval(normal, dim);
-	temp= ((*maxp * norm >= 0.0) ? 1.0 : -1.0);
-	for (k= dim, colp= normal; k--; colp++)
-	  *colp= 0.0;
-	*maxp= temp;
-	zzinc_(Znearlysingular);
-	trace0((qh ferr, "qh_normalize: norm=%2.2g too small during p%d\n", 
-	       norm, qh furthest_id));
-	return;
+        maxp= qh_maxabsval(normal, dim);
+        temp= ((*maxp * norm >= 0.0) ? 1.0 : -1.0);
+        for (k=dim, colp=normal; k--; colp++)
+          *colp= 0.0;
+        *maxp= temp;
+        zzinc_(Znearlysingular);
+        trace0((qh ferr, 1, "qh_normalize: norm=%2.2g too small during p%d\n",
+               norm, qh furthest_id));
+        return;
       }
     }
   }
@@ -875,13 +878,13 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="projectpoint">-</a>
-  
+
   qh_projectpoint( point, facet, dist )
     project point onto a facet by dist
 
   returns:
     returns a new point
-    
+
   notes:
     if dist= distplane(point,facet)
       this projects point to hyperplane
@@ -889,21 +892,22 @@
 */
 pointT *qh_projectpoint(pointT *point, facetT *facet, realT dist) {
   pointT *newpoint, *np, *normal;
-  int normsize= qh normal_size,k;
+  int normsize= qh normal_size;
+  int k;
   void **freelistp; /* used !qh_NOmem */
-  
+
   qh_memalloc_(normsize, freelistp, newpoint, pointT);
   np= newpoint;
   normal= facet->normal;
-  for(k= qh hull_dim; k--; )
+  for (k=qh hull_dim; k--; )
     *(np++)= *point++ - dist * *normal++;
   return(newpoint);
 } /* projectpoint */
 
-  
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="setfacetplane">-</a>
-  
+
   qh_setfacetplane( facet )
     sets the hyperplane for a facet
     if qh.RANDOMdist, joggles hyperplane
@@ -925,7 +929,8 @@
 void qh_setfacetplane(facetT *facet) {
   pointT *point;
   vertexT *vertex, **vertexp;
-  int k,i, normsize= qh normal_size, oldtrace= 0;
+  int normsize= qh normal_size;
+  int k,i, oldtrace= 0;
   realT dist;
   void **freelistp; /* used !qh_NOmem */
   coordT *coord, *gmcoord;
@@ -938,12 +943,12 @@
   if (facet == qh tracefacet) {
     oldtrace= qh IStracing;
     qh IStracing= 5;
-    fprintf (qh ferr, "qh_setfacetplane: facet f%d created.\n", facet->id);
-    fprintf (qh ferr, "  Last point added to hull was p%d.", qh furthest_id);
+    qh_fprintf(qh ferr, 8012, "qh_setfacetplane: facet f%d created.\n", facet->id);
+    qh_fprintf(qh ferr, 8013, "  Last point added to hull was p%d.", qh furthest_id);
     if (zzval_(Ztotmerge))
-      fprintf(qh ferr, "  Last merge was #%d.", zzval_(Ztotmerge));
-    fprintf (qh ferr, "\n\nCurrent summary is:\n");
-      qh_printsummary (qh ferr);
+      qh_fprintf(qh ferr, 8014, "  Last merge was #%d.", zzval_(Ztotmerge));
+    qh_fprintf(qh ferr, 8015, "\n\nCurrent summary is:\n");
+      qh_printsummary(qh ferr);
   }
   if (qh hull_dim <= 4) {
     i= 0;
@@ -951,10 +956,10 @@
       gmcoord= qh gm_matrix;
       FOREACHvertex_(facet->vertices) {
         qh gm_row[i++]= gmcoord;
-	coord= vertex->point;
-	for (k= qh hull_dim; k--; )
-	  *(gmcoord++)= *coord++ * qh_randomfactor();
-      }	  
+        coord= vertex->point;
+        for (k=qh hull_dim; k--; )
+          *(gmcoord++)= *coord++ * qh_randomfactor(qh RANDOMa, qh RANDOMb);
+      }
     }else {
       FOREACHvertex_(facet->vertices)
        qh gm_row[i++]= vertex->point;
@@ -967,36 +972,36 @@
     gmcoord= qh gm_matrix;
     FOREACHvertex_(facet->vertices) {
       if (vertex->point != point0) {
-	qh gm_row[i++]= gmcoord;
-	coord= vertex->point;
-	point= point0;
-	for(k= qh hull_dim; k--; )
-	  *(gmcoord++)= *coord++ - *point++;
+        qh gm_row[i++]= gmcoord;
+        coord= vertex->point;
+        point= point0;
+        for (k=qh hull_dim; k--; )
+          *(gmcoord++)= *coord++ - *point++;
       }
     }
     qh gm_row[i]= gmcoord;  /* for areasimplex */
     if (qh RANDOMdist) {
       gmcoord= qh gm_matrix;
-      for (i= qh hull_dim-1; i--; ) {
-	for (k= qh hull_dim; k--; )
-	  *(gmcoord++) *= qh_randomfactor();
+      for (i=qh hull_dim-1; i--; ) {
+        for (k=qh hull_dim; k--; )
+          *(gmcoord++) *= qh_randomfactor(qh RANDOMa, qh RANDOMb);
       }
     }
     qh_sethyperplane_gauss(qh hull_dim, qh gm_row, point0, facet->toporient,
-           	facet->normal, &facet->offset, &nearzero);
-    if (nearzero) { 
-      if (qh_orientoutside (facet)) {
-	trace0((qh ferr, "qh_setfacetplane: flipped orientation after testing interior_point during p%d\n", qh furthest_id));
+                facet->normal, &facet->offset, &nearzero);
+    if (nearzero) {
+      if (qh_orientoutside(facet)) {
+        trace0((qh ferr, 2, "qh_setfacetplane: flipped orientation after testing interior_point during p%d\n", qh furthest_id));
       /* this is part of using Gaussian Elimination.  For example in 5-d
-	   1 1 1 1 0
-	   1 1 1 1 1
-	   0 0 0 1 0
-	   0 1 0 0 0
-	   1 0 0 0 0
-	   norm= 0.38 0.38 -0.76 0.38 0
-	 has a determinate of 1, but g.e. after subtracting pt. 0 has
-	 0's in the diagonal, even with full pivoting.  It does work
-	 if you subtract pt. 4 instead. */
+           1 1 1 1 0
+           1 1 1 1 1
+           0 0 0 1 0
+           0 1 0 0 0
+           1 0 0 0 0
+           norm= 0.38 0.38 -0.76 0.38 0
+         has a determinate of 1, but g.e. after subtracting pt. 0 has
+         0's in the diagonal, even with full pivoting.  It does work
+         if you subtract pt. 4 instead. */
       }
     }
   }
@@ -1015,36 +1020,36 @@
     qh RANDOMdist= False;
     FOREACHvertex_(facet->vertices) {
       if (vertex->point != point0) {
-	boolT istrace= False;
-	zinc_(Zdiststat);
+        boolT istrace= False;
+        zinc_(Zdiststat);
         qh_distplane(vertex->point, facet, &dist);
         dist= fabs_(dist);
         zinc_(Znewvertex);
         wadd_(Wnewvertex, dist);
         if (dist > wwval_(Wnewvertexmax)) {
           wwval_(Wnewvertexmax)= dist;
-	  if (dist > qh max_outside) {
-	    qh max_outside= dist;  /* used by qh_maxouter() */
-	    if (dist > qh TRACEdist) 
-	      istrace= True;
-	  }
-	}else if (-dist > qh TRACEdist)
-	  istrace= True;
-	if (istrace) {
-	  fprintf (qh ferr, "qh_setfacetplane: ====== vertex p%d (v%d) increases max_outside to %2.2g for new facet f%d last p%d\n",
-	        qh_pointid(vertex->point), vertex->id, dist, facet->id, qh furthest_id);
-	  qh_errprint ("DISTANT", facet, NULL, NULL, NULL);
-	}
+          if (dist > qh max_outside) {
+            qh max_outside= dist;  /* used by qh_maxouter() */
+            if (dist > qh TRACEdist)
+              istrace= True;
+          }
+        }else if (-dist > qh TRACEdist)
+          istrace= True;
+        if (istrace) {
+          qh_fprintf(qh ferr, 8016, "qh_setfacetplane: ====== vertex p%d(v%d) increases max_outside to %2.2g for new facet f%d last p%d\n",
+                qh_pointid(vertex->point), vertex->id, dist, facet->id, qh furthest_id);
+          qh_errprint("DISTANT", facet, NULL, NULL, NULL);
+        }
       }
     }
     qh RANDOMdist= qh old_randomdist;
   }
   if (qh IStracing >= 3) {
-    fprintf (qh ferr, "qh_setfacetplane: f%d offset %2.2g normal: ",
-	     facet->id, facet->offset);
+    qh_fprintf(qh ferr, 8017, "qh_setfacetplane: f%d offset %2.2g normal: ",
+             facet->id, facet->offset);
     for (k=0; k < qh hull_dim; k++)
-      fprintf (qh ferr, "%2.2g ", facet->normal[k]);
-    fprintf (qh ferr, "\n");
+      qh_fprintf(qh ferr, 8018, "%2.2g ", facet->normal[k]);
+    qh_fprintf(qh ferr, 8019, "\n");
   }
   if (facet == qh tracefacet)
     qh IStracing= oldtrace;
@@ -1053,10 +1058,10 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="sethyperplane_det">-</a>
-  
+
   qh_sethyperplane_det( dim, rows, point0, toporient, normal, offset, nearzero )
-    given dim X dim array indexed by rows[], one row per point, 
-        toporient (flips all signs),
+    given dim X dim array indexed by rows[], one row per point,
+        toporient(flips all signs),
         and point0 (any row)
     set normalized hyperplane equation from oriented simplex
 
@@ -1076,7 +1081,7 @@
     Plan: exactly translate the facet so that V_0 is the origin
           exactly rotate the facet so that V_1 is on the x-axis and y_2=0.
           exactly rotate the effective perturbation to only effect n_0
-	     this introduces a factor of sqrt(3)
+             this introduces a factor of sqrt(3)
     n_0 = ((y_2-y_0)*(z_1-z_0) - (z_2-z_0)*(y_1-y_0)) / norm
     Let M_d be the max coordinate difference
     Let M_a be the greater of M_d and the max abs. coordinate
@@ -1095,7 +1100,7 @@
     Then minnorm = 2 u M_a M_d M_d M_d / qh.ONEmerge
     Note that qh.one_merge is approx. 82 u M_a and norm is usually about M_d M_d M_d
 */
-void qh_sethyperplane_det (int dim, coordT **rows, coordT *point0, 
+void qh_sethyperplane_det(int dim, coordT **rows, coordT *point0,
           boolT toporient, coordT *normal, realT *offset, boolT *nearzero) {
   realT maxround, dist;
   int i;
@@ -1110,58 +1115,58 @@
     *nearzero= False;  /* since nearzero norm => incident points */
   }else if (dim == 3) {
     normal[0]= det2_(dY(2,0), dZ(2,0),
-		     dY(1,0), dZ(1,0));
+                     dY(1,0), dZ(1,0));
     normal[1]= det2_(dX(1,0), dZ(1,0),
-		     dX(2,0), dZ(2,0));
+                     dX(2,0), dZ(2,0));
     normal[2]= det2_(dX(2,0), dY(2,0),
-		     dX(1,0), dY(1,0));
+                     dX(1,0), dY(1,0));
     qh_normalize2 (normal, dim, toporient, NULL, NULL);
     *offset= -(point0[0]*normal[0] + point0[1]*normal[1]
-	       + point0[2]*normal[2]);
+               + point0[2]*normal[2]);
     maxround= qh DISTround;
     for (i=dim; i--; ) {
       point= rows[i];
       if (point != point0) {
         dist= *offset + (point[0]*normal[0] + point[1]*normal[1]
-	       + point[2]*normal[2]);
+               + point[2]*normal[2]);
         if (dist > maxround || dist < -maxround) {
-  	  *nearzero= True;
-	  break;
-	}
+          *nearzero= True;
+          break;
+        }
       }
     }
   }else if (dim == 4) {
     normal[0]= - det3_(dY(2,0), dZ(2,0), dW(2,0),
-			dY(1,0), dZ(1,0), dW(1,0),
-			dY(3,0), dZ(3,0), dW(3,0));
+                        dY(1,0), dZ(1,0), dW(1,0),
+                        dY(3,0), dZ(3,0), dW(3,0));
     normal[1]=   det3_(dX(2,0), dZ(2,0), dW(2,0),
-		        dX(1,0), dZ(1,0), dW(1,0),
-		        dX(3,0), dZ(3,0), dW(3,0));
+                        dX(1,0), dZ(1,0), dW(1,0),
+                        dX(3,0), dZ(3,0), dW(3,0));
     normal[2]= - det3_(dX(2,0), dY(2,0), dW(2,0),
-			dX(1,0), dY(1,0), dW(1,0),
-			dX(3,0), dY(3,0), dW(3,0));
+                        dX(1,0), dY(1,0), dW(1,0),
+                        dX(3,0), dY(3,0), dW(3,0));
     normal[3]=   det3_(dX(2,0), dY(2,0), dZ(2,0),
-		        dX(1,0), dY(1,0), dZ(1,0),
-		        dX(3,0), dY(3,0), dZ(3,0));
+                        dX(1,0), dY(1,0), dZ(1,0),
+                        dX(3,0), dY(3,0), dZ(3,0));
     qh_normalize2 (normal, dim, toporient, NULL, NULL);
     *offset= -(point0[0]*normal[0] + point0[1]*normal[1]
-	       + point0[2]*normal[2] + point0[3]*normal[3]);
+               + point0[2]*normal[2] + point0[3]*normal[3]);
     maxround= qh DISTround;
     for (i=dim; i--; ) {
       point= rows[i];
       if (point != point0) {
         dist= *offset + (point[0]*normal[0] + point[1]*normal[1]
-	       + point[2]*normal[2] + point[3]*normal[3]);
+               + point[2]*normal[2] + point[3]*normal[3]);
         if (dist > maxround || dist < -maxround) {
-  	  *nearzero= True;
-	  break;
-	}
+          *nearzero= True;
+          break;
+        }
       }
     }
   }
   if (*nearzero) {
     zzinc_(Zminnorm);
-    trace0((qh ferr, "qh_sethyperplane_det: degenerate norm during p%d.\n", qh furthest_id));
+    trace0((qh ferr, 3, "qh_sethyperplane_det: degenerate norm during p%d.\n", qh furthest_id));
     zzinc_(Znearlysingular);
   }
 } /* sethyperplane_det */
@@ -1169,9 +1174,9 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="sethyperplane_gauss">-</a>
-  
+
   qh_sethyperplane_gauss( dim, rows, point0, toporient, normal, offset, nearzero )
-    given (dim-1) X dim array of rows[i]= V_{i+1} - V_0 (point0)
+    given(dim-1) X dim array of rows[i]= V_{i+1} - V_0 (point0)
     set normalized hyperplane equation from oriented simplex
 
   returns:
@@ -1181,38 +1186,38 @@
   notes:
     if nearzero
       orientation may be incorrect because of incorrect sign flips in gausselim
-    solves [V_n-V_0,...,V_1-V_0, 0 .. 0 1] * N == [0 .. 0 1] 
-        or [V_n-V_0,...,V_1-V_0, 0 .. 0 1] * N == [0] 
+    solves [V_n-V_0,...,V_1-V_0, 0 .. 0 1] * N == [0 .. 0 1]
+        or [V_n-V_0,...,V_1-V_0, 0 .. 0 1] * N == [0]
     i.e., N is normal to the hyperplane, and the unnormalized
         distance to [0 .. 1] is either 1 or   0
 
   design:
     perform gaussian elimination
     flip sign for negative values
-    perform back substitution 
+    perform back substitution
     normalize result
     compute offset
 */
-void qh_sethyperplane_gauss (int dim, coordT **rows, pointT *point0, 
-		boolT toporient, coordT *normal, coordT *offset, boolT *nearzero) {
+void qh_sethyperplane_gauss(int dim, coordT **rows, pointT *point0,
+                boolT toporient, coordT *normal, coordT *offset, boolT *nearzero) {
   coordT *pointcoord, *normalcoef;
   int k;
   boolT sign= toporient, nearzero2= False;
-  
+
   qh_gausselim(rows, dim-1, dim, &sign, nearzero);
-  for(k= dim-1; k--; ) {
+  for (k=dim-1; k--; ) {
     if ((rows[k])[k] < 0)
       sign ^= 1;
   }
   if (*nearzero) {
     zzinc_(Znearlysingular);
-    trace0((qh ferr, "qh_sethyperplane_gauss: nearly singular or axis parallel hyperplane during p%d.\n", qh furthest_id));
+    trace0((qh ferr, 4, "qh_sethyperplane_gauss: nearly singular or axis parallel hyperplane during p%d.\n", qh furthest_id));
     qh_backnormal(rows, dim-1, dim, sign, normal, &nearzero2);
   }else {
     qh_backnormal(rows, dim-1, dim, sign, normal, &nearzero2);
     if (nearzero2) {
       zzinc_(Znearlysingular);
-      trace0((qh ferr, "qh_sethyperplane_gauss: singular or axis parallel hyperplane at normalization during p%d.\n", qh furthest_id));
+      trace0((qh ferr, 5, "qh_sethyperplane_gauss: singular or axis parallel hyperplane at normalization during p%d.\n", qh furthest_id));
     }
   }
   if (nearzero2)
@@ -1221,9 +1226,9 @@
   pointcoord= point0;
   normalcoef= normal;
   *offset= -(*pointcoord++ * *normalcoef++);
-  for(k= dim-1; k--; )
+  for (k=dim-1; k--; )
     *offset -= *pointcoord++ * *normalcoef++;
 } /* sethyperplane_gauss */
 
-  
 
+

Modified: trunk/scipy/spatial/qhull/src/geom.h
===================================================================
--- trunk/scipy/spatial/qhull/src/geom.h	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/geom.h	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,30 +1,34 @@
 /*<html><pre>  -<a                             href="qh-geom.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-  geom.h 
+  geom.h
     header file for geometric routines
 
    see qh-geom.htm and geom.c
 
-   copyright (c) 1993-2003 The Geometry Center        
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/geom.h#18 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 */
 
 #ifndef qhDEFgeom
 #define qhDEFgeom 1
 
+#include "libqhull.h"
+
 /* ============ -macros- ======================== */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >--------------------------------</a><a name="fabs_">-</a>
-   
+
   fabs_(a)
     returns the absolute value of a
 */
 #define fabs_( a ) ((( a ) < 0 ) ? -( a ):( a ))
-               
+
 /*-<a                             href="qh-geom.htm#TOC"
   >--------------------------------</a><a name="fmax_">-</a>
-  
+
   fmax_(a,b)
     returns the maximum value of a and b
 */
@@ -44,7 +48,7 @@
   maximize_(maxval, val)
     set maxval to val if val is greater than maxval
 */
-#define maximize_( maxval, val ) {if (( maxval ) < ( val )) ( maxval )= ( val );}
+#define maximize_( maxval, val ) { if (( maxval ) < ( val )) ( maxval )= ( val ); }
 
 /*-<a                             href="qh-geom.htm#TOC"
   >--------------------------------</a><a name="minimize_">-</a>
@@ -52,25 +56,25 @@
   minimize_(minval, val)
     set minval to val if val is less than minval
 */
-#define minimize_( minval, val ) {if (( minval ) > ( val )) ( minval )= ( val );}
+#define minimize_( minval, val ) { if (( minval ) > ( val )) ( minval )= ( val ); }
 
 /*-<a                             href="qh-geom.htm#TOC"
   >--------------------------------</a><a name="det2_">-</a>
 
-  det2_(a1, a2,     
+  det2_(a1, a2,
         b1, b2)
-  
+
     compute a 2-d determinate
 */
 #define det2_( a1,a2,b1,b2 ) (( a1 )*( b2 ) - ( a2 )*( b1 ))
 
 /*-<a                             href="qh-geom.htm#TOC"
   >--------------------------------</a><a name="det3_">-</a>
-  
-  det3_(a1, a2, a3,    
+
+  det3_(a1, a2, a3,
        b1, b2, b3,
        c1, c2, c3)
-  
+
     compute a 3-d determinate
 */
 #define det3_( a1,a2,a3,b1,b2,b3,c1,c2,c3 ) ( ( a1 )*det2_( b2,b3,c2,c3 ) \
@@ -78,11 +82,11 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >--------------------------------</a><a name="dX">-</a>
-  
+
   dX( p1, p2 )
   dY( p1, p2 )
   dZ( p1, p2 )
-  
+
     given two indices into rows[],
 
     compute the difference between X, Y, or Z coordinates
@@ -94,82 +98,77 @@
 
 /*============= prototypes in alphabetical order, infrequent at end ======= */
 
-void    qh_backnormal (realT **rows, int numrow, int numcol, boolT sign, coordT *normal, boolT *nearzero);
-void	qh_distplane (pointT *point, facetT *facet, realT *dist);
-facetT *qh_findbest (pointT *point, facetT *startfacet,
-		     boolT bestoutside, boolT isnewfacets, boolT noupper,
-		     realT *dist, boolT *isoutside, int *numpart);
-facetT *qh_findbesthorizon (boolT ischeckmax, pointT *point, 
-	             facetT *startfacet, boolT noupper, realT *bestdist, int *numpart);
-facetT *qh_findbestnew (pointT *point, facetT *startfacet, realT *dist, 
-		     boolT bestoutside, boolT *isoutside, int *numpart);
-void 	qh_gausselim(realT **rows, int numrow, int numcol, boolT *sign, boolT *nearzero);
+void    qh_backnormal(realT **rows, int numrow, int numcol, boolT sign, coordT *normal, boolT *nearzero);
+void    qh_distplane(pointT *point, facetT *facet, realT *dist);
+facetT *qh_findbest(pointT *point, facetT *startfacet,
+                     boolT bestoutside, boolT isnewfacets, boolT noupper,
+                     realT *dist, boolT *isoutside, int *numpart);
+facetT *qh_findbesthorizon(boolT ischeckmax, pointT *point,
+                     facetT *startfacet, boolT noupper, realT *bestdist, int *numpart);
+facetT *qh_findbestnew(pointT *point, facetT *startfacet, realT *dist,
+                     boolT bestoutside, boolT *isoutside, int *numpart);
+void    qh_gausselim(realT **rows, int numrow, int numcol, boolT *sign, boolT *nearzero);
 realT   qh_getangle(pointT *vect1, pointT *vect2);
 pointT *qh_getcenter(setT *vertices);
 pointT *qh_getcentrum(facetT *facet);
 realT   qh_getdistance(facetT *facet, facetT *neighbor, realT *mindist, realT *maxdist);
-void    qh_normalize (coordT *normal, int dim, boolT toporient);
-void    qh_normalize2 (coordT *normal, int dim, boolT toporient, 
+void    qh_normalize(coordT *normal, int dim, boolT toporient);
+void    qh_normalize2 (coordT *normal, int dim, boolT toporient,
             realT *minnorm, boolT *ismin);
 pointT *qh_projectpoint(pointT *point, facetT *facet, realT dist);
 
 void    qh_setfacetplane(facetT *newfacets);
-void 	qh_sethyperplane_det (int dim, coordT **rows, coordT *point0, 
+void    qh_sethyperplane_det(int dim, coordT **rows, coordT *point0,
               boolT toporient, coordT *normal, realT *offset, boolT *nearzero);
-void 	qh_sethyperplane_gauss (int dim, coordT **rows, pointT *point0, 
-	     boolT toporient, coordT *normal, coordT *offset, boolT *nearzero);
-boolT   qh_sharpnewfacets (void);
+void    qh_sethyperplane_gauss(int dim, coordT **rows, pointT *point0,
+             boolT toporient, coordT *normal, coordT *offset, boolT *nearzero);
+boolT   qh_sharpnewfacets(void);
 
 /*========= infrequently used code in geom2.c =============*/
 
-
-coordT *qh_copypoints (coordT *points, int numpoints, int dimension);
-void    qh_crossproduct (int dim, realT vecA[3], realT vecB[3], realT vecC[3]);
-realT 	qh_determinant (realT **rows, int dim, boolT *nearzero);
-realT   qh_detjoggle (pointT *points, int numpoints, int dimension);
-void    qh_detroundoff (void);
+coordT *qh_copypoints(coordT *points, int numpoints, int dimension);
+void    qh_crossproduct(int dim, realT vecA[3], realT vecB[3], realT vecC[3]);
+realT   qh_determinant(realT **rows, int dim, boolT *nearzero);
+realT   qh_detjoggle(pointT *points, int numpoints, int dimension);
+void    qh_detroundoff(void);
 realT   qh_detsimplex(pointT *apex, setT *points, int dim, boolT *nearzero);
-realT   qh_distnorm (int dim, pointT *point, pointT *normal, realT *offsetp);
-realT   qh_distround (int dimension, realT maxabs, realT maxsumabs);
+realT   qh_distnorm(int dim, pointT *point, pointT *normal, realT *offsetp);
+realT   qh_distround(int dimension, realT maxabs, realT maxsumabs);
 realT   qh_divzero(realT numer, realT denom, realT mindenom1, boolT *zerodiv);
-realT   qh_facetarea (facetT *facet);
-realT   qh_facetarea_simplex (int dim, coordT *apex, setT *vertices, 
+realT   qh_facetarea(facetT *facet);
+realT   qh_facetarea_simplex(int dim, coordT *apex, setT *vertices,
           vertexT *notvertex,  boolT toporient, coordT *normal, realT *offset);
-pointT *qh_facetcenter (setT *vertices);
-facetT *qh_findgooddist (pointT *point, facetT *facetA, realT *distp, facetT **facetlist);
-void    qh_getarea (facetT *facetlist);
+pointT *qh_facetcenter(setT *vertices);
+facetT *qh_findgooddist(pointT *point, facetT *facetA, realT *distp, facetT **facetlist);
+void    qh_getarea(facetT *facetlist);
 boolT   qh_gram_schmidt(int dim, realT **rows);
-boolT   qh_inthresholds (coordT *normal, realT *angle);
-void    qh_joggleinput (void);
-realT  *qh_maxabsval (realT *normal, int dim);
+boolT   qh_inthresholds(coordT *normal, realT *angle);
+void    qh_joggleinput(void);
+realT  *qh_maxabsval(realT *normal, int dim);
 setT   *qh_maxmin(pointT *points, int numpoints, int dimension);
-realT   qh_maxouter (void);
-void    qh_maxsimplex (int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex);
-realT   qh_minabsval (realT *normal, int dim);
-int     qh_mindiff (realT *vecA, realT *vecB, int dim);
-boolT   qh_orientoutside (facetT *facet);
-void    qh_outerinner (facetT *facet, realT *outerplane, realT *innerplane);
+realT   qh_maxouter(void);
+void    qh_maxsimplex(int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex);
+realT   qh_minabsval(realT *normal, int dim);
+int     qh_mindiff(realT *vecA, realT *vecB, int dim);
+boolT   qh_orientoutside(facetT *facet);
+void    qh_outerinner(facetT *facet, realT *outerplane, realT *innerplane);
 coordT  qh_pointdist(pointT *point1, pointT *point2, int dim);
-void    qh_printmatrix (FILE *fp, char *string, realT **rows, int numrow, int numcol);
-void    qh_printpoints (FILE *fp, char *string, setT *points);
-void    qh_projectinput (void);
-void 	qh_projectpoints (signed char *project, int n, realT *points, 
+void    qh_printmatrix(FILE *fp, const char *string, realT **rows, int numrow, int numcol);
+void    qh_printpoints(FILE *fp, const char *string, setT *points);
+void    qh_projectinput(void);
+void    qh_projectpoints(signed char *project, int n, realT *points,
              int numpoints, int dim, realT *newpoints, int newdim);
-int     qh_rand( void);
-void    qh_srand( int seed);
-realT   qh_randomfactor (void);
-void    qh_randommatrix (realT *buffer, int dim, realT **row);
-void    qh_rotateinput (realT **rows);
-void    qh_rotatepoints (realT *points, int numpoints, int dim, realT **rows);
-void    qh_scaleinput (void);
-void    qh_scalelast (coordT *points, int numpoints, int dim, coordT low,
-		   coordT high, coordT newhigh);
-void 	qh_scalepoints (pointT *points, int numpoints, int dim,
-  		realT *newlows, realT *newhighs);
-boolT   qh_sethalfspace (int dim, coordT *coords, coordT **nextp, 
+void    qh_rotateinput(realT **rows);
+void    qh_rotatepoints(realT *points, int numpoints, int dim, realT **rows);
+void    qh_scaleinput(void);
+void    qh_scalelast(coordT *points, int numpoints, int dim, coordT low,
+                   coordT high, coordT newhigh);
+void    qh_scalepoints(pointT *points, int numpoints, int dim,
+                realT *newlows, realT *newhighs);
+boolT   qh_sethalfspace(int dim, coordT *coords, coordT **nextp,
               coordT *normal, coordT *offset, coordT *feasible);
-coordT *qh_sethalfspace_all (int dim, int count, coordT *halfspaces, pointT *feasible);
-pointT *qh_voronoi_center (int dim, setT *points);
+coordT *qh_sethalfspace_all(int dim, int count, coordT *halfspaces, pointT *feasible);
+pointT *qh_voronoi_center(int dim, setT *points);
 
 #endif /* qhDEFgeom */
 

Modified: trunk/scipy/spatial/qhull/src/geom2.c
===================================================================
--- trunk/scipy/spatial/qhull/src/geom2.c	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/geom2.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -2,66 +2,68 @@
   >-------------------------------</a><a name="TOP">-</a>
 
 
-   geom2.c 
+   geom2.c
    infrequently used geometric routines of qhull
 
    see qh-geom.htm and geom.h
 
-   copyright (c) 1993-2003 The Geometry Center        
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/geom2.c#29 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 
    frequently used code goes into geom.c
 */
-   
+
 #include "qhull_a.h"
-   
+
 /*================== functions in alphabetic order ============*/
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="copypoints">-</a>
 
   qh_copypoints( points, numpoints, dimension)
-    return malloc'd copy of points
+    return qh_malloc'd copy of points
 */
-coordT *qh_copypoints (coordT *points, int numpoints, int dimension) {
+coordT *qh_copypoints(coordT *points, int numpoints, int dimension) {
   int size;
   coordT *newpoints;
 
-  size= numpoints * dimension * sizeof(coordT);
-  if (!(newpoints=(coordT*)malloc(size))) {
-    fprintf(qh ferr, "qhull error: insufficient memory to copy %d points\n",
+  size= numpoints * dimension * (int)sizeof(coordT);
+  if (!(newpoints=(coordT*)qh_malloc((size_t)size))) {
+    qh_fprintf(qh ferr, 6004, "qhull error: insufficient memory to copy %d points\n",
         numpoints);
     qh_errexit(qh_ERRmem, NULL, NULL);
   }
-  memcpy ((char *)newpoints, (char *)points, size);
+  memcpy((char *)newpoints, (char *)points, (size_t)size);
   return newpoints;
 } /* copypoints */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="crossproduct">-</a>
-  
+
   qh_crossproduct( dim, vecA, vecB, vecC )
     crossproduct of 2 dim vectors
     C= A x B
-  
+
   notes:
     from Glasner, Graphics Gems I, p. 639
     only defined for dim==3
 */
-void qh_crossproduct (int dim, realT vecA[3], realT vecB[3], realT vecC[3]){
+void qh_crossproduct(int dim, realT vecA[3], realT vecB[3], realT vecC[3]){
 
   if (dim == 3) {
     vecC[0]=   det2_(vecA[1], vecA[2],
-		     vecB[1], vecB[2]);
+                     vecB[1], vecB[2]);
     vecC[1]= - det2_(vecA[0], vecA[2],
-		     vecB[0], vecB[2]);
+                     vecB[0], vecB[2]);
     vecC[2]=   det2_(vecA[0], vecA[1],
-		     vecB[0], vecB[1]);
+                     vecB[0], vecB[1]);
   }
 } /* vcross */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="determinant">-</a>
-  
+
   qh_determinant( rows, dim, nearzero )
     compute signed determinant of a square matrix
     uses qh.NEARzero to test for degenerate matrices
@@ -71,34 +73,34 @@
     overwrites rows and the matrix
     if dim == 2 or 3
       nearzero iff determinant < qh NEARzero[dim-1]
-      (not quite correct, not critical)
+      (!quite correct, not critical)
     if dim >= 4
       nearzero iff diagonal[k] < qh NEARzero[k]
 */
-realT qh_determinant (realT **rows, int dim, boolT *nearzero) {
+realT qh_determinant(realT **rows, int dim, boolT *nearzero) {
   realT det=0;
   int i;
   boolT sign= False;
 
   *nearzero= False;
   if (dim < 2) {
-    fprintf (qh ferr, "qhull internal error (qh_determinate): only implemented for dimension >= 2\n");
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_fprintf(qh ferr, 6005, "qhull internal error (qh_determinate): only implemented for dimension >= 2\n");
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }else if (dim == 2) {
     det= det2_(rows[0][0], rows[0][1],
-		 rows[1][0], rows[1][1]);
+                 rows[1][0], rows[1][1]);
     if (fabs_(det) < qh NEARzero[1])  /* not really correct, what should this be? */
       *nearzero= True;
   }else if (dim == 3) {
     det= det3_(rows[0][0], rows[0][1], rows[0][2],
-		 rows[1][0], rows[1][1], rows[1][2],
-		 rows[2][0], rows[2][1], rows[2][2]);
+                 rows[1][0], rows[1][1], rows[1][2],
+                 rows[2][0], rows[2][1], rows[2][2]);
     if (fabs_(det) < qh NEARzero[2])  /* not really correct, what should this be? */
       *nearzero= True;
-  }else {	
+  }else {
     qh_gausselim(rows, dim, dim, &sign, nearzero);  /* if nearzero, diagonal still ok*/
     det= 1.0;
-    for (i= dim; i--; )
+    for (i=dim; i--; )
       det *= (rows[i])[i];
     if (sign)
       det= -det;
@@ -108,7 +110,7 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="detjoggle">-</a>
-  
+
   qh_detjoggle( points, numpoints, dimension )
     determine default max joggle for point array
       as qh_distround * qh_JOGGLEdefault
@@ -122,7 +124,7 @@
 
     loop duplicated from qh_maxmin
 */
-realT qh_detjoggle (pointT *points, int numpoints, int dimension) {
+realT qh_detjoggle(pointT *points, int numpoints, int dimension) {
   realT abscoord, distround, joggle, maxcoord, mincoord;
   pointT *point, *pointtemp;
   realT maxabs= -REALmax;
@@ -130,7 +132,7 @@
   realT maxwidth= 0;
   int k;
 
-  for (k= 0; k < dimension; k++) {
+  for (k=0; k < dimension; k++) {
     if (qh SCALElast && k == dimension-1)
       abscoord= maxwidth;
     else if (qh DELAUNAY && k == dimension-1) /* will qh_setdelaunay() */
@@ -139,7 +141,7 @@
       maxcoord= -REALmax;
       mincoord= REALmax;
       FORALLpoint_(points, numpoints) {
-	maximize_(maxcoord, point[k]);
+        maximize_(maxcoord, point[k]);
         minimize_(mincoord, point[k]);
       }
       maximize_(maxwidth, maxcoord-mincoord);
@@ -148,19 +150,19 @@
     sumabs += abscoord;
     maximize_(maxabs, abscoord);
   } /* for k */
-  distround= qh_distround (qh hull_dim, maxabs, sumabs);
+  distround= qh_distround(qh hull_dim, maxabs, sumabs);
   joggle= distround * qh_JOGGLEdefault;
   maximize_(joggle, REALepsilon * qh_JOGGLEdefault);
-  trace2((qh ferr, "qh_detjoggle: joggle=%2.2g maxwidth=%2.2g\n", joggle, maxwidth));
+  trace2((qh ferr, 2001, "qh_detjoggle: joggle=%2.2g maxwidth=%2.2g\n", joggle, maxwidth));
   return joggle;
 } /* detjoggle */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="detroundoff">-</a>
-  
+
   qh_detroundoff()
     determine maximum roundoff errors from
-      REALepsilon, REALmax, REALmin, qh.hull_dim, qh.MAXabs_coord, 
+      REALepsilon, REALmax, REALmin, qh.hull_dim, qh.MAXabs_coord,
       qh.MAXsumcoord, qh.MAXwidth, qh.MINdenom_1
 
     accounts for qh.SETroundoff, qh.RANDOMdist, qh MERGEexact
@@ -185,17 +187,17 @@
       qh.MINoutside, qh.WIDEfacet
     initialize qh.max_vertex and qh.minvertex
 */
-void qh_detroundoff (void) {
+void qh_detroundoff(void) {
 
-  qh_option ("_max-width", NULL, &qh MAXwidth);
+  qh_option("_max-width", NULL, &qh MAXwidth);
   if (!qh SETroundoff) {
-    qh DISTround= qh_distround (qh hull_dim, qh MAXabs_coord, qh MAXsumcoord);
+    qh DISTround= qh_distround(qh hull_dim, qh MAXabs_coord, qh MAXsumcoord);
     if (qh RANDOMdist)
       qh DISTround += qh RANDOMfactor * qh MAXabs_coord;
-    qh_option ("Error-roundoff", NULL, &qh DISTround);
+    qh_option("Error-roundoff", NULL, &qh DISTround);
   }
   qh MINdenom= qh MINdenom_1 * qh MAXabs_coord;
-  qh MINdenom_1_2= sqrt (qh MINdenom_1 * qh hull_dim) ;  /* if will be normalized */
+  qh MINdenom_1_2= sqrt(qh MINdenom_1 * qh hull_dim) ;  /* if will be normalized */
   qh MINdenom_2= qh MINdenom_1_2 * qh MAXabs_coord;
                                               /* for inner product */
   qh ANGLEround= 1.01 * qh hull_dim * REALepsilon;
@@ -203,49 +205,49 @@
     qh ANGLEround += qh RANDOMfactor;
   if (qh premerge_cos < REALmax/2) {
     qh premerge_cos -= qh ANGLEround;
-    if (qh RANDOMdist) 
-      qh_option ("Angle-premerge-with-random", NULL, &qh premerge_cos);
+    if (qh RANDOMdist)
+      qh_option("Angle-premerge-with-random", NULL, &qh premerge_cos);
   }
   if (qh postmerge_cos < REALmax/2) {
     qh postmerge_cos -= qh ANGLEround;
     if (qh RANDOMdist)
-      qh_option ("Angle-postmerge-with-random", NULL, &qh postmerge_cos);
+      qh_option("Angle-postmerge-with-random", NULL, &qh postmerge_cos);
   }
   qh premerge_centrum += 2 * qh DISTround;    /*2 for centrum and distplane()*/
   qh postmerge_centrum += 2 * qh DISTround;
   if (qh RANDOMdist && (qh MERGEexact || qh PREmerge))
-    qh_option ("Centrum-premerge-with-random", NULL, &qh premerge_centrum);
+    qh_option("Centrum-premerge-with-random", NULL, &qh premerge_centrum);
   if (qh RANDOMdist && qh POSTmerge)
-    qh_option ("Centrum-postmerge-with-random", NULL, &qh postmerge_centrum);
+    qh_option("Centrum-postmerge-with-random", NULL, &qh postmerge_centrum);
   { /* compute ONEmerge, max vertex offset for merging simplicial facets */
     realT maxangle= 1.0, maxrho;
-    
+
     minimize_(maxangle, qh premerge_cos);
     minimize_(maxangle, qh postmerge_cos);
     /* max diameter * sin theta + DISTround for vertex to its hyperplane */
-    qh ONEmerge= sqrt (qh hull_dim) * qh MAXwidth *
-      sqrt (1.0 - maxangle * maxangle) + qh DISTround;  
+    qh ONEmerge= sqrt((realT)qh hull_dim) * qh MAXwidth *
+      sqrt(1.0 - maxangle * maxangle) + qh DISTround;
     maxrho= qh hull_dim * qh premerge_centrum + qh DISTround;
     maximize_(qh ONEmerge, maxrho);
     maxrho= qh hull_dim * qh postmerge_centrum + qh DISTround;
     maximize_(qh ONEmerge, maxrho);
     if (qh MERGING)
-      qh_option ("_one-merge", NULL, &qh ONEmerge);
+      qh_option("_one-merge", NULL, &qh ONEmerge);
   }
   qh NEARinside= qh ONEmerge * qh_RATIOnearinside; /* only used if qh KEEPnearinside */
   if (qh JOGGLEmax < REALmax/2 && (qh KEEPcoplanar || qh KEEPinside)) {
-    realT maxdist;	       /* adjust qh.NEARinside for joggle */
-    qh KEEPnearinside= True;   
-    maxdist= sqrt (qh hull_dim) * qh JOGGLEmax + qh DISTround;
+    realT maxdist;             /* adjust qh.NEARinside for joggle */
+    qh KEEPnearinside= True;
+    maxdist= sqrt((realT)qh hull_dim) * qh JOGGLEmax + qh DISTround;
     maxdist= 2*maxdist;        /* vertex and coplanar point can joggle in opposite directions */
     maximize_(qh NEARinside, maxdist);  /* must agree with qh_nearcoplanar() */
   }
   if (qh KEEPnearinside)
-    qh_option ("_near-inside", NULL, &qh NEARinside);
+    qh_option("_near-inside", NULL, &qh NEARinside);
   if (qh JOGGLEmax < qh DISTround) {
-    fprintf (qh ferr, "qhull error: the joggle for 'QJn', %.2g, is below roundoff for distance computations, %.2g\n",
+    qh_fprintf(qh ferr, 6006, "qhull error: the joggle for 'QJn', %.2g, is below roundoff for distance computations, %.2g\n",
          qh JOGGLEmax, qh DISTround);
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
   if (qh MINvisible > REALmax/2) {
     if (!qh MERGING)
@@ -256,26 +258,26 @@
       qh MINvisible= qh_COPLANARratio * qh premerge_centrum;
     if (qh APPROXhull && qh MINvisible > qh MINoutside)
       qh MINvisible= qh MINoutside;
-    qh_option ("Visible-distance", NULL, &qh MINvisible);
+    qh_option("Visible-distance", NULL, &qh MINvisible);
   }
   if (qh MAXcoplanar > REALmax/2) {
     qh MAXcoplanar= qh MINvisible;
-    qh_option ("U-coplanar-distance", NULL, &qh MAXcoplanar);
+    qh_option("U-coplanar-distance", NULL, &qh MAXcoplanar);
   }
   if (!qh APPROXhull) {             /* user may specify qh MINoutside */
     qh MINoutside= 2 * qh MINvisible;
-    if (qh premerge_cos < REALmax/2) 
+    if (qh premerge_cos < REALmax/2)
       maximize_(qh MINoutside, (1- qh premerge_cos) * qh MAXabs_coord);
-    qh_option ("Width-outside", NULL, &qh MINoutside);
+    qh_option("Width-outside", NULL, &qh MINoutside);
   }
   qh WIDEfacet= qh MINoutside;
-  maximize_(qh WIDEfacet, qh_WIDEcoplanar * qh MAXcoplanar); 
-  maximize_(qh WIDEfacet, qh_WIDEcoplanar * qh MINvisible); 
-  qh_option ("_wide-facet", NULL, &qh WIDEfacet);
-  if (qh MINvisible > qh MINoutside + 3 * REALepsilon 
+  maximize_(qh WIDEfacet, qh_WIDEcoplanar * qh MAXcoplanar);
+  maximize_(qh WIDEfacet, qh_WIDEcoplanar * qh MINvisible);
+  qh_option("_wide-facet", NULL, &qh WIDEfacet);
+  if (qh MINvisible > qh MINoutside + 3 * REALepsilon
   && !qh BESToutside && !qh FORCEoutput)
-    fprintf (qh ferr, "qhull input warning: minimum visibility V%.2g is greater than \nminimum outside W%.2g.  Flipped facets are likely.\n",
-	     qh MINvisible, qh MINoutside);
+    qh_fprintf(qh ferr, 7001, "qhull input warning: minimum visibility V%.2g is greater than \nminimum outside W%.2g.  Flipped facets are likely.\n",
+             qh MINvisible, qh MINoutside);
   qh max_vertex= qh DISTround;
   qh min_vertex= -qh DISTround;
   /* numeric constants reported in printsummary */
@@ -283,7 +285,7 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="detsimplex">-</a>
-  
+
   qh_detsimplex( apex, points, dim, nearzero )
     compute determinant of a simplex with point apex and base points
 
@@ -312,42 +314,42 @@
     rows[i++]= gmcoord;
     coordp= point;
     coorda= apex;
-    for (k= dim; k--; )
+    for (k=dim; k--; )
       *(gmcoord++)= *coordp++ - *coorda++;
   }
   if (i < dim) {
-    fprintf (qh ferr, "qhull internal error (qh_detsimplex): #points %d < dimension %d\n", 
+    qh_fprintf(qh ferr, 6007, "qhull internal error (qh_detsimplex): #points %d < dimension %d\n",
                i, dim);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
-  det= qh_determinant (rows, dim, nearzero);
-  trace2((qh ferr, "qh_detsimplex: det=%2.2g for point p%d, dim %d, nearzero? %d\n",
-	  det, qh_pointid(apex), dim, *nearzero)); 
+  det= qh_determinant(rows, dim, nearzero);
+  trace2((qh ferr, 2002, "qh_detsimplex: det=%2.2g for point p%d, dim %d, nearzero? %d\n",
+          det, qh_pointid(apex), dim, *nearzero));
   return det;
 } /* detsimplex */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="distnorm">-</a>
-  
+
   qh_distnorm( dim, point, normal, offset )
     return distance from point to hyperplane at normal/offset
 
   returns:
     dist
-  
-  notes:  
+
+  notes:
     dist > 0 if point is outside of hyperplane
-  
+
   see:
     qh_distplane in geom.c
 */
-realT qh_distnorm (int dim, pointT *point, pointT *normal, realT *offsetp) {
+realT qh_distnorm(int dim, pointT *point, pointT *normal, realT *offsetp) {
   coordT *normalp= normal, *coordp= point;
   realT dist;
   int k;
 
   dist= *offsetp;
-  for (k= dim; k--; )
+  for (k=dim; k--; )
     dist += *(coordp++) * *(normalp++);
   return dist;
 } /* distnorm */
@@ -355,7 +357,7 @@
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="distround">-</a>
 
-  qh_distround ( dimension, maxabs, maxsumabs )
+  qh_distround(dimension, maxabs, maxsumabs )
     compute maximum round-off error for a distance computation
       to a normalized hyperplane
     maxabs is the maximum absolute value of a coordinate
@@ -370,21 +372,21 @@
     use sqrt(dim) since one vector is normalized
       or use maxsumabs since one vector is < 1
 */
-realT qh_distround (int dimension, realT maxabs, realT maxsumabs) {
+realT qh_distround(int dimension, realT maxabs, realT maxsumabs) {
   realT maxdistsum, maxround;
 
-  maxdistsum= sqrt (dimension) * maxabs;
+  maxdistsum= sqrt((realT)dimension) * maxabs;
   minimize_( maxdistsum, maxsumabs);
   maxround= REALepsilon * (dimension * maxdistsum * 1.01 + maxabs);
               /* adds maxabs for offset */
-  trace4((qh ferr, "qh_distround: %2.2g maxabs %2.2g maxsumabs %2.2g maxdistsum %2.2g\n",
-	         maxround, maxabs, maxsumabs, maxdistsum));
+  trace4((qh ferr, 4008, "qh_distround: %2.2g maxabs %2.2g maxsumabs %2.2g maxdistsum %2.2g\n",
+                 maxround, maxabs, maxsumabs, maxdistsum));
   return maxround;
 } /* distround */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="divzero">-</a>
-  
+
   qh_divzero( numer, denom, mindenom1, zerodiv )
     divide by a number that's nearly zero
     mindenom1= minimum denominator for dividing into 1.0
@@ -392,7 +394,7 @@
   returns:
     quotient
     sets zerodiv and returns 0.0 if it would overflow
-  
+
   design:
     if numer is nearly zero and abs(numer) < abs(denom)
       return numer/denom
@@ -403,10 +405,10 @@
     else
       return 0 and zerodiv
 */
-realT qh_divzero (realT numer, realT denom, realT mindenom1, boolT *zerodiv) {
+realT qh_divzero(realT numer, realT denom, realT mindenom1, boolT *zerodiv) {
   realT temp, numerx, denomx;
-  
 
+
   if (numer < mindenom1 && numer > -mindenom1) {
     numerx= fabs_(numer);
     denomx= fabs_(denom);
@@ -427,22 +429,22 @@
     return 0.0;
   }
 } /* divzero */
-  
 
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="facetarea">-</a>
 
   qh_facetarea( facet )
     return area for a facet
-  
+
   notes:
-    if non-simplicial, 
+    if non-simplicial,
       uses centrum to triangulate facet and sums the projected areas.
     if (qh DELAUNAY),
       computes projected area instead for last coordinate
     assumes facet->normal exists
     projecting tricoplanar facets to the hyperplane does not appear to make a difference
-  
+
   design:
     if simplicial
       compute area
@@ -451,7 +453,7 @@
         compute area from centrum to ridge
     negate area if upper Delaunay facet
 */
-realT qh_facetarea (facetT *facet) {
+realT qh_facetarea(facetT *facet) {
   vertexT *apex;
   pointT *centrum;
   realT area= 0.0;
@@ -459,22 +461,22 @@
 
   if (facet->simplicial) {
     apex= SETfirstt_(facet->vertices, vertexT);
-    area= qh_facetarea_simplex (qh hull_dim, apex->point, facet->vertices, 
+    area= qh_facetarea_simplex(qh hull_dim, apex->point, facet->vertices,
                     apex, facet->toporient, facet->normal, &facet->offset);
   }else {
     if (qh CENTERtype == qh_AScentrum)
       centrum= facet->center;
     else
-      centrum= qh_getcentrum (facet);
-    FOREACHridge_(facet->ridges) 
-      area += qh_facetarea_simplex (qh hull_dim, centrum, ridge->vertices, 
-                 NULL, (ridge->top == facet),  facet->normal, &facet->offset);
+      centrum= qh_getcentrum(facet);
+    FOREACHridge_(facet->ridges)
+      area += qh_facetarea_simplex(qh hull_dim, centrum, ridge->vertices,
+                 NULL, (boolT)(ridge->top == facet),  facet->normal, &facet->offset);
     if (qh CENTERtype != qh_AScentrum)
-      qh_memfree (centrum, qh normal_size);
+      qh_memfree(centrum, qh normal_size);
   }
   if (facet->upperdelaunay && qh DELAUNAY)
     area= -area;  /* the normal should be [0,...,1] */
-  trace4((qh ferr, "qh_facetarea: f%d area %2.2g\n", facet->id, area)); 
+  trace4((qh ferr, 4009, "qh_facetarea: f%d area %2.2g\n", facet->id, area));
   return area;
 } /* facetarea */
 
@@ -482,22 +484,22 @@
   >-------------------------------</a><a name="facetarea_simplex">-</a>
 
   qh_facetarea_simplex( dim, apex, vertices, notvertex, toporient, normal, offset )
-    return area for a simplex defined by 
+    return area for a simplex defined by
       an apex, a base of vertices, an orientation, and a unit normal
-    if simplicial or tricoplanar facet, 
+    if simplicial or tricoplanar facet,
       notvertex is defined and it is skipped in vertices
-  
+
   returns:
     computes area of simplex projected to plane [normal,offset]
     returns 0 if vertex too far below plane (qh WIDEfacet)
       vertex can't be apex of tricoplanar facet
-  
+
   notes:
     if (qh DELAUNAY),
       computes projected area instead for last coordinate
     uses qh gm_matrix/gm_row and qh hull_dim
     helper function for qh_facetarea
-  
+
   design:
     if Notvertex
       translate simplex to apex
@@ -505,13 +507,13 @@
       project simplex to normal/offset
       translate simplex to apex
     if Delaunay
-      set last row/column to 0 with -1 on diagonal 
+      set last row/column to 0 with -1 on diagonal
     else
       set last row to Normal
     compute determinate
     scale and flip sign for area
 */
-realT qh_facetarea_simplex (int dim, coordT *apex, setT *vertices, 
+realT qh_facetarea_simplex(int dim, coordT *apex, setT *vertices,
         vertexT *notvertex,  boolT toporient, coordT *normal, realT *offset) {
   pointT *coorda, *coordp, *gmcoord;
   coordT **rows, *normalp;
@@ -530,76 +532,76 @@
     coordp= vertex->point;
     normalp= normal;
     if (notvertex) {
-      for (k= dim; k--; )
-	*(gmcoord++)= *coordp++ - *coorda++;
+      for (k=dim; k--; )
+        *(gmcoord++)= *coordp++ - *coorda++;
     }else {
       dist= *offset;
-      for (k= dim; k--; )
-	dist += *coordp++ * *normalp++;
+      for (k=dim; k--; )
+        dist += *coordp++ * *normalp++;
       if (dist < -qh WIDEfacet) {
-	zinc_(Znoarea);
-	return 0.0;
+        zinc_(Znoarea);
+        return 0.0;
       }
       coordp= vertex->point;
       normalp= normal;
-      for (k= dim; k--; )
-	*(gmcoord++)= (*coordp++ - dist * *normalp++) - *coorda++;
+      for (k=dim; k--; )
+        *(gmcoord++)= (*coordp++ - dist * *normalp++) - *coorda++;
     }
   }
   if (i != dim-1) {
-    fprintf (qh ferr, "qhull internal error (qh_facetarea_simplex): #points %d != dim %d -1\n", 
+    qh_fprintf(qh ferr, 6008, "qhull internal error (qh_facetarea_simplex): #points %d != dim %d -1\n",
                i, dim);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   rows[i]= gmcoord;
   if (qh DELAUNAY) {
-    for (i= 0; i < dim-1; i++)
+    for (i=0; i < dim-1; i++)
       rows[i][dim-1]= 0.0;
-    for (k= dim; k--; )
+    for (k=dim; k--; )
       *(gmcoord++)= 0.0;
     rows[dim-1][dim-1]= -1.0;
   }else {
     normalp= normal;
-    for (k= dim; k--; )
+    for (k=dim; k--; )
       *(gmcoord++)= *normalp++;
   }
   zinc_(Zdetsimplex);
-  area= qh_determinant (rows, dim, &nearzero);
+  area= qh_determinant(rows, dim, &nearzero);
   if (toporient)
     area= -area;
   area *= qh AREAfactor;
-  trace4((qh ferr, "qh_facetarea_simplex: area=%2.2g for point p%d, toporient %d, nearzero? %d\n",
-	  area, qh_pointid(apex), toporient, nearzero)); 
+  trace4((qh ferr, 4010, "qh_facetarea_simplex: area=%2.2g for point p%d, toporient %d, nearzero? %d\n",
+          area, qh_pointid(apex), toporient, nearzero));
   return area;
 } /* facetarea_simplex */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="facetcenter">-</a>
-  
+
   qh_facetcenter( vertices )
     return Voronoi center (Voronoi vertex) for a facet's vertices
 
   returns:
     return temporary point equal to the center
-    
+
   see:
     qh_voronoi_center()
 */
-pointT *qh_facetcenter (setT *vertices) {
-  setT *points= qh_settemp (qh_setsize (vertices));
+pointT *qh_facetcenter(setT *vertices) {
+  setT *points= qh_settemp(qh_setsize(vertices));
   vertexT *vertex, **vertexp;
   pointT *center;
-  
-  FOREACHvertex_(vertices) 
-    qh_setappend (&points, vertex->point);
-  center= qh_voronoi_center (qh hull_dim-1, points);
-  qh_settempfree (&points);
+
+  FOREACHvertex_(vertices)
+    qh_setappend(&points, vertex->point);
+  center= qh_voronoi_center(qh hull_dim-1, points);
+  qh_settempfree(&points);
   return center;
 } /* facetcenter */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="findgooddist">-</a>
-  
+
   qh_findgooddist( point, facetA, dist, facetlist )
     find best good facet visible for point from facetA
     assumes facetA is visible from point
@@ -608,7 +610,7 @@
     best facet, i.e., good facet that is furthest from point
       distance to best facet
       NULL if none
-      
+
     moves good, visible facets (and some other visible facets)
       to end of qh facet_list
 
@@ -624,20 +626,20 @@
         update best good neighbor
         if no good neighbors, update best facet
 */
-facetT *qh_findgooddist (pointT *point, facetT *facetA, realT *distp, 
+facetT *qh_findgooddist(pointT *point, facetT *facetA, realT *distp,
                facetT **facetlist) {
   realT bestdist= -REALmax, dist;
   facetT *neighbor, **neighborp, *bestfacet=NULL, *facet;
-  boolT goodseen= False;  
+  boolT goodseen= False;
 
   if (facetA->good) {
-    zinc_(Zcheckpart);  /* calls from check_bestdist occur after print stats */
-    qh_distplane (point, facetA, &bestdist);
+    zzinc_(Zcheckpart);  /* calls from check_bestdist occur after print stats */
+    qh_distplane(point, facetA, &bestdist);
     bestfacet= facetA;
     goodseen= True;
   }
-  qh_removefacet (facetA);
-  qh_appendfacet (facetA);
+  qh_removefacet(facetA);
+  qh_appendfacet(facetA);
   *facetlist= facetA;
   facetA->visitid= ++qh visit_id;
   FORALLfacet_(*facetlist) {
@@ -647,11 +649,11 @@
       neighbor->visitid= qh visit_id;
       if (goodseen && !neighbor->good)
         continue;
-      zinc_(Zcheckpart); 
-      qh_distplane (point, neighbor, &dist);
+      zzinc_(Zcheckpart);
+      qh_distplane(point, neighbor, &dist);
       if (dist > 0) {
-        qh_removefacet (neighbor);
-        qh_appendfacet (neighbor);
+        qh_removefacet(neighbor);
+        qh_appendfacet(neighbor);
         if (neighbor->good) {
           goodseen= True;
           if (dist > bestdist) {
@@ -664,60 +666,66 @@
   }
   if (bestfacet) {
     *distp= bestdist;
-    trace2((qh ferr, "qh_findgooddist: p%d is %2.2g above good facet f%d\n",
+    trace2((qh ferr, 2003, "qh_findgooddist: p%d is %2.2g above good facet f%d\n",
       qh_pointid(point), bestdist, bestfacet->id));
     return bestfacet;
   }
-  trace4((qh ferr, "qh_findgooddist: no good facet for p%d above f%d\n", 
+  trace4((qh ferr, 4011, "qh_findgooddist: no good facet for p%d above f%d\n",
       qh_pointid(point), facetA->id));
   return NULL;
 }  /* findgooddist */
-    
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="getarea">-</a>
-  
+
   qh_getarea( facetlist )
     set area of all facets in facetlist
     collect statistics
+    nop if hasAreaVolume
 
   returns:
     sets qh totarea/totvol to total area and volume of convex hull
     for Delaunay triangulation, computes projected area of the lower or upper hull
       ignores upper hull if qh ATinfinity
-  
+
   notes:
     could compute outer volume by expanding facet area by rays from interior
     the following attempt at perpendicular projection underestimated badly:
-      qh.totoutvol += (-dist + facet->maxoutside + qh DISTround) 
+      qh.totoutvol += (-dist + facet->maxoutside + qh DISTround)
                             * area/ qh hull_dim;
   design:
     for each facet on facetlist
       compute facet->area
       update qh.totarea and qh.totvol
 */
-void qh_getarea (facetT *facetlist) {
+void qh_getarea(facetT *facetlist) {
   realT area;
   realT dist;
   facetT *facet;
 
+  if (qh hasAreaVolume)
+    return;
   if (qh REPORTfreq)
-    fprintf (qh ferr, "computing area of each facet and volume of the convex hull\n");
-  else 
-    trace1((qh ferr, "qh_getarea: computing volume and area for each facet\n"));
+    qh_fprintf(qh ferr, 8020, "computing area of each facet and volume of the convex hull\n");
+  else
+    trace1((qh ferr, 1001, "qh_getarea: computing volume and area for each facet\n"));
   qh totarea= qh totvol= 0.0;
   FORALLfacet_(facetlist) {
     if (!facet->normal)
       continue;
     if (facet->upperdelaunay && qh ATinfinity)
       continue;
-    facet->f.area= area= qh_facetarea (facet);
-    facet->isarea= True;
+    if (!facet->isarea) {
+      facet->f.area= qh_facetarea(facet);
+      facet->isarea= True;
+    }
+    area= facet->f.area;
     if (qh DELAUNAY) {
       if (facet->upperdelaunay == qh UPPERdelaunay)
-	qh totarea += area;
+        qh totarea += area;
     }else {
       qh totarea += area;
-      qh_distplane (qh interior_point, facet, &dist);
+      qh_distplane(qh interior_point, facet, &dist);
       qh totvol += -dist * area/ qh hull_dim;
     }
     if (qh PRINTstatistics) {
@@ -726,11 +734,12 @@
       wmin_(Wareamin, area);
     }
   }
+  qh hasAreaVolume= True;
 } /* getarea */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="gram_schmidt">-</a>
-  
+
   qh_gram_schmidt( dim, row )
     implements Gram-Schmidt orthogonalization by rows
 
@@ -753,8 +762,8 @@
 boolT qh_gram_schmidt(int dim, realT **row) {
   realT *rowi, *rowj, norm;
   int i, j, k;
-  
-  for(i=0; i < dim; i++) {
+
+  for (i=0; i < dim; i++) {
     rowi= row[i];
     for (norm= 0.0, k= dim; k--; rowi++)
       norm += *rowi * *rowi;
@@ -762,14 +771,14 @@
     wmin_(Wmindenom, norm);
     if (norm == 0.0)  /* either 0 or overflow due to sqrt */
       return False;
-    for(k= dim; k--; )
-      *(--rowi) /= norm;  
-    for(j= i+1; j < dim; j++) {
+    for (k=dim; k--; )
+      *(--rowi) /= norm;
+    for (j=i+1; j < dim; j++) {
       rowj= row[j];
-      for(norm= 0.0, k=dim; k--; )
-	norm += *rowi++ * *rowj++;
-      for(k=dim; k--; )
-	*(--rowj) -= *(--rowi) * norm;
+      for (norm= 0.0, k=dim; k--; )
+        norm += *rowi++ * *rowj++;
+      for (k=dim; k--; )
+        *(--rowj) -= *(--rowi) * norm;
     }
   }
   return True;
@@ -778,7 +787,7 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="inthresholds">-</a>
-  
+
   qh_inthresholds( normal, angle )
     return True if normal within qh.lower_/upper_threshold
 
@@ -786,7 +795,7 @@
     estimate of angle by summing of threshold diffs
       angle may be NULL
       smaller "angle" is better
-  
+
   notes:
     invalid if qh.SPLITthresholds
 
@@ -798,21 +807,21 @@
     for each dimension
       test threshold
 */
-boolT qh_inthresholds (coordT *normal, realT *angle) {
+boolT qh_inthresholds(coordT *normal, realT *angle) {
   boolT within= True;
   int k;
   realT threshold;
 
   if (angle)
     *angle= 0.0;
-  for(k= 0; k < qh hull_dim; k++) {
+  for (k=0; k < qh hull_dim; k++) {
     threshold= qh lower_threshold[k];
     if (threshold > -REALmax/2) {
       if (normal[k] < threshold)
         within= False;
       if (angle) {
-	threshold -= normal[k];
-	*angle += fabs_(threshold);
+        threshold -= normal[k];
+        *angle += fabs_(threshold);
       }
     }
     if (qh upper_threshold[k] < REALmax/2) {
@@ -820,23 +829,23 @@
       if (normal[k] > threshold)
         within= False;
       if (angle) {
-	threshold -= normal[k];
-	*angle += fabs_(threshold);
+        threshold -= normal[k];
+        *angle += fabs_(threshold);
       }
     }
   }
   return within;
 } /* inthresholds */
-    
 
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="joggleinput">-</a>
-  
+
   qh_joggleinput()
     randomly joggle input to Qhull by qh.JOGGLEmax
     initial input is qh.first_point/qh.num_points of qh.hull_dim
       repeated calls use qh.input_points/qh.num_points
- 
+
   returns:
     joggles points at qh.first_point/qh.num_points
     copies data to qh.input_points/qh.input_malloc if first time
@@ -861,8 +870,8 @@
     if qh.DELAUNAY
       sets the Delaunay projection
 */
-void qh_joggleinput (void) {
-  int size, i, seed;
+void qh_joggleinput(void) {
+  int i, seed, size;
   coordT *coordp, *inputp;
   realT randr, randa, randb;
 
@@ -870,66 +879,66 @@
     qh input_points= qh first_point;
     qh input_malloc= qh POINTSmalloc;
     size= qh num_points * qh hull_dim * sizeof(coordT);
-    if (!(qh first_point=(coordT*)malloc(size))) {
-      fprintf(qh ferr, "qhull error: insufficient memory to joggle %d points\n",
+    if (!(qh first_point=(coordT*)qh_malloc((size_t)size))) {
+      qh_fprintf(qh ferr, 6009, "qhull error: insufficient memory to joggle %d points\n",
           qh num_points);
       qh_errexit(qh_ERRmem, NULL, NULL);
     }
     qh POINTSmalloc= True;
     if (qh JOGGLEmax == 0.0) {
-      qh JOGGLEmax= qh_detjoggle (qh input_points, qh num_points, qh hull_dim);
-      qh_option ("QJoggle", NULL, &qh JOGGLEmax);
+      qh JOGGLEmax= qh_detjoggle(qh input_points, qh num_points, qh hull_dim);
+      qh_option("QJoggle", NULL, &qh JOGGLEmax);
     }
   }else {                 /* repeated call */
     if (!qh RERUN && qh build_cnt > qh_JOGGLEretry) {
       if (((qh build_cnt-qh_JOGGLEretry-1) % qh_JOGGLEagain) == 0) {
-	realT maxjoggle= qh MAXwidth * qh_JOGGLEmaxincrease;
-	if (qh JOGGLEmax < maxjoggle) {
-	  qh JOGGLEmax *= qh_JOGGLEincrease;
-	  minimize_(qh JOGGLEmax, maxjoggle); 
-	}
+        realT maxjoggle= qh MAXwidth * qh_JOGGLEmaxincrease;
+        if (qh JOGGLEmax < maxjoggle) {
+          qh JOGGLEmax *= qh_JOGGLEincrease;
+          minimize_(qh JOGGLEmax, maxjoggle);
+        }
       }
     }
-    qh_option ("QJoggle", NULL, &qh JOGGLEmax);
+    qh_option("QJoggle", NULL, &qh JOGGLEmax);
   }
   if (qh build_cnt > 1 && qh JOGGLEmax > fmax_(qh MAXwidth/4, 0.1)) {
-      fprintf (qh ferr, "qhull error: the current joggle for 'QJn', %.2g, is too large for the width\nof the input.  If possible, recompile Qhull with higher-precision reals.\n",
-	        qh JOGGLEmax);
-      qh_errexit (qh_ERRqhull, NULL, NULL);
+      qh_fprintf(qh ferr, 6010, "qhull error: the current joggle for 'QJn', %.2g, is too large for the width\nof the input.  If possible, recompile Qhull with higher-precision reals.\n",
+                qh JOGGLEmax);
+      qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   /* for some reason, using qh ROTATErandom and qh_RANDOMseed does not repeat the run. Use 'TRn' instead */
   seed= qh_RANDOMint;
-  qh_option ("_joggle-seed", &seed, NULL);
-  trace0((qh ferr, "qh_joggleinput: joggle input by %2.2g with seed %d\n", 
+  qh_option("_joggle-seed", &seed, NULL);
+  trace0((qh ferr, 6, "qh_joggleinput: joggle input by %2.2g with seed %d\n",
     qh JOGGLEmax, seed));
   inputp= qh input_points;
   coordp= qh first_point;
   randa= 2.0 * qh JOGGLEmax/qh_RANDOMmax;
   randb= -qh JOGGLEmax;
   size= qh num_points * qh hull_dim;
-  for (i= size; i--; ) {
+  for (i=size; i--; ) {
     randr= qh_RANDOMint;
     *(coordp++)= *(inputp++) + (randr * randa + randb);
   }
   if (qh DELAUNAY) {
     qh last_low= qh last_high= qh last_newhigh= REALmax;
-    qh_setdelaunay (qh hull_dim, qh num_points, qh first_point);
+    qh_setdelaunay(qh hull_dim, qh num_points, qh first_point);
   }
 } /* joggleinput */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="maxabsval">-</a>
-  
+
   qh_maxabsval( normal, dim )
     return pointer to maximum absolute value of a dim vector
     returns NULL if dim=0
 */
-realT *qh_maxabsval (realT *normal, int dim) {
+realT *qh_maxabsval(realT *normal, int dim) {
   realT maxval= -REALmax;
   realT *maxp= NULL, *colp, absval;
   int k;
 
-  for (k= dim, colp= normal; k--; colp++) {
+  for (k=dim, colp= normal; k--; colp++) {
     absval= fabs_(*colp);
     if (absval > maxval) {
       maxval= absval;
@@ -942,9 +951,9 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="maxmin">-</a>
-  
+
   qh_maxmin( points, numpoints, dimension )
-    return max/min points for each dimension      
+    return max/min points for each dimension
     determine max and min coordinates
 
   returns:
@@ -984,24 +993,24 @@
   && REALmax > 0.0 && -REALmax < 0.0)
     ; /* all ok */
   else {
-    fprintf (qh ferr, "qhull error: floating point constants in user.h are wrong\n\
+    qh_fprintf(qh ferr, 6011, "qhull error: floating point constants in user.h are wrong\n\
 REALepsilon %g REALmin %g REALmax %g -REALmax %g\n",
-	     REALepsilon, REALmin, REALmax, -REALmax);
-    qh_errexit (qh_ERRinput, NULL, NULL);
+             REALepsilon, REALmin, REALmax, -REALmax);
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
   set= qh_settemp(2*dimension);
-  for(k= 0; k < dimension; k++) {
+  for (k=0; k < dimension; k++) {
     if (points == qh GOODpointp)
       minimum= maximum= points + dimension;
     else
       minimum= maximum= points;
     FORALLpoint_(points, numpoints) {
       if (point == qh GOODpointp)
-	continue;
+        continue;
       if (maximum[k] < point[k])
-	maximum= point;
+        maximum= point;
       else if (minimum[k] > point[k])
-	minimum= point;
+        minimum= point;
     }
     if (k == dimension-1) {
       qh MINlastcoord= minimum[k];
@@ -1020,15 +1029,15 @@
     }
     maximize_(qh MAXabs_coord, maxcoord);
     qh MAXsumcoord += maxcoord;
-    qh_setappend (&set, maximum);
-    qh_setappend (&set, minimum);
+    qh_setappend(&set, maximum);
+    qh_setappend(&set, minimum);
     /* calculation of qh NEARzero is based on error formula 4.4-13 of
        Golub & van Loan, authors say n^3 can be ignored and 10 be used in
        place of rho */
     qh NEARzero[k]= 80 * qh MAXsumcoord * REALepsilon;
   }
   if (qh IStracing >=1)
-    qh_printpoints (qh ferr, "qh_maxmin: found the max and min points (by dim):", set);
+    qh_printpoints(qh ferr, "qh_maxmin: found the max and min points(by dim):", set);
   return(set);
 } /* maxmin */
 
@@ -1042,33 +1051,33 @@
 
   see:
     qh_outerinner()
-    
+
   notes:
     need to add another qh.DISTround if testing actual point with computation
 
   for joggle:
     qh_setfacetplane() updated qh.max_outer for Wnewvertexmax (max distance to vertex)
-    need to use Wnewvertexmax since could have a coplanar point for a high 
+    need to use Wnewvertexmax since could have a coplanar point for a high
       facet that is replaced by a low facet
     need to add qh.JOGGLEmax if testing input points
 */
-realT qh_maxouter (void) {
+realT qh_maxouter(void) {
   realT dist;
 
   dist= fmax_(qh max_outside, qh DISTround);
   dist += qh DISTround;
-  trace4((qh ferr, "qh_maxouter: max distance from facet to outer plane is %2.2g max_outside is %2.2g\n", dist, qh max_outside));
+  trace4((qh ferr, 4012, "qh_maxouter: max distance from facet to outer plane is %2.2g max_outside is %2.2g\n", dist, qh max_outside));
   return dist;
 } /* maxouter */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="maxsimplex">-</a>
-  
+
   qh_maxsimplex( dim, maxpoints, points, numpoints, simplex )
-    determines maximum simplex for a set of points 
+    determines maximum simplex for a set of points
     starts from points already in simplex
     skips qh.GOODpointp (assumes that it isn't in maxpoints)
-  
+
   returns:
     simplex with dim+1 points
 
@@ -1082,114 +1091,114 @@
       (find points with max or min x coordinate)
     for each remaining dimension
       add point that maximizes the determinate
-        (use points from maxpoints first)    
+        (use points from maxpoints first)
 */
-void qh_maxsimplex (int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex) {
+void qh_maxsimplex(int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex) {
   pointT *point, **pointp, *pointtemp, *maxpoint, *minx=NULL, *maxx=NULL;
   boolT nearzero, maxnearzero= False;
   int k, sizinit;
   realT maxdet= -REALmax, det, mincoord= REALmax, maxcoord= -REALmax;
 
-  sizinit= qh_setsize (*simplex);
+  sizinit= qh_setsize(*simplex);
   if (sizinit < 2) {
-    if (qh_setsize (maxpoints) >= 2) {
+    if (qh_setsize(maxpoints) >= 2) {
       FOREACHpoint_(maxpoints) {
         if (maxcoord < point[0]) {
           maxcoord= point[0];
           maxx= point;
         }
-	if (mincoord > point[0]) {
+        if (mincoord > point[0]) {
           mincoord= point[0];
           minx= point;
         }
       }
     }else {
       FORALLpoint_(points, numpoints) {
-	if (point == qh GOODpointp)
-	  continue;
+        if (point == qh GOODpointp)
+          continue;
         if (maxcoord < point[0]) {
-	  maxcoord= point[0];
+          maxcoord= point[0];
           maxx= point;
         }
-	if (mincoord > point[0]) {
+        if (mincoord > point[0]) {
           mincoord= point[0];
           minx= point;
-	}
+        }
       }
     }
-    qh_setunique (simplex, minx);
-    if (qh_setsize (*simplex) < 2)
-      qh_setunique (simplex, maxx);
-    sizinit= qh_setsize (*simplex);
+    qh_setunique(simplex, minx);
+    if (qh_setsize(*simplex) < 2)
+      qh_setunique(simplex, maxx);
+    sizinit= qh_setsize(*simplex);
     if (sizinit < 2) {
-      qh_precision ("input has same x coordinate");
+      qh_precision("input has same x coordinate");
       if (zzval_(Zsetplane) > qh hull_dim+1) {
-	fprintf (qh ferr, "qhull precision error (qh_maxsimplex for voronoi_center):\n%d points with the same x coordinate.\n",
-		 qh_setsize(maxpoints)+numpoints);
-	qh_errexit (qh_ERRprec, NULL, NULL);
+        qh_fprintf(qh ferr, 6012, "qhull precision error (qh_maxsimplex for voronoi_center):\n%d points with the same x coordinate.\n",
+                 qh_setsize(maxpoints)+numpoints);
+        qh_errexit(qh_ERRprec, NULL, NULL);
       }else {
-	fprintf (qh ferr, "qhull input error: input is less than %d-dimensional since it has the same x coordinate\n", qh hull_dim);
-	qh_errexit (qh_ERRinput, NULL, NULL);
+        qh_fprintf(qh ferr, 6013, "qhull input error: input is less than %d-dimensional since it has the same x coordinate\n", qh hull_dim);
+        qh_errexit(qh_ERRinput, NULL, NULL);
       }
     }
   }
-  for(k= sizinit; k < dim+1; k++) {
+  for (k=sizinit; k < dim+1; k++) {
     maxpoint= NULL;
     maxdet= -REALmax;
     FOREACHpoint_(maxpoints) {
-      if (!qh_setin (*simplex, point)) {
+      if (!qh_setin(*simplex, point)) {
         det= qh_detsimplex(point, *simplex, k, &nearzero);
         if ((det= fabs_(det)) > maxdet) {
-	  maxdet= det;
+          maxdet= det;
           maxpoint= point;
-	  maxnearzero= nearzero;
+          maxnearzero= nearzero;
         }
       }
     }
     if (!maxpoint || maxnearzero) {
       zinc_(Zsearchpoints);
       if (!maxpoint) {
-        trace0((qh ferr, "qh_maxsimplex: searching all points for %d-th initial vertex.\n", k+1));
+        trace0((qh ferr, 7, "qh_maxsimplex: searching all points for %d-th initial vertex.\n", k+1));
       }else {
-        trace0((qh ferr, "qh_maxsimplex: searching all points for %d-th initial vertex, better than p%d det %2.2g\n",
-		k+1, qh_pointid(maxpoint), maxdet));
+        trace0((qh ferr, 8, "qh_maxsimplex: searching all points for %d-th initial vertex, better than p%d det %2.2g\n",
+                k+1, qh_pointid(maxpoint), maxdet));
       }
       FORALLpoint_(points, numpoints) {
-	if (point == qh GOODpointp)
-	  continue;
-        if (!qh_setin (*simplex, point)) {
+        if (point == qh GOODpointp)
+          continue;
+        if (!qh_setin(*simplex, point)) {
           det= qh_detsimplex(point, *simplex, k, &nearzero);
           if ((det= fabs_(det)) > maxdet) {
-	    maxdet= det;
+            maxdet= det;
             maxpoint= point;
-	    maxnearzero= nearzero;
-	  }
+            maxnearzero= nearzero;
+          }
         }
       }
     } /* !maxpoint */
     if (!maxpoint) {
-      fprintf (qh ferr, "qhull internal error (qh_maxsimplex): not enough points available\n");
-      qh_errexit (qh_ERRqhull, NULL, NULL);
+      qh_fprintf(qh ferr, 6014, "qhull internal error (qh_maxsimplex): not enough points available\n");
+      qh_errexit(qh_ERRqhull, NULL, NULL);
     }
     qh_setappend(simplex, maxpoint);
-    trace1((qh ferr, "qh_maxsimplex: selected point p%d for %d`th initial vertex, det=%2.2g\n",
-	    qh_pointid(maxpoint), k+1, maxdet));
-  } /* k */ 
+    trace1((qh ferr, 1002, "qh_maxsimplex: selected point p%d for %d`th initial vertex, det=%2.2g\n",
+            qh_pointid(maxpoint), k+1, maxdet));
+  } /* k */
 } /* maxsimplex */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="minabsval">-</a>
-  
+
   qh_minabsval( normal, dim )
     return minimum absolute value of a dim vector
 */
-realT qh_minabsval (realT *normal, int dim) {
+realT qh_minabsval(realT *normal, int dim) {
   realT minval= 0;
   realT maxval= 0;
   realT *colp;
   int k;
 
-  for (k= dim, colp= normal; k--; colp++) {
+  for (k=dim, colp=normal; k--; colp++) {
     maximize_(maxval, *colp);
     minimize_(minval, *colp);
   }
@@ -1199,16 +1208,16 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="mindiff">-</a>
-  
-  qh_mindif( vecA, vecB, dim )
+
+  qh_mindif ( vecA, vecB, dim )
     return index of min abs. difference of two vectors
 */
-int qh_mindiff (realT *vecA, realT *vecB, int dim) {
+int qh_mindiff(realT *vecA, realT *vecB, int dim) {
   realT mindiff= REALmax, diff;
   realT *vecAp= vecA, *vecBp= vecB;
   int k, mink= 0;
 
-  for (k= 0; k < dim; k++) {
+  for (k=0; k < dim; k++) {
     diff= *vecAp++ - *vecBp++;
     diff= fabs_(diff);
     if (diff < mindiff) {
@@ -1223,20 +1232,20 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="orientoutside">-</a>
-  
+
   qh_orientoutside( facet  )
     make facet outside oriented via qh.interior_point
 
   returns:
     True if facet reversed orientation.
 */
-boolT qh_orientoutside (facetT *facet) {
+boolT qh_orientoutside(facetT *facet) {
   int k;
   realT dist;
 
-  qh_distplane (qh interior_point, facet, &dist);
+  qh_distplane(qh interior_point, facet, &dist);
   if (dist > 0) {
-    for (k= qh hull_dim; k--; )
+    for (k=qh hull_dim; k--; )
       facet->normal[k]= -facet->normal[k];
     facet->offset= -facet->offset;
     return True;
@@ -1246,7 +1255,7 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="outerinner">-</a>
-  
+
   qh_outerinner( facet, outerplane, innerplane  )
     if facet and qh.maxoutdone (i.e., qh_check_maxout)
       returns outer and inner plane for facet
@@ -1259,11 +1268,13 @@
 
   notes:
     outerplaner or innerplane may be NULL
-    
+    facet is const
+    Does not error (QhullFacet)
+
     includes qh.DISTround for actual points
     adds another qh.DISTround if testing with floating point arithmetic
 */
-void qh_outerinner (facetT *facet, realT *outerplane, realT *innerplane) {
+void qh_outerinner(facetT *facet, realT *outerplane, realT *innerplane) {
   realT dist, mindist;
   vertexT *vertex, **vertexp;
 
@@ -1271,33 +1282,33 @@
     if (!qh_MAXoutside || !facet || !qh maxoutdone) {
       *outerplane= qh_maxouter();       /* includes qh.DISTround */
     }else { /* qh_MAXoutside ... */
-#if qh_MAXoutside 
+#if qh_MAXoutside
       *outerplane= facet->maxoutside + qh DISTround;
 #endif
-      
+
     }
     if (qh JOGGLEmax < REALmax/2)
-      *outerplane += qh JOGGLEmax * sqrt (qh hull_dim);
+      *outerplane += qh JOGGLEmax * sqrt((realT)qh hull_dim);
   }
   if (innerplane) {
     if (facet) {
       mindist= REALmax;
       FOREACHvertex_(facet->vertices) {
         zinc_(Zdistio);
-        qh_distplane (vertex->point, facet, &dist);
+        qh_distplane(vertex->point, facet, &dist);
         minimize_(mindist, dist);
       }
       *innerplane= mindist - qh DISTround;
-    }else 
+    }else
       *innerplane= qh min_vertex - qh DISTround;
     if (qh JOGGLEmax < REALmax/2)
-      *innerplane -= qh JOGGLEmax * sqrt (qh hull_dim);
+      *innerplane -= qh JOGGLEmax * sqrt((realT)qh hull_dim);
   }
 } /* outerinner */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="pointdist">-</a>
-  
+
   qh_pointdist( point1, point2, dim )
     return distance between two points
 
@@ -1307,7 +1318,7 @@
 coordT qh_pointdist(pointT *point1, pointT *point2, int dim) {
   coordT dist, diff;
   int k;
-  
+
   dist= 0.0;
   for (k= (dim > 0 ? dim : -dim); k--; ) {
     diff= *point1++ - *point2++;
@@ -1321,7 +1332,7 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="printmatrix">-</a>
-  
+
   qh_printmatrix( fp, string, rows, numrow, numcol )
     print matrix to fp given by row vectors
     print string as header
@@ -1329,53 +1340,53 @@
   notes:
     print a vector by qh_printmatrix(fp, "", &vect, 1, len)
 */
-void qh_printmatrix (FILE *fp, char *string, realT **rows, int numrow, int numcol) {
+void qh_printmatrix(FILE *fp, const char *string, realT **rows, int numrow, int numcol) {
   realT *rowp;
   realT r; /*bug fix*/
   int i,k;
 
-  fprintf (fp, "%s\n", string);
-  for (i= 0; i < numrow; i++) {
+  qh_fprintf(fp, 9001, "%s\n", string);
+  for (i=0; i < numrow; i++) {
     rowp= rows[i];
-    for (k= 0; k < numcol; k++) {
+    for (k=0; k < numcol; k++) {
       r= *rowp++;
-      fprintf (fp, "%6.3g ", r);
+      qh_fprintf(fp, 9002, "%6.3g ", r);
     }
-    fprintf (fp, "\n");
+    qh_fprintf(fp, 9003, "\n");
   }
 } /* printmatrix */
 
-  
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="printpoints">-</a>
-  
+
   qh_printpoints( fp, string, points )
     print pointids to fp for a set of points
     if string, prints string and 'p' point ids
 */
-void qh_printpoints (FILE *fp, char *string, setT *points) {
+void qh_printpoints(FILE *fp, const char *string, setT *points) {
   pointT *point, **pointp;
 
   if (string) {
-    fprintf (fp, "%s", string);
-    FOREACHpoint_(points) 
-      fprintf (fp, " p%d", qh_pointid(point));
-    fprintf (fp, "\n");
+    qh_fprintf(fp, 9004, "%s", string);
+    FOREACHpoint_(points)
+      qh_fprintf(fp, 9005, " p%d", qh_pointid(point));
+    qh_fprintf(fp, 9006, "\n");
   }else {
-    FOREACHpoint_(points) 
-      fprintf (fp, " %d", qh_pointid(point));
-    fprintf (fp, "\n");
+    FOREACHpoint_(points)
+      qh_fprintf(fp, 9007, " %d", qh_pointid(point));
+    qh_fprintf(fp, 9008, "\n");
   }
 } /* printpoints */
 
-  
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="projectinput">-</a>
-  
+
   qh_projectinput()
     project input points using qh.lower_bound/upper_bound and qh DELAUNAY
-    if qh.lower_bound[k]=qh.upper_bound[k]= 0, 
-      removes dimension k 
+    if qh.lower_bound[k]=qh.upper_bound[k]= 0,
+      removes dimension k
     if halfspace intersection
       removes dimension k from qh.feasible_point
     input points in qh first_point, num_points, input_dim
@@ -1383,12 +1394,12 @@
   returns:
     new point array in qh first_point of qh hull_dim coordinates
     sets qh POINTSmalloc
-    if qh DELAUNAY 
+    if qh DELAUNAY
       projects points to paraboloid
       lowbound/highbound is also projected
     if qh ATinfinity
       adds point "at-infinity"
-    if qh POINTSmalloc 
+    if qh POINTSmalloc
       frees old point array
 
   notes:
@@ -1404,21 +1415,21 @@
     if qh DELAUNAY
       if qh ATINFINITY
         projects points to paraboloid
-        computes "infinity" point as vertex average and 10% above all points 
+        computes "infinity" point as vertex average and 10% above all points
       else
         uses qh_setdelaunay to project points to paraboloid
 */
-void qh_projectinput (void) {
+void qh_projectinput(void) {
   int k,i;
   int newdim= qh input_dim, newnum= qh num_points;
   signed char *project;
   int size= (qh input_dim+1)*sizeof(*project);
   pointT *newpoints, *coord, *infinity;
   realT paraboloid, maxboloid= 0;
-  
-  project= (signed char*)qh_memalloc (size);
-  memset ((char*)project, 0, size);
-  for (k= 0; k < qh input_dim; k++) {   /* skip Delaunay bound */
+
+  project= (signed char*)qh_memalloc(size);
+  memset((char*)project, 0, (size_t)size);
+  for (k=0; k < qh input_dim; k++) {   /* skip Delaunay bound */
     if (qh lower_bound[k] == 0 && qh upper_bound[k] == 0) {
       project[k]= -1;
       newdim--;
@@ -1431,32 +1442,32 @@
       newnum++;
   }
   if (newdim != qh hull_dim) {
-    fprintf(qh ferr, "qhull internal error (qh_projectinput): dimension after projection %d != hull_dim %d\n", newdim, qh hull_dim);
+    qh_fprintf(qh ferr, 6015, "qhull internal error (qh_projectinput): dimension after projection %d != hull_dim %d\n", newdim, qh hull_dim);
     qh_errexit(qh_ERRqhull, NULL, NULL);
   }
-  if (!(newpoints=(coordT*)malloc(newnum*newdim*sizeof(coordT)))){
-    fprintf(qh ferr, "qhull error: insufficient memory to project %d points\n",
+  if (!(newpoints=(coordT*)qh_malloc(newnum*newdim*sizeof(coordT)))){
+    qh_fprintf(qh ferr, 6016, "qhull error: insufficient memory to project %d points\n",
            qh num_points);
     qh_errexit(qh_ERRmem, NULL, NULL);
   }
-  qh_projectpoints (project, qh input_dim+1, qh first_point,
+  qh_projectpoints(project, qh input_dim+1, qh first_point,
                     qh num_points, qh input_dim, newpoints, newdim);
-  trace1((qh ferr, "qh_projectinput: updating lower and upper_bound\n"));
-  qh_projectpoints (project, qh input_dim+1, qh lower_bound,
+  trace1((qh ferr, 1003, "qh_projectinput: updating lower and upper_bound\n"));
+  qh_projectpoints(project, qh input_dim+1, qh lower_bound,
                     1, qh input_dim+1, qh lower_bound, newdim+1);
-  qh_projectpoints (project, qh input_dim+1, qh upper_bound,
+  qh_projectpoints(project, qh input_dim+1, qh upper_bound,
                     1, qh input_dim+1, qh upper_bound, newdim+1);
   if (qh HALFspace) {
     if (!qh feasible_point) {
-      fprintf(qh ferr, "qhull internal error (qh_projectinput): HALFspace defined without qh.feasible_point\n");
+      qh_fprintf(qh ferr, 6017, "qhull internal error (qh_projectinput): HALFspace defined without qh.feasible_point\n");
       qh_errexit(qh_ERRqhull, NULL, NULL);
     }
-    qh_projectpoints (project, qh input_dim, qh feasible_point,
-		      1, qh input_dim, qh feasible_point, newdim);
+    qh_projectpoints(project, qh input_dim, qh feasible_point,
+                      1, qh input_dim, qh feasible_point, newdim);
   }
-  qh_memfree(project, ((qh input_dim+1)*sizeof(*project)));
+  qh_memfree(project, (qh input_dim+1)*sizeof(*project));
   if (qh POINTSmalloc)
-    free (qh first_point);
+    qh_free(qh first_point);
   qh first_point= newpoints;
   qh POINTSmalloc= True;
   if (qh DELAUNAY && qh ATinfinity) {
@@ -1468,7 +1479,7 @@
       paraboloid= 0.0;
       for (k=0; k < qh hull_dim-1; k++) {
         paraboloid += *coord * *coord;
-	infinity[k] += *coord;
+        infinity[k] += *coord;
         coord++;
       }
       *(coord++)= paraboloid;
@@ -1479,20 +1490,20 @@
       *(coord++) /= qh num_points;
     *(coord++)= maxboloid * 1.1;
     qh num_points++;
-    trace0((qh ferr, "qh_projectinput: projected points to paraboloid for Delaunay\n"));
+    trace0((qh ferr, 9, "qh_projectinput: projected points to paraboloid for Delaunay\n"));
   }else if (qh DELAUNAY)  /* !qh ATinfinity */
     qh_setdelaunay( qh hull_dim, qh num_points, qh first_point);
 } /* projectinput */
 
-  
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="projectpoints">-</a>
-  
+
   qh_projectpoints( project, n, points, numpoints, dim, newpoints, newdim )
     project points/numpoints/dim to newpoints/newdim
     if project[k] == -1
-      delete dimension k 
-    if project[k] == 1 
+      delete dimension k
+    if project[k] == 1
       add dimension k by duplicating previous column
     n is size of project
 
@@ -1506,33 +1517,33 @@
         skip dimension
       else
         determine start of column in newpoints
-        determine start of column in points 
+        determine start of column in points
           if project == +1, duplicate previous column
         copy dimension (column) from points to newpoints
 */
-void qh_projectpoints (signed char *project, int n, realT *points, 
+void qh_projectpoints(signed char *project, int n, realT *points,
         int numpoints, int dim, realT *newpoints, int newdim) {
   int testdim= dim, oldk=0, newk=0, i,j=0,k;
   realT *newp, *oldp;
-  
-  for (k= 0; k < n; k++)
+
+  for (k=0; k < n; k++)
     testdim += project[k];
   if (testdim != newdim) {
-    fprintf (qh ferr, "qhull internal error (qh_projectpoints): newdim %d should be %d after projection\n",
+    qh_fprintf(qh ferr, 6018, "qhull internal error (qh_projectpoints): newdim %d should be %d after projection\n",
       newdim, testdim);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
-  for (j= 0; j<n; j++) {
+  for (j=0; j<n; j++) {
     if (project[j] == -1)
       oldk++;
     else {
       newp= newpoints+newk++;
       if (project[j] == +1) {
-	if (oldk >= dim)
-	  continue;
-	oldp= points+oldk;
-      }else 
-	oldp= points+oldk++;
+        if (oldk >= dim)
+          continue;
+        oldp= points+oldk;
+      }else
+        oldp= points+oldk++;
       for (i=numpoints; i--; ) {
         *newp= *oldp;
         newp += newdim;
@@ -1542,105 +1553,14 @@
     if (oldk >= dim)
       break;
   }
-  trace1((qh ferr, "qh_projectpoints: projected %d points from dim %d to dim %d\n", 
+  trace1((qh ferr, 1004, "qh_projectpoints: projected %d points from dim %d to dim %d\n",
     numpoints, dim, newdim));
 } /* projectpoints */
-        
 
-/*-<a                             href="qh-geom.htm#TOC"
-  >-------------------------------</a><a name="rand">-</a>
-  
-  qh_rand() 
-  qh_srand( seed )
-    generate pseudo-random number between 1 and 2^31 -2
 
-  notes:
-    from Park & Miller's minimimal standard random number generator
-       Communications of the ACM, 31:1192-1201, 1988.
-    does not use 0 or 2^31 -1
-       this is silently enforced by qh_srand()
-    can make 'Rn' much faster by moving qh_rand to qh_distplane
-*/
-int qh_rand_seed= 1;  /* define as global variable instead of using qh */
-
-int qh_rand( void) {
-#define qh_rand_a 16807
-#define qh_rand_m 2147483647
-#define qh_rand_q 127773  /* m div a */
-#define qh_rand_r 2836    /* m mod a */
-  int lo, hi, test;
-  int seed = qh_rand_seed;
-
-  hi = seed / qh_rand_q;  /* seed div q */
-  lo = seed % qh_rand_q;  /* seed mod q */
-  test = qh_rand_a * lo - qh_rand_r * hi;
-  if (test > 0)
-    seed= test;
-  else
-    seed= test + qh_rand_m;
-  qh_rand_seed= seed;
-  /* seed = seed < qh_RANDOMmax/2 ? 0 : qh_RANDOMmax;  for testing */
-  /* seed = qh_RANDOMmax;  for testing */
-  return seed;
-} /* rand */
-
-void qh_srand( int seed) {
-  if (seed < 1)
-    qh_rand_seed= 1;
-  else if (seed >= qh_rand_m)
-    qh_rand_seed= qh_rand_m - 1;
-  else
-    qh_rand_seed= seed;
-} /* qh_srand */
-
 /*-<a                             href="qh-geom.htm#TOC"
-  >-------------------------------</a><a name="randomfactor">-</a>
-  
-  qh_randomfactor()
-    return a random factor within qh.RANDOMmax of 1.0
-
-  notes:
-    qh.RANDOMa/b are defined in global.c
-*/
-realT qh_randomfactor (void) {
-  realT randr;
-
-  randr= qh_RANDOMint;
-  return randr * qh RANDOMa + qh RANDOMb;
-} /* randomfactor */
-
-/*-<a                             href="qh-geom.htm#TOC"
-  >-------------------------------</a><a name="randommatrix">-</a>
-  
-  qh_randommatrix( buffer, dim, rows )
-    generate a random dim X dim matrix in range [-1,1]
-    assumes buffer is [dim+1, dim]
-
-  returns:
-    sets buffer to random numbers
-    sets rows to rows of buffer
-      sets row[dim] as scratch row
-*/
-void qh_randommatrix (realT *buffer, int dim, realT **rows) {
-  int i, k;
-  realT **rowi, *coord, realr;
-
-  coord= buffer;
-  rowi= rows;
-  for (i=0; i < dim; i++) {
-    *(rowi++)= coord;
-    for (k=0; k < dim; k++) {
-      realr= qh_RANDOMint;
-      *(coord++)= 2.0 * realr/(qh_RANDOMmax+1) - 1.0;
-    }
-  }
-  *rowi= coord;
-} /* randommatrix */
-
-        
-/*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="rotateinput">-</a>
-  
+
   qh_rotateinput( rows )
     rotate input using row matrix
     input points given by qh first_point, num_points, hull_dim
@@ -1654,18 +1574,18 @@
   design:
     see qh_rotatepoints
 */
-void qh_rotateinput (realT **rows) {
+void qh_rotateinput(realT **rows) {
 
   if (!qh POINTSmalloc) {
-    qh first_point= qh_copypoints (qh first_point, qh num_points, qh hull_dim);
+    qh first_point= qh_copypoints(qh first_point, qh num_points, qh hull_dim);
     qh POINTSmalloc= True;
   }
-  qh_rotatepoints (qh first_point, qh num_points, qh hull_dim, rows);
+  qh_rotatepoints(qh first_point, qh num_points, qh hull_dim, rows);
 }  /* rotateinput */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="rotatepoints">-</a>
-  
+
   qh_rotatepoints( points, numpoints, dim, row )
     rotate numpoints points by a d-dim row matrix
     assumes rows[dim] is a scratch buffer
@@ -1680,30 +1600,30 @@
       for each coordinate
         rotate by partial inner product
 */
-void qh_rotatepoints (realT *points, int numpoints, int dim, realT **row) {
+void qh_rotatepoints(realT *points, int numpoints, int dim, realT **row) {
   realT *point, *rowi, *coord= NULL, sum, *newval;
   int i,j,k;
 
   if (qh IStracing >= 1)
-    qh_printmatrix (qh ferr, "qh_rotatepoints: rotate points by", row, dim, dim);
+    qh_printmatrix(qh ferr, "qh_rotatepoints: rotate points by", row, dim, dim);
   for (point= points, j= numpoints; j--; point += dim) {
     newval= row[dim];
-    for (i= 0; i < dim; i++) {
+    for (i=0; i < dim; i++) {
       rowi= row[i];
       coord= point;
       for (sum= 0.0, k= dim; k--; )
         sum += *rowi++ * *coord++;
       *(newval++)= sum;
     }
-    for (k= dim; k--; )
+    for (k=dim; k--; )
       *(--coord)= *(--newval);
   }
-} /* rotatepoints */  
-  
+} /* rotatepoints */
 
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="scaleinput">-</a>
-  
+
   qh_scaleinput()
     scale input points using qh low_bound/high_bound
     input points given by qh first_point, num_points, hull_dim
@@ -1716,19 +1636,19 @@
   design:
     see qh_scalepoints
 */
-void qh_scaleinput (void) {
+void qh_scaleinput(void) {
 
   if (!qh POINTSmalloc) {
-    qh first_point= qh_copypoints (qh first_point, qh num_points, qh hull_dim);
+    qh first_point= qh_copypoints(qh first_point, qh num_points, qh hull_dim);
     qh POINTSmalloc= True;
   }
-  qh_scalepoints (qh first_point, qh num_points, qh hull_dim,
+  qh_scalepoints(qh first_point, qh num_points, qh hull_dim,
        qh lower_bound, qh upper_bound);
 }  /* scaleinput */
-  
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="scalelast">-</a>
-  
+
   qh_scalelast( points, numpoints, dim, low, high, newhigh )
     scale last coordinate to [0,m] for Delaunay triangulations
     input points given by points, numpoints, dim
@@ -1740,42 +1660,42 @@
 
   notes:
     when called by qh_setdelaunay, low/high may not match actual data
-    
+
   design:
     compute scale and shift factors
     apply to last coordinate of each point
 */
-void qh_scalelast (coordT *points, int numpoints, int dim, coordT low,
-		   coordT high, coordT newhigh) {
+void qh_scalelast(coordT *points, int numpoints, int dim, coordT low,
+                   coordT high, coordT newhigh) {
   realT scale, shift;
   coordT *coord;
   int i;
   boolT nearzero= False;
 
-  trace4((qh ferr, "qh_scalelast: scale last coordinate from [%2.2g, %2.2g] to [0,%2.2g]\n",
+  trace4((qh ferr, 4013, "qh_scalelast: scale last coordinate from [%2.2g, %2.2g] to [0,%2.2g]\n",
     low, high, newhigh));
   qh last_low= low;
   qh last_high= high;
   qh last_newhigh= newhigh;
-  scale= qh_divzero (newhigh, high - low,
+  scale= qh_divzero(newhigh, high - low,
                   qh MINdenom_1, &nearzero);
   if (nearzero) {
     if (qh DELAUNAY)
-      fprintf (qh ferr, "qhull input error: can not scale last coordinate.  Input is cocircular\n   or cospherical.   Use option 'Qz' to add a point at infinity.\n");
+      qh_fprintf(qh ferr, 6019, "qhull input error: can not scale last coordinate.  Input is cocircular\n   or cospherical.   Use option 'Qz' to add a point at infinity.\n");
     else
-      fprintf (qh ferr, "qhull input error: can not scale last coordinate.  New bounds [0, %2.2g] are too wide for\nexisting bounds [%2.2g, %2.2g] (width %2.2g)\n",
-		newhigh, low, high, high-low);
-    qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6020, "qhull input error: can not scale last coordinate.  New bounds [0, %2.2g] are too wide for\nexisting bounds [%2.2g, %2.2g] (width %2.2g)\n",
+                newhigh, low, high, high-low);
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
   shift= - low * newhigh / (high-low);
   coord= points + dim - 1;
-  for (i= numpoints; i--; coord += dim)
+  for (i=numpoints; i--; coord += dim)
     *coord= *coord * scale + shift;
 } /* scalelast */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="scalepoints">-</a>
-  
+
   qh_scalepoints( points, numpoints, dim, newlows, newhighs )
     scale points to new lowbound and highbound
     retains old bound when newlow= -REALmax or newhigh= +REALmax
@@ -1791,20 +1711,20 @@
       scale all points
       enforce new low and high bound for all points
 */
-void qh_scalepoints (pointT *points, int numpoints, int dim,
-	realT *newlows, realT *newhighs) {
+void qh_scalepoints(pointT *points, int numpoints, int dim,
+        realT *newlows, realT *newhighs) {
   int i,k;
   realT shift, scale, *coord, low, high, newlow, newhigh, mincoord, maxcoord;
   boolT nearzero= False;
-     
-  for (k= 0; k < dim; k++) {
+
+  for (k=0; k < dim; k++) {
     newhigh= newhighs[k];
     newlow= newlows[k];
     if (newhigh > REALmax/2 && newlow < -REALmax/2)
       continue;
     low= REALmax;
     high= -REALmax;
-    for (i= numpoints, coord= points+k; i--; coord += dim) {
+    for (i=numpoints, coord=points+k; i--; coord += dim) {
       minimize_(low, *coord);
       maximize_(high, *coord);
     }
@@ -1813,20 +1733,20 @@
     if (newlow < -REALmax/2)
       newlow= low;
     if (qh DELAUNAY && k == dim-1 && newhigh < newlow) {
-      fprintf (qh ferr, "qhull input error: 'Qb%d' or 'QB%d' inverts paraboloid since high bound %.2g < low bound %.2g\n",
-	       k, k, newhigh, newlow);
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6021, "qhull input error: 'Qb%d' or 'QB%d' inverts paraboloid since high bound %.2g < low bound %.2g\n",
+               k, k, newhigh, newlow);
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
-    scale= qh_divzero (newhigh - newlow, high - low,
+    scale= qh_divzero(newhigh - newlow, high - low,
                   qh MINdenom_1, &nearzero);
     if (nearzero) {
-      fprintf (qh ferr, "qhull input error: %d'th dimension's new bounds [%2.2g, %2.2g] too wide for\nexisting bounds [%2.2g, %2.2g]\n",
+      qh_fprintf(qh ferr, 6022, "qhull input error: %d'th dimension's new bounds [%2.2g, %2.2g] too wide for\nexisting bounds [%2.2g, %2.2g]\n",
               k, newlow, newhigh, low, high);
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
     shift= (newlow * high - low * newhigh)/(high-low);
     coord= points+k;
-    for (i= numpoints; i--; coord += dim)
+    for (i=numpoints; i--; coord += dim)
       *coord= *coord * scale + shift;
     coord= points+k;
     if (newlow < newhigh) {
@@ -1836,22 +1756,22 @@
       mincoord= newhigh;
       maxcoord= newlow;
     }
-    for (i= numpoints; i--; coord += dim) {
+    for (i=numpoints; i--; coord += dim) {
       minimize_(*coord, maxcoord);  /* because of roundoff error */
       maximize_(*coord, mincoord);
     }
-    trace0((qh ferr, "qh_scalepoints: scaled %d'th coordinate [%2.2g, %2.2g] to [%.2g, %.2g] for %d points by %2.2g and shifted %2.2g\n",
+    trace0((qh ferr, 10, "qh_scalepoints: scaled %d'th coordinate [%2.2g, %2.2g] to [%.2g, %.2g] for %d points by %2.2g and shifted %2.2g\n",
       k, low, high, newlow, newhigh, numpoints, scale, shift));
   }
-} /* scalepoints */    
+} /* scalepoints */
 
-       
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="setdelaunay">-</a>
-  
+
   qh_setdelaunay( dim, count, points )
     project count points to dim-d paraboloid for Delaunay triangulation
-    
+
     dim is one more than the dimension of the input set
     assumes dim is at least 3 (i.e., at least a 2-d Delaunay triangulation)
 
@@ -1867,39 +1787,39 @@
     for each point
       sets point[dim-1] to sum of squares of coordinates
     scale points to 'Qbb' if needed
-      
+
   notes:
     to project one point, use
-      qh_setdelaunay (qh hull_dim, 1, point)
-      
-    Do not use options 'Qbk', 'QBk', or 'QbB' since they scale 
+      qh_setdelaunay(qh hull_dim, 1, point)
+
+    Do not use options 'Qbk', 'QBk', or 'QbB' since they scale
     the coordinates after the original projection.
 
 */
-void qh_setdelaunay (int dim, int count, pointT *points) {
+void qh_setdelaunay(int dim, int count, pointT *points) {
   int i, k;
   coordT *coordp, coord;
   realT paraboloid;
 
-  trace0((qh ferr, "qh_setdelaunay: project %d points to paraboloid for Delaunay triangulation\n", count));
+  trace0((qh ferr, 11, "qh_setdelaunay: project %d points to paraboloid for Delaunay triangulation\n", count));
   coordp= points;
-  for (i= 0; i < count; i++) {
+  for (i=0; i < count; i++) {
     coord= *coordp++;
     paraboloid= coord*coord;
-    for (k= dim-2; k--; ) {
+    for (k=dim-2; k--; ) {
       coord= *coordp++;
       paraboloid += coord*coord;
     }
     *coordp++ = paraboloid;
   }
-  if (qh last_low < REALmax/2) 
-    qh_scalelast (points, count, dim, qh last_low, qh last_high, qh last_newhigh);
+  if (qh last_low < REALmax/2)
+    qh_scalelast(points, count, dim, qh last_low, qh last_high, qh last_newhigh);
 } /* setdelaunay */
 
-  
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="sethalfspace">-</a>
-  
+
   qh_sethalfspace( dim, coords, nextp, normal, offset, feasible )
     set point to dual of halfspace relative to feasible point
     halfspace is normal coefficients and offset.
@@ -1913,7 +1833,7 @@
     compute distance from feasible point to halfspace
     divide each normal coefficient by -dist
 */
-boolT qh_sethalfspace (int dim, coordT *coords, coordT **nextp, 
+boolT qh_sethalfspace(int dim, coordT *coords, coordT **nextp,
          coordT *normal, coordT *offset, coordT *feasible) {
   coordT *normp= normal, *feasiblep= feasible, *coordp= coords;
   realT dist;
@@ -1922,103 +1842,103 @@
   boolT zerodiv;
 
   dist= *offset;
-  for (k= dim; k--; )
+  for (k=dim; k--; )
     dist += *(normp++) * *(feasiblep++);
   if (dist > 0)
     goto LABELerroroutside;
   normp= normal;
   if (dist < -qh MINdenom) {
-    for (k= dim; k--; )
+    for (k=dim; k--; )
       *(coordp++)= *(normp++) / -dist;
   }else {
-    for (k= dim; k--; ) {
-      *(coordp++)= qh_divzero (*(normp++), -dist, qh MINdenom_1, &zerodiv);
-      if (zerodiv) 
+    for (k=dim; k--; ) {
+      *(coordp++)= qh_divzero(*(normp++), -dist, qh MINdenom_1, &zerodiv);
+      if (zerodiv)
         goto LABELerroroutside;
     }
   }
   *nextp= coordp;
   if (qh IStracing >= 4) {
-    fprintf (qh ferr, "qh_sethalfspace: halfspace at offset %6.2g to point: ", *offset);
-    for (k= dim, coordp= coords; k--; ) {
+    qh_fprintf(qh ferr, 8021, "qh_sethalfspace: halfspace at offset %6.2g to point: ", *offset);
+    for (k=dim, coordp=coords; k--; ) {
       r= *coordp++;
-      fprintf (qh ferr, " %6.2g", r);
+      qh_fprintf(qh ferr, 8022, " %6.2g", r);
     }
-    fprintf (qh ferr, "\n");
+    qh_fprintf(qh ferr, 8023, "\n");
   }
   return True;
 LABELerroroutside:
   feasiblep= feasible;
   normp= normal;
-  fprintf(qh ferr, "qhull input error: feasible point is not clearly inside halfspace\nfeasible point: ");
-  for (k= dim; k--; )
-    fprintf (qh ferr, qh_REAL_1, r=*(feasiblep++));
-  fprintf (qh ferr, "\n     halfspace: "); 
-  for (k= dim; k--; )
-    fprintf (qh ferr, qh_REAL_1, r=*(normp++));
-  fprintf (qh ferr, "\n     at offset: ");
-  fprintf (qh ferr, qh_REAL_1, *offset);
-  fprintf (qh ferr, " and distance: ");
-  fprintf (qh ferr, qh_REAL_1, dist);
-  fprintf (qh ferr, "\n");
+  qh_fprintf(qh ferr, 6023, "qhull input error: feasible point is not clearly inside halfspace\nfeasible point: ");
+  for (k=dim; k--; )
+    qh_fprintf(qh ferr, 8024, qh_REAL_1, r=*(feasiblep++));
+  qh_fprintf(qh ferr, 8025, "\n     halfspace: ");
+  for (k=dim; k--; )
+    qh_fprintf(qh ferr, 8026, qh_REAL_1, r=*(normp++));
+  qh_fprintf(qh ferr, 8027, "\n     at offset: ");
+  qh_fprintf(qh ferr, 8028, qh_REAL_1, *offset);
+  qh_fprintf(qh ferr, 8029, " and distance: ");
+  qh_fprintf(qh ferr, 8030, qh_REAL_1, dist);
+  qh_fprintf(qh ferr, 8031, "\n");
   return False;
 } /* sethalfspace */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="sethalfspace_all">-</a>
-  
+
   qh_sethalfspace_all( dim, count, halfspaces, feasible )
     generate dual for halfspace intersection with feasible point
     array of count halfspaces
-      each halfspace is normal coefficients followed by offset 
+      each halfspace is normal coefficients followed by offset
       the origin is inside the halfspace if the offset is negative
 
   returns:
     malloc'd array of count X dim-1 points
 
   notes:
-    call before qh_init_B or qh_initqhull_globals 
+    call before qh_init_B or qh_initqhull_globals
     unused/untested code: please email bradb@shore.net if this works ok for you
-    If using option 'Fp', also set qh feasible_point. It is a malloc'd array 
+    If using option 'Fp', also set qh feasible_point. It is a malloc'd array
       that is freed by qh_freebuffers.
 
   design:
     see qh_sethalfspace
 */
-coordT *qh_sethalfspace_all (int dim, int count, coordT *halfspaces, pointT *feasible) {
+coordT *qh_sethalfspace_all(int dim, int count, coordT *halfspaces, pointT *feasible) {
   int i, newdim;
   pointT *newpoints;
   coordT *coordp, *normalp, *offsetp;
 
-  trace0((qh ferr, "qh_sethalfspace_all: compute dual for halfspace intersection\n"));
+  trace0((qh ferr, 12, "qh_sethalfspace_all: compute dual for halfspace intersection\n"));
   newdim= dim - 1;
-  if (!(newpoints=(coordT*)malloc(count*newdim*sizeof(coordT)))){
-    fprintf(qh ferr, "qhull error: insufficient memory to compute dual of %d halfspaces\n",
+  if (!(newpoints=(coordT*)qh_malloc(count*newdim*sizeof(coordT)))){
+    qh_fprintf(qh ferr, 6024, "qhull error: insufficient memory to compute dual of %d halfspaces\n",
           count);
     qh_errexit(qh_ERRmem, NULL, NULL);
   }
   coordp= newpoints;
   normalp= halfspaces;
-  for (i= 0; i < count; i++) {
+  for (i=0; i < count; i++) {
     offsetp= normalp + newdim;
-    if (!qh_sethalfspace (newdim, coordp, &coordp, normalp, offsetp, feasible)) {
-      fprintf (qh ferr, "The halfspace was at index %d\n", i);
-      qh_errexit (qh_ERRinput, NULL, NULL);
+    if (!qh_sethalfspace(newdim, coordp, &coordp, normalp, offsetp, feasible)) {
+      qh_fprintf(qh ferr, 8032, "The halfspace was at index %d\n", i);
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
     normalp= offsetp + 1;
   }
   return newpoints;
 } /* sethalfspace_all */
 
-  
+
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="sharpnewfacets">-</a>
-  
+
   qh_sharpnewfacets()
 
   returns:
     true if could be an acute angle (facets in different quadrants)
- 
+
   notes:
     for qh_findbest
 
@@ -2027,18 +1947,18 @@
       if two facets are in different quadrants
         set issharp
 */
-boolT qh_sharpnewfacets () {
+boolT qh_sharpnewfacets() {
   facetT *facet;
   boolT issharp = False;
   int *quadrant, k;
-  
-  quadrant= (int*)qh_memalloc (qh hull_dim * sizeof(int));
+
+  quadrant= (int*)qh_memalloc(qh hull_dim * sizeof(int));
   FORALLfacet_(qh newfacet_list) {
     if (facet == qh newfacet_list) {
-      for (k= qh hull_dim; k--; )
-      	quadrant[ k]= (facet->normal[ k] > 0);
+      for (k=qh hull_dim; k--; )
+        quadrant[ k]= (facet->normal[ k] > 0);
     }else {
-      for (k= qh hull_dim; k--; ) {
+      for (k=qh hull_dim; k--; ) {
         if (quadrant[ k] != (facet->normal[ k] > 0)) {
           issharp= True;
           break;
@@ -2049,13 +1969,13 @@
       break;
   }
   qh_memfree( quadrant, qh hull_dim * sizeof(int));
-  trace3((qh ferr, "qh_sharpnewfacets: %d\n", issharp));
+  trace3((qh ferr, 3001, "qh_sharpnewfacets: %d\n", issharp));
   return issharp;
 } /* sharpnewfacets */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="voronoi_center">-</a>
-  
+
   qh_voronoi_center( dim, points )
     return Voronoi center for a set of points
     dim is the orginal dimension of the points
@@ -2063,7 +1983,7 @@
 
   returns:
     center as a temporary point
-    if non-simplicial, 
+    if non-simplicial,
       returns center for max simplex of points
 
   notes:
@@ -2077,9 +1997,9 @@
     compute determinate
     compute Voronoi center (see Bowyer & Woodwark)
 */
-pointT *qh_voronoi_center (int dim, setT *points) {
+pointT *qh_voronoi_center(int dim, setT *points) {
   pointT *point, **pointp, *point0;
-  pointT *center= (pointT*)qh_memalloc (qh center_size);
+  pointT *center= (pointT*)qh_memalloc(qh center_size);
   setT *simplex;
   int i, j, k, size= qh_setsize(points);
   coordT *gmcoord;
@@ -2089,12 +2009,13 @@
   if (size == dim+1)
     simplex= points;
   else if (size < dim+1) {
-    fprintf (qh ferr, "qhull internal error (qh_voronoi_center):\n  need at least %d points to construct a Voronoi center\n",
-	     dim+1);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_fprintf(qh ferr, 6025, "qhull internal error (qh_voronoi_center):\n  need at least %d points to construct a Voronoi center\n",
+             dim+1);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
+    simplex= points;  /* never executed -- avoids warning */
   }else {
-    simplex= qh_settemp (dim+1);
-    qh_maxsimplex (dim, points, NULL, 0, &simplex);
+    simplex= qh_settemp(dim+1);
+    qh_maxsimplex(dim, points, NULL, 0, &simplex);
   }
   point0= SETfirstt_(simplex, pointT);
   gmcoord= qh gm_matrix;
@@ -2108,53 +2029,53 @@
   sum2row= gmcoord;
   for (i=0; i < dim; i++) {
     sum2= 0.0;
-    for (k= 0; k < dim; k++) {
+    for (k=0; k < dim; k++) {
       diffp= qh gm_row[k] + i;
       sum2 += *diffp * *diffp;
     }
     *(gmcoord++)= sum2;
   }
-  det= qh_determinant (qh gm_row, dim, &nearzero);
-  factor= qh_divzero (0.5, det, qh MINdenom, &infinite);
+  det= qh_determinant(qh gm_row, dim, &nearzero);
+  factor= qh_divzero(0.5, det, qh MINdenom, &infinite);
   if (infinite) {
     for (k=dim; k--; )
       center[k]= qh_INFINITE;
     if (qh IStracing)
-      qh_printpoints (qh ferr, "qh_voronoi_center: at infinity for ", simplex);
+      qh_printpoints(qh ferr, "qh_voronoi_center: at infinity for ", simplex);
   }else {
     for (i=0; i < dim; i++) {
       gmcoord= qh gm_matrix;
       sum2p= sum2row;
       for (k=0; k < dim; k++) {
-	qh gm_row[k]= gmcoord;
-	if (k == i) {
-	  for (j= dim; j--; )
-	    *(gmcoord++)= *sum2p++;
-	}else {
-	  FOREACHpoint_(simplex) {
-	    if (point != point0)
-	      *(gmcoord++)= point[k] - point0[k];
-	  }
-	}
+        qh gm_row[k]= gmcoord;
+        if (k == i) {
+          for (j=dim; j--; )
+            *(gmcoord++)= *sum2p++;
+        }else {
+          FOREACHpoint_(simplex) {
+            if (point != point0)
+              *(gmcoord++)= point[k] - point0[k];
+          }
+        }
       }
-      center[i]= qh_determinant (qh gm_row, dim, &nearzero)*factor + point0[i];
+      center[i]= qh_determinant(qh gm_row, dim, &nearzero)*factor + point0[i];
     }
 #ifndef qh_NOtrace
     if (qh IStracing >= 3) {
-      fprintf (qh ferr, "qh_voronoi_center: det %2.2g factor %2.2g ", det, factor);
-      qh_printmatrix (qh ferr, "center:", &center, 1, dim);
+      qh_fprintf(qh ferr, 8033, "qh_voronoi_center: det %2.2g factor %2.2g ", det, factor);
+      qh_printmatrix(qh ferr, "center:", &center, 1, dim);
       if (qh IStracing >= 5) {
-	qh_printpoints (qh ferr, "points", simplex);
-	FOREACHpoint_(simplex)
-	  fprintf (qh ferr, "p%d dist %.2g, ", qh_pointid (point),
-		   qh_pointdist (point, center, dim));
-	fprintf (qh ferr, "\n");
+        qh_printpoints(qh ferr, "points", simplex);
+        FOREACHpoint_(simplex)
+          qh_fprintf(qh ferr, 8034, "p%d dist %.2g, ", qh_pointid(point),
+                   qh_pointdist(point, center, dim));
+        qh_fprintf(qh ferr, 8035, "\n");
       }
     }
 #endif
   }
   if (simplex != points)
-    qh_settempfree (&simplex);
+    qh_settempfree(&simplex);
   return center;
 } /* voronoi_center */
 

Modified: trunk/scipy/spatial/qhull/src/global.c
===================================================================
--- trunk/scipy/spatial/qhull/src/global.c	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/global.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,3 +1,4 @@
+
 /*<html><pre>  -<a                             href="qh-globa.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
@@ -6,26 +7,30 @@
 
    see README
 
-   see qhull.h for qh.globals and function prototypes
+   see libqhull.h for qh.globals and function prototypes
 
    see qhull_a.h for internal functions
 
-   copyright (c) 1993-2003, The Geometry Center
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/global.c#60 $$Change: 1183 $
+   $DateTime: 2010/01/13 20:59:32 $$Author: bbarber $
  */
 
 #include "qhull_a.h"
 
-/*========= qh definition (see qhull.h) =======================*/
+/*========= qh definition -- globals defined in libqhull.h =======================*/
 
+int qhull_inuse= 0; /* not used */
+
 #if qh_QHpointer
-qhT *qh_qh= NULL;	/* pointer to all global variables */
+qhT *qh_qh= NULL;       /* pointer to all global variables */
 #else
-qhT qh_qh;     		/* all global variables.
-			   Add "= {0}" if this causes a compiler error.
-			   Also qh_qhstat in stat.c and qhmem in mem.c.  */
+qhT qh_qh;              /* all global variables.
+                           Add "= {0}" if this causes a compiler error.
+                           Also qh_qhstat in stat.c and qhmem in mem.c.  */
 #endif
 
-/*-<a                             href	="qh-globa.htm#TOC"
+/*-<a                             href  ="qh-globa.htm#TOC"
   >--------------------------------</a><a name="qh_version">-</a>
 
   qh_version
@@ -34,15 +39,15 @@
     the revision increases on code changes only
 
   notes:
-    change date:    Changes.txt, Announce.txt, README.txt, 
-                    qhull.man, qhull.txt, qhull-news.html, Eudora signatures, 
+    change date:    Changes.txt, Announce.txt, index.htm, README.txt,
+                    qhull-news.html, Eudora signatures,
     change version: README.txt, qh-get.htm, File_id.diz, Makefile.txt
     change year:    Copying.txt
     check download size
-    recompile user_eg.c, rbox.c, qhull.c, qconvex.c, qdelaun.c qvoronoi.c, qhalf.c
+    recompile user_eg.c, rbox.c, libqhull.c, qconvex.c, qdelaun.c qvoronoi.c, qhalf.c
 */
 
-char *qh_version = "2003.1 2003/12/30";
+const char *qh_version = "2010.1 2010/01/14";
 
 /*-<a                             href="qh-globa.htm#TOC"
   >-------------------------------</a><a name="appendprint">-</a>
@@ -50,7 +55,7 @@
   qh_appendprint( printFormat )
     append printFormat to qh.PRINTout unless already defined
 */
-void qh_appendprint (qh_PRINT format) {
+void qh_appendprint(qh_PRINT format) {
   int i;
 
   for (i=0; i < qh_PRINTEND; i++) {
@@ -62,10 +67,10 @@
     }
   }
 } /* appendprint */
-     
+
 /*-<a                             href="qh-globa.htm#TOC"
   >-------------------------------</a><a name="checkflags">-</a>
-  
+
   qh_checkflags( commandStr, hiddenFlags )
     errors if commandStr contains hiddenFlags
     hiddenFlags starts and ends with a space and is space deliminated (checked)
@@ -73,22 +78,24 @@
   notes:
     ignores first word (e.g., "qconvex i")
     use qh_strtol/strtod since strtol/strtod may or may not skip trailing spaces
-  
+
   see:
     qh_initflags() initializes Qhull according to commandStr
 */
 void qh_checkflags(char *command, char *hiddenflags) {
-  char *s= command, *t, *chkerr, key, opt, prevopt;
+  char *s= command, *t, *chkerr; /* qh_skipfilename is non-const */
+  char key, opt, prevopt;
   char chkkey[]= "   ";
   char chkopt[]=  "    ";
   char chkopt2[]= "     ";
+  boolT waserr= False;
 
   if (*hiddenflags != ' ' || hiddenflags[strlen(hiddenflags)-1] != ' ') {
-    fprintf(qh ferr, "qhull error (qh_checkflags): hiddenflags must start and end with a space: \"%s\"", hiddenflags);
+    qh_fprintf(qh ferr, 6026, "qhull error (qh_checkflags): hiddenflags must start and end with a space: \"%s\"", hiddenflags);
     qh_errexit(qh_ERRinput, NULL, NULL);
   }
-  if (strpbrk(hiddenflags, ",\n\r\t")) { 
-    fprintf(qh ferr, "qhull error (qh_checkflags): hiddenflags contains commas, newlines, or tabs: \"%s\"", hiddenflags);
+  if (strpbrk(hiddenflags, ",\n\r\t")) {
+    qh_fprintf(qh ferr, 6027, "qhull error (qh_checkflags): hiddenflags contains commas, newlines, or tabs: \"%s\"", hiddenflags);
     qh_errexit(qh_ERRinput, NULL, NULL);
   }
   while (*s && !isspace(*s))  /* skip program name */
@@ -102,13 +109,8 @@
       break;
     key = *s++;
     chkerr = NULL;
-    if (key == '\'') {         /* TO 'file name' */
-      t= strchr(s, '\'');
-      if (!t) {
-	fprintf(qh ferr, "qhull error (qh_checkflags): missing the 2nd single-quote for:\n%s\n", s-1);
-	qh_errexit(qh_ERRinput, NULL, NULL);
-      }
-      s= t+1;
+    if (key == 'T' && (*s == 'I' || *s == 'O')) {  /* TI or TO 'file name' */
+      s= qh_skipfilename(++s);
       continue;
     }
     chkkey[1]= key;
@@ -120,42 +122,111 @@
       chkopt[1]= key;
       chkopt2[1]= key;
       while (!chkerr && *s && !isspace(*s)) {
-	opt= *s++;
-	if (isalpha(opt)) {
-	  chkopt[2]= opt;
-	  if (strstr(hiddenflags, chkopt))
-	    chkerr= chkopt;
-	  if (prevopt != ' ') {
- 	    chkopt2[2]= prevopt;
- 	    chkopt2[3]= opt;
-	    if (strstr(hiddenflags, chkopt2))
-	      chkerr= chkopt2;
-	  }
-	}else if (key == 'Q' && isdigit(opt) && prevopt != 'b' 
-	      && (prevopt == ' ' || islower(prevopt))) {
-  	    chkopt[2]= opt;
-	    if (strstr(hiddenflags, chkopt))
-	      chkerr= chkopt;
-	}else {
-	  qh_strtod (s-1, &t);
-	  if (s < t)
-	    s= t;
-	}
+        opt= *s++;
+        if (isalpha(opt)) {
+          chkopt[2]= opt;
+          if (strstr(hiddenflags, chkopt))
+            chkerr= chkopt;
+          if (prevopt != ' ') {
+            chkopt2[2]= prevopt;
+            chkopt2[3]= opt;
+            if (strstr(hiddenflags, chkopt2))
+              chkerr= chkopt2;
+          }
+        }else if (key == 'Q' && isdigit(opt) && prevopt != 'b'
+              && (prevopt == ' ' || islower(prevopt))) {
+            chkopt[2]= opt;
+            if (strstr(hiddenflags, chkopt))
+              chkerr= chkopt;
+        }else {
+          qh_strtod(s-1, &t);
+          if (s < t)
+            s= t;
+        }
         prevopt= opt;
       }
     }
     if (chkerr) {
       *chkerr= '\'';
       chkerr[strlen(chkerr)-1]=  '\'';
-      fprintf(qh ferr, "qhull error: option %s is not used with this program.\n             It may be used with qhull.\n", chkerr);
-      qh_errexit(qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6029, "qhull error: option %s is not used with this program.\n             It may be used with qhull.\n", chkerr);
+      waserr= True;
     }
   }
+  if (waserr)
+    qh_errexit(qh_ERRinput, NULL, NULL);
 } /* checkflags */
-    
+
 /*-<a                             href="qh-globa.htm#TOC"
+  >-------------------------------</a><a name="qh_clear_outputflags">-</a>
+
+  qh_clear_outputflags()
+    Clear output flags for QhullPoints
+*/
+void qh_clear_outputflags(void) {
+  int i,k;
+
+  qh ANNOTATEoutput= False;
+  qh DOintersections= False;
+  qh DROPdim= -1;
+  qh FORCEoutput= False;
+  qh GETarea= False;
+  qh GOODpoint= 0;
+  qh GOODpointp= NULL;
+  qh GOODthreshold= False;
+  qh GOODvertex= 0;
+  qh GOODvertexp= NULL;
+  qh IStracing= 0;
+  qh KEEParea= False;
+  qh KEEPmerge= False;
+  qh KEEPminArea= REALmax;
+  qh PRINTcentrums= False;
+  qh PRINTcoplanar= False;
+  qh PRINTdots= False;
+  qh PRINTgood= False;
+  qh PRINTinner= False;
+  qh PRINTneighbors= False;
+  qh PRINTnoplanes= False;
+  qh PRINToptions1st= False;
+  qh PRINTouter= False;
+  qh PRINTprecision= True;
+  qh PRINTridges= False;
+  qh PRINTspheres= False;
+  qh PRINTstatistics= False;
+  qh PRINTsummary= False;
+  qh PRINTtransparent= False;
+  qh SPLITthresholds= False;
+  qh TRACElevel= 0;
+  qh TRInormals= False;
+  qh USEstdout= False;
+  qh VERIFYoutput= False;
+  for (k=qh input_dim+1; k--; ) {  /* duplicated in qh_initqhull_buffers and qh_clear_ouputflags */
+    qh lower_threshold[k]= -REALmax;
+    qh upper_threshold[k]= REALmax;
+    qh lower_bound[k]= -REALmax;
+    qh upper_bound[k]= REALmax;
+  }
+
+  for (i=0; i < qh_PRINTEND; i++) {
+    qh PRINTout[i]= qh_PRINTnone;
+  }
+
+  if (!qh qhull_commandsiz2)
+      qh qhull_commandsiz2= (int)strlen(qh qhull_command); /* WARN64 */
+  else {
+      qh qhull_command[qh qhull_commandsiz2]= '\0';
+  }
+  if (!qh qhull_optionsiz2)
+    qh qhull_optionsiz2= (int)strlen(qh qhull_options);  /* WARN64 */
+  else {
+    qh qhull_options[qh qhull_optionsiz2]= '\0';
+    qh qhull_optionlen= qh_OPTIONline;  /* start a new line */
+  }
+} /* clear_outputflags */
+
+/*-<a                             href="qh-globa.htm#TOC"
   >-------------------------------</a><a name="clock">-</a>
-  
+
   qh_clock()
     return user CPU time in 100ths (qh_SECtick)
     only defined for qh_CLOCKtype == 2
@@ -164,7 +235,7 @@
     use first value to determine time 0
     from Stevens '92 8.15
 */
-unsigned long qh_clock (void) {
+unsigned long qh_clock(void) {
 
 #if (qh_CLOCKtype == 2)
   struct tms time;
@@ -173,21 +244,21 @@
   unsigned long ticks;
 
   if (!clktck) {
-    if ((clktck= sysconf (_SC_CLK_TCK)) < 0) {
-      fprintf (qh ferr, "qhull internal error (qh_clock): sysconf() failed.  Use qh_CLOCKtype 1 in user.h\n");
-      qh_errexit (qh_ERRqhull, NULL, NULL);
+    if ((clktck= sysconf(_SC_CLK_TCK)) < 0) {
+      qh_fprintf(qh ferr, 6030, "qhull internal error (qh_clock): sysconf() failed.  Use qh_CLOCKtype 1 in user.h\n");
+      qh_errexit(qh_ERRqhull, NULL, NULL);
     }
   }
-  if (times (&time) == -1) {
-    fprintf (qh ferr, "qhull internal error (qh_clock): times() failed.  Use qh_CLOCKtype 1 in user.h\n");
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+  if (times(&time) == -1) {
+    qh_fprintf(qh ferr, 6031, "qhull internal error (qh_clock): times() failed.  Use qh_CLOCKtype 1 in user.h\n");
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   ratio= qh_SECticks / (double)clktck;
   ticks= time.tms_utime * ratio;
   return ticks;
 #else
-  fprintf (qh ferr, "qhull internal error (qh_clock): use qh_CLOCKtype 2 in user.h\n");
-  qh_errexit (qh_ERRqhull, NULL, NULL); /* never returns */
+  qh_fprintf(qh ferr, 6032, "qhull internal error (qh_clock): use qh_CLOCKtype 2 in user.h\n");
+  qh_errexit(qh_ERRqhull, NULL, NULL); /* never returns */
   return 0;
 #endif
 } /* clock */
@@ -201,46 +272,46 @@
   notes:
     must match qh_initbuffers()
 */
-void qh_freebuffers (void) {
+void qh_freebuffers(void) {
 
-  trace5((qh ferr, "qh_freebuffers: freeing up global memory buffers\n"));
+  trace5((qh ferr, 5001, "qh_freebuffers: freeing up global memory buffers\n"));
   /* allocated by qh_initqhull_buffers */
-  qh_memfree (qh NEARzero, qh hull_dim * sizeof(realT));
-  qh_memfree (qh lower_threshold, (qh input_dim+1) * sizeof(realT));
-  qh_memfree (qh upper_threshold, (qh input_dim+1) * sizeof(realT));
-  qh_memfree (qh lower_bound, (qh input_dim+1) * sizeof(realT));
-  qh_memfree (qh upper_bound, (qh input_dim+1) * sizeof(realT));
-  qh_memfree (qh gm_matrix, (qh hull_dim+1) * qh hull_dim * sizeof(coordT));
-  qh_memfree (qh gm_row, (qh hull_dim+1) * sizeof(coordT *));
+  qh_memfree(qh NEARzero, qh hull_dim * sizeof(realT));
+  qh_memfree(qh lower_threshold, (qh input_dim+1) * sizeof(realT));
+  qh_memfree(qh upper_threshold, (qh input_dim+1) * sizeof(realT));
+  qh_memfree(qh lower_bound, (qh input_dim+1) * sizeof(realT));
+  qh_memfree(qh upper_bound, (qh input_dim+1) * sizeof(realT));
+  qh_memfree(qh gm_matrix, (qh hull_dim+1) * qh hull_dim * sizeof(coordT));
+  qh_memfree(qh gm_row, (qh hull_dim+1) * sizeof(coordT *));
   qh NEARzero= qh lower_threshold= qh upper_threshold= NULL;
   qh lower_bound= qh upper_bound= NULL;
   qh gm_matrix= NULL;
   qh gm_row= NULL;
-  qh_setfree (&qh other_points);
-  qh_setfree (&qh del_vertices);
-  qh_setfree (&qh coplanarset);
+  qh_setfree(&qh other_points);
+  qh_setfree(&qh del_vertices);
+  qh_setfree(&qh coplanarfacetset);
   if (qh line)                /* allocated by qh_readinput, freed if no error */
-    free (qh line);
+    qh_free(qh line);
   if (qh half_space)
-    free (qh half_space);
+    qh_free(qh half_space);
   if (qh temp_malloc)
-    free (qh temp_malloc);
+    qh_free(qh temp_malloc);
   if (qh feasible_point)      /* allocated by qh_readfeasible */
-    free (qh feasible_point);
+    qh_free(qh feasible_point);
   if (qh feasible_string)     /* allocated by qh_initflags */
-    free (qh feasible_string);
+    qh_free(qh feasible_string);
   qh line= qh feasible_string= NULL;
   qh half_space= qh feasible_point= qh temp_malloc= NULL;
   /* usually allocated by qh_readinput */
   if (qh first_point && qh POINTSmalloc) {
-    free(qh first_point);
+    qh_free(qh first_point);
     qh first_point= NULL;
   }
   if (qh input_points && qh input_malloc) { /* set by qh_joggleinput */
-    free (qh input_points);
+    qh_free(qh input_points);
     qh input_points= NULL;
   }
-  trace5((qh ferr, "qh_freebuffers: finished\n"));
+  trace5((qh ferr, 5002, "qh_freebuffers: finished\n"));
 } /* freebuffers */
 
 
@@ -250,7 +321,7 @@
   qh_freebuild( allmem )
     free global memory used by qh_initbuild and qh_buildhull
     if !allmem,
-      does not free short memory (freed by qh_memfreeshort)
+      does not free short memory (e.g., facetT, freed by qh_memfreeshort)
 
   design:
     free centrums
@@ -265,28 +336,27 @@
     free merge set
     free temporary sets
 */
-void qh_freebuild (boolT allmem) {
+void qh_freebuild(boolT allmem) {
   facetT *facet;
   vertexT *vertex;
   ridgeT *ridge, **ridgep;
   mergeT *merge, **mergep;
 
-  trace1((qh ferr, "qh_freebuild: free memory from qh_inithull and qh_buildhull\n"));
+  trace1((qh ferr, 1005, "qh_freebuild: free memory from qh_inithull and qh_buildhull\n"));
   if (qh del_vertices)
-    qh_settruncate (qh del_vertices, 0);
+    qh_settruncate(qh del_vertices, 0);
   if (allmem) {
-    qh_clearcenters (qh_ASnone);
     while ((vertex= qh vertex_list)) {
       if (vertex->next)
-        qh_delvertex (vertex);
+        qh_delvertex(vertex);
       else {
-        qh_memfree (vertex, sizeof(vertexT));
+        qh_memfree(vertex, (int)sizeof(vertexT));
         qh newvertex_list= qh vertex_list= NULL;
       }
     }
   }else if (qh VERTEXneighbors) {
     FORALLvertices
-      qh_setfreelong (&(vertex->neighbors));
+      qh_setfreelong(&(vertex->neighbors));
   }
   qh VERTEXneighbors= False;
   qh GOODclosest= NULL;
@@ -297,48 +367,48 @@
     }
     FORALLfacets {
       if (facet->visible) {
-	FOREACHridge_(facet->ridges) {
-	  if (!otherfacet_(ridge, facet)->visible)
-	    ridge->seen= True;  /* an unattached ridge */
-	}
+        FOREACHridge_(facet->ridges) {
+          if (!otherfacet_(ridge, facet)->visible)
+            ridge->seen= True;  /* an unattached ridge */
+        }
       }
     }
     while ((facet= qh facet_list)) {
       FOREACHridge_(facet->ridges) {
         if (ridge->seen) {
           qh_setfree(&(ridge->vertices));
-          qh_memfree(ridge, sizeof(ridgeT));
+          qh_memfree(ridge, (int)sizeof(ridgeT));
         }else
           ridge->seen= True;
       }
-      qh_setfree (&(facet->outsideset));
-      qh_setfree (&(facet->coplanarset));
-      qh_setfree (&(facet->neighbors));
-      qh_setfree (&(facet->ridges));
-      qh_setfree (&(facet->vertices));
+      qh_setfree(&(facet->outsideset));
+      qh_setfree(&(facet->coplanarset));
+      qh_setfree(&(facet->neighbors));
+      qh_setfree(&(facet->ridges));
+      qh_setfree(&(facet->vertices));
       if (facet->next)
-        qh_delfacet (facet);
+        qh_delfacet(facet);
       else {
-        qh_memfree (facet, sizeof(facetT));
+        qh_memfree(facet, (int)sizeof(facetT));
         qh visible_list= qh newfacet_list= qh facet_list= NULL;
       }
     }
   }else {
     FORALLfacets {
-      qh_setfreelong (&(facet->outsideset));
-      qh_setfreelong (&(facet->coplanarset));
+      qh_setfreelong(&(facet->outsideset));
+      qh_setfreelong(&(facet->coplanarset));
       if (!facet->simplicial) {
-        qh_setfreelong (&(facet->neighbors));
-        qh_setfreelong (&(facet->ridges));
-        qh_setfreelong (&(facet->vertices));
+        qh_setfreelong(&(facet->neighbors));
+        qh_setfreelong(&(facet->ridges));
+        qh_setfreelong(&(facet->vertices));
       }
     }
   }
-  qh_setfree (&(qh hash_table));
-  qh_memfree (qh interior_point, qh normal_size);
+  qh_setfree(&(qh hash_table));
+  qh_memfree(qh interior_point, qh normal_size);
   qh interior_point= NULL;
   FOREACHmerge_(qh facet_mergeset)  /* usually empty */
-    qh_memfree (merge, sizeof(mergeT));
+    qh_memfree(merge, (int)sizeof(mergeT));
   qh facet_mergeset= NULL;  /* temp set */
   qh degen_mergeset= NULL;  /* temp set */
   qh_settempfree_all();
@@ -348,33 +418,51 @@
   >-------------------------------</a><a name="freeqhull">-</a>
 
   qh_freeqhull( allmem )
-    free global memory
-    if !allmem,
-      does not free short memory (freed by qh_memfreeshort)
+    see qh_freeqhull2
+    if qh_QHpointer, frees qh_qh
+*/
+void qh_freeqhull(boolT allmem) {
+    qh_freeqhull2(allmem);
+#if qh_QHpointer
+    qh_free(qh_qh);
+    qh_qh= NULL;
+#endif
+}
 
-  notes:
-    sets qh.NOerrexit in case caller forgets to
+/*-<a                             href="qh-globa.htm#TOC"
+>-------------------------------</a><a name="freeqhull2">-</a>
 
-  design:
-    free global and temporary memory from qh_initbuild and qh_buildhull
-    free buffers
-    free statistics
+qh_freeqhull2( allmem )
+  free global memory
+  if !allmem,
+    does not free short memory (freed by qh_memfreeshort)
+
+notes:
+  sets qh.NOerrexit in case caller forgets to
+
+see:
+  see qh_initqhull_start2()
+
+design:
+  free global and temporary memory from qh_initbuild and qh_buildhull
+  free buffers
+  free statistics
 */
-void qh_freeqhull (boolT allmem) {
+void qh_freeqhull2(boolT allmem) {
 
-  trace1((qh ferr, "qh_freeqhull: free global memory\n"));
-  qh NOerrexit= True;  /* no more setjmp since called at exit */
-  qh_freebuild (allmem);
+  trace1((qh ferr, 1006, "qh_freeqhull2: free global memory\n"));
+  qh NOerrexit= True;  /* no more setjmp since called at exit and ~QhullQh */
+  qh_freebuild(allmem);
   qh_freebuffers();
   qh_freestatistics();
 #if qh_QHpointer
-  free (qh_qh);
-  qh_qh= NULL;
+  memset((char *)qh_qh, 0, sizeof(qhT));
+  /* qh_qh freed by caller, qh_freeqhull() */
 #else
   memset((char *)&qh_qh, 0, sizeof(qhT));
+#endif
   qh NOerrexit= True;
-#endif
-} /* freeqhull */
+} /* freeqhull2 */
 
 /*-<a                             href="qh-globa.htm#TOC"
   >-------------------------------</a><a name="init_A">-</a>
@@ -394,10 +482,10 @@
     called before error handling initialized
     qh_errexit() may not be used
 */
-void qh_init_A (FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[]) {
-  qh_meminit (errfile);
-  qh_initqhull_start (infile, outfile, errfile);
-  qh_init_qhull_command (argc, argv);
+void qh_init_A(FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[]) {
+  qh_meminit(errfile);
+  qh_initqhull_start(infile, outfile, errfile);
+  qh_init_qhull_command(argc, argv);
 } /* init_A */
 
 /*-<a                             href="qh-globa.htm#TOC"
@@ -412,7 +500,7 @@
       points[dim] is the first coordinate of the second point
 
     ismalloc=True
-      Qhull will call free(points) on exit or input transformation
+      Qhull will call qh_free(points) on exit or input transformation
     ismalloc=False
       Qhull will allocate a new point array if needed for input transformation
 
@@ -441,29 +529,29 @@
     called after points are defined
     qh_errexit() may be used
 */
-void qh_init_B (coordT *points, int numpoints, int dim, boolT ismalloc) {
-  qh_initqhull_globals (points, numpoints, dim, ismalloc);
+void qh_init_B(coordT *points, int numpoints, int dim, boolT ismalloc) {
+  qh_initqhull_globals(points, numpoints, dim, ismalloc);
   if (qhmem.LASTsize == 0)
     qh_initqhull_mem();
   /* mem.c and qset.c are initialized */
   qh_initqhull_buffers();
-  qh_initthresholds (qh qhull_command);
+  qh_initthresholds(qh qhull_command);
   if (qh PROJECTinput || (qh DELAUNAY && qh PROJECTdelaunay))
     qh_projectinput();
   if (qh SCALEinput)
     qh_scaleinput();
   if (qh ROTATErandom >= 0) {
-    qh_randommatrix (qh gm_matrix, qh hull_dim, qh gm_row);
+    qh_randommatrix(qh gm_matrix, qh hull_dim, qh gm_row);
     if (qh DELAUNAY) {
       int k, lastk= qh hull_dim-1;
-      for (k= 0; k < lastk; k++) {
+      for (k=0; k < lastk; k++) {
         qh gm_row[k][lastk]= 0.0;
         qh gm_row[lastk][k]= 0.0;
       }
       qh gm_row[lastk][lastk]= 1.0;
     }
-    qh_gram_schmidt (qh hull_dim, qh gm_row);
-    qh_rotateinput (qh gm_row);
+    qh_gram_schmidt(qh hull_dim, qh gm_row);
+    qh_rotateinput(qh gm_row);
   }
 } /* init_B */
 
@@ -474,7 +562,7 @@
     build qh.qhull_command from argc/argv
 
   returns:
-    a space-deliminated string of options (just as typed)
+    a space-delimited string of options (just as typed)
 
   notes:
     makes option string easy to input and output
@@ -482,28 +570,10 @@
     argc/argv may be 0/NULL
 */
 void qh_init_qhull_command(int argc, char *argv[]) {
-  int i;
-  char *s;
 
-  if (argc) {
-    if ((s= strrchr( argv[0], '\\'))) /* Borland gives full path */
-      strcpy (qh qhull_command, s+1);
-    else
-      strcpy (qh qhull_command, argv[0]);
-    if ((s= strstr (qh qhull_command, ".EXE"))
-    ||  (s= strstr (qh qhull_command, ".exe")))
-      *s= '\0';
+  if (!qh_argv_to_command(argc, argv, qh qhull_command, (int)sizeof(qh qhull_command))){
+    qh_exit(qh_ERRinput);  /* error reported, can not use qh_errexit */
   }
-  for (i=1; i < argc; i++) {
-    if (strlen (qh qhull_command) + strlen(argv[i]) + 1 < sizeof(qh qhull_command)) {
-      strcat (qh qhull_command, " ");
-      strcat (qh qhull_command, argv[i]);
-    }else {
-      fprintf (qh ferr, "qhull input error: more than %d characters in command line\n",
-        (int)sizeof(qh qhull_command));
-      exit (1);  /* can not use qh_errexit */
-    }
-  }
 } /* init_qhull_command */
 
 /*-<a                             href="qh-globa.htm#TOC"
@@ -534,8 +604,6 @@
           check syntax
           append approriate option to option string
           set appropriate global variable or append printFormat to print options
-
-
 */
 void qh_initflags(char *command) {
   int k, i, lastproject;
@@ -543,12 +611,14 @@
   boolT isgeom= False, wasproject;
   realT r;
 
-  if (command != &qh qhull_command[0]) {
-    *qh qhull_command= '\0';
-    strncat( qh qhull_command, command, sizeof( qh qhull_command));
+  if (command <= &qh qhull_command[0] || command > &qh qhull_command[0] + sizeof(qh qhull_command)) {
+    if (command != &qh qhull_command[0]) {
+      *qh qhull_command= '\0';
+      strncat( qh qhull_command, command, sizeof( qh qhull_command));
+    }
+    while (*s && !isspace(*s))  /* skip program name */
+      s++;
   }
-  while (*s && !isspace(*s))  /* skip program name */
-    s++;
   while (*s) {
     while (*s && isspace(*s))
       s++;
@@ -559,802 +629,786 @@
     prev_s= s;
     switch (*s++) {
     case 'd':
-      qh_option ("delaunay", NULL, NULL);
+      qh_option("delaunay", NULL, NULL);
       qh DELAUNAY= True;
       break;
     case 'f':
-      qh_option ("facets", NULL, NULL);
-      qh_appendprint (qh_PRINTfacets);
+      qh_option("facets", NULL, NULL);
+      qh_appendprint(qh_PRINTfacets);
       break;
     case 'i':
-      qh_option ("incidence", NULL, NULL);
-      qh_appendprint (qh_PRINTincidences);
+      qh_option("incidence", NULL, NULL);
+      qh_appendprint(qh_PRINTincidences);
       break;
     case 'm':
-      qh_option ("mathematica", NULL, NULL);
-      qh_appendprint (qh_PRINTmathematica);
+      qh_option("mathematica", NULL, NULL);
+      qh_appendprint(qh_PRINTmathematica);
       break;
     case 'n':
-      qh_option ("normals", NULL, NULL);
-      qh_appendprint (qh_PRINTnormals);
+      qh_option("normals", NULL, NULL);
+      qh_appendprint(qh_PRINTnormals);
       break;
     case 'o':
-      qh_option ("offFile", NULL, NULL);
-      qh_appendprint (qh_PRINToff);
+      qh_option("offFile", NULL, NULL);
+      qh_appendprint(qh_PRINToff);
       break;
     case 'p':
-      qh_option ("points", NULL, NULL);
-      qh_appendprint (qh_PRINTpoints);
+      qh_option("points", NULL, NULL);
+      qh_appendprint(qh_PRINTpoints);
       break;
     case 's':
-      qh_option ("summary", NULL, NULL);
+      qh_option("summary", NULL, NULL);
       qh PRINTsummary= True;
       break;
     case 'v':
-      qh_option ("voronoi", NULL, NULL);
+      qh_option("voronoi", NULL, NULL);
       qh VORONOI= True;
       qh DELAUNAY= True;
       break;
     case 'A':
       if (!isdigit(*s) && *s != '.' && *s != '-')
-	fprintf(qh ferr, "qhull warning: no maximum cosine angle given for option 'An'.  Ignored.\n");
+        qh_fprintf(qh ferr, 7002, "qhull warning: no maximum cosine angle given for option 'An'.  Ignored.\n");
       else {
-	if (*s == '-') {
-	  qh premerge_cos= -qh_strtod (s, &s);
-          qh_option ("Angle-premerge-", NULL, &qh premerge_cos);
-	  qh PREmerge= True;
-	}else {
-	  qh postmerge_cos= qh_strtod (s, &s);
-          qh_option ("Angle-postmerge", NULL, &qh postmerge_cos);
-	  qh POSTmerge= True;
-	}
-	qh MERGING= True;
+        if (*s == '-') {
+          qh premerge_cos= -qh_strtod(s, &s);
+          qh_option("Angle-premerge-", NULL, &qh premerge_cos);
+          qh PREmerge= True;
+        }else {
+          qh postmerge_cos= qh_strtod(s, &s);
+          qh_option("Angle-postmerge", NULL, &qh postmerge_cos);
+          qh POSTmerge= True;
+        }
+        qh MERGING= True;
       }
       break;
     case 'C':
       if (!isdigit(*s) && *s != '.' && *s != '-')
-	fprintf(qh ferr, "qhull warning: no centrum radius given for option 'Cn'.  Ignored.\n");
+        qh_fprintf(qh ferr, 7003, "qhull warning: no centrum radius given for option 'Cn'.  Ignored.\n");
       else {
-	if (*s == '-') {
-	  qh premerge_centrum= -qh_strtod (s, &s);
-          qh_option ("Centrum-premerge-", NULL, &qh premerge_centrum);
-	  qh PREmerge= True;
-	}else {
-	  qh postmerge_centrum= qh_strtod (s, &s);
-          qh_option ("Centrum-postmerge", NULL, &qh postmerge_centrum);
-	  qh POSTmerge= True;
-	}
-	qh MERGING= True;
+        if (*s == '-') {
+          qh premerge_centrum= -qh_strtod(s, &s);
+          qh_option("Centrum-premerge-", NULL, &qh premerge_centrum);
+          qh PREmerge= True;
+        }else {
+          qh postmerge_centrum= qh_strtod(s, &s);
+          qh_option("Centrum-postmerge", NULL, &qh postmerge_centrum);
+          qh POSTmerge= True;
+        }
+        qh MERGING= True;
       }
       break;
     case 'E':
       if (*s == '-')
-	fprintf(qh ferr, "qhull warning: negative maximum roundoff given for option 'An'.  Ignored.\n");
+        qh_fprintf(qh ferr, 7004, "qhull warning: negative maximum roundoff given for option 'An'.  Ignored.\n");
       else if (!isdigit(*s))
-	fprintf(qh ferr, "qhull warning: no maximum roundoff given for option 'En'.  Ignored.\n");
+        qh_fprintf(qh ferr, 7005, "qhull warning: no maximum roundoff given for option 'En'.  Ignored.\n");
       else {
-	qh DISTround= qh_strtod (s, &s);
-        qh_option ("Distance-roundoff", NULL, &qh DISTround);
-	qh SETroundoff= True;
+        qh DISTround= qh_strtod(s, &s);
+        qh_option("Distance-roundoff", NULL, &qh DISTround);
+        qh SETroundoff= True;
       }
       break;
     case 'H':
       start= s;
       qh HALFspace= True;
-      qh_strtod (s, &t);
+      qh_strtod(s, &t);
       while (t > s)  {
-        if (*t && !isspace (*t)) {
-	  if (*t == ',')
-	    t++;
-	  else
-	    fprintf (qh ferr, "qhull warning: origin for Halfspace intersection should be 'Hn,n,n,...'\n");
-	}
+        if (*t && !isspace(*t)) {
+          if (*t == ',')
+            t++;
+          else
+            qh_fprintf(qh ferr, 7006, "qhull warning: origin for Halfspace intersection should be 'Hn,n,n,...'\n");
+        }
         s= t;
-	qh_strtod (s, &t);
+        qh_strtod(s, &t);
       }
       if (start < t) {
-        if (!(qh feasible_string= (char*)calloc (t-start+1, 1))) {
-          fprintf(qh ferr, "qhull error: insufficient memory for 'Hn,n,n'\n");
+        if (!(qh feasible_string= (char*)calloc((size_t)(t-start+1), (size_t)1))) {
+          qh_fprintf(qh ferr, 6034, "qhull error: insufficient memory for 'Hn,n,n'\n");
           qh_errexit(qh_ERRmem, NULL, NULL);
         }
-        strncpy (qh feasible_string, start, t-start);
-        qh_option ("Halfspace-about", NULL, NULL);
-        qh_option (qh feasible_string, NULL, NULL);
+        strncpy(qh feasible_string, start, (size_t)(t-start));
+        qh_option("Halfspace-about", NULL, NULL);
+        qh_option(qh feasible_string, NULL, NULL);
       }else
-        qh_option ("Halfspace", NULL, NULL);
+        qh_option("Halfspace", NULL, NULL);
       break;
     case 'R':
       if (!isdigit(*s))
-	fprintf(qh ferr, "qhull warning: missing random perturbation for option 'Rn'.  Ignored\n");
+        qh_fprintf(qh ferr, 7007, "qhull warning: missing random perturbation for option 'Rn'.  Ignored\n");
       else {
-	qh RANDOMfactor= qh_strtod (s, &s);
-        qh_option ("Random_perturb", NULL, &qh RANDOMfactor);
+        qh RANDOMfactor= qh_strtod(s, &s);
+        qh_option("Random_perturb", NULL, &qh RANDOMfactor);
         qh RANDOMdist= True;
       }
       break;
     case 'V':
       if (!isdigit(*s) && *s != '-')
-	fprintf(qh ferr, "qhull warning: missing visible distance for option 'Vn'.  Ignored\n");
+        qh_fprintf(qh ferr, 7008, "qhull warning: missing visible distance for option 'Vn'.  Ignored\n");
       else {
-	qh MINvisible= qh_strtod (s, &s);
-        qh_option ("Visible", NULL, &qh MINvisible);
+        qh MINvisible= qh_strtod(s, &s);
+        qh_option("Visible", NULL, &qh MINvisible);
       }
       break;
     case 'U':
       if (!isdigit(*s) && *s != '-')
-	fprintf(qh ferr, "qhull warning: missing coplanar distance for option 'Un'.  Ignored\n");
+        qh_fprintf(qh ferr, 7009, "qhull warning: missing coplanar distance for option 'Un'.  Ignored\n");
       else {
-	qh MAXcoplanar= qh_strtod (s, &s);
-        qh_option ("U-coplanar", NULL, &qh MAXcoplanar);
+        qh MAXcoplanar= qh_strtod(s, &s);
+        qh_option("U-coplanar", NULL, &qh MAXcoplanar);
       }
       break;
     case 'W':
       if (*s == '-')
-	fprintf(qh ferr, "qhull warning: negative outside width for option 'Wn'.  Ignored.\n");
+        qh_fprintf(qh ferr, 7010, "qhull warning: negative outside width for option 'Wn'.  Ignored.\n");
       else if (!isdigit(*s))
-	fprintf(qh ferr, "qhull warning: missing outside width for option 'Wn'.  Ignored\n");
+        qh_fprintf(qh ferr, 7011, "qhull warning: missing outside width for option 'Wn'.  Ignored\n");
       else {
-	qh MINoutside= qh_strtod (s, &s);
-        qh_option ("W-outside", NULL, &qh MINoutside);
+        qh MINoutside= qh_strtod(s, &s);
+        qh_option("W-outside", NULL, &qh MINoutside);
         qh APPROXhull= True;
       }
       break;
     /************  sub menus ***************/
     case 'F':
       while (*s && !isspace(*s)) {
-	switch(*s++) {
-	case 'a':
-	  qh_option ("Farea", NULL, NULL);
-	  qh_appendprint (qh_PRINTarea);
-	  qh GETarea= True;
-	  break;
-	case 'A':
-	  qh_option ("FArea-total", NULL, NULL);
-	  qh GETarea= True;
-	  break;
+        switch (*s++) {
+        case 'a':
+          qh_option("Farea", NULL, NULL);
+          qh_appendprint(qh_PRINTarea);
+          qh GETarea= True;
+          break;
+        case 'A':
+          qh_option("FArea-total", NULL, NULL);
+          qh GETarea= True;
+          break;
         case 'c':
-          qh_option ("Fcoplanars", NULL, NULL);
-          qh_appendprint (qh_PRINTcoplanars);
+          qh_option("Fcoplanars", NULL, NULL);
+          qh_appendprint(qh_PRINTcoplanars);
           break;
         case 'C':
-          qh_option ("FCentrums", NULL, NULL);
-          qh_appendprint (qh_PRINTcentrums);
+          qh_option("FCentrums", NULL, NULL);
+          qh_appendprint(qh_PRINTcentrums);
           break;
-	case 'd':
-          qh_option ("Fd-cdd-in", NULL, NULL);
-	  qh CDDinput= True;
-	  break;
-	case 'D':
-          qh_option ("FD-cdd-out", NULL, NULL);
-	  qh CDDoutput= True;
-	  break;
-	case 'F':
-	  qh_option ("FFacets-xridge", NULL, NULL);
-          qh_appendprint (qh_PRINTfacets_xridge);
-	  break;
+        case 'd':
+          qh_option("Fd-cdd-in", NULL, NULL);
+          qh CDDinput= True;
+          break;
+        case 'D':
+          qh_option("FD-cdd-out", NULL, NULL);
+          qh CDDoutput= True;
+          break;
+        case 'F':
+          qh_option("FFacets-xridge", NULL, NULL);
+          qh_appendprint(qh_PRINTfacets_xridge);
+          break;
         case 'i':
-          qh_option ("Finner", NULL, NULL);
-          qh_appendprint (qh_PRINTinner);
+          qh_option("Finner", NULL, NULL);
+          qh_appendprint(qh_PRINTinner);
           break;
         case 'I':
-          qh_option ("FIDs", NULL, NULL);
-          qh_appendprint (qh_PRINTids);
+          qh_option("FIDs", NULL, NULL);
+          qh_appendprint(qh_PRINTids);
           break;
         case 'm':
-          qh_option ("Fmerges", NULL, NULL);
-          qh_appendprint (qh_PRINTmerges);
+          qh_option("Fmerges", NULL, NULL);
+          qh_appendprint(qh_PRINTmerges);
           break;
         case 'M':
-          qh_option ("FMaple", NULL, NULL);
-          qh_appendprint (qh_PRINTmaple);
+          qh_option("FMaple", NULL, NULL);
+          qh_appendprint(qh_PRINTmaple);
           break;
         case 'n':
-          qh_option ("Fneighbors", NULL, NULL);
-          qh_appendprint (qh_PRINTneighbors);
+          qh_option("Fneighbors", NULL, NULL);
+          qh_appendprint(qh_PRINTneighbors);
           break;
         case 'N':
-          qh_option ("FNeighbors-vertex", NULL, NULL);
-          qh_appendprint (qh_PRINTvneighbors);
+          qh_option("FNeighbors-vertex", NULL, NULL);
+          qh_appendprint(qh_PRINTvneighbors);
           break;
         case 'o':
-          qh_option ("Fouter", NULL, NULL);
-          qh_appendprint (qh_PRINTouter);
+          qh_option("Fouter", NULL, NULL);
+          qh_appendprint(qh_PRINTouter);
           break;
-	case 'O':
-	  if (qh PRINToptions1st) {
-	    qh_option ("FOptions", NULL, NULL);
-	    qh_appendprint (qh_PRINToptions);
-	  }else
-	    qh PRINToptions1st= True;
-	  break;
-	case 'p':
-	  qh_option ("Fpoint-intersect", NULL, NULL);
-	  qh_appendprint (qh_PRINTpointintersect);
-	  break;
-	case 'P':
-	  qh_option ("FPoint-nearest", NULL, NULL);
-	  qh_appendprint (qh_PRINTpointnearest);
-	  break;
-	case 'Q':
-	  qh_option ("FQhull", NULL, NULL);
-	  qh_appendprint (qh_PRINTqhull);
-	  break;
+        case 'O':
+          if (qh PRINToptions1st) {
+            qh_option("FOptions", NULL, NULL);
+            qh_appendprint(qh_PRINToptions);
+          }else
+            qh PRINToptions1st= True;
+          break;
+        case 'p':
+          qh_option("Fpoint-intersect", NULL, NULL);
+          qh_appendprint(qh_PRINTpointintersect);
+          break;
+        case 'P':
+          qh_option("FPoint-nearest", NULL, NULL);
+          qh_appendprint(qh_PRINTpointnearest);
+          break;
+        case 'Q':
+          qh_option("FQhull", NULL, NULL);
+          qh_appendprint(qh_PRINTqhull);
+          break;
         case 's':
-          qh_option ("Fsummary", NULL, NULL);
-          qh_appendprint (qh_PRINTsummary);
+          qh_option("Fsummary", NULL, NULL);
+          qh_appendprint(qh_PRINTsummary);
           break;
         case 'S':
-          qh_option ("FSize", NULL, NULL);
-          qh_appendprint (qh_PRINTsize);
+          qh_option("FSize", NULL, NULL);
+          qh_appendprint(qh_PRINTsize);
           qh GETarea= True;
           break;
         case 't':
-          qh_option ("Ftriangles", NULL, NULL);
-          qh_appendprint (qh_PRINTtriangles);
+          qh_option("Ftriangles", NULL, NULL);
+          qh_appendprint(qh_PRINTtriangles);
           break;
         case 'v':
           /* option set in qh_initqhull_globals */
-          qh_appendprint (qh_PRINTvertices);
+          qh_appendprint(qh_PRINTvertices);
           break;
         case 'V':
-          qh_option ("FVertex-average", NULL, NULL);
-          qh_appendprint (qh_PRINTaverage);
+          qh_option("FVertex-average", NULL, NULL);
+          qh_appendprint(qh_PRINTaverage);
           break;
-	case 'x':
-	  qh_option ("Fxtremes", NULL, NULL);
-	  qh_appendprint (qh_PRINTextremes);
-	  break;
-	default:
-	  s--;
-	  fprintf (qh ferr, "qhull warning: unknown 'F' output option %c, rest ignored\n", (int)s[0]);
-	  while (*++s && !isspace(*s));
-	  break;
-	}
+        case 'x':
+          qh_option("Fxtremes", NULL, NULL);
+          qh_appendprint(qh_PRINTextremes);
+          break;
+        default:
+          s--;
+          qh_fprintf(qh ferr, 7012, "qhull warning: unknown 'F' output option %c, rest ignored\n", (int)s[0]);
+          while (*++s && !isspace(*s));
+          break;
+        }
       }
       break;
     case 'G':
       isgeom= True;
-      qh_appendprint (qh_PRINTgeom);
+      qh_appendprint(qh_PRINTgeom);
       while (*s && !isspace(*s)) {
-	switch(*s++) {
+        switch (*s++) {
         case 'a':
-          qh_option ("Gall-points", NULL, NULL);
+          qh_option("Gall-points", NULL, NULL);
           qh PRINTdots= True;
           break;
         case 'c':
-          qh_option ("Gcentrums", NULL, NULL);
+          qh_option("Gcentrums", NULL, NULL);
           qh PRINTcentrums= True;
           break;
-	case 'h':
-          qh_option ("Gintersections", NULL, NULL);
-	  qh DOintersections= True;
-	  break;
-	case 'i':
-          qh_option ("Ginner", NULL, NULL);
-	  qh PRINTinner= True;
-	  break;
-	case 'n':
-          qh_option ("Gno-planes", NULL, NULL);
-	  qh PRINTnoplanes= True;
-	  break;
-	case 'o':
-          qh_option ("Gouter", NULL, NULL);
-	  qh PRINTouter= True;
-	  break;
-	case 'p':
-          qh_option ("Gpoints", NULL, NULL);
-	  qh PRINTcoplanar= True;
-	  break;
-	case 'r':
-          qh_option ("Gridges", NULL, NULL);
-	  qh PRINTridges= True;
-	  break;
-	case 't':
-          qh_option ("Gtransparent", NULL, NULL);
-	  qh PRINTtransparent= True;
-	  break;
-	case 'v':
-          qh_option ("Gvertices", NULL, NULL);
-	  qh PRINTspheres= True;
-	  break;
-	case 'D':
-	  if (!isdigit (*s))
-	    fprintf (qh ferr, "qhull input error: missing dimension for option 'GDn'\n");
-	  else {
-	    if (qh DROPdim >= 0)
-	      fprintf (qh ferr, "qhull warning: can only drop one dimension.  Previous 'GD%d' ignored\n",
-	           qh DROPdim);
-  	    qh DROPdim= qh_strtol (s, &s);
-            qh_option ("GDrop-dim", &qh DROPdim, NULL);
+        case 'h':
+          qh_option("Gintersections", NULL, NULL);
+          qh DOintersections= True;
+          break;
+        case 'i':
+          qh_option("Ginner", NULL, NULL);
+          qh PRINTinner= True;
+          break;
+        case 'n':
+          qh_option("Gno-planes", NULL, NULL);
+          qh PRINTnoplanes= True;
+          break;
+        case 'o':
+          qh_option("Gouter", NULL, NULL);
+          qh PRINTouter= True;
+          break;
+        case 'p':
+          qh_option("Gpoints", NULL, NULL);
+          qh PRINTcoplanar= True;
+          break;
+        case 'r':
+          qh_option("Gridges", NULL, NULL);
+          qh PRINTridges= True;
+          break;
+        case 't':
+          qh_option("Gtransparent", NULL, NULL);
+          qh PRINTtransparent= True;
+          break;
+        case 'v':
+          qh_option("Gvertices", NULL, NULL);
+          qh PRINTspheres= True;
+          break;
+        case 'D':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 6035, "qhull input error: missing dimension for option 'GDn'\n");
+          else {
+            if (qh DROPdim >= 0)
+              qh_fprintf(qh ferr, 7013, "qhull warning: can only drop one dimension.  Previous 'GD%d' ignored\n",
+                   qh DROPdim);
+            qh DROPdim= qh_strtol(s, &s);
+            qh_option("GDrop-dim", &qh DROPdim, NULL);
           }
-	  break;
-	default:
-	  s--;
-	  fprintf (qh ferr, "qhull warning: unknown 'G' print option %c, rest ignored\n", (int)s[0]);
-	  while (*++s && !isspace(*s));
-	  break;
-	}
+          break;
+        default:
+          s--;
+          qh_fprintf(qh ferr, 7014, "qhull warning: unknown 'G' print option %c, rest ignored\n", (int)s[0]);
+          while (*++s && !isspace(*s));
+          break;
+        }
       }
       break;
     case 'P':
       while (*s && !isspace(*s)) {
-	switch(*s++) {
-	case 'd': case 'D':  /* see qh_initthresholds() */
-	  key= s[-1];
-	  i= qh_strtol (s, &s);
-	  r= 0;
-	  if (*s == ':') {
-	    s++;
-	    r= qh_strtod (s, &s);
-	  }
-	  if (key == 'd')
-  	    qh_option ("Pdrop-facets-dim-less", &i, &r);
-  	  else
-  	    qh_option ("PDrop-facets-dim-more", &i, &r);
-	  break;
+        switch (*s++) {
+        case 'd': case 'D':  /* see qh_initthresholds() */
+          key= s[-1];
+          i= qh_strtol(s, &s);
+          r= 0;
+          if (*s == ':') {
+            s++;
+            r= qh_strtod(s, &s);
+          }
+          if (key == 'd')
+            qh_option("Pdrop-facets-dim-less", &i, &r);
+          else
+            qh_option("PDrop-facets-dim-more", &i, &r);
+          break;
         case 'g':
-          qh_option ("Pgood-facets", NULL, NULL);
+          qh_option("Pgood-facets", NULL, NULL);
           qh PRINTgood= True;
           break;
         case 'G':
-          qh_option ("PGood-facet-neighbors", NULL, NULL);
+          qh_option("PGood-facet-neighbors", NULL, NULL);
           qh PRINTneighbors= True;
           break;
         case 'o':
-          qh_option ("Poutput-forced", NULL, NULL);
+          qh_option("Poutput-forced", NULL, NULL);
           qh FORCEoutput= True;
           break;
         case 'p':
-          qh_option ("Pprecision-ignore", NULL, NULL);
+          qh_option("Pprecision-ignore", NULL, NULL);
           qh PRINTprecision= False;
           break;
-	case 'A':
-	  if (!isdigit (*s))
-	    fprintf (qh ferr, "qhull input error: missing facet count for keep area option 'PAn'\n");
-	  else {
-  	    qh KEEParea= qh_strtol (s, &s);
-            qh_option ("PArea-keep", &qh KEEParea, NULL);
+        case 'A':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 6036, "qhull input error: missing facet count for keep area option 'PAn'\n");
+          else {
+            qh KEEParea= qh_strtol(s, &s);
+            qh_option("PArea-keep", &qh KEEParea, NULL);
             qh GETarea= True;
           }
-	  break;
-	case 'F':
-	  if (!isdigit (*s))
-	    fprintf (qh ferr, "qhull input error: missing facet area for option 'PFn'\n");
-	  else {
-  	    qh KEEPminArea= qh_strtod (s, &s);
-            qh_option ("PFacet-area-keep", NULL, &qh KEEPminArea);
+          break;
+        case 'F':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 6037, "qhull input error: missing facet area for option 'PFn'\n");
+          else {
+            qh KEEPminArea= qh_strtod(s, &s);
+            qh_option("PFacet-area-keep", NULL, &qh KEEPminArea);
             qh GETarea= True;
           }
-	  break;
-	case 'M':
-	  if (!isdigit (*s))
-	    fprintf (qh ferr, "qhull input error: missing merge count for option 'PMn'\n");
-	  else {
-  	    qh KEEPmerge= qh_strtol (s, &s);
-            qh_option ("PMerge-keep", &qh KEEPmerge, NULL);
+          break;
+        case 'M':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 6038, "qhull input error: missing merge count for option 'PMn'\n");
+          else {
+            qh KEEPmerge= qh_strtol(s, &s);
+            qh_option("PMerge-keep", &qh KEEPmerge, NULL);
           }
-	  break;
-	default:
-	  s--;
-	  fprintf (qh ferr, "qhull warning: unknown 'P' print option %c, rest ignored\n", (int)s[0]);
-	  while (*++s && !isspace(*s));
-	  break;
-	}
+          break;
+        default:
+          s--;
+          qh_fprintf(qh ferr, 7015, "qhull warning: unknown 'P' print option %c, rest ignored\n", (int)s[0]);
+          while (*++s && !isspace(*s));
+          break;
+        }
       }
       break;
     case 'Q':
       lastproject= -1;
       while (*s && !isspace(*s)) {
-	switch(*s++) {
-	case 'b': case 'B':  /* handled by qh_initthresholds */
-	  key= s[-1];
-	  if (key == 'b' && *s == 'B') {
-	    s++;
-	    r= qh_DEFAULTbox;
-	    qh SCALEinput= True;
-	    qh_option ("QbBound-unit-box", NULL, &r);
-	    break;
-	  }
-	  if (key == 'b' && *s == 'b') {
-	    s++;
-	    qh SCALElast= True;
-	    qh_option ("Qbbound-last", NULL, NULL);
-	    break;
-	  }
-	  k= qh_strtol (s, &s);
-	  r= 0.0;
-	  wasproject= False;
-	  if (*s == ':') {
-	    s++;
-	    if ((r= qh_strtod(s, &s)) == 0.0) {
- 	      t= s;            /* need true dimension for memory allocation */
-	      while (*t && !isspace(*t)) {
-	        if (toupper(*t++) == 'B'
-	         && k == qh_strtol (t, &t)
-	         && *t++ == ':'
-	         && qh_strtod(t, &t) == 0.0) {
-	          qh PROJECTinput++;
-	          trace2((qh ferr, "qh_initflags: project dimension %d\n", k));
-	          qh_option ("Qb-project-dim", &k, NULL);
-		  wasproject= True;
-	          lastproject= k;
-	          break;
-		}
-	      }
-	    }
-  	  }
-	  if (!wasproject) {
-	    if (lastproject == k && r == 0.0)
-	      lastproject= -1;  /* doesn't catch all possible sequences */
-	    else if (key == 'b') {
-	      qh SCALEinput= True;
-	      if (r == 0.0)
-		r= -qh_DEFAULTbox;
-	      qh_option ("Qbound-dim-low", &k, &r);
-	    }else {
-	      qh SCALEinput= True;
-	      if (r == 0.0)
-		r= qh_DEFAULTbox;
-	      qh_option ("QBound-dim-high", &k, &r);
-	    }
-	  }
-	  break;
-	case 'c':
-	  qh_option ("Qcoplanar-keep", NULL, NULL);
-	  qh KEEPcoplanar= True;
-	  break;
-	case 'f':
-	  qh_option ("Qfurthest-outside", NULL, NULL);
-	  qh BESToutside= True;
-	  break;
-	case 'g':
-	  qh_option ("Qgood-facets-only", NULL, NULL);
-	  qh ONLYgood= True;
-	  break;
-	case 'i':
-	  qh_option ("Qinterior-keep", NULL, NULL);
-	  qh KEEPinside= True;
-	  break;
-	case 'm':
-	  qh_option ("Qmax-outside-only", NULL, NULL);
-	  qh ONLYmax= True;
-	  break;
-	case 'r':
-	  qh_option ("Qrandom-outside", NULL, NULL);
-	  qh RANDOMoutside= True;
-	  break;
-	case 's':
-	  qh_option ("Qsearch-initial-simplex", NULL, NULL);
-	  qh ALLpoints= True;
-	  break;
-	case 't':
-	  qh_option ("Qtriangulate", NULL, NULL);
-	  qh TRIangulate= True;
-	  break;
-	case 'T':
-	  qh_option ("QTestPoints", NULL, NULL);
-	  if (!isdigit (*s))
-	    fprintf (qh ferr, "qhull input error: missing number of test points for option 'QTn'\n");
-	  else {
-  	    qh TESTpoints= qh_strtol (s, &s);
-            qh_option ("QTestPoints", &qh TESTpoints, NULL);
+        switch (*s++) {
+        case 'b': case 'B':  /* handled by qh_initthresholds */
+          key= s[-1];
+          if (key == 'b' && *s == 'B') {
+            s++;
+            r= qh_DEFAULTbox;
+            qh SCALEinput= True;
+            qh_option("QbBound-unit-box", NULL, &r);
+            break;
           }
-	  break;
-	case 'u':
-	  qh_option ("QupperDelaunay", NULL, NULL);
-	  qh UPPERdelaunay= True;
-	  break;
-	case 'v':
-	  qh_option ("Qvertex-neighbors-convex", NULL, NULL);
-	  qh TESTvneighbors= True;
-	  break;
-	case 'x':
-	  qh_option ("Qxact-merge", NULL, NULL);
-	  qh MERGEexact= True;
-	  break;
-	case 'z':
-	  qh_option ("Qz-infinity-point", NULL, NULL);
-	  qh ATinfinity= True;
-	  break;
-	case '0':
-	  qh_option ("Q0-no-premerge", NULL, NULL);
-	  qh NOpremerge= True;
-	  break;
-	case '1':
-	  if (!isdigit(*s)) {
-	    qh_option ("Q1-no-angle-sort", NULL, NULL);
-	    qh ANGLEmerge= False;
-	    break; 
-	  }
-	  switch(*s++) {
-  	  case '0':
-	    qh_option ("Q10-no-narrow", NULL, NULL);
-	    qh NOnarrow= True;
-	    break; 
-  	  case '1':
-	    qh_option ("Q11-trinormals Qtriangulate", NULL, NULL);
-	    qh TRInormals= True;
-	    qh TRIangulate= True;
-	    break; 
-	  default:
-	    s--;
-	    fprintf (qh ferr, "qhull warning: unknown 'Q' qhull option 1%c, rest ignored\n", (int)s[0]);
-	    while (*++s && !isspace(*s));
-	    break;
-	  }
-	  break;
-	case '2':
-	  qh_option ("Q2-no-merge-independent", NULL, NULL);
-	  qh MERGEindependent= False;
-	  goto LABELcheckdigit;
-	  break; /* no warnings */
-	case '3':
-	  qh_option ("Q3-no-merge-vertices", NULL, NULL);
-	  qh MERGEvertices= False;
-	LABELcheckdigit:
-	  if (isdigit(*s))
-	    fprintf (qh ferr, "qhull warning: can not follow '1', '2', or '3' with a digit.  '%c' skipped.\n",
-	             *s++);
-	  break;
-	case '4':
-	  qh_option ("Q4-avoid-old-into-new", NULL, NULL);
-	  qh AVOIDold= True;
-	  break;
-	case '5':
-	  qh_option ("Q5-no-check-outer", NULL, NULL);
-	  qh SKIPcheckmax= True;
-	  break;
-	case '6':
-	  qh_option ("Q6-no-concave-merge", NULL, NULL);
-	  qh SKIPconvex= True;
-	  break;
-	case '7':
-	  qh_option ("Q7-no-breadth-first", NULL, NULL);
-	  qh VIRTUALmemory= True;
-	  break;
-	case '8':
-	  qh_option ("Q8-no-near-inside", NULL, NULL);
-	  qh NOnearinside= True;
-	  break;
-	case '9':
-	  qh_option ("Q9-pick-furthest", NULL, NULL);
-	  qh PICKfurthest= True;
-	  break;
-	case 'G':
-	  i= qh_strtol (s, &t);
-	  if (qh GOODpoint)
-	    fprintf (qh ferr, "qhull warning: good point already defined for option 'QGn'.  Ignored\n");
+          if (key == 'b' && *s == 'b') {
+            s++;
+            qh SCALElast= True;
+            qh_option("Qbbound-last", NULL, NULL);
+            break;
+          }
+          k= qh_strtol(s, &s);
+          r= 0.0;
+          wasproject= False;
+          if (*s == ':') {
+            s++;
+            if ((r= qh_strtod(s, &s)) == 0.0) {
+              t= s;            /* need true dimension for memory allocation */
+              while (*t && !isspace(*t)) {
+                if (toupper(*t++) == 'B'
+                 && k == qh_strtol(t, &t)
+                 && *t++ == ':'
+                 && qh_strtod(t, &t) == 0.0) {
+                  qh PROJECTinput++;
+                  trace2((qh ferr, 2004, "qh_initflags: project dimension %d\n", k));
+                  qh_option("Qb-project-dim", &k, NULL);
+                  wasproject= True;
+                  lastproject= k;
+                  break;
+                }
+              }
+            }
+          }
+          if (!wasproject) {
+            if (lastproject == k && r == 0.0)
+              lastproject= -1;  /* doesn't catch all possible sequences */
+            else if (key == 'b') {
+              qh SCALEinput= True;
+              if (r == 0.0)
+                r= -qh_DEFAULTbox;
+              qh_option("Qbound-dim-low", &k, &r);
+            }else {
+              qh SCALEinput= True;
+              if (r == 0.0)
+                r= qh_DEFAULTbox;
+              qh_option("QBound-dim-high", &k, &r);
+            }
+          }
+          break;
+        case 'c':
+          qh_option("Qcoplanar-keep", NULL, NULL);
+          qh KEEPcoplanar= True;
+          break;
+        case 'f':
+          qh_option("Qfurthest-outside", NULL, NULL);
+          qh BESToutside= True;
+          break;
+        case 'g':
+          qh_option("Qgood-facets-only", NULL, NULL);
+          qh ONLYgood= True;
+          break;
+        case 'i':
+          qh_option("Qinterior-keep", NULL, NULL);
+          qh KEEPinside= True;
+          break;
+        case 'm':
+          qh_option("Qmax-outside-only", NULL, NULL);
+          qh ONLYmax= True;
+          break;
+        case 'r':
+          qh_option("Qrandom-outside", NULL, NULL);
+          qh RANDOMoutside= True;
+          break;
+        case 's':
+          qh_option("Qsearch-initial-simplex", NULL, NULL);
+          qh ALLpoints= True;
+          break;
+        case 't':
+          qh_option("Qtriangulate", NULL, NULL);
+          qh TRIangulate= True;
+          break;
+        case 'T':
+          qh_option("QTestPoints", NULL, NULL);
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 6039, "qhull input error: missing number of test points for option 'QTn'\n");
+          else {
+            qh TESTpoints= qh_strtol(s, &s);
+            qh_option("QTestPoints", &qh TESTpoints, NULL);
+          }
+          break;
+        case 'u':
+          qh_option("QupperDelaunay", NULL, NULL);
+          qh UPPERdelaunay= True;
+          break;
+        case 'v':
+          qh_option("Qvertex-neighbors-convex", NULL, NULL);
+          qh TESTvneighbors= True;
+          break;
+        case 'x':
+          qh_option("Qxact-merge", NULL, NULL);
+          qh MERGEexact= True;
+          break;
+        case 'z':
+          qh_option("Qz-infinity-point", NULL, NULL);
+          qh ATinfinity= True;
+          break;
+        case '0':
+          qh_option("Q0-no-premerge", NULL, NULL);
+          qh NOpremerge= True;
+          break;
+        case '1':
+          if (!isdigit(*s)) {
+            qh_option("Q1-no-angle-sort", NULL, NULL);
+            qh ANGLEmerge= False;
+            break;
+          }
+          switch (*s++) {
+          case '0':
+            qh_option("Q10-no-narrow", NULL, NULL);
+            qh NOnarrow= True;
+            break;
+          case '1':
+            qh_option("Q11-trinormals Qtriangulate", NULL, NULL);
+            qh TRInormals= True;
+            qh TRIangulate= True;
+            break;
+          default:
+            s--;
+            qh_fprintf(qh ferr, 7016, "qhull warning: unknown 'Q' qhull option 1%c, rest ignored\n", (int)s[0]);
+            while (*++s && !isspace(*s));
+            break;
+          }
+          break;
+        case '2':
+          qh_option("Q2-no-merge-independent", NULL, NULL);
+          qh MERGEindependent= False;
+          goto LABELcheckdigit;
+          break; /* no warnings */
+        case '3':
+          qh_option("Q3-no-merge-vertices", NULL, NULL);
+          qh MERGEvertices= False;
+        LABELcheckdigit:
+          if (isdigit(*s))
+            qh_fprintf(qh ferr, 7017, "qhull warning: can not follow '1', '2', or '3' with a digit.  '%c' skipped.\n",
+                     *s++);
+          break;
+        case '4':
+          qh_option("Q4-avoid-old-into-new", NULL, NULL);
+          qh AVOIDold= True;
+          break;
+        case '5':
+          qh_option("Q5-no-check-outer", NULL, NULL);
+          qh SKIPcheckmax= True;
+          break;
+        case '6':
+          qh_option("Q6-no-concave-merge", NULL, NULL);
+          qh SKIPconvex= True;
+          break;
+        case '7':
+          qh_option("Q7-no-breadth-first", NULL, NULL);
+          qh VIRTUALmemory= True;
+          break;
+        case '8':
+          qh_option("Q8-no-near-inside", NULL, NULL);
+          qh NOnearinside= True;
+          break;
+        case '9':
+          qh_option("Q9-pick-furthest", NULL, NULL);
+          qh PICKfurthest= True;
+          break;
+        case 'G':
+          i= qh_strtol(s, &t);
+          if (qh GOODpoint)
+            qh_fprintf(qh ferr, 7018, "qhull warning: good point already defined for option 'QGn'.  Ignored\n");
           else if (s == t)
-	    fprintf (qh ferr, "qhull warning: missing good point id for option 'QGn'.  Ignored\n");
-	  else if (i < 0 || *s == '-') {
- 	    qh GOODpoint= i-1;
-  	    qh_option ("QGood-if-dont-see-point", &i, NULL);
-	  }else {
- 	    qh GOODpoint= i+1;
-  	    qh_option ("QGood-if-see-point", &i, NULL);
-  	  }
- 	  s= t;
-	  break;
-	case 'J':
+            qh_fprintf(qh ferr, 7019, "qhull warning: missing good point id for option 'QGn'.  Ignored\n");
+          else if (i < 0 || *s == '-') {
+            qh GOODpoint= i-1;
+            qh_option("QGood-if-dont-see-point", &i, NULL);
+          }else {
+            qh GOODpoint= i+1;
+            qh_option("QGood-if-see-point", &i, NULL);
+          }
+          s= t;
+          break;
+        case 'J':
           if (!isdigit(*s) && *s != '-')
-   	    qh JOGGLEmax= 0.0;
-	  else {
- 	    qh JOGGLEmax= (realT) qh_strtod (s, &s);
-            qh_option ("QJoggle", NULL, &qh JOGGLEmax);
-	  }
-	  break;
-	case 'R':
+            qh JOGGLEmax= 0.0;
+          else {
+            qh JOGGLEmax= (realT) qh_strtod(s, &s);
+            qh_option("QJoggle", NULL, &qh JOGGLEmax);
+          }
+          break;
+        case 'R':
           if (!isdigit(*s) && *s != '-')
-	    fprintf (qh ferr, "qhull warning: missing random seed for option 'QRn'.  Ignored\n");
-	  else {
- 	    qh ROTATErandom= i= qh_strtol(s, &s);
-   	    if (i > 0)
-   	      qh_option ("QRotate-id", &i, NULL );
-	    else if (i < -1)
-   	      qh_option ("QRandom-seed", &i, NULL );
+            qh_fprintf(qh ferr, 7020, "qhull warning: missing random seed for option 'QRn'.  Ignored\n");
+          else {
+            qh ROTATErandom= i= qh_strtol(s, &s);
+            if (i > 0)
+              qh_option("QRotate-id", &i, NULL );
+            else if (i < -1)
+              qh_option("QRandom-seed", &i, NULL );
           }
-	  break;
-	case 'V':
-	  i= qh_strtol (s, &t);
-	  if (qh GOODvertex)
-	    fprintf (qh ferr, "qhull warning: good vertex already defined for option 'QVn'.  Ignored\n");
+          break;
+        case 'V':
+          i= qh_strtol(s, &t);
+          if (qh GOODvertex)
+            qh_fprintf(qh ferr, 7021, "qhull warning: good vertex already defined for option 'QVn'.  Ignored\n");
           else if (s == t)
-	    fprintf (qh ferr, "qhull warning: no good point id given for option 'QVn'.  Ignored\n");
-	  else if (i < 0) {
- 	    qh GOODvertex= i - 1;
- 	    qh_option ("QV-good-facets-not-point", &i, NULL);
-	  }else {
-  	    qh_option ("QV-good-facets-point", &i, NULL);
-	    qh GOODvertex= i + 1;
+            qh_fprintf(qh ferr, 7022, "qhull warning: no good point id given for option 'QVn'.  Ignored\n");
+          else if (i < 0) {
+            qh GOODvertex= i - 1;
+            qh_option("QV-good-facets-not-point", &i, NULL);
+          }else {
+            qh_option("QV-good-facets-point", &i, NULL);
+            qh GOODvertex= i + 1;
           }
- 	  s= t;
-	  break;
-	default:
-	  s--;
-	  fprintf (qh ferr, "qhull warning: unknown 'Q' qhull option %c, rest ignored\n", (int)s[0]);
-	  while (*++s && !isspace(*s));
-	  break;
-	}
+          s= t;
+          break;
+        default:
+          s--;
+          qh_fprintf(qh ferr, 7023, "qhull warning: unknown 'Q' qhull option %c, rest ignored\n", (int)s[0]);
+          while (*++s && !isspace(*s));
+          break;
+        }
       }
       break;
     case 'T':
       while (*s && !isspace(*s)) {
-	if (isdigit(*s) || *s == '-')
-	  qh IStracing= qh_strtol(s, &s);
-	else switch(*s++) {
-	case 'c':
-          qh_option ("Tcheck-frequently", NULL, NULL);
-	  qh CHECKfrequently= True;
-	  break;
-	case 's':
-          qh_option ("Tstatistics", NULL, NULL);
-	  qh PRINTstatistics= True;
-	  break;
-	case 'v':
-          qh_option ("Tverify", NULL, NULL);
-	  qh VERIFYoutput= True;
-	  break;
-	case 'z':
-	  if (!qh fout)
-	    fprintf (qh ferr, "qhull warning: output file undefined (stdout).  Option 'Tz' ignored.\n");
-	  else {
-	    qh_option ("Tz-stdout", NULL, NULL);
-  	    qh ferr= qh fout;
-  	    qhmem.ferr= qh fout;
-	  }
-	  break;
-	case 'C':
-	  if (!isdigit(*s))
-	    fprintf (qh ferr, "qhull warning: missing point id for cone for trace option 'TCn'.  Ignored\n");
-	  else {
-	    i= qh_strtol (s, &s);
-	    qh_option ("TCone-stop", &i, NULL);
-	    qh STOPcone= i + 1;
+        if (isdigit(*s) || *s == '-')
+          qh IStracing= qh_strtol(s, &s);
+        else switch (*s++) {
+        case 'a':
+          qh_option("Tannotate-output", NULL, NULL);
+          qh ANNOTATEoutput= True;
+          break;
+        case 'c':
+          qh_option("Tcheck-frequently", NULL, NULL);
+          qh CHECKfrequently= True;
+          break;
+        case 's':
+          qh_option("Tstatistics", NULL, NULL);
+          qh PRINTstatistics= True;
+          break;
+        case 'v':
+          qh_option("Tverify", NULL, NULL);
+          qh VERIFYoutput= True;
+          break;
+        case 'z':
+          if (qh ferr == qh_FILEstderr) {
+            /* The C++ interface captures the output in qh_fprint_qhull() */
+            qh_option("Tz-stdout", NULL, NULL);
+            qh USEstdout= True;
+          }else if (!qh fout)
+            qh_fprintf(qh ferr, 7024, "qhull warning: output file undefined(stdout).  Option 'Tz' ignored.\n");
+          else {
+            qh_option("Tz-stdout", NULL, NULL);
+            qh USEstdout= True;
+            qh ferr= qh fout;
+            qhmem.ferr= qh fout;
           }
-	  break;
-	case 'F':
-	  if (!isdigit(*s))
-	    fprintf (qh ferr, "qhull warning: missing frequency count for trace option 'TFn'.  Ignored\n");
-	  else {
-	    qh REPORTfreq= qh_strtol (s, &s);
-            qh_option ("TFacet-log", &qh REPORTfreq, NULL);
-	    qh REPORTfreq2= qh REPORTfreq/2;  /* for tracemerging() */
-	  }
-	  break;
-	case 'I':
-	  if (s[0] != ' ' || s[1] == '\"' || s[1] == '\'' ||isspace (s[1])) {
-	    s++;
-	    fprintf (qh ferr, "qhull warning: option 'TI' mistyped.\nUse 'TI', one space, file name, and space or end-of-line.\nDo not use quotes.  Option 'FI' ignored.\n");
-	  }else {  /* not a procedure because of qh_option (filename, NULL, NULL); */
-	    char filename[500], *t= filename;
+          break;
+        case 'C':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 7025, "qhull warning: missing point id for cone for trace option 'TCn'.  Ignored\n");
+          else {
+            i= qh_strtol(s, &s);
+            qh_option("TCone-stop", &i, NULL);
+            qh STOPcone= i + 1;
+          }
+          break;
+        case 'F':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 7026, "qhull warning: missing frequency count for trace option 'TFn'.  Ignored\n");
+          else {
+            qh REPORTfreq= qh_strtol(s, &s);
+            qh_option("TFacet-log", &qh REPORTfreq, NULL);
+            qh REPORTfreq2= qh REPORTfreq/2;  /* for tracemerging() */
+          }
+          break;
+        case 'I':
+          if (!isspace(*s))
+            qh_fprintf(qh ferr, 7027, "qhull warning: missing space between 'TI' and filename, %s\n", s);
+          while (isspace(*s))
+            s++;
+          t= qh_skipfilename(s);
+          {
+            char filename[qh_FILENAMElen];
 
-	    s++;
-	    while (*s) {
-	      if (t - filename >= sizeof (filename)-2) {
-		fprintf (qh ferr, "qhull error: filename for 'TI' too long.\n");
-		qh_errexit (qh_ERRinput, NULL, NULL);
-	      }
-	      if (isspace (*s))
-		break;
-	      *(t++)= *s++;
-	    }
-	    *t= '\0';
-	    if (!freopen (filename, "r", stdin)) {
-	      fprintf (qh ferr, "qhull error: could not open file \"%s\".", filename);
-	      qh_errexit (qh_ERRinput, NULL, NULL);
-	    }else {
-	      qh_option ("TInput-file", NULL, NULL);
-	      qh_option (filename, NULL, NULL);
-	    }
-	  }
-	  break;
-	case 'O':
-	  if (s[0] != ' ' || s[1] == '\"' || isspace (s[1])) {
-	    s++;
-	    fprintf (qh ferr, "qhull warning: option 'TO' mistyped.\nUse 'TO', one space, file name, and space or end-of-line.\nThe file name may be enclosed in single quotes.\nDo not use double quotes.  Option 'FO' ignored.\n");
-	  }else {  /* not a procedure because of qh_option (filename, NULL, NULL); */
-	    char filename[500], *t= filename;
-	    boolT isquote= False;
+            qh_copyfilename(filename, (int)sizeof(filename), s, (int)(t-s));   /* WARN64 */
+            s= t;
+            if (!freopen(filename, "r", stdin)) {
+              qh_fprintf(qh ferr, 6041, "qhull error: could not open file \"%s\".", filename);
+              qh_errexit(qh_ERRinput, NULL, NULL);
+            }else {
+              qh_option("TInput-file", NULL, NULL);
+              qh_option(filename, NULL, NULL);
+            }
+          }
+          break;
+        case 'O':
+            if (!isspace(*s))
+                qh_fprintf(qh ferr, 7028, "qhull warning: missing space between 'TO' and filename, %s\n", s);
+            while (isspace(*s))
+                s++;
+            t= qh_skipfilename(s);
+            {
+              char filename[qh_FILENAMElen];
 
-	    s++;
-	    if (*s == '\'') {
-	      isquote= True;
-	      s++;
-	    }
-	    while (*s) {
-	      if (t - filename >= sizeof (filename)-2) {
-		fprintf (qh ferr, "qhull error: filename for 'TO' too long.\n");
-		qh_errexit (qh_ERRinput, NULL, NULL);
-	      }
-	      if (isquote) {
-		if (*s == '\'') {
-		  s++;
-		  isquote= False;
-		  break;
-		}
-	      }else if (isspace (*s))
-		break;
-	      *(t++)= *s++;
-	    }
-	    *t= '\0';
-	    if (isquote)
-	      fprintf (qh ferr, "qhull error: missing end quote for option 'TO'.  Rest of line ignored.\n");
-	    else if (!freopen (filename, "w", stdout)) {
-	      fprintf (qh ferr, "qhull error: could not open file \"%s\".", filename);
-	      qh_errexit (qh_ERRinput, NULL, NULL);
-	    }else {
-	      qh_option ("TOutput-file", NULL, NULL);
-	      qh_option (filename, NULL, NULL);
-	    }
-	  }
-	  break;
-	case 'P':
-	  if (!isdigit(*s))
-	    fprintf (qh ferr, "qhull warning: missing point id for trace option 'TPn'.  Ignored\n");
-	  else {
-	    qh TRACEpoint= qh_strtol (s, &s);
-            qh_option ("Trace-point", &qh TRACEpoint, NULL);
+              qh_copyfilename(filename, (int)sizeof(filename), s, (int)(t-s));  /* WARN64 */
+              s= t;
+              if (!freopen(filename, "w", stdout)) {
+                qh_fprintf(qh ferr, 6044, "qhull error: could not open file \"%s\".", filename);
+                qh_errexit(qh_ERRinput, NULL, NULL);
+              }else {
+                qh_option("TOutput-file", NULL, NULL);
+              qh_option(filename, NULL, NULL);
+            }
           }
-	  break;
-	case 'M':
-	  if (!isdigit(*s))
-	    fprintf (qh ferr, "qhull warning: missing merge id for trace option 'TMn'.  Ignored\n");
-	  else {
-	    qh TRACEmerge= qh_strtol (s, &s);
-            qh_option ("Trace-merge", &qh TRACEmerge, NULL);
+          break;
+        case 'P':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 7029, "qhull warning: missing point id for trace option 'TPn'.  Ignored\n");
+          else {
+            qh TRACEpoint= qh_strtol(s, &s);
+            qh_option("Trace-point", &qh TRACEpoint, NULL);
           }
-	  break;
-	case 'R':
-	  if (!isdigit(*s))
-	    fprintf (qh ferr, "qhull warning: missing rerun count for trace option 'TRn'.  Ignored\n");
-	  else {
-	    qh RERUN= qh_strtol (s, &s);
-            qh_option ("TRerun", &qh RERUN, NULL);
+          break;
+        case 'M':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 7030, "qhull warning: missing merge id for trace option 'TMn'.  Ignored\n");
+          else {
+            qh TRACEmerge= qh_strtol(s, &s);
+            qh_option("Trace-merge", &qh TRACEmerge, NULL);
           }
-	  break;
-	case 'V':
-	  i= qh_strtol (s, &t);
-	  if (s == t)
-	    fprintf (qh ferr, "qhull warning: missing furthest point id for trace option 'TVn'.  Ignored\n");
-	  else if (i < 0) {
-	    qh STOPpoint= i - 1;
-            qh_option ("TV-stop-before-point", &i, NULL);
-	  }else {
-	    qh STOPpoint= i + 1;
-            qh_option ("TV-stop-after-point", &i, NULL);
+          break;
+        case 'R':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 7031, "qhull warning: missing rerun count for trace option 'TRn'.  Ignored\n");
+          else {
+            qh RERUN= qh_strtol(s, &s);
+            qh_option("TRerun", &qh RERUN, NULL);
           }
+          break;
+        case 'V':
+          i= qh_strtol(s, &t);
+          if (s == t)
+            qh_fprintf(qh ferr, 7032, "qhull warning: missing furthest point id for trace option 'TVn'.  Ignored\n");
+          else if (i < 0) {
+            qh STOPpoint= i - 1;
+            qh_option("TV-stop-before-point", &i, NULL);
+          }else {
+            qh STOPpoint= i + 1;
+            qh_option("TV-stop-after-point", &i, NULL);
+          }
           s= t;
-	  break;
-	case 'W':
-	  if (!isdigit(*s))
-	    fprintf (qh ferr, "qhull warning: missing max width for trace option 'TWn'.  Ignored\n");
-	  else {
- 	    qh TRACEdist= (realT) qh_strtod (s, &s);
-            qh_option ("TWide-trace", NULL, &qh TRACEdist);
+          break;
+        case 'W':
+          if (!isdigit(*s))
+            qh_fprintf(qh ferr, 7033, "qhull warning: missing max width for trace option 'TWn'.  Ignored\n");
+          else {
+            qh TRACEdist= (realT) qh_strtod(s, &s);
+            qh_option("TWide-trace", NULL, &qh TRACEdist);
           }
-	  break;
-	default:
-	  s--;
-	  fprintf (qh ferr, "qhull warning: unknown 'T' trace option %c, rest ignored\n", (int)s[0]);
-	  while (*++s && !isspace(*s));
-	  break;
-	}
+          break;
+        default:
+          s--;
+          qh_fprintf(qh ferr, 7034, "qhull warning: unknown 'T' trace option %c, rest ignored\n", (int)s[0]);
+          while (*++s && !isspace(*s));
+          break;
+        }
       }
       break;
     default:
-      fprintf (qh ferr, "qhull warning: unknown flag %c (%x)\n", (int)s[-1],
-	       (int)s[-1]);
+      qh_fprintf(qh ferr, 7035, "qhull warning: unknown flag %c(%x)\n", (int)s[-1],
+               (int)s[-1]);
       break;
     }
     if (s-1 == prev_s && *s && !isspace(*s)) {
-      fprintf (qh ferr, "qhull warning: missing space after flag %c (%x); reserved for menu. Skipped.\n",
-	       (int)*prev_s, (int)*prev_s);
+      qh_fprintf(qh ferr, 7036, "qhull warning: missing space after flag %c(%x); reserved for menu. Skipped.\n",
+               (int)*prev_s, (int)*prev_s);
       while (*s && !isspace(*s))
-	s++;
+        s++;
     }
   }
+  if (qh STOPcone && qh JOGGLEmax < REALmax/2)
+    qh_fprintf(qh ferr, 7078, "qhull warning: 'TCn' (stopCone) ignored when used with 'QJn' (joggle)\n");
   if (isgeom && !qh FORCEoutput && qh PRINTout[1])
-    fprintf (qh ferr, "qhull warning: additional output formats are not compatible with Geomview\n");
+    qh_fprintf(qh ferr, 7037, "qhull warning: additional output formats are not compatible with Geomview\n");
   /* set derived values in qh_initqhull_globals */
 } /* initflags */
 
@@ -1368,21 +1422,21 @@
   notes:
     must match qh_freebuffers()
 */
-void qh_initqhull_buffers (void) {
+void qh_initqhull_buffers(void) {
   int k;
 
-  qh TEMPsize= (qhmem.LASTsize - sizeof (setT))/SETelemsize;
+  qh TEMPsize= (qhmem.LASTsize - sizeof(setT))/SETelemsize;
   if (qh TEMPsize <= 0 || qh TEMPsize > qhmem.LASTsize)
     qh TEMPsize= 8;  /* e.g., if qh_NOmem */
-  qh other_points= qh_setnew (qh TEMPsize);
-  qh del_vertices= qh_setnew (qh TEMPsize);
-  qh coplanarset= qh_setnew (qh TEMPsize);
+  qh other_points= qh_setnew(qh TEMPsize);
+  qh del_vertices= qh_setnew(qh TEMPsize);
+  qh coplanarfacetset= qh_setnew(qh TEMPsize);
   qh NEARzero= (realT *)qh_memalloc(qh hull_dim * sizeof(realT));
   qh lower_threshold= (realT *)qh_memalloc((qh input_dim+1) * sizeof(realT));
   qh upper_threshold= (realT *)qh_memalloc((qh input_dim+1) * sizeof(realT));
   qh lower_bound= (realT *)qh_memalloc((qh input_dim+1) * sizeof(realT));
   qh upper_bound= (realT *)qh_memalloc((qh input_dim+1) * sizeof(realT));
-  for(k= qh input_dim+1; k--; ) {
+  for (k=qh input_dim+1; k--; ) {  /* duplicated in qh_initqhull_buffers and qh_clear_ouputflags */
     qh lower_threshold[k]= -REALmax;
     qh upper_threshold[k]= REALmax;
     qh lower_bound[k]= -REALmax;
@@ -1417,21 +1471,19 @@
     initialize points array from input arguments
     test for qh.ZEROcentrum
       (i.e., use opposite vertex instead of cetrum for convexity testing)
-    test for qh.PRINTgood (i.e., only print 'good' facets)
     initialize qh.CENTERtype, qh.normal_size,
       qh.center_size, qh.TRACEpoint/level,
     initialize and test random numbers
-    check for conflicting print output options
+    qh_initqhull_outputflags() -- adjust and test output flags
 */
-void qh_initqhull_globals (coordT *points, int numpoints, int dim, boolT ismalloc) {
+void qh_initqhull_globals(coordT *points, int numpoints, int dim, boolT ismalloc) {
   int seed, pointsneeded, extra= 0, i, randi, k;
-  boolT printgeom= False, printmath= False, printcoplanar= False;
   realT randr;
   realT factorial;
 
   time_t timedata;
 
-  trace0((qh ferr, "qh_initqhull_globals: for %s | %s\n", qh rbox_command,
+  trace0((qh ferr, 13, "qh_initqhull_globals: for %s | %s\n", qh rbox_command,
       qh qhull_command));
   qh POINTSmalloc= ismalloc;
   qh first_point= points;
@@ -1441,12 +1493,12 @@
     qh MERGING= True;
     if (qh hull_dim <= 4) {
       qh PREmerge= True;
-      qh_option ("_pre-merge", NULL, NULL);
+      qh_option("_pre-merge", NULL, NULL);
     }else {
       qh MERGEexact= True;
-      qh_option ("Qxact_merge", NULL, NULL);
+      qh_option("Qxact_merge", NULL, NULL);
     }
-  }else if (qh MERGEexact) 
+  }else if (qh MERGEexact)
     qh MERGING= True;
   if (!qh NOpremerge && qh JOGGLEmax > REALmax/2) {
 #ifdef qh_NOmerge
@@ -1454,91 +1506,85 @@
 #endif
   }
   if (qh TRIangulate && qh JOGGLEmax < REALmax/2 && qh PRINTprecision)
-    fprintf(qh ferr, "qhull warning: joggle ('QJ') always produces simplicial output.  Triangulated output ('Qt') does nothing.\n");
+    qh_fprintf(qh ferr, 7038, "qhull warning: joggle('QJ') always produces simplicial output.  Triangulated output('Qt') does nothing.\n");
   if (qh JOGGLEmax < REALmax/2 && qh DELAUNAY && !qh SCALEinput && !qh SCALElast) {
     qh SCALElast= True;
-    qh_option ("Qbbound-last-qj", NULL, NULL);
+    qh_option("Qbbound-last-qj", NULL, NULL);
   }
   if (qh MERGING && !qh POSTmerge && qh premerge_cos > REALmax/2
   && qh premerge_centrum == 0) {
     qh ZEROcentrum= True;
     qh ZEROall_ok= True;
-    qh_option ("_zero-centrum", NULL, NULL);
+    qh_option("_zero-centrum", NULL, NULL);
   }
   if (qh JOGGLEmax < REALmax/2 && REALepsilon > 2e-8 && qh PRINTprecision)
-    fprintf(qh ferr, "qhull warning: real epsilon, %2.2g, is probably too large for joggle ('QJn')\nRecompile with double precision reals (see user.h).\n",
+    qh_fprintf(qh ferr, 7039, "qhull warning: real epsilon, %2.2g, is probably too large for joggle('QJn')\nRecompile with double precision reals(see user.h).\n",
           REALepsilon);
 #ifdef qh_NOmerge
   if (qh MERGING) {
-    fprintf (qh ferr, "qhull input error: merging not installed (qh_NOmerge + 'Qx', 'Cn' or 'An')\n");
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_fprintf(qh ferr, 6045, "qhull input error: merging not installed(qh_NOmerge + 'Qx', 'Cn' or 'An')\n");
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
 #endif
-  if (!(qh PRINTgood || qh PRINTneighbors)) {
-    if (qh KEEParea || qh KEEPminArea < REALmax/2 || qh KEEPmerge || qh DELAUNAY
-	|| (!qh ONLYgood && (qh GOODvertex || qh GOODpoint))) {
-      qh PRINTgood= True;
-      qh_option ("Pgood", NULL, NULL);
-    }
-  }
   if (qh DELAUNAY && qh KEEPcoplanar && !qh KEEPinside) {
     qh KEEPinside= True;
-    qh_option ("Qinterior-keep", NULL, NULL);
+    qh_option("Qinterior-keep", NULL, NULL);
   }
   if (qh DELAUNAY && qh HALFspace) {
-    fprintf (qh ferr, "qhull input error: can not use Delaunay ('d') or Voronoi ('v') with halfspace intersection ('H')\n");
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_fprintf(qh ferr, 6046, "qhull input error: can not use Delaunay('d') or Voronoi('v') with halfspace intersection('H')\n");
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
   if (!qh DELAUNAY && (qh UPPERdelaunay || qh ATinfinity)) {
-    fprintf (qh ferr, "qhull input error: use upper-Delaunay ('Qu') or infinity-point ('Qz') with Delaunay ('d') or Voronoi ('v')\n");
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_fprintf(qh ferr, 6047, "qhull input error: use upper-Delaunay('Qu') or infinity-point('Qz') with Delaunay('d') or Voronoi('v')\n");
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
   if (qh UPPERdelaunay && qh ATinfinity) {
-    fprintf (qh ferr, "qhull input error: can not use infinity-point ('Qz') with upper-Delaunay ('Qu')\n");
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_fprintf(qh ferr, 6048, "qhull input error: can not use infinity-point('Qz') with upper-Delaunay('Qu')\n");
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
   if (qh SCALElast && !qh DELAUNAY && qh PRINTprecision)
-    fprintf (qh ferr, "qhull input warning: option 'Qbb' (scale-last-coordinate) is normally used with 'd' or 'v'\n");
+    qh_fprintf(qh ferr, 7040, "qhull input warning: option 'Qbb' (scale-last-coordinate) is normally used with 'd' or 'v'\n");
   qh DOcheckmax= (!qh SKIPcheckmax && qh MERGING );
-  qh KEEPnearinside= (qh DOcheckmax && !(qh KEEPinside && qh KEEPcoplanar) 
+  qh KEEPnearinside= (qh DOcheckmax && !(qh KEEPinside && qh KEEPcoplanar)
                           && !qh NOnearinside);
   if (qh MERGING)
     qh CENTERtype= qh_AScentrum;
   else if (qh VORONOI)
     qh CENTERtype= qh_ASvoronoi;
   if (qh TESTvneighbors && !qh MERGING) {
-    fprintf(qh ferr, "qhull input error: test vertex neighbors ('Qv') needs a merge option\n");
-    qh_errexit (qh_ERRinput, NULL ,NULL);
+    qh_fprintf(qh ferr, 6049, "qhull input error: test vertex neighbors('Qv') needs a merge option\n");
+    qh_errexit(qh_ERRinput, NULL ,NULL);
   }
   if (qh PROJECTinput || (qh DELAUNAY && qh PROJECTdelaunay)) {
     qh hull_dim -= qh PROJECTinput;
     if (qh DELAUNAY) {
       qh hull_dim++;
-      extra= 1;
+      if (qh ATinfinity)
+        extra= 1;
     }
   }
   if (qh hull_dim <= 1) {
-    fprintf(qh ferr, "qhull error: dimension %d must be > 1\n", qh hull_dim);
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_fprintf(qh ferr, 6050, "qhull error: dimension %d must be > 1\n", qh hull_dim);
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
-  for (k= 2, factorial=1.0; k < qh hull_dim; k++)
+  for (k=2, factorial=1.0; k < qh hull_dim; k++)
     factorial *= k;
   qh AREAfactor= 1.0 / factorial;
-  trace2((qh ferr, "qh_initqhull_globals: initialize globals.  dim %d numpoints %d malloc? %d projected %d to hull_dim %d\n",
-	dim, numpoints, ismalloc, qh PROJECTinput, qh hull_dim));
+  trace2((qh ferr, 2005, "qh_initqhull_globals: initialize globals.  dim %d numpoints %d malloc? %d projected %d to hull_dim %d\n",
+        dim, numpoints, ismalloc, qh PROJECTinput, qh hull_dim));
   qh normal_size= qh hull_dim * sizeof(coordT);
   qh center_size= qh normal_size - sizeof(coordT);
   pointsneeded= qh hull_dim+1;
   if (qh hull_dim > qh_DIMmergeVertex) {
     qh MERGEvertices= False;
-    qh_option ("Q3-no-merge-vertices-dim-high", NULL, NULL);
+    qh_option("Q3-no-merge-vertices-dim-high", NULL, NULL);
   }
   if (qh GOODpoint)
     pointsneeded++;
 #ifdef qh_NOtrace
   if (qh IStracing) {
-    fprintf (qh ferr, "qhull input error: tracing is not installed (qh_NOtrace in user.h)");
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_fprintf(qh ferr, 6051, "qhull input error: tracing is not installed(qh_NOtrace in user.h)");
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
 #endif
   if (qh RERUN > 1) {
@@ -1550,12 +1596,12 @@
     qh IStracing= 0;
   }
   if (qh ROTATErandom == 0 || qh ROTATErandom == -1) {
-    seed= time (&timedata);
+    seed= (int)time(&timedata);
     if (qh ROTATErandom  == -1) {
       seed= -seed;
-      qh_option ("QRandom-seed", &seed, NULL );
+      qh_option("QRandom-seed", &seed, NULL );
     }else
-      qh_option ("QRotate-random", &seed, NULL);
+      qh_option("QRotate-random", &seed, NULL);
     qh ROTATErandom= seed;
   }
   seed= qh ROTATErandom;
@@ -1565,47 +1611,118 @@
     seed= -seed;
   qh_RANDOMseed_(seed);
   randr= 0.0;
-  for (i= 1000; i--; ) {
+  for (i=1000; i--; ) {
     randi= qh_RANDOMint;
     randr += randi;
     if (randi > qh_RANDOMmax) {
-      fprintf (qh ferr, "\
+      qh_fprintf(qh ferr, 8036, "\
 qhull configuration error (qh_RANDOMmax in user.h):\n\
-   random integer %d > qh_RANDOMmax (%.8g)\n",
-	       randi, qh_RANDOMmax);
-      qh_errexit (qh_ERRinput, NULL, NULL);
+   random integer %d > qh_RANDOMmax(%.8g)\n",
+               randi, qh_RANDOMmax);
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
   }
   qh_RANDOMseed_(seed);
   randr = randr/1000;
-  if (randr < qh_RANDOMmax/10
-  || randr > qh_RANDOMmax * 5)
-    fprintf (qh ferr, "\
+  if (randr < qh_RANDOMmax * 0.1
+  || randr > qh_RANDOMmax * 0.9)
+    qh_fprintf(qh ferr, 8037, "\
 qhull configuration warning (qh_RANDOMmax in user.h):\n\
    average of 1000 random integers (%.2g) is much different than expected (%.2g).\n\
    Is qh_RANDOMmax (%.2g) wrong?\n",
-	     randr, qh_RANDOMmax/2.0, qh_RANDOMmax);
+             randr, qh_RANDOMmax * 0.5, qh_RANDOMmax);
   qh RANDOMa= 2.0 * qh RANDOMfactor/qh_RANDOMmax;
   qh RANDOMb= 1.0 - qh RANDOMfactor;
   if (qh_HASHfactor < 1.1) {
-    fprintf(qh ferr, "qhull internal error (qh_initqhull_globals): qh_HASHfactor %d must be at least 1.1.  Qhull uses linear hash probing\n",
+    qh_fprintf(qh ferr, 6052, "qhull internal error (qh_initqhull_globals): qh_HASHfactor %d must be at least 1.1.  Qhull uses linear hash probing\n",
       qh_HASHfactor);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   if (numpoints+extra < pointsneeded) {
-    fprintf(qh ferr,"qhull input error: not enough points (%d) to construct initial simplex (need %d)\n",
-	    numpoints, pointsneeded);
+    qh_fprintf(qh ferr, 6214, "qhull input error: not enough points(%d) to construct initial simplex(need %d)\n",
+            numpoints, pointsneeded);
     qh_errexit(qh_ERRinput, NULL, NULL);
   }
+  qh_initqhull_outputflags();
+} /* initqhull_globals */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >-------------------------------</a><a name="initqhull_mem">-</a>
+
+  qh_initqhull_mem(  )
+    initialize mem.c for qhull
+    qh.hull_dim and qh.normal_size determine some of the allocation sizes
+    if qh.MERGING,
+      includes ridgeT
+    calls qh_user_memsizes() to add up to 10 additional sizes for quick allocation
+      (see numsizes below)
+
+  returns:
+    mem.c already for qh_memalloc/qh_memfree (errors if called beforehand)
+
+  notes:
+    qh_produceoutput() prints memsizes
+
+*/
+void qh_initqhull_mem(void) {
+  int numsizes;
+  int i;
+
+  numsizes= 8+10;
+  qh_meminitbuffers(qh IStracing, qh_MEMalign, numsizes,
+                     qh_MEMbufsize,qh_MEMinitbuf);
+  qh_memsize((int)sizeof(vertexT));
+  if (qh MERGING) {
+    qh_memsize((int)sizeof(ridgeT));
+    qh_memsize((int)sizeof(mergeT));
+  }
+  qh_memsize((int)sizeof(facetT));
+  i= sizeof(setT) + (qh hull_dim - 1) * SETelemsize;  /* ridge.vertices */
+  qh_memsize(i);
+  qh_memsize(qh normal_size);        /* normal */
+  i += SETelemsize;                 /* facet.vertices, .ridges, .neighbors */
+  qh_memsize(i);
+  qh_user_memsizes();
+  qh_memsetup();
+} /* initqhull_mem */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >-------------------------------</a><a name="initqhull_outputflags">-</a>
+
+  qh_initqhull_outputflags
+    initialize flags concerned with output
+
+  returns:
+    adjust user flags as needed
+
+  see:
+    qh_clear_outputflags() resets the flags
+
+  design:
+    test for qh.PRINTgood (i.e., only print 'good' facets)
+    check for conflicting print output options
+*/
+void qh_initqhull_outputflags(void) {
+  boolT printgeom= False, printmath= False, printcoplanar= False;
+  int i;
+
+  trace3((qh ferr, 3024, "qh_initqhull_outputflags: %s\n", qh qhull_command));
+  if (!(qh PRINTgood || qh PRINTneighbors)) {
+    if (qh KEEParea || qh KEEPminArea < REALmax/2 || qh KEEPmerge || qh DELAUNAY
+        || (!qh ONLYgood && (qh GOODvertex || qh GOODpoint))) {
+      qh PRINTgood= True;
+      qh_option("Pgood", NULL, NULL);
+    }
+  }
   if (qh PRINTtransparent) {
     if (qh hull_dim != 4 || !qh DELAUNAY || qh VORONOI || qh DROPdim >= 0) {
-      fprintf(qh ferr,"qhull input error: transparent Delaunay ('Gt') needs 3-d Delaunay ('d') w/o 'GDn'\n");
+      qh_fprintf(qh ferr, 6215, "qhull input error: transparent Delaunay('Gt') needs 3-d Delaunay('d') w/o 'GDn'\n");
       qh_errexit(qh_ERRinput, NULL, NULL);
     }
     qh DROPdim = 3;
     qh PRINTridges = True;
   }
-  for (i= qh_PRINTEND; i--; ) {
+  for (i=qh_PRINTEND; i--; ) {
     if (qh PRINTout[i] == qh_PRINTgeom)
       printgeom= True;
     else if (qh PRINTout[i] == qh_PRINTmathematica || qh PRINTout[i] == qh_PRINTmaple)
@@ -1615,135 +1732,120 @@
     else if (qh PRINTout[i] == qh_PRINTpointnearest)
       printcoplanar= True;
     else if (qh PRINTout[i] == qh_PRINTpointintersect && !qh HALFspace) {
-      fprintf (qh ferr, "qhull input error: option 'Fp' is only used for \nhalfspace intersection ('Hn,n,n').\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6053, "qhull input error: option 'Fp' is only used for \nhalfspace intersection('Hn,n,n').\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }else if (qh PRINTout[i] == qh_PRINTtriangles && (qh HALFspace || qh VORONOI)) {
-      fprintf (qh ferr, "qhull input error: option 'Ft' is not available for Voronoi vertices or halfspace intersection\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6054, "qhull input error: option 'Ft' is not available for Voronoi vertices or halfspace intersection\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }else if (qh PRINTout[i] == qh_PRINTcentrums && qh VORONOI) {
-      fprintf (qh ferr, "qhull input error: option 'FC' is not available for Voronoi vertices ('v')\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6055, "qhull input error: option 'FC' is not available for Voronoi vertices('v')\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }else if (qh PRINTout[i] == qh_PRINTvertices) {
       if (qh VORONOI)
-        qh_option ("Fvoronoi", NULL, NULL);
-      else 
-        qh_option ("Fvertices", NULL, NULL);
+        qh_option("Fvoronoi", NULL, NULL);
+      else
+        qh_option("Fvertices", NULL, NULL);
     }
   }
   if (printcoplanar && qh DELAUNAY && qh JOGGLEmax < REALmax/2) {
-    if (qh PRINTprecision) 
-      fprintf (qh ferr, "qhull input warning: 'QJ' (joggle) will usually prevent coincident input sites for options 'Fc' and 'FP'\n");
+    if (qh PRINTprecision)
+      qh_fprintf(qh ferr, 7041, "qhull input warning: 'QJ' (joggle) will usually prevent coincident input sites for options 'Fc' and 'FP'\n");
   }
-  if (!qh KEEPcoplanar && !qh KEEPinside && !qh ONLYgood) {
-    if ((qh PRINTcoplanar && qh PRINTspheres) || printcoplanar) {
-      qh KEEPcoplanar = True;
-      qh_option ("Qcoplanar", NULL, NULL);
-    }
-  }
   if (printmath && (qh hull_dim > 3 || qh VORONOI)) {
-    fprintf (qh ferr, "qhull input error: Mathematica and Maple output is only available for 2-d and 3-d convex hulls and 2-d Delaunay triangulations\n");
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_fprintf(qh ferr, 6056, "qhull input error: Mathematica and Maple output is only available for 2-d and 3-d convex hulls and 2-d Delaunay triangulations\n");
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
   if (printgeom) {
     if (qh hull_dim > 4) {
-      fprintf (qh ferr, "qhull input error: Geomview output is only available for 2-d, 3-d and 4-d\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6057, "qhull input error: Geomview output is only available for 2-d, 3-d and 4-d\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
     if (qh PRINTnoplanes && !(qh PRINTcoplanar + qh PRINTcentrums
      + qh PRINTdots + qh PRINTspheres + qh DOintersections + qh PRINTridges)) {
-      fprintf (qh ferr, "qhull input error: no output specified for Geomview\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6058, "qhull input error: no output specified for Geomview\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
     if (qh VORONOI && (qh hull_dim > 3 || qh DROPdim >= 0)) {
-      fprintf (qh ferr, "qhull input error: Geomview output for Voronoi diagrams only for 2-d\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6059, "qhull input error: Geomview output for Voronoi diagrams only for 2-d\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
     /* can not warn about furthest-site Geomview output: no lower_threshold */
     if (qh hull_dim == 4 && qh DROPdim == -1 &&
-	(qh PRINTcoplanar || qh PRINTspheres || qh PRINTcentrums)) {
-      fprintf (qh ferr, "qhull input warning: coplanars, vertices, and centrums output not\n\
-available for 4-d output (ignored).  Could use 'GDn' instead.\n");
+        (qh PRINTcoplanar || qh PRINTspheres || qh PRINTcentrums)) {
+      qh_fprintf(qh ferr, 7042, "qhull input warning: coplanars, vertices, and centrums output not\n\
+available for 4-d output(ignored).  Could use 'GDn' instead.\n");
       qh PRINTcoplanar= qh PRINTspheres= qh PRINTcentrums= False;
     }
   }
+  if (!qh KEEPcoplanar && !qh KEEPinside && !qh ONLYgood) {
+    if ((qh PRINTcoplanar && qh PRINTspheres) || printcoplanar) {
+      if (qh QHULLfinished) {
+        qh_fprintf(qh ferr, 7072, "qhull output warning: ignoring coplanar points, option 'Qc' was not set for the first run of qhull.\n");
+      }else {
+        qh KEEPcoplanar = True;
+        qh_option("Qcoplanar", NULL, NULL);
+      }
+    }
+  }
   qh PRINTdim= qh hull_dim;
   if (qh DROPdim >=0) {    /* after Geomview checks */
     if (qh DROPdim < qh hull_dim) {
       qh PRINTdim--;
       if (!printgeom || qh hull_dim < 3)
-        fprintf (qh ferr, "qhull input warning: drop dimension 'GD%d' is only available for 3-d/4-d Geomview\n", qh DROPdim);
+        qh_fprintf(qh ferr, 7043, "qhull input warning: drop dimension 'GD%d' is only available for 3-d/4-d Geomview\n", qh DROPdim);
     }else
       qh DROPdim= -1;
   }else if (qh VORONOI) {
     qh DROPdim= qh hull_dim-1;
     qh PRINTdim= qh hull_dim-1;
   }
-} /* initqhull_globals */
- 
+} /* qh_initqhull_outputflags */
+
 /*-<a                             href="qh-globa.htm#TOC"
-  >-------------------------------</a><a name="initqhull_mem">-</a>
+  >-------------------------------</a><a name="initqhull_start">-</a>
 
-  qh_initqhull_mem(  )
-    initialize mem.c for qhull
-    qh.hull_dim and qh.normal_size determine some of the allocation sizes
-    if qh.MERGING,
-      includes ridgeT
-    calls qh_user_memsizes() to add up to 10 additional sizes for quick allocation
-      (see numsizes below)
-
-  returns:
-    mem.c already for qh_memalloc/qh_memfree (errors if called beforehand)
-
-  notes:
-    qh_produceoutput() prints memsizes
-
+  qh_initqhull_start( infile, outfile, errfile )
+    allocate memory if needed and call qh_initqhull_start2()
 */
-void qh_initqhull_mem (void) {
-  int numsizes;
-  int i;
+void qh_initqhull_start(FILE *infile, FILE *outfile, FILE *errfile) {
 
-  numsizes= 8+10;
-  qh_meminitbuffers (qh IStracing, qh_MEMalign, numsizes,
-                     qh_MEMbufsize,qh_MEMinitbuf);
-  qh_memsize(sizeof(vertexT));
-  if (qh MERGING) {
-    qh_memsize(sizeof(ridgeT));
-    qh_memsize(sizeof(mergeT));
+#if qh_QHpointer
+  if (qh_qh) {
+    qh_fprintf(errfile, 6205, "qhull error (qh_initqhull_start): qh_qh already defined.  Call qh_save_qhull() first\n");
+    qh_exit(qh_ERRqhull);  /* no error handler */
   }
-  qh_memsize(sizeof(facetT));
-  i= sizeof(setT) + (qh hull_dim - 1) * SETelemsize;  /* ridge.vertices */
-  qh_memsize(i);
-  qh_memsize(qh normal_size);        /* normal */
-  i += SETelemsize;                 /* facet.vertices, .ridges, .neighbors */
-  qh_memsize(i);
-  qh_user_memsizes();
-  qh_memsetup();
-} /* initqhull_mem */
+  if (!(qh_qh= (qhT *)qh_malloc(sizeof(qhT)))) {
+    qh_fprintf(errfile, 6060, "qhull error (qh_initqhull_start): insufficient memory\n");
+    qh_exit(qh_ERRmem);  /* no error handler */
+  }
+#endif
+  qh_initstatistics();
+  qh_initqhull_start2(infile, outfile, errfile);
+} /* initqhull_start */
 
 /*-<a                             href="qh-globa.htm#TOC"
-  >-------------------------------</a><a name="initqhull_start">-</a>
+  >-------------------------------</a><a name="initqhull_start2">-</a>
 
-  qh_initqhull_start( infile, outfile, errfile )
+  qh_initqhull_start2( infile, outfile, errfile )
     start initialization of qhull
     initialize statistics, stdio, default values for global variables
-
+    assumes qh_qh is defined
+  notes:
+    report errors elsewhere, error handling and g_qhull_output [Qhull.cpp, QhullQh()] not in initialized
   see:
     qh_maxmin() determines the precision constants
+    qh_freeqhull2()
 */
-void qh_initqhull_start (FILE *infile, FILE *outfile, FILE *errfile) {
+void qh_initqhull_start2(FILE *infile, FILE *outfile, FILE *errfile) {
+  time_t timedata;
+  int seed;
 
-  qh_CPUclock; /* start the clock */
+  qh_CPUclock; /* start the clock(for qh_clock).  One-shot. */
 #if qh_QHpointer
-  if (!(qh_qh= (qhT *)malloc (sizeof(qhT)))) {
-    fprintf (errfile, "qhull error (qh_initqhull_globals): insufficient memory\n");
-    exit (qh_ERRmem);  /* no error handler */
-  }
   memset((char *)qh_qh, 0, sizeof(qhT));   /* every field is 0, FALSE, NULL */
 #else
   memset((char *)&qh_qh, 0, sizeof(qhT));
 #endif
-  strcat (qh qhull, "qhull");
-  qh_initstatistics();
   qh ANGLEmerge= True;
   qh DROPdim= -1;
   qh ferr= errfile;
@@ -1780,8 +1882,12 @@
   qh TRACEpoint= -1; /* recompile or use 'TPn' */
   qh tracefacet_id= UINT_MAX;  /* recompile to trace a facet */
   qh tracevertex_id= UINT_MAX; /* recompile to trace a vertex */
-  qh_RANDOMseed_(1);
-} /* initqhull_start */
+  seed= (int)time(&timedata);
+  qh_RANDOMseed_(seed);
+  qh run_id= qh_RANDOMint+1; /* disallow 0 [UsingLibQhull::NOqhRunId] */
+  qh_option("run-id", &qh run_id, NULL);
+  strcat(qh qhull, "qhull");
+} /* initqhull_start2 */
 
 /*-<a                             href="qh-globa.htm#TOC"
   >-------------------------------</a><a name="initthresholds">-</a>
@@ -1805,8 +1911,8 @@
 */
 void qh_initthresholds(char *command) {
   realT value;
-  int index, maxdim, k;
-  char *s= command;
+  int idx, maxdim, k;
+  char *s= command; /* non-const due to strtol */
   char key;
 
   maxdim= qh input_dim;
@@ -1818,78 +1924,78 @@
     if (*s == 'P') {
       s++;
       while (*s && !isspace(key= *s++)) {
-	if (key == 'd' || key == 'D') {
-	  if (!isdigit(*s)) {
-	    fprintf(qh ferr, "qhull warning: no dimension given for Print option '%c' at: %s.  Ignored\n",
-		    key, s-1);
-	    continue;
-	  }
-	  index= qh_strtol (s, &s);
-	  if (index >= qh hull_dim) {
-	    fprintf(qh ferr, "qhull warning: dimension %d for Print option '%c' is >= %d.  Ignored\n",
-	        index, key, qh hull_dim);
-	    continue;
-	  }
-	  if (*s == ':') {
-	    s++;
-	    value= qh_strtod(s, &s);
-	    if (fabs((double)value) > 1.0) {
-	      fprintf(qh ferr, "qhull warning: value %2.4g for Print option %c is > +1 or < -1.  Ignored\n",
-	              value, key);
-	      continue;
-	    }
-	  }else
-	    value= 0.0;
-	  if (key == 'd')
-	    qh lower_threshold[index]= value;
-	  else
-	    qh upper_threshold[index]= value;
-	}
+        if (key == 'd' || key == 'D') {
+          if (!isdigit(*s)) {
+            qh_fprintf(qh ferr, 7044, "qhull warning: no dimension given for Print option '%c' at: %s.  Ignored\n",
+                    key, s-1);
+            continue;
+          }
+          idx= qh_strtol(s, &s);
+          if (idx >= qh hull_dim) {
+            qh_fprintf(qh ferr, 7045, "qhull warning: dimension %d for Print option '%c' is >= %d.  Ignored\n",
+                idx, key, qh hull_dim);
+            continue;
+          }
+          if (*s == ':') {
+            s++;
+            value= qh_strtod(s, &s);
+            if (fabs((double)value) > 1.0) {
+              qh_fprintf(qh ferr, 7046, "qhull warning: value %2.4g for Print option %c is > +1 or < -1.  Ignored\n",
+                      value, key);
+              continue;
+            }
+          }else
+            value= 0.0;
+          if (key == 'd')
+            qh lower_threshold[idx]= value;
+          else
+            qh upper_threshold[idx]= value;
+        }
       }
     }else if (*s == 'Q') {
       s++;
       while (*s && !isspace(key= *s++)) {
-	if (key == 'b' && *s == 'B') {
-	  s++;
-	  for (k=maxdim; k--; ) {
-	    qh lower_bound[k]= -qh_DEFAULTbox;
-	    qh upper_bound[k]= qh_DEFAULTbox;
-	  }
-	}else if (key == 'b' && *s == 'b')
-	  s++;
-	else if (key == 'b' || key == 'B') {
-	  if (!isdigit(*s)) {
-	    fprintf(qh ferr, "qhull warning: no dimension given for Qhull option %c.  Ignored\n",
-		    key);
-	    continue;
-	  }
-	  index= qh_strtol (s, &s);
-	  if (index >= maxdim) {
-	    fprintf(qh ferr, "qhull warning: dimension %d for Qhull option %c is >= %d.  Ignored\n",
-	        index, key, maxdim);
-	    continue;
-	  }
-	  if (*s == ':') {
-	    s++;
-	    value= qh_strtod(s, &s);
-	  }else if (key == 'b')
-	    value= -qh_DEFAULTbox;
-	  else
-	    value= qh_DEFAULTbox;
-	  if (key == 'b')
-	    qh lower_bound[index]= value;
-	  else
-	    qh upper_bound[index]= value;
-	}
+        if (key == 'b' && *s == 'B') {
+          s++;
+          for (k=maxdim; k--; ) {
+            qh lower_bound[k]= -qh_DEFAULTbox;
+            qh upper_bound[k]= qh_DEFAULTbox;
+          }
+        }else if (key == 'b' && *s == 'b')
+          s++;
+        else if (key == 'b' || key == 'B') {
+          if (!isdigit(*s)) {
+            qh_fprintf(qh ferr, 7047, "qhull warning: no dimension given for Qhull option %c.  Ignored\n",
+                    key);
+            continue;
+          }
+          idx= qh_strtol(s, &s);
+          if (idx >= maxdim) {
+            qh_fprintf(qh ferr, 7048, "qhull warning: dimension %d for Qhull option %c is >= %d.  Ignored\n",
+                idx, key, maxdim);
+            continue;
+          }
+          if (*s == ':') {
+            s++;
+            value= qh_strtod(s, &s);
+          }else if (key == 'b')
+            value= -qh_DEFAULTbox;
+          else
+            value= qh_DEFAULTbox;
+          if (key == 'b')
+            qh lower_bound[idx]= value;
+          else
+            qh upper_bound[idx]= value;
+        }
       }
     }else {
-      while (*s && !isspace (*s))
+      while (*s && !isspace(*s))
         s++;
     }
-    while (isspace (*s))
+    while (isspace(*s))
       s++;
   }
-  for (k= qh hull_dim; k--; ) {
+  for (k=qh hull_dim; k--; ) {
     if (qh lower_threshold[k] > -REALmax/2) {
       qh GOODthreshold= True;
       if (qh upper_threshold[k] < REALmax/2) {
@@ -1909,27 +2015,28 @@
     add an option description to qh.qhull_options
 
   notes:
+    NOerrors -- qh_option can not call qh_errexit() [qh_initqhull_start2]
     will be printed with statistics ('Ts') and errors
     strlen(option) < 40
 */
-void qh_option (char *option, int *i, realT *r) {
+void qh_option(const char *option, int *i, realT *r) {
   char buf[200];
   int len, maxlen;
 
-  sprintf (buf, "  %s", option);
+  sprintf(buf, "  %s", option);
   if (i)
-    sprintf (buf+strlen(buf), " %d", *i);
+    sprintf(buf+strlen(buf), " %d", *i);
   if (r)
-    sprintf (buf+strlen(buf), " %2.2g", *r);
-  len= strlen(buf);
+    sprintf(buf+strlen(buf), " %2.2g", *r);
+  len= (int)strlen(buf);  /* WARN64 */
   qh qhull_optionlen += len;
-  maxlen= sizeof (qh qhull_options) - len -1;
+  maxlen= sizeof(qh qhull_options) - len -1;
   maximize_(maxlen, 0);
-  if (qh qhull_optionlen >= 80 && maxlen > 0) {
+  if (qh qhull_optionlen >= qh_OPTIONline && maxlen > 0) {
     qh qhull_optionlen= len;
-    strncat (qh qhull_options, "\n", maxlen--);
+    strncat(qh qhull_options, "\n", (size_t)(maxlen--));
   }
-  strncat (qh qhull_options, buf, maxlen);
+  strncat(qh qhull_options, buf, (size_t)maxlen);
 } /* option */
 
 #if qh_QHpointer
@@ -1939,7 +2046,7 @@
   qh_restore_qhull( oldqh )
     restores a previously saved qhull
     also restores qh_qhstat and qhmem.tempstack
-
+    Sets *oldqh to NULL
   notes:
     errors if current qhull hasn't been saved or freed
     uses qhmem for error reporting
@@ -1949,29 +2056,31 @@
     is complicated.  The procedures will be redesigned.
 
   see:
-    qh_save_qhull()
+    qh_save_qhull(), UsingLibQhull
 */
-void qh_restore_qhull (qhT **oldqh) {
+void qh_restore_qhull(qhT **oldqh) {
 
-  if (*oldqh && strcmp ((*oldqh)->qhull, "qhull")) {
-    fprintf (qhmem.ferr, "qhull internal error (qh_restore_qhull): %p is not a qhull data structure\n",
+  if (*oldqh && strcmp((*oldqh)->qhull, "qhull")) {
+    qh_fprintf(qhmem.ferr, 6061, "qhull internal error (qh_restore_qhull): %p is not a qhull data structure\n",
                   *oldqh);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   if (qh_qh) {
-    fprintf (qhmem.ferr, "qhull internal error (qh_restore_qhull): did not save or free existing qhull\n");
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_fprintf(qhmem.ferr, 6062, "qhull internal error (qh_restore_qhull): did not save or free existing qhull\n");
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   if (!*oldqh || !(*oldqh)->old_qhstat) {
-    fprintf (qhmem.ferr, "qhull internal error (qh_restore_qhull): did not previously save qhull %p\n",
+    qh_fprintf(qhmem.ferr, 6063, "qhull internal error (qh_restore_qhull): did not previously save qhull %p\n",
                   *oldqh);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   qh_qh= *oldqh;
   *oldqh= NULL;
   qh_qhstat= qh old_qhstat;
   qhmem.tempstack= qh old_tempstack;
-  trace1((qh ferr, "qh_restore_qhull: restored qhull from %p\n", *oldqh));
+  qh old_qhstat= 0;
+  qh old_tempstack= 0;
+  trace1((qh ferr, 1007, "qh_restore_qhull: restored qhull from %p\n", *oldqh));
 } /* restore_qhull */
 
 /*-<a                             href="qh-globa.htm#TOC"
@@ -1994,13 +2103,13 @@
   see:
     qh_restore_qhull()
 */
-qhT *qh_save_qhull (void) {
+qhT *qh_save_qhull(void) {
   qhT *oldqh;
 
-  trace1((qhmem.ferr, "qh_save_qhull: save qhull %p\n", qh_qh));
+  trace1((qhmem.ferr, 1045, "qh_save_qhull: save qhull %p\n", qh_qh));
   if (!qh_qh) {
-    fprintf (qhmem.ferr, "qhull internal error (qh_save_qhull): qhull not initialized\n");
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_fprintf(qhmem.ferr, 6064, "qhull internal error (qh_save_qhull): qhull not initialized\n");
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   qh old_qhstat= qh_qhstat;
   qh_qhstat= NULL;
@@ -2013,29 +2122,3 @@
 
 #endif
 
-/*-<a                             href="qh-globa.htm#TOC"
-  >-------------------------------</a><a name="strtol">-</a>
-
-  qh_strtol( s, endp) qh_strtod( s, endp)
-    internal versions of strtol() and strtod()
-    does not skip trailing spaces
-  notes:
-    some implementations of strtol()/strtod() skip trailing spaces
-*/
-double qh_strtod (const char *s, char **endp) {
-  double result;
-
-  result= strtod (s, endp);
-  if (s < (*endp) && (*endp)[-1] == ' ')
-    (*endp)--;
-  return result;
-} /* strtod */
-
-int qh_strtol (const char *s, char **endp) {
-  int result;
-
-  result= (int) strtol (s, endp, 10);
-  if (s< (*endp) && (*endp)[-1] == ' ')
-    (*endp)--;
-  return result;
-} /* strtol */

Modified: trunk/scipy/spatial/qhull/src/io.c
===================================================================
--- trunk/scipy/spatial/qhull/src/io.c	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/io.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,7 +1,7 @@
 /*<html><pre>  -<a                             href="qh-io.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-   io.c 
+   io.c
    Input/Output routines of qhull application
 
    see qh-io.htm and io.h
@@ -13,7 +13,9 @@
    unix.c and user.c are the only callers of io.c functions
    This allows the user to avoid loading io.o from qhull.a
 
-   copyright (c) 1993-2003 The Geometry Center        
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/io.c#38 $$Change: 1179 $
+   $DateTime: 2010/01/12 19:53:15 $$Author: bbarber $
 */
 
 #include "qhull_a.h"
@@ -22,9 +24,11 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="produce_output">-</a>
-  
+
   qh_produce_output()
+  qh_produce_output2()
     prints out the result of qhull in desired format
+    qh_produce_output2() does not call qh_prepare_output()
     if qh.GETarea
       computes and prints area and volume
     qh.PRINTout[] is an array of output formats
@@ -33,66 +37,63 @@
     prints output in qh.PRINTout order
 */
 void qh_produce_output(void) {
-  int i, tempsize= qh_setsize ((setT*)qhmem.tempstack), d_1;
+    int tempsize= qh_setsize(qhmem.tempstack);
 
-  if (qh VORONOI) {
-    qh_clearcenters (qh_ASvoronoi);
-    qh_vertexneighbors();
-  }
-  if (qh TRIangulate) {
-    qh_triangulate(); 
-    if (qh VERIFYoutput && !qh CHECKfrequently) 
-      qh_checkpolygon (qh facet_list);
-  }
-  qh_findgood_all (qh facet_list); 
-  if (qh GETarea)
-    qh_getarea(qh facet_list);
-  if (qh KEEParea || qh KEEPmerge || qh KEEPminArea < REALmax/2)
-    qh_markkeep (qh facet_list);
+    qh_prepare_output();
+    qh_produce_output2();
+    if (qh_setsize(qhmem.tempstack) != tempsize) {
+        qh_fprintf(qh ferr, 6206, "qhull internal error (qh_produce_output): temporary sets not empty(%d)\n",
+            qh_setsize(qhmem.tempstack));
+        qh_errexit(qh_ERRqhull, NULL, NULL);
+    }
+} /* produce_output */
+
+
+void qh_produce_output2(void) {
+  int i, tempsize= qh_setsize(qhmem.tempstack), d_1;
+
   if (qh PRINTsummary)
     qh_printsummary(qh ferr);
   else if (qh PRINTout[0] == qh_PRINTnone)
     qh_printsummary(qh fout);
-  for (i= 0; i < qh_PRINTEND; i++)
-    qh_printfacets (qh fout, qh PRINTout[i], qh facet_list, NULL, !qh_ALL);
+  for (i=0; i < qh_PRINTEND; i++)
+    qh_printfacets(qh fout, qh PRINTout[i], qh facet_list, NULL, !qh_ALL);
   qh_allstatistics();
   if (qh PRINTprecision && !qh MERGING && (qh JOGGLEmax > REALmax/2 || qh RERUN))
-    qh_printstats (qh ferr, qhstat precision, NULL);
-  if (qh VERIFYoutput && (zzval_(Zridge) > 0 || zzval_(Zridgemid) > 0)) 
-    qh_printstats (qh ferr, qhstat vridges, NULL);
+    qh_printstats(qh ferr, qhstat precision, NULL);
+  if (qh VERIFYoutput && (zzval_(Zridge) > 0 || zzval_(Zridgemid) > 0))
+    qh_printstats(qh ferr, qhstat vridges, NULL);
   if (qh PRINTstatistics) {
-    qh_collectstatistics();
     qh_printstatistics(qh ferr, "");
-    qh_memstatistics (qh ferr);
+    qh_memstatistics(qh ferr);
     d_1= sizeof(setT) + (qh hull_dim - 1) * SETelemsize;
-    fprintf(qh ferr, "\
+    qh_fprintf(qh ferr, 8040, "\
     size in bytes: merge %d ridge %d vertex %d facet %d\n\
          normal %d ridge vertices %d facet vertices or neighbors %d\n",
-	    sizeof(mergeT), sizeof(ridgeT),
-	    sizeof(vertexT), sizeof(facetT),
-	    qh normal_size, d_1, d_1 + SETelemsize);
+            (int)sizeof(mergeT), (int)sizeof(ridgeT),
+            (int)sizeof(vertexT), (int)sizeof(facetT),
+            qh normal_size, d_1, d_1 + SETelemsize);
   }
-  if (qh_setsize ((setT*)qhmem.tempstack) != tempsize) {
-    fprintf (qh ferr, "qhull internal error (qh_produce_output): temporary sets not empty (%d)\n",
-	     qh_setsize ((setT*)qhmem.tempstack));
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+  if (qh_setsize(qhmem.tempstack) != tempsize) {
+    qh_fprintf(qh ferr, 6065, "qhull internal error (qh_produce_output2): temporary sets not empty(%d)\n",
+             qh_setsize(qhmem.tempstack));
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
-} /* produce_output */
+} /* produce_output2 */
 
-
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="dfacet">-</a>
-  
+
   dfacet( id )
     print facet by id, for debugging
 
 */
-void dfacet (unsigned id) {
+void dfacet(unsigned id) {
   facetT *facet;
 
   FORALLfacets {
     if (facet->id == id) {
-      qh_printfacet (qh fout, facet);
+      qh_printfacet(qh fout, facet);
       break;
     }
   }
@@ -101,16 +102,16 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="dvertex">-</a>
-  
+
   dvertex( id )
     print vertex by id, for debugging
 */
-void dvertex (unsigned id) {
+void dvertex(unsigned id) {
   vertexT *vertex;
 
   FORALLvertices {
     if (vertex->id == id) {
-      qh_printvertex (qh fout, vertex);
+      qh_printvertex(qh fout, vertex);
       break;
     }
   }
@@ -119,29 +120,29 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="compare_vertexpoint">-</a>
-  
+
   qh_compare_vertexpoint( p1, p2 )
-    used by qsort() to order vertices by point id 
+    used by qsort() to order vertices by point id
 */
 int qh_compare_vertexpoint(const void *p1, const void *p2) {
-  vertexT *a= *((vertexT **)p1), *b= *((vertexT **)p2);
- 
-  return ((qh_pointid(a->point) > qh_pointid(b->point)?1:-1));
+  const vertexT *a= *((vertexT *const*)p1), *b= *((vertexT *const*)p2);
+
+  return((qh_pointid(a->point) > qh_pointid(b->point)?1:-1));
 } /* compare_vertexpoint */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="compare_facetarea">-</a>
-  
+
   qh_compare_facetarea( p1, p2 )
     used by qsort() to order facets by area
 */
 int qh_compare_facetarea(const void *p1, const void *p2) {
-  facetT *a= *((facetT **)p1), *b= *((facetT **)p2);
+  const facetT *a= *((facetT *const*)p1), *b= *((facetT *const*)p2);
 
   if (!a->isarea)
     return -1;
   if (!b->isarea)
-    return 1; 
+    return 1;
   if (a->f.area > b->f.area)
     return 1;
   else if (a->f.area == b->f.area)
@@ -151,37 +152,70 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="compare_facetmerge">-</a>
-  
+
   qh_compare_facetmerge( p1, p2 )
     used by qsort() to order facets by number of merges
 */
 int qh_compare_facetmerge(const void *p1, const void *p2) {
-  facetT *a= *((facetT **)p1), *b= *((facetT **)p2);
- 
-  return (a->nummerge - b->nummerge);
+  const facetT *a= *((facetT *const*)p1), *b= *((facetT *const*)p2);
+
+  return(a->nummerge - b->nummerge);
 } /* compare_facetvisit */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="compare_facetvisit">-</a>
-  
+
   qh_compare_facetvisit( p1, p2 )
     used by qsort() to order facets by visit id or id
 */
 int qh_compare_facetvisit(const void *p1, const void *p2) {
-  facetT *a= *((facetT **)p1), *b= *((facetT **)p2);
+  const facetT *a= *((facetT *const*)p1), *b= *((facetT *const*)p2);
   int i,j;
 
   if (!(i= a->visitid))
-    i= - a->id; /* do not convert to int */
+    i= 0 - a->id; /* do not convert to int, sign distinguishes id from visitid */
   if (!(j= b->visitid))
-    j= - b->id;
-  return (i - j);
+    j= 0 - b->id;
+  return(i - j);
 } /* compare_facetvisit */
 
 /*-<a                             href="qh-io.htm#TOC"
+  >-------------------------------</a><a name="copyfilename">-</a>
+
+  qh_copyfilename( dest, size, source, length )
+    copy filename identified by qh_skipfilename()
+
+  notes:
+    see qh_skipfilename() for syntax
+*/
+void qh_copyfilename(char *filename, int size, const char* source, int length) {
+  char c= *source;
+
+  if (length > size + 1) {
+      qh_fprintf(qh ferr, 6040, "qhull error: filename is more than %d characters, %s\n",  size-1, source);
+      qh_errexit(qh_ERRinput, NULL, NULL);
+  }
+  strncpy(filename, source, length);
+  filename[length]= '\0';
+  if (c == '\'' || c == '"') {
+    char *s= filename + 1;
+    char *t= filename;
+    while (*s) {
+      if (*s == c) {
+          if (s[-1] == '\\')
+              t[-1]= c;
+      }else
+          *t++= *s;
+      s++;
+    }
+    *t= '\0';
+  }
+} /* copyfilename */
+
+/*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="countfacets">-</a>
-  
-  qh_countfacets( facetlist, facets, printall, 
+
+  qh_countfacets( facetlist, facets, printall,
           numfacets, numsimplicial, totneighbors, numridges, numcoplanar, numtricoplanars  )
     count good facets for printing and set visitid
     if allfacets, ignores qh_skipfacet()
@@ -193,10 +227,10 @@
     numfacets, numsimplicial, total neighbors, numridges, coplanars
     each facet with ->visitid indicating 1-relative position
       ->visitid==0 indicates not good
-  
+
   notes
     numfacets >= numsimplicial
-    if qh.NEWfacets, 
+    if qh.NEWfacets,
       does not count visible facets (matches qh_printafacet)
 
   design:
@@ -205,7 +239,7 @@
         mark facet->visitid
         update counts
 */
-void qh_countfacets (facetT *facetlist, setT *facets, boolT printall,
+void qh_countfacets(facetT *facetlist, setT *facets, boolT printall,
     int *numfacetsp, int *numsimplicialp, int *totneighborsp, int *numridgesp, int *numcoplanarsp, int *numtricoplanarsp) {
   facetT *facet, **facetp;
   int numfacets= 0, numsimplicial= 0, numridges= 0, totneighbors= 0, numcoplanars= 0, numtricoplanars= 0;
@@ -216,32 +250,33 @@
       facet->visitid= 0;
     else {
       facet->visitid= ++numfacets;
-      totneighbors += qh_setsize (facet->neighbors);
+      totneighbors += qh_setsize(facet->neighbors);
       if (facet->simplicial) {
         numsimplicial++;
-	if (facet->keepcentrum && facet->tricoplanar)
-	  numtricoplanars++;
+        if (facet->keepcentrum && facet->tricoplanar)
+          numtricoplanars++;
       }else
-        numridges += qh_setsize (facet->ridges);
+        numridges += qh_setsize(facet->ridges);
       if (facet->coplanarset)
-        numcoplanars += qh_setsize (facet->coplanarset);
+        numcoplanars += qh_setsize(facet->coplanarset);
     }
   }
+
   FOREACHfacet_(facets) {
     if ((facet->visible && qh NEWfacets)
     || (!printall && qh_skipfacet(facet)))
       facet->visitid= 0;
     else {
       facet->visitid= ++numfacets;
-      totneighbors += qh_setsize (facet->neighbors);
+      totneighbors += qh_setsize(facet->neighbors);
       if (facet->simplicial){
         numsimplicial++;
-	if (facet->keepcentrum && facet->tricoplanar)
-	  numtricoplanars++;
+        if (facet->keepcentrum && facet->tricoplanar)
+          numtricoplanars++;
       }else
-        numridges += qh_setsize (facet->ridges);
+        numridges += qh_setsize(facet->ridges);
       if (facet->coplanarset)
-        numcoplanars += qh_setsize (facet->coplanarset);
+        numcoplanars += qh_setsize(facet->coplanarset);
     }
   }
   qh visit_id += numfacets+1;
@@ -255,15 +290,15 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="detvnorm">-</a>
-  
+
   qh_detvnorm( vertex, vertexA, centers, offset )
     compute separating plane of the Voronoi diagram for a pair of input sites
     centers= set of facets (i.e., Voronoi vertices)
       facet->visitid= 0 iff vertex-at-infinity (i.e., unbounded)
-        
+
   assumes:
     qh_ASvoronoi and qh_vertexneighbors() already set
-  
+
   returns:
     norm
       a pointer into qh.gm_matrix to qh.hull_dim-1 reals
@@ -273,13 +308,13 @@
         sign adjusted so that qh.GOODvertexp is inside
       else
         sign adjusted so that vertex is inside
-      
+
     qh.gm_matrix= simplex of points from centers relative to first center
-    
+
   notes:
     in io.c so that code for 'v Tv' can be removed by removing io.c
     returns pointer into qh.gm_matrix to avoid tracking of temporary memory
-  
+
   design:
     determine midpoint of input sites
     build points as the set of Voronoi vertices
@@ -294,13 +329,13 @@
       test that Voronoi vertices not in the simplex are still on the hyperplane
     free up temporary memory
 */
-pointT *qh_detvnorm (vertexT *vertex, vertexT *vertexA, setT *centers, realT *offsetp) {
+pointT *qh_detvnorm(vertexT *vertex, vertexT *vertexA, setT *centers, realT *offsetp) {
   facetT *facet, **facetp;
   int  i, k, pointid, pointidA, point_i, point_n;
   setT *simplex= NULL;
   pointT *point, **pointp, *point0, *midpoint, *normal, *inpoint;
   coordT *coord, *gmcoord, *normalp;
-  setT *points= qh_settemp (qh TEMPsize);
+  setT *points= qh_settemp(qh TEMPsize);
   boolT nearzero= False;
   boolT unbounded= False;
   int numcenters= 0;
@@ -308,7 +343,7 @@
   realT dist, offset, angle, zero= 0.0;
 
   midpoint= qh gm_matrix + qh hull_dim * qh hull_dim;  /* last row */
-  for (k= 0; k < dim; k++)
+  for (k=0; k < dim; k++)
     midpoint[k]= (vertex->point[k] + vertexA->point[k])/2;
   FOREACHfacet_(centers) {
     numcenters++;
@@ -316,81 +351,81 @@
       unbounded= True;
     else {
       if (!facet->center)
-        facet->center= qh_facetcenter (facet->vertices);
-      qh_setappend (&points, facet->center);
+        facet->center= qh_facetcenter(facet->vertices);
+      qh_setappend(&points, facet->center);
     }
   }
   if (numcenters > dim) {
-    simplex= qh_settemp (qh TEMPsize);
-    qh_setappend (&simplex, vertex->point);
+    simplex= qh_settemp(qh TEMPsize);
+    qh_setappend(&simplex, vertex->point);
     if (unbounded)
-      qh_setappend (&simplex, midpoint);
-    qh_maxsimplex (dim, points, NULL, 0, &simplex);
-    qh_setdelnth (simplex, 0);
+      qh_setappend(&simplex, midpoint);
+    qh_maxsimplex(dim, points, NULL, 0, &simplex);
+    qh_setdelnth(simplex, 0);
   }else if (numcenters == dim) {
     if (unbounded)
-      qh_setappend (&points, midpoint);
-    simplex= points; 
+      qh_setappend(&points, midpoint);
+    simplex= points;
   }else {
-    fprintf(qh ferr, "qh_detvnorm: too few points (%d) to compute separating plane\n", numcenters);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_fprintf(qh ferr, 6216, "qhull internal error (qh_detvnorm): too few points(%d) to compute separating plane\n", numcenters);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   i= 0;
   gmcoord= qh gm_matrix;
   point0= SETfirstt_(simplex, pointT);
   FOREACHpoint_(simplex) {
     if (qh IStracing >= 4)
-      qh_printmatrix(qh ferr, "qh_detvnorm: Voronoi vertex or midpoint", 
+      qh_printmatrix(qh ferr, "qh_detvnorm: Voronoi vertex or midpoint",
                               &point, 1, dim);
     if (point != point0) {
       qh gm_row[i++]= gmcoord;
       coord= point0;
-      for (k= dim; k--; )
+      for (k=dim; k--; )
         *(gmcoord++)= *point++ - *coord++;
     }
   }
   qh gm_row[i]= gmcoord;  /* does not overlap midpoint, may be used later for qh_areasimplex */
   normal= gmcoord;
-  qh_sethyperplane_gauss (dim, qh gm_row, point0, True,
-           	normal, &offset, &nearzero);
+  qh_sethyperplane_gauss(dim, qh gm_row, point0, True,
+                normal, &offset, &nearzero);
   if (qh GOODvertexp == vertexA->point)
     inpoint= vertexA->point;
   else
     inpoint= vertex->point;
   zinc_(Zdistio);
-  dist= qh_distnorm (dim, inpoint, normal, &offset);
+  dist= qh_distnorm(dim, inpoint, normal, &offset);
   if (dist > 0) {
     offset= -offset;
     normalp= normal;
-    for (k= dim; k--; ) {
+    for (k=dim; k--; ) {
       *normalp= -(*normalp);
       normalp++;
     }
   }
   if (qh VERIFYoutput || qh PRINTstatistics) {
-    pointid= qh_pointid (vertex->point);
-    pointidA= qh_pointid (vertexA->point);
+    pointid= qh_pointid(vertex->point);
+    pointidA= qh_pointid(vertexA->point);
     if (!unbounded) {
       zinc_(Zdiststat);
-      dist= qh_distnorm (dim, midpoint, normal, &offset);
+      dist= qh_distnorm(dim, midpoint, normal, &offset);
       if (dist < 0)
         dist= -dist;
       zzinc_(Zridgemid);
       wwmax_(Wridgemidmax, dist);
       wwadd_(Wridgemid, dist);
-      trace4((qh ferr, "qh_detvnorm: points %d %d midpoint dist %2.2g\n",
+      trace4((qh ferr, 4014, "qh_detvnorm: points %d %d midpoint dist %2.2g\n",
                  pointid, pointidA, dist));
-      for (k= 0; k < dim; k++) 
+      for (k=0; k < dim; k++)
         midpoint[k]= vertexA->point[k] - vertex->point[k];  /* overwrites midpoint! */
-      qh_normalize (midpoint, dim, False);
-      angle= qh_distnorm (dim, midpoint, normal, &zero); /* qh_detangle uses dim+1 */
+      qh_normalize(midpoint, dim, False);
+      angle= qh_distnorm(dim, midpoint, normal, &zero); /* qh_detangle uses dim+1 */
       if (angle < 0.0)
-	angle= angle + 1.0;
+        angle= angle + 1.0;
       else
-	angle= angle - 1.0;
+        angle= angle - 1.0;
       if (angle < 0.0)
-	angle -= angle;
-      trace4((qh ferr, "qh_detvnorm: points %d %d angle %2.2g nearzero %d\n",
+        angle -= angle;
+      trace4((qh ferr, 4015, "qh_detvnorm: points %d %d angle %2.2g nearzero %d\n",
                  pointid, pointidA, angle, nearzero));
       if (nearzero) {
         zzinc_(Zridge0);
@@ -404,16 +439,16 @@
     }
     if (simplex != points) {
       FOREACHpoint_i_(points) {
-        if (!qh_setin (simplex, point)) {
+        if (!qh_setin(simplex, point)) {
           facet= SETelemt_(centers, point_i, facetT);
-	  zinc_(Zdiststat);
-  	  dist= qh_distnorm (dim, point, normal, &offset);
+          zinc_(Zdiststat);
+          dist= qh_distnorm(dim, point, normal, &offset);
           if (dist < 0)
             dist= -dist;
-	  zzinc_(Zridge);
+          zzinc_(Zridge);
           wwmax_(Wridgemax, dist);
           wwadd_(Wridge, dist);
-          trace4((qh ferr, "qh_detvnorm: points %d %d Voronoi vertex %d dist %2.2g\n",
+          trace4((qh ferr, 4016, "qh_detvnorm: points %d %d Voronoi vertex %d dist %2.2g\n",
                              pointid, pointidA, facet->visitid, dist));
         }
       }
@@ -421,8 +456,8 @@
   }
   *offsetp= offset;
   if (simplex != points)
-    qh_settempfree (&simplex);
-  qh_settempfree (&points);
+    qh_settempfree(&simplex);
+  qh_settempfree(&points);
   return normal;
 } /* detvnorm */
 
@@ -437,28 +472,28 @@
     temporary set of centers (facets, i.e., Voronoi vertices)
     sorted by center id
 */
-setT *qh_detvridge (vertexT *vertex) {
-  setT *centers= qh_settemp (qh TEMPsize);
-  setT *tricenters= qh_settemp (qh TEMPsize);
+setT *qh_detvridge(vertexT *vertex) {
+  setT *centers= qh_settemp(qh TEMPsize);
+  setT *tricenters= qh_settemp(qh TEMPsize);
   facetT *neighbor, **neighborp;
   boolT firstinf= True;
-  
+
   FOREACHneighbor_(vertex) {
     if (neighbor->seen) {
       if (neighbor->visitid) {
-	if (!neighbor->tricoplanar || qh_setunique (&tricenters, neighbor->center)) 
-	  qh_setappend (&centers, neighbor);
+        if (!neighbor->tricoplanar || qh_setunique(&tricenters, neighbor->center))
+          qh_setappend(&centers, neighbor);
       }else if (firstinf) {
         firstinf= False;
-        qh_setappend (&centers, neighbor);
+        qh_setappend(&centers, neighbor);
       }
     }
   }
-  qsort (SETaddr_(centers, facetT), qh_setsize (centers),
-             sizeof (facetT *), qh_compare_facetvisit);
-  qh_settempfree (&tricenters);
+  qsort(SETaddr_(centers, facetT), (size_t)qh_setsize(centers),
+             sizeof(facetT *), qh_compare_facetvisit);
+  qh_settempfree(&tricenters);
   return centers;
-} /* detvridge */      
+} /* detvridge */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="detvridge3">-</a>
@@ -470,7 +505,7 @@
 
   returns:
     temporary set of centers (facets, i.e., Voronoi vertices)
-    listed in adjacency order (not oriented)
+    listed in adjacency order (!oriented)
     all facet->seen2= True
 
   design:
@@ -480,11 +515,11 @@
         add neighbor to set of Voronoi vertices
 */
 setT *qh_detvridge3 (vertexT *atvertex, vertexT *vertex) {
-  setT *centers= qh_settemp (qh TEMPsize);
-  setT *tricenters= qh_settemp (qh TEMPsize);
+  setT *centers= qh_settemp(qh TEMPsize);
+  setT *tricenters= qh_settemp(qh TEMPsize);
   facetT *neighbor, **neighborp, *facet= NULL;
   boolT firstinf= True;
-  
+
   FOREACHneighbor_(atvertex)
     neighbor->seen2= False;
   FOREACHneighbor_(vertex) {
@@ -493,23 +528,23 @@
       break;
     }
   }
-  while (facet) { 
+  while (facet) {
     facet->seen2= True;
     if (neighbor->seen) {
       if (facet->visitid) {
-	if (!facet->tricoplanar || qh_setunique (&tricenters, facet->center)) 
-	  qh_setappend (&centers, facet);
+        if (!facet->tricoplanar || qh_setunique(&tricenters, facet->center))
+          qh_setappend(&centers, facet);
       }else if (firstinf) {
         firstinf= False;
-        qh_setappend (&centers, facet);
+        qh_setappend(&centers, facet);
       }
     }
     FOREACHneighbor_(facet) {
       if (!neighbor->seen2) {
-	if (qh_setin (vertex->neighbors, neighbor))
+        if (qh_setin(vertex->neighbors, neighbor))
           break;
-	else
-	  neighbor->seen2= True;
+        else
+          neighbor->seen2= True;
       }
     }
     facet= neighbor;
@@ -517,21 +552,21 @@
   if (qh CHECKfrequently) {
     FOREACHneighbor_(vertex) {
       if (!neighbor->seen2) {
-	fprintf (stderr, "qh_detvridge3: neigbors of vertex p%d are not connected at facet %d\n",
-	         qh_pointid (vertex->point), neighbor->id);
-	qh_errexit (qh_ERRqhull, neighbor, NULL);
+          qh_fprintf(qh ferr, 6217, "qhull internal error (qh_detvridge3): neighbors of vertex p%d are not connected at facet %d\n",
+                 qh_pointid(vertex->point), neighbor->id);
+        qh_errexit(qh_ERRqhull, neighbor, NULL);
       }
     }
   }
-  FOREACHneighbor_(atvertex) 
+  FOREACHneighbor_(atvertex)
     neighbor->seen2= True;
-  qh_settempfree (&tricenters);
+  qh_settempfree(&tricenters);
   return centers;
-} /* detvridge3 */      
+} /* detvridge3 */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="eachvoronoi">-</a>
-  
+
   qh_eachvoronoi( fp, printvridge, vertex, visitall, innerouter, inorder )
     if visitall,
       visit all Voronoi ridges for vertex (i.e., an input site)
@@ -542,19 +577,19 @@
       all facet->seen= False
       all facet->seen2= True (for qh_detvridge3)
       all facet->visitid == 0 if vertex_at_infinity
-                         == index of Voronoi vertex 
+                         == index of Voronoi vertex
                          >= qh.num_facets if ignored
     innerouter:
-      qh_RIDGEall--  both inner (bounded) and outer (unbounded) ridges
+      qh_RIDGEall--  both inner (bounded) and outer(unbounded) ridges
       qh_RIDGEinner- only inner
       qh_RIDGEouter- only outer
-      
+
     if inorder
       orders vertices for 3-d Voronoi diagrams
-  
+
   returns:
     number of visited ridges (does not include previously visited ridges)
-    
+
     if printvridge,
       calls printvridge( fp, vertex, vertexA, centers)
         fp== any pointer (assumes FILE*)
@@ -564,26 +599,26 @@
                  ordered for 3-d Voronoi diagram
   notes:
     uses qh.vertex_visit
-  
+
   see:
     qh_eachvoronoi_all()
-  
+
   design:
     mark selected neighbors of atvertex
     for each selected neighbor (either Voronoi vertex or vertex-at-infinity)
-      for each unvisited vertex 
+      for each unvisited vertex
         if atvertex and vertex share more than d-1 neighbors
           bump totalcount
           if printvridge defined
             build the set of shared neighbors (i.e., Voronoi vertices)
             call printvridge
 */
-int qh_eachvoronoi (FILE *fp, printvridgeT printvridge, vertexT *atvertex, boolT visitall, qh_RIDGE innerouter, boolT inorder) {
+int qh_eachvoronoi(FILE *fp, printvridgeT printvridge, vertexT *atvertex, boolT visitall, qh_RIDGE innerouter, boolT inorder) {
   boolT unbounded;
   int count;
   facetT *neighbor, **neighborp, *neighborA, **neighborAp;
   setT *centers;
-  setT *tricenters= qh_settemp (qh TEMPsize);
+  setT *tricenters= qh_settemp(qh TEMPsize);
 
   vertexT *vertex, **vertexp;
   boolT firstinf;
@@ -593,31 +628,31 @@
   qh vertex_visit++;
   atvertex->seen= True;
   if (visitall) {
-    FORALLvertices 
+    FORALLvertices
       vertex->seen= False;
   }
   FOREACHneighbor_(atvertex) {
-    if (neighbor->visitid < numfacets) 
+    if (neighbor->visitid < numfacets)
       neighbor->seen= True;
   }
   FOREACHneighbor_(atvertex) {
     if (neighbor->seen) {
       FOREACHvertex_(neighbor->vertices) {
         if (vertex->visitid != qh vertex_visit && !vertex->seen) {
-	  vertex->visitid= qh vertex_visit;
+          vertex->visitid= qh vertex_visit;
           count= 0;
           firstinf= True;
-	  qh_settruncate (tricenters, 0);
+          qh_settruncate(tricenters, 0);
           FOREACHneighborA_(vertex) {
             if (neighborA->seen) {
-	      if (neighborA->visitid) {
-		if (!neighborA->tricoplanar || qh_setunique (&tricenters, neighborA->center))
-		  count++;
+              if (neighborA->visitid) {
+                if (!neighborA->tricoplanar || qh_setunique(&tricenters, neighborA->center))
+                  count++;
               }else if (firstinf) {
                 count++;
                 firstinf= False;
-	      }
-	    }
+              }
+            }
           }
           if (count >= qh hull_dim - 1) {  /* e.g., 3 for 3-d Voronoi */
             if (firstinf) {
@@ -630,63 +665,63 @@
               unbounded= True;
             }
             totridges++;
-            trace4((qh ferr, "qh_eachvoronoi: Voronoi ridge of %d vertices between sites %d and %d\n",
-                  count, qh_pointid (atvertex->point), qh_pointid (vertex->point)));
-            if (printvridge) { 
-	      if (inorder && qh hull_dim == 3+1) /* 3-d Voronoi diagram */
+            trace4((qh ferr, 4017, "qh_eachvoronoi: Voronoi ridge of %d vertices between sites %d and %d\n",
+                  count, qh_pointid(atvertex->point), qh_pointid(vertex->point)));
+            if (printvridge && fp) {
+              if (inorder && qh hull_dim == 3+1) /* 3-d Voronoi diagram */
                 centers= qh_detvridge3 (atvertex, vertex);
-	      else
-                centers= qh_detvridge (vertex);
+              else
+                centers= qh_detvridge(vertex);
               (*printvridge) (fp, atvertex, vertex, centers, unbounded);
-              qh_settempfree (&centers);
+              qh_settempfree(&centers);
             }
           }
         }
       }
     }
   }
-  FOREACHneighbor_(atvertex) 
+  FOREACHneighbor_(atvertex)
     neighbor->seen= False;
-  qh_settempfree (&tricenters);
+  qh_settempfree(&tricenters);
   return totridges;
 } /* eachvoronoi */
-  
 
+
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="eachvoronoi_all">-</a>
-  
-  qh_eachvoronoi_all( fp, printvridge, isupper, innerouter, inorder )
+
+  qh_eachvoronoi_all( fp, printvridge, isUpper, innerouter, inorder )
     visit all Voronoi ridges
-    
+
     innerouter:
       see qh_eachvoronoi()
-      
+
     if inorder
       orders vertices for 3-d Voronoi diagrams
-    
+
   returns
-    total number of ridges 
+    total number of ridges
 
-    if isupper == facet->upperdelaunay  (i.e., a Vornoi vertex)
-      facet->visitid= Voronoi vertex index (same as 'o' format)
-    else 
+    if isUpper == facet->upperdelaunay  (i.e., a Vornoi vertex)
+      facet->visitid= Voronoi vertex index(same as 'o' format)
+    else
       facet->visitid= 0
 
     if printvridge,
       calls printvridge( fp, vertex, vertexA, centers)
       [see qh_eachvoronoi]
-      
+
   notes:
     Not used for qhull.exe
     same effect as qh_printvdiagram but ridges not sorted by point id
 */
-int qh_eachvoronoi_all (FILE *fp, printvridgeT printvridge, boolT isupper, qh_RIDGE innerouter, boolT inorder) {
+int qh_eachvoronoi_all(FILE *fp, printvridgeT printvridge, boolT isUpper, qh_RIDGE innerouter, boolT inorder) {
   facetT *facet;
   vertexT *vertex;
   int numcenters= 1;  /* vertex 0 is vertex-at-infinity */
   int totridges= 0;
 
-  qh_clearcenters (qh_ASvoronoi);
+  qh_clearcenters(qh_ASvoronoi);
   qh_vertexneighbors();
   maximize_(qh visit_id, (unsigned) qh num_facets);
   FORALLfacets {
@@ -695,23 +730,23 @@
     facet->seen2= True;
   }
   FORALLfacets {
-    if (facet->upperdelaunay == isupper)
+    if (facet->upperdelaunay == isUpper)
       facet->visitid= numcenters++;
   }
-  FORALLvertices 
+  FORALLvertices
     vertex->seen= False;
   FORALLvertices {
     if (qh GOODvertex > 0 && qh_pointid(vertex->point)+1 != qh GOODvertex)
       continue;
-    totridges += qh_eachvoronoi (fp, printvridge, vertex, 
+    totridges += qh_eachvoronoi(fp, printvridge, vertex,
                    !qh_ALL, innerouter, inorder);
   }
   return totridges;
 } /* eachvoronoi_all */
-      
+
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="facet2point">-</a>
-  
+
   qh_facet2point( facet, point0, point1, mindist )
     return two projected temporary vertices for a 2-d facet
     may be non-simplicial
@@ -723,7 +758,7 @@
 void qh_facet2point(facetT *facet, pointT **point0, pointT **point1, realT *mindist) {
   vertexT *vertex0, *vertex1;
   realT dist;
-  
+
   if (facet->toporient ^ qh_ORIENTclock) {
     vertex0= SETfirstt_(facet->vertices, vertexT);
     vertex1= SETsecondt_(facet->vertices, vertexT);
@@ -736,21 +771,21 @@
   *mindist= dist;
   *point0= qh_projectpoint(vertex0->point, facet, dist);
   qh_distplane(vertex1->point, facet, &dist);
-  minimize_(*mindist, dist);		
+  minimize_(*mindist, dist);
   *point1= qh_projectpoint(vertex1->point, facet, dist);
 } /* facet2point */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="facetvertices">-</a>
-  
+
   qh_facetvertices( facetlist, facets, allfacets )
     returns temporary set of vertices in a set and/or list of facets
     if allfacets, ignores qh_skipfacet()
 
   returns:
     vertices with qh.vertex_visit
-    
+
   notes:
     optimized for allfacets of facet_list
 
@@ -761,38 +796,38 @@
       for each selected facet in facets or facetlist
         append unvisited vertices to vertex set
 */
-setT *qh_facetvertices (facetT *facetlist, setT *facets, boolT allfacets) {
+setT *qh_facetvertices(facetT *facetlist, setT *facets, boolT allfacets) {
   setT *vertices;
   facetT *facet, **facetp;
   vertexT *vertex, **vertexp;
 
   qh vertex_visit++;
   if (facetlist == qh facet_list && allfacets && !facets) {
-    vertices= qh_settemp (qh num_vertices);
+    vertices= qh_settemp(qh num_vertices);
     FORALLvertices {
-      vertex->visitid= qh vertex_visit; 
-      qh_setappend (&vertices, vertex);
+      vertex->visitid= qh vertex_visit;
+      qh_setappend(&vertices, vertex);
     }
   }else {
-    vertices= qh_settemp (qh TEMPsize);
+    vertices= qh_settemp(qh TEMPsize);
     FORALLfacet_(facetlist) {
-      if (!allfacets && qh_skipfacet (facet))
+      if (!allfacets && qh_skipfacet(facet))
         continue;
       FOREACHvertex_(facet->vertices) {
         if (vertex->visitid != qh vertex_visit) {
           vertex->visitid= qh vertex_visit;
-          qh_setappend (&vertices, vertex);
+          qh_setappend(&vertices, vertex);
         }
       }
     }
   }
   FOREACHfacet_(facets) {
-    if (!allfacets && qh_skipfacet (facet))
+    if (!allfacets && qh_skipfacet(facet))
       continue;
     FOREACHvertex_(facet->vertices) {
       if (vertex->visitid != qh vertex_visit) {
         vertex->visitid= qh vertex_visit;
-        qh_setappend (&vertices, vertex);
+        qh_setappend(&vertices, vertex);
       }
     }
   }
@@ -801,39 +836,39 @@
 
 /*-<a                             href="qh-geom.htm#TOC"
   >-------------------------------</a><a name="geomplanes">-</a>
-  
+
   qh_geomplanes( facet, outerplane, innerplane )
-    return outer and inner planes for Geomview 
+    return outer and inner planes for Geomview
     qh.PRINTradius is size of vertices and points (includes qh.JOGGLEmax)
 
   notes:
     assume precise calculations in io.c with roundoff covered by qh_GEOMepsilon
 */
-void qh_geomplanes (facetT *facet, realT *outerplane, realT *innerplane) {
+void qh_geomplanes(facetT *facet, realT *outerplane, realT *innerplane) {
   realT radius;
 
   if (qh MERGING || qh JOGGLEmax < REALmax/2) {
-    qh_outerinner (facet, outerplane, innerplane);
+    qh_outerinner(facet, outerplane, innerplane);
     radius= qh PRINTradius;
     if (qh JOGGLEmax < REALmax/2)
-      radius -= qh JOGGLEmax * sqrt (qh hull_dim);  /* already accounted for in qh_outerinner() */
+      radius -= qh JOGGLEmax * sqrt((realT)qh hull_dim);  /* already accounted for in qh_outerinner() */
     *outerplane += radius;
     *innerplane -= radius;
     if (qh PRINTcoplanar || qh PRINTspheres) {
       *outerplane += qh MAXabs_coord * qh_GEOMepsilon;
       *innerplane -= qh MAXabs_coord * qh_GEOMepsilon;
     }
-  }else 
+  }else
     *innerplane= *outerplane= 0;
 } /* geomplanes */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="markkeep">-</a>
-  
+
   qh_markkeep( facetlist )
     mark good facets that meet qh.KEEParea, qh.KEEPmerge, and qh.KEEPminArea
-    ignores visible facets (not part of convex hull)
+    ignores visible facets (!part of convex hull)
 
   returns:
     may clear facet->good
@@ -849,23 +884,23 @@
       clear facet->good for all but n most merged facets
     if qh.KEEPminarea
       clear facet->good if area too small
-    update qh.num_good    
+    update qh.num_good
 */
-void qh_markkeep (facetT *facetlist) {
+void qh_markkeep(facetT *facetlist) {
   facetT *facet, **facetp;
-  setT *facets= qh_settemp (qh num_facets);
+  setT *facets= qh_settemp(qh num_facets);
   int size, count;
 
-  trace2((qh ferr, "qh_markkeep: only keep %d largest and/or %d most merged facets and/or min area %.2g\n",
+  trace2((qh ferr, 2006, "qh_markkeep: only keep %d largest and/or %d most merged facets and/or min area %.2g\n",
           qh KEEParea, qh KEEPmerge, qh KEEPminArea));
   FORALLfacet_(facetlist) {
     if (!facet->visible && facet->good)
-      qh_setappend (&facets, facet);
+      qh_setappend(&facets, facet);
   }
-  size= qh_setsize (facets);
+  size= qh_setsize(facets);
   if (qh KEEParea) {
-    qsort (SETaddr_(facets, facetT), size,
-             sizeof (facetT *), qh_compare_facetarea);
+    qsort(SETaddr_(facets, facetT), (size_t)size,
+             sizeof(facetT *), qh_compare_facetarea);
     if ((count= size - qh KEEParea) > 0) {
       FOREACHfacet_(facets) {
         facet->good= False;
@@ -875,8 +910,8 @@
     }
   }
   if (qh KEEPmerge) {
-    qsort (SETaddr_(facets, facetT), size,
-             sizeof (facetT *), qh_compare_facetmerge);
+    qsort(SETaddr_(facets, facetT), (size_t)size,
+             sizeof(facetT *), qh_compare_facetmerge);
     if ((count= size - qh KEEPmerge) > 0) {
       FOREACHfacet_(facets) {
         facet->good= False;
@@ -888,10 +923,10 @@
   if (qh KEEPminArea < REALmax/2) {
     FOREACHfacet_(facets) {
       if (!facet->isarea || facet->f.area < qh KEEPminArea)
-	facet->good= False;
+        facet->good= False;
     }
   }
-  qh_settempfree (&facets);
+  qh_settempfree(&facets);
   count= 0;
   FORALLfacet_(facetlist) {
     if (facet->good)
@@ -903,59 +938,59 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="markvoronoi">-</a>
-  
-  qh_markvoronoi( facetlist, facets, printall, islower, numcenters )
+
+  qh_markvoronoi( facetlist, facets, printall, isLower, numcenters )
     mark voronoi vertices for printing by site pairs
-  
+
   returns:
     temporary set of vertices indexed by pointid
-    islower set if printing lower hull (i.e., at least one facet is lower hull)
+    isLower set if printing lower hull (i.e., at least one facet is lower hull)
     numcenters= total number of Voronoi vertices
     bumps qh.printoutnum for vertex-at-infinity
     clears all facet->seen and sets facet->seen2
-    
+
     if selected
       facet->visitid= Voronoi vertex id
     else if upper hull (or 'Qu' and lower hull)
       facet->visitid= 0
     else
       facet->visitid >= qh num_facets
-  
+
   notes:
     ignores qh.ATinfinity, if defined
 */
-setT *qh_markvoronoi (facetT *facetlist, setT *facets, boolT printall, boolT *islowerp, int *numcentersp) {
+setT *qh_markvoronoi(facetT *facetlist, setT *facets, boolT printall, boolT *isLowerp, int *numcentersp) {
   int numcenters=0;
   facetT *facet, **facetp;
   setT *vertices;
-  boolT islower= False;
+  boolT isLower= False;
 
   qh printoutnum++;
-  qh_clearcenters (qh_ASvoronoi);  /* in case, qh_printvdiagram2 called by user */
+  qh_clearcenters(qh_ASvoronoi);  /* in case, qh_printvdiagram2 called by user */
   qh_vertexneighbors();
   vertices= qh_pointvertex();
-  if (qh ATinfinity) 
+  if (qh ATinfinity)
     SETelem_(vertices, qh num_points-1)= NULL;
   qh visit_id++;
   maximize_(qh visit_id, (unsigned) qh num_facets);
-  FORALLfacet_(facetlist) { 
-    if (printall || !qh_skipfacet (facet)) {
+  FORALLfacet_(facetlist) {
+    if (printall || !qh_skipfacet(facet)) {
       if (!facet->upperdelaunay) {
-        islower= True;
-	break;
+        isLower= True;
+        break;
       }
     }
   }
   FOREACHfacet_(facets) {
-    if (printall || !qh_skipfacet (facet)) {
+    if (printall || !qh_skipfacet(facet)) {
       if (!facet->upperdelaunay) {
-        islower= True;
-	break;
+        isLower= True;
+        break;
       }
     }
   }
   FORALLfacets {
-    if (facet->normal && (facet->upperdelaunay == islower))
+    if (facet->normal && (facet->upperdelaunay == isLower))
       facet->visitid= 0;  /* facetlist or facets may overwrite */
     else
       facet->visitid= qh visit_id;
@@ -964,22 +999,22 @@
   }
   numcenters++;  /* qh_INFINITE */
   FORALLfacet_(facetlist) {
-    if (printall || !qh_skipfacet (facet))
+    if (printall || !qh_skipfacet(facet))
       facet->visitid= numcenters++;
   }
   FOREACHfacet_(facets) {
-    if (printall || !qh_skipfacet (facet))
-      facet->visitid= numcenters++;  
+    if (printall || !qh_skipfacet(facet))
+      facet->visitid= numcenters++;
   }
-  *islowerp= islower;
+  *isLowerp= isLower;
   *numcentersp= numcenters;
-  trace2((qh ferr, "qh_markvoronoi: islower %d numcenters %d\n", islower, numcenters));
+  trace2((qh ferr, 2007, "qh_markvoronoi: isLower %d numcenters %d\n", isLower, numcenters));
   return vertices;
 } /* markvoronoi */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="order_vertexneighbors">-</a>
-  
+
   qh_order_vertexneighbors( vertex )
     order facet neighbors of a 2-d or 3-d vertex by adjacency
 
@@ -996,33 +1031,63 @@
   setT *newset;
   facetT *facet, *neighbor, **neighborp;
 
-  trace4((qh ferr, "qh_order_vertexneighbors: order neighbors of v%d for 3-d\n", vertex->id));
-  newset= qh_settemp (qh_setsize (vertex->neighbors));
-  facet= (facetT*)qh_setdellast (vertex->neighbors);
-  qh_setappend (&newset, facet);
-  while (qh_setsize (vertex->neighbors)) {
+  trace4((qh ferr, 4018, "qh_order_vertexneighbors: order neighbors of v%d for 3-d\n", vertex->id));
+  newset= qh_settemp(qh_setsize(vertex->neighbors));
+  facet= (facetT*)qh_setdellast(vertex->neighbors);
+  qh_setappend(&newset, facet);
+  while (qh_setsize(vertex->neighbors)) {
     FOREACHneighbor_(vertex) {
-      if (qh_setin (facet->neighbors, neighbor)) {
+      if (qh_setin(facet->neighbors, neighbor)) {
         qh_setdel(vertex->neighbors, neighbor);
-        qh_setappend (&newset, neighbor);
+        qh_setappend(&newset, neighbor);
         facet= neighbor;
         break;
       }
     }
     if (!neighbor) {
-      fprintf (qh ferr, "qhull internal error (qh_order_vertexneighbors): no neighbor of v%d for f%d\n",
+      qh_fprintf(qh ferr, 6066, "qhull internal error (qh_order_vertexneighbors): no neighbor of v%d for f%d\n",
         vertex->id, facet->id);
-      qh_errexit (qh_ERRqhull, facet, NULL);
+      qh_errexit(qh_ERRqhull, facet, NULL);
     }
   }
-  qh_setfree (&vertex->neighbors);
-  qh_settemppop ();
+  qh_setfree(&vertex->neighbors);
+  qh_settemppop();
   vertex->neighbors= newset;
 } /* order_vertexneighbors */
 
 /*-<a                             href="qh-io.htm#TOC"
+  >-------------------------------</a><a name="prepare_output">-</a>
+
+  qh_prepare_output( )
+    prepare for qh_produce_output2() according to
+      qh.KEEPminArea, KEEParea, KEEPmerge, GOODvertex, GOODthreshold, GOODpoint, ONLYgood, SPLITthresholds
+    does not reset facet->good
+
+  notes
+    except for PRINTstatistics, no-op if previously called with same options
+*/
+void qh_prepare_output(void) {
+  if (qh VORONOI) {
+    qh_clearcenters (qh_ASvoronoi);
+    qh_vertexneighbors();
+  }
+  if (qh TRIangulate && !qh hasTriangulation) {
+    qh_triangulate();
+    if (qh VERIFYoutput && !qh CHECKfrequently)
+      qh_checkpolygon (qh facet_list);
+  }
+  qh_findgood_all (qh facet_list);
+  if (qh GETarea)
+    qh_getarea(qh facet_list);
+  if (qh KEEParea || qh KEEPmerge || qh KEEPminArea < REALmax/2)
+    qh_markkeep (qh facet_list);
+  if (qh PRINTstatistics)
+    qh_collectstatistics();
+}
+
+/*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printafacet">-</a>
-  
+
   qh_printafacet( fp, format, facet, printall )
     print facet to fp in given output format (see qh.PRINTout)
 
@@ -1043,7 +1108,7 @@
     call appropriate routine for format
     or output results directly
 */
-void qh_printafacet(FILE *fp, int format, facetT *facet, boolT printall) {
+void qh_printafacet(FILE *fp, qh_PRINT format, facetT *facet, boolT printall) {
   realT color[4], offset, dist, outerplane, innerplane;
   boolT zerodiv;
   coordT *point, *normp, *coordp, **pointp, *feasiblep;
@@ -1051,7 +1116,7 @@
   vertexT *vertex, **vertexp;
   facetT *neighbor, **neighborp;
 
-  if (!printall && qh_skipfacet (facet))
+  if (!printall && qh_skipfacet(facet))
     return;
   if (facet->visible && qh NEWfacets && format != qh_PRINTfacets)
     return;
@@ -1059,30 +1124,30 @@
   switch (format) {
   case qh_PRINTarea:
     if (facet->isarea) {
-      fprintf (fp, qh_REAL_1, facet->f.area);
-      fprintf (fp, "\n");
+      qh_fprintf(fp, 9009, qh_REAL_1, facet->f.area);
+      qh_fprintf(fp, 9010, "\n");
     }else
-      fprintf (fp, "0\n");
+      qh_fprintf(fp, 9011, "0\n");
     break;
   case qh_PRINTcoplanars:
-    fprintf (fp, "%d", qh_setsize (facet->coplanarset));
+    qh_fprintf(fp, 9012, "%d", qh_setsize(facet->coplanarset));
     FOREACHpoint_(facet->coplanarset)
-      fprintf (fp, " %d", qh_pointid (point));
-    fprintf (fp, "\n");
+      qh_fprintf(fp, 9013, " %d", qh_pointid(point));
+    qh_fprintf(fp, 9014, "\n");
     break;
   case qh_PRINTcentrums:
-    qh_printcenter (fp, format, NULL, facet);
+    qh_printcenter(fp, format, NULL, facet);
     break;
   case qh_PRINTfacets:
-    qh_printfacet (fp, facet);
+    qh_printfacet(fp, facet);
     break;
   case qh_PRINTfacets_xridge:
-    qh_printfacetheader (fp, facet);
+    qh_printfacetheader(fp, facet);
     break;
   case qh_PRINTgeom:  /* either 2 , 3, or 4-d by qh_printbegin */
     if (!facet->normal)
       break;
-    for (k= qh hull_dim; k--; ) {
+    for (k=qh hull_dim; k--; ) {
       color[k]= (facet->normal[k]+1.0)/2.0;
       maximize_(color[k], -1.0);
       minimize_(color[k], +1.0);
@@ -1091,153 +1156,155 @@
     if (qh PRINTdim != qh hull_dim)
       qh_normalize2 (color, 3, True, NULL, NULL);
     if (qh hull_dim <= 2)
-      qh_printfacet2geom (fp, facet, color);
+      qh_printfacet2geom(fp, facet, color);
     else if (qh hull_dim == 3) {
       if (facet->simplicial)
-        qh_printfacet3geom_simplicial (fp, facet, color);
+        qh_printfacet3geom_simplicial(fp, facet, color);
       else
-        qh_printfacet3geom_nonsimplicial (fp, facet, color);
+        qh_printfacet3geom_nonsimplicial(fp, facet, color);
     }else {
       if (facet->simplicial)
-        qh_printfacet4geom_simplicial (fp, facet, color);
+        qh_printfacet4geom_simplicial(fp, facet, color);
       else
-        qh_printfacet4geom_nonsimplicial (fp, facet, color);
+        qh_printfacet4geom_nonsimplicial(fp, facet, color);
     }
     break;
   case qh_PRINTids:
-    fprintf (fp, "%d\n", facet->id);
+    qh_fprintf(fp, 9015, "%d\n", facet->id);
     break;
   case qh_PRINTincidences:
   case qh_PRINToff:
   case qh_PRINTtriangles:
-    if (qh hull_dim == 3 && format != qh_PRINTtriangles) 
-      qh_printfacet3vertex (fp, facet, format);
+    if (qh hull_dim == 3 && format != qh_PRINTtriangles)
+      qh_printfacet3vertex(fp, facet, format);
     else if (facet->simplicial || qh hull_dim == 2 || format == qh_PRINToff)
-      qh_printfacetNvertex_simplicial (fp, facet, format);
+      qh_printfacetNvertex_simplicial(fp, facet, format);
     else
-      qh_printfacetNvertex_nonsimplicial (fp, facet, qh printoutvar++, format);
+      qh_printfacetNvertex_nonsimplicial(fp, facet, qh printoutvar++, format);
     break;
   case qh_PRINTinner:
-    qh_outerinner (facet, NULL, &innerplane);
+    qh_outerinner(facet, NULL, &innerplane);
     offset= facet->offset - innerplane;
     goto LABELprintnorm;
     break; /* prevent warning */
   case qh_PRINTmerges:
-    fprintf (fp, "%d\n", facet->nummerge);
+    qh_fprintf(fp, 9016, "%d\n", facet->nummerge);
     break;
   case qh_PRINTnormals:
     offset= facet->offset;
     goto LABELprintnorm;
     break; /* prevent warning */
   case qh_PRINTouter:
-    qh_outerinner (facet, &outerplane, NULL);
+    qh_outerinner(facet, &outerplane, NULL);
     offset= facet->offset - outerplane;
   LABELprintnorm:
     if (!facet->normal) {
-      fprintf (fp, "no normal for facet f%d\n", facet->id);
+      qh_fprintf(fp, 9017, "no normal for facet f%d\n", facet->id);
       break;
     }
     if (qh CDDoutput) {
-      fprintf (fp, qh_REAL_1, -offset);
-      for (k=0; k < qh hull_dim; k++) 
-	fprintf (fp, qh_REAL_1, -facet->normal[k]);
+      qh_fprintf(fp, 9018, qh_REAL_1, -offset);
+      for (k=0; k < qh hull_dim; k++)
+        qh_fprintf(fp, 9019, qh_REAL_1, -facet->normal[k]);
     }else {
-      for (k=0; k < qh hull_dim; k++) 
-	fprintf (fp, qh_REAL_1, facet->normal[k]);
-      fprintf (fp, qh_REAL_1, offset);
+      for (k=0; k < qh hull_dim; k++)
+        qh_fprintf(fp, 9020, qh_REAL_1, facet->normal[k]);
+      qh_fprintf(fp, 9021, qh_REAL_1, offset);
     }
-    fprintf (fp, "\n");
+    qh_fprintf(fp, 9022, "\n");
     break;
   case qh_PRINTmathematica:  /* either 2 or 3-d by qh_printbegin */
   case qh_PRINTmaple:
     if (qh hull_dim == 2)
-      qh_printfacet2math (fp, facet, format, qh printoutvar++);
-    else 
-      qh_printfacet3math (fp, facet, format, qh printoutvar++);
+      qh_printfacet2math(fp, facet, format, qh printoutvar++);
+    else
+      qh_printfacet3math(fp, facet, format, qh printoutvar++);
     break;
   case qh_PRINTneighbors:
-    fprintf (fp, "%d", qh_setsize (facet->neighbors));
+    qh_fprintf(fp, 9023, "%d", qh_setsize(facet->neighbors));
     FOREACHneighbor_(facet)
-      fprintf (fp, " %d", 
-	       neighbor->visitid ? neighbor->visitid - 1: - neighbor->id);
-    fprintf (fp, "\n");
+      qh_fprintf(fp, 9024, " %d",
+               neighbor->visitid ? neighbor->visitid - 1: 0 - neighbor->id);
+    qh_fprintf(fp, 9025, "\n");
     break;
   case qh_PRINTpointintersect:
     if (!qh feasible_point) {
-      fprintf (fp, "qhull input error (qh_printafacet): option 'Fp' needs qh feasible_point\n");
+      qh_fprintf(qh ferr, 6067, "qhull input error (qh_printafacet): option 'Fp' needs qh feasible_point\n");
       qh_errexit( qh_ERRinput, NULL, NULL);
     }
     if (facet->offset > 0)
       goto LABELprintinfinite;
-    point= coordp= (coordT*)qh_memalloc (qh normal_size);
+    point= coordp= (coordT*)qh_memalloc(qh normal_size);
     normp= facet->normal;
     feasiblep= qh feasible_point;
     if (facet->offset < -qh MINdenom) {
-      for (k= qh hull_dim; k--; )
+      for (k=qh hull_dim; k--; )
         *(coordp++)= (*(normp++) / - facet->offset) + *(feasiblep++);
     }else {
-      for (k= qh hull_dim; k--; ) {
-        *(coordp++)= qh_divzero (*(normp++), facet->offset, qh MINdenom_1,
-				 &zerodiv) + *(feasiblep++);
+      for (k=qh hull_dim; k--; ) {
+        *(coordp++)= qh_divzero(*(normp++), facet->offset, qh MINdenom_1,
+                                 &zerodiv) + *(feasiblep++);
         if (zerodiv) {
-          qh_memfree (point, qh normal_size);
+          qh_memfree(point, qh normal_size);
           goto LABELprintinfinite;
         }
       }
     }
-    qh_printpoint (fp, NULL, point);
-    qh_memfree (point, qh normal_size);
+    qh_printpoint(fp, NULL, point);
+    qh_memfree(point, qh normal_size);
     break;
   LABELprintinfinite:
-    for (k= qh hull_dim; k--; )
-      fprintf (fp, qh_REAL_1, qh_INFINITE);
-    fprintf (fp, "\n");   
+    for (k=qh hull_dim; k--; )
+      qh_fprintf(fp, 9026, qh_REAL_1, qh_INFINITE);
+    qh_fprintf(fp, 9027, "\n");
     break;
   case qh_PRINTpointnearest:
     FOREACHpoint_(facet->coplanarset) {
       int id, id2;
-      vertex= qh_nearvertex (facet, point, &dist);
-      id= qh_pointid (vertex->point);
-      id2= qh_pointid (point);
-      fprintf (fp, "%d %d %d " qh_REAL_1 "\n", id, id2, facet->id, dist);
+      vertex= qh_nearvertex(facet, point, &dist);
+      id= qh_pointid(vertex->point);
+      id2= qh_pointid(point);
+      qh_fprintf(fp, 9028, "%d %d %d " qh_REAL_1 "\n", id, id2, facet->id, dist);
     }
     break;
   case qh_PRINTpoints:  /* VORONOI only by qh_printbegin */
     if (qh CDDoutput)
-      fprintf (fp, "1 ");
-    qh_printcenter (fp, format, NULL, facet);
+      qh_fprintf(fp, 9029, "1 ");
+    qh_printcenter(fp, format, NULL, facet);
     break;
   case qh_PRINTvertices:
-    fprintf (fp, "%d", qh_setsize (facet->vertices));
+    qh_fprintf(fp, 9030, "%d", qh_setsize(facet->vertices));
     FOREACHvertex_(facet->vertices)
-      fprintf (fp, " %d", qh_pointid (vertex->point));
-    fprintf (fp, "\n");
+      qh_fprintf(fp, 9031, " %d", qh_pointid(vertex->point));
+    qh_fprintf(fp, 9032, "\n");
     break;
+  default:
+    break;
   }
 } /* printafacet */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printbegin">-</a>
-  
+
   qh_printbegin(  )
     prints header for all output formats
 
   returns:
     checks for valid format
-  
+
   notes:
     uses qh.visit_id for 3/4off
     changes qh.interior_point if printing centrums
     qh_countfacets clears facet->visitid for non-good facets
-    
+
   see
     qh_printend() and qh_printafacet()
-    
+
   design:
     count facets and related statistics
     print header for format
 */
-void qh_printbegin (FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall) {
+void qh_printbegin(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
   int numfacets, numsimplicial, numridges, totneighbors, numcoplanars, numtricoplanars;
   int i, num;
   facetT *facet, **facetp;
@@ -1246,98 +1313,101 @@
   pointT *point, **pointp, *pointtemp;
 
   qh printoutnum= 0;
-  qh_countfacets (facetlist, facets, printall, &numfacets, &numsimplicial, 
+  qh_countfacets(facetlist, facets, printall, &numfacets, &numsimplicial,
       &totneighbors, &numridges, &numcoplanars, &numtricoplanars);
   switch (format) {
   case qh_PRINTnone:
     break;
   case qh_PRINTarea:
-    fprintf (fp, "%d\n", numfacets);
+    qh_fprintf(fp, 9033, "%d\n", numfacets);
     break;
   case qh_PRINTcoplanars:
-    fprintf (fp, "%d\n", numfacets);
+    qh_fprintf(fp, 9034, "%d\n", numfacets);
     break;
   case qh_PRINTcentrums:
     if (qh CENTERtype == qh_ASnone)
-      qh_clearcenters (qh_AScentrum);
-    fprintf (fp, "%d\n%d\n", qh hull_dim, numfacets);
+      qh_clearcenters(qh_AScentrum);
+    qh_fprintf(fp, 9035, "%d\n%d\n", qh hull_dim, numfacets);
     break;
   case qh_PRINTfacets:
   case qh_PRINTfacets_xridge:
     if (facetlist)
-      qh_printvertexlist (fp, "Vertices and facets:\n", facetlist, facets, printall);
+      qh_printvertexlist(fp, "Vertices and facets:\n", facetlist, facets, printall);
     break;
-  case qh_PRINTgeom: 
+  case qh_PRINTgeom:
     if (qh hull_dim > 4)  /* qh_initqhull_globals also checks */
       goto LABELnoformat;
     if (qh VORONOI && qh hull_dim > 3)  /* PRINTdim == DROPdim == hull_dim-1 */
       goto LABELnoformat;
     if (qh hull_dim == 2 && (qh PRINTridges || qh DOintersections))
-      fprintf (qh ferr, "qhull warning: output for ridges and intersections not implemented in 2-d\n");
+      qh_fprintf(qh ferr, 7049, "qhull warning: output for ridges and intersections not implemented in 2-d\n");
     if (qh hull_dim == 4 && (qh PRINTinner || qh PRINTouter ||
-			     (qh PRINTdim == 4 && qh PRINTcentrums)))
-      fprintf (qh ferr, "qhull warning: output for outer/inner planes and centrums not implemented in 4-d\n");
+                             (qh PRINTdim == 4 && qh PRINTcentrums)))
+      qh_fprintf(qh ferr, 7050, "qhull warning: output for outer/inner planes and centrums not implemented in 4-d\n");
     if (qh PRINTdim == 4 && (qh PRINTspheres))
-      fprintf (qh ferr, "qhull warning: output for vertices not implemented in 4-d\n");
+      qh_fprintf(qh ferr, 7051, "qhull warning: output for vertices not implemented in 4-d\n");
     if (qh PRINTdim == 4 && qh DOintersections && qh PRINTnoplanes)
-      fprintf (qh ferr, "qhull warning: 'Gnh' generates no output in 4-d\n");
+      qh_fprintf(qh ferr, 7052, "qhull warning: 'Gnh' generates no output in 4-d\n");
     if (qh PRINTdim == 2) {
-      fprintf(fp, "{appearance {linewidth 3} LIST # %s | %s\n",
-	      qh rbox_command, qh qhull_command);
+      qh_fprintf(fp, 9036, "{appearance {linewidth 3} LIST # %s | %s\n",
+              qh rbox_command, qh qhull_command);
     }else if (qh PRINTdim == 3) {
-      fprintf(fp, "{appearance {+edge -evert linewidth 2} LIST # %s | %s\n",
-	      qh rbox_command, qh qhull_command);
+      qh_fprintf(fp, 9037, "{appearance {+edge -evert linewidth 2} LIST # %s | %s\n",
+              qh rbox_command, qh qhull_command);
     }else if (qh PRINTdim == 4) {
       qh visit_id++;
       num= 0;
       FORALLfacet_(facetlist)    /* get number of ridges to be printed */
-        qh_printend4geom (NULL, facet, &num, printall);
+        qh_printend4geom(NULL, facet, &num, printall);
       FOREACHfacet_(facets)
-        qh_printend4geom (NULL, facet, &num, printall);
+        qh_printend4geom(NULL, facet, &num, printall);
       qh ridgeoutnum= num;
       qh printoutvar= 0;  /* counts number of ridges in output */
-      fprintf (fp, "LIST # %s | %s\n", qh rbox_command, qh qhull_command);
+      qh_fprintf(fp, 9038, "LIST # %s | %s\n", qh rbox_command, qh qhull_command);
     }
+
     if (qh PRINTdots) {
       qh printoutnum++;
-      num= qh num_points + qh_setsize (qh other_points);
+      num= qh num_points + qh_setsize(qh other_points);
       if (qh DELAUNAY && qh ATinfinity)
-	num--;
+        num--;
       if (qh PRINTdim == 4)
-        fprintf (fp, "4VECT %d %d 1\n", num, num);
+        qh_fprintf(fp, 9039, "4VECT %d %d 1\n", num, num);
       else
-	fprintf (fp, "VECT %d %d 1\n", num, num);
-      for (i= num; i--; ) {
+        qh_fprintf(fp, 9040, "VECT %d %d 1\n", num, num);
+
+      for (i=num; i--; ) {
         if (i % 20 == 0)
-          fprintf (fp, "\n");
-	fprintf (fp, "1 ");
+          qh_fprintf(fp, 9041, "\n");
+        qh_fprintf(fp, 9042, "1 ");
       }
-      fprintf (fp, "# 1 point per line\n1 ");
-      for (i= num-1; i--; ) {
+      qh_fprintf(fp, 9043, "# 1 point per line\n1 ");
+      for (i=num-1; i--; ) { /* num at least 3 for D2 */
         if (i % 20 == 0)
-          fprintf (fp, "\n");
-	fprintf (fp, "0 ");
+          qh_fprintf(fp, 9044, "\n");
+        qh_fprintf(fp, 9045, "0 ");
       }
-      fprintf (fp, "# 1 color for all\n");
+      qh_fprintf(fp, 9046, "# 1 color for all\n");
       FORALLpoints {
         if (!qh DELAUNAY || !qh ATinfinity || qh_pointid(point) != qh num_points-1) {
-	  if (qh PRINTdim == 4)
-	    qh_printpoint (fp, NULL, point);
-	  else
-	    qh_printpoint3 (fp, point);
-	}
+          if (qh PRINTdim == 4)
+            qh_printpoint(fp, NULL, point);
+            else
+              qh_printpoint3 (fp, point);
+        }
       }
       FOREACHpoint_(qh other_points) {
-	if (qh PRINTdim == 4)
-	  qh_printpoint (fp, NULL, point);
-	else
-	  qh_printpoint3 (fp, point);
+        if (qh PRINTdim == 4)
+          qh_printpoint(fp, NULL, point);
+        else
+          qh_printpoint3 (fp, point);
       }
-      fprintf (fp, "0 1 1 1  # color of points\n");
+      qh_fprintf(fp, 9047, "0 1 1 1  # color of points\n");
     }
+
     if (qh PRINTdim == 4  && !qh PRINTnoplanes)
       /* 4dview loads up multiple 4OFF objects slowly */
-      fprintf(fp, "4OFF %d %d 1\n", 3*qh ridgeoutnum, qh ridgeoutnum);
+      qh_fprintf(fp, 9048, "4OFF %d %d 1\n", 3*qh ridgeoutnum, qh ridgeoutnum);
     qh PRINTcradius= 2 * qh DISTround;  /* include test DISTround */
     if (qh PREmerge) {
       maximize_(qh PRINTcradius, qh premerge_centrum + qh DISTround);
@@ -1351,98 +1421,97 @@
     }else if (!qh PREmerge && qh POSTmerge && qh postmerge_cos < REALmax/2) {
       maximize_(qh PRINTradius, (1- qh postmerge_cos) * qh MAXabs_coord);
     }
-    maximize_(qh PRINTradius, qh MINvisible); 
+    maximize_(qh PRINTradius, qh MINvisible);
     if (qh JOGGLEmax < REALmax/2)
-      qh PRINTradius += qh JOGGLEmax * sqrt (qh hull_dim);
+      qh PRINTradius += qh JOGGLEmax * sqrt((realT)qh hull_dim);
     if (qh PRINTdim != 4 &&
-	(qh PRINTcoplanar || qh PRINTspheres || qh PRINTcentrums)) {
-      vertices= qh_facetvertices (facetlist, facets, printall);
+        (qh PRINTcoplanar || qh PRINTspheres || qh PRINTcentrums)) {
+      vertices= qh_facetvertices(facetlist, facets, printall);
       if (qh PRINTspheres && qh PRINTdim <= 3)
-         qh_printspheres (fp, vertices, qh PRINTradius);
+        qh_printspheres(fp, vertices, qh PRINTradius);
       if (qh PRINTcoplanar || qh PRINTcentrums) {
         qh firstcentrum= True;
         if (qh PRINTcoplanar&& !qh PRINTspheres) {
-          FOREACHvertex_(vertices) 
-            qh_printpointvect2 (fp, vertex->point, NULL,
-				qh interior_point, qh PRINTradius);
-	}
+          FOREACHvertex_(vertices)
+            qh_printpointvect2 (fp, vertex->point, NULL, qh interior_point, qh PRINTradius);
+        }
         FORALLfacet_(facetlist) {
-	  if (!printall && qh_skipfacet(facet))
-	    continue;
-	  if (!facet->normal)
-	    continue;
+          if (!printall && qh_skipfacet(facet))
+            continue;
+          if (!facet->normal)
+            continue;
           if (qh PRINTcentrums && qh PRINTdim <= 3)
-            qh_printcentrum (fp, facet, qh PRINTcradius);
-	  if (!qh PRINTcoplanar)
-	    continue;
+            qh_printcentrum(fp, facet, qh PRINTcradius);
+          if (!qh PRINTcoplanar)
+            continue;
           FOREACHpoint_(facet->coplanarset)
             qh_printpointvect2 (fp, point, facet->normal, NULL, qh PRINTradius);
           FOREACHpoint_(facet->outsideset)
             qh_printpointvect2 (fp, point, facet->normal, NULL, qh PRINTradius);
         }
         FOREACHfacet_(facets) {
-	  if (!printall && qh_skipfacet(facet))
-	    continue;
-	  if (!facet->normal)
-	    continue;
+          if (!printall && qh_skipfacet(facet))
+            continue;
+          if (!facet->normal)
+            continue;
           if (qh PRINTcentrums && qh PRINTdim <= 3)
-            qh_printcentrum (fp, facet, qh PRINTcradius);
-	  if (!qh PRINTcoplanar)
-	    continue;
+            qh_printcentrum(fp, facet, qh PRINTcradius);
+          if (!qh PRINTcoplanar)
+            continue;
           FOREACHpoint_(facet->coplanarset)
             qh_printpointvect2 (fp, point, facet->normal, NULL, qh PRINTradius);
           FOREACHpoint_(facet->outsideset)
             qh_printpointvect2 (fp, point, facet->normal, NULL, qh PRINTradius);
         }
       }
-      qh_settempfree (&vertices);
+      qh_settempfree(&vertices);
     }
     qh visit_id++; /* for printing hyperplane intersections */
     break;
   case qh_PRINTids:
-    fprintf (fp, "%d\n", numfacets);
+    qh_fprintf(fp, 9049, "%d\n", numfacets);
     break;
   case qh_PRINTincidences:
     if (qh VORONOI && qh PRINTprecision)
-      fprintf (qh ferr, "qhull warning: writing Delaunay.  Use 'p' or 'o' for Voronoi centers\n");
+      qh_fprintf(qh ferr, 7053, "qhull warning: writing Delaunay.  Use 'p' or 'o' for Voronoi centers\n");
     qh printoutvar= qh vertex_id;  /* centrum id for non-simplicial facets */
     if (qh hull_dim <= 3)
-      fprintf(fp, "%d\n", numfacets);
+      qh_fprintf(fp, 9050, "%d\n", numfacets);
     else
-      fprintf(fp, "%d\n", numsimplicial+numridges);
+      qh_fprintf(fp, 9051, "%d\n", numsimplicial+numridges);
     break;
   case qh_PRINTinner:
   case qh_PRINTnormals:
   case qh_PRINTouter:
     if (qh CDDoutput)
-      fprintf (fp, "%s | %s\nbegin\n    %d %d real\n", qh rbox_command, 
-              qh qhull_command, numfacets, qh hull_dim+1);
+      qh_fprintf(fp, 9052, "%s | %s\nbegin\n    %d %d real\n", qh rbox_command,
+            qh qhull_command, numfacets, qh hull_dim+1);
     else
-      fprintf (fp, "%d\n%d\n", qh hull_dim+1, numfacets);
+      qh_fprintf(fp, 9053, "%d\n%d\n", qh hull_dim+1, numfacets);
     break;
-  case qh_PRINTmathematica:  
+  case qh_PRINTmathematica:
   case qh_PRINTmaple:
     if (qh hull_dim > 3)  /* qh_initbuffers also checks */
       goto LABELnoformat;
     if (qh VORONOI)
-      fprintf (qh ferr, "qhull warning: output is the Delaunay triangulation\n");
+      qh_fprintf(qh ferr, 7054, "qhull warning: output is the Delaunay triangulation\n");
     if (format == qh_PRINTmaple) {
       if (qh hull_dim == 2)
-	fprintf(fp, "PLOT(CURVES(\n");
+        qh_fprintf(fp, 9054, "PLOT(CURVES(\n");
       else
-	fprintf(fp, "PLOT3D(POLYGONS(\n");
+        qh_fprintf(fp, 9055, "PLOT3D(POLYGONS(\n");
     }else
-      fprintf(fp, "{\n");
+      qh_fprintf(fp, 9056, "{\n");
     qh printoutvar= 0;   /* counts number of facets for notfirst */
     break;
   case qh_PRINTmerges:
-    fprintf (fp, "%d\n", numfacets);
+    qh_fprintf(fp, 9057, "%d\n", numfacets);
     break;
   case qh_PRINTpointintersect:
-    fprintf (fp, "%d\n%d\n", qh hull_dim, numfacets);
+    qh_fprintf(fp, 9058, "%d\n%d\n", qh hull_dim, numfacets);
     break;
   case qh_PRINTneighbors:
-    fprintf (fp, "%d\n", numfacets);
+    qh_fprintf(fp, 9059, "%d\n", numfacets);
     break;
   case qh_PRINToff:
   case qh_PRINTtriangles:
@@ -1450,53 +1519,53 @@
       goto LABELnoformat;
     num = qh hull_dim;
     if (format == qh_PRINToff || qh hull_dim == 2)
-      fprintf (fp, "%d\n%d %d %d\n", num, 
-        qh num_points+qh_setsize (qh other_points), numfacets, totneighbors/2);
+      qh_fprintf(fp, 9060, "%d\n%d %d %d\n", num,
+        qh num_points+qh_setsize(qh other_points), numfacets, totneighbors/2);
     else { /* qh_PRINTtriangles */
-      qh printoutvar= qh num_points+qh_setsize (qh other_points); /* first centrum */
+      qh printoutvar= qh num_points+qh_setsize(qh other_points); /* first centrum */
       if (qh DELAUNAY)
         num--;  /* drop last dimension */
-      fprintf (fp, "%d\n%d %d %d\n", num, qh printoutvar 
-	+ numfacets - numsimplicial, numsimplicial + numridges, totneighbors/2);
+      qh_fprintf(fp, 9061, "%d\n%d %d %d\n", num, qh printoutvar
+        + numfacets - numsimplicial, numsimplicial + numridges, totneighbors/2);
     }
     FORALLpoints
-      qh_printpointid (qh fout, NULL, num, point, -1);
+      qh_printpointid(qh fout, NULL, num, point, -1);
     FOREACHpoint_(qh other_points)
-      qh_printpointid (qh fout, NULL, num, point, -1);
+      qh_printpointid(qh fout, NULL, num, point, -1);
     if (format == qh_PRINTtriangles && qh hull_dim > 2) {
       FORALLfacets {
-	if (!facet->simplicial && facet->visitid)
-          qh_printcenter (qh fout, format, NULL, facet);
+        if (!facet->simplicial && facet->visitid)
+          qh_printcenter(qh fout, format, NULL, facet);
       }
     }
     break;
   case qh_PRINTpointnearest:
-    fprintf (fp, "%d\n", numcoplanars);
+    qh_fprintf(fp, 9062, "%d\n", numcoplanars);
     break;
   case qh_PRINTpoints:
     if (!qh VORONOI)
       goto LABELnoformat;
     if (qh CDDoutput)
-      fprintf (fp, "%s | %s\nbegin\n%d %d real\n", qh rbox_command,
-             qh qhull_command, numfacets, qh hull_dim);
+      qh_fprintf(fp, 9063, "%s | %s\nbegin\n%d %d real\n", qh rbox_command,
+           qh qhull_command, numfacets, qh hull_dim);
     else
-      fprintf (fp, "%d\n%d\n", qh hull_dim-1, numfacets);
+      qh_fprintf(fp, 9064, "%d\n%d\n", qh hull_dim-1, numfacets);
     break;
   case qh_PRINTvertices:
-    fprintf (fp, "%d\n", numfacets);
+    qh_fprintf(fp, 9065, "%d\n", numfacets);
     break;
   case qh_PRINTsummary:
   default:
   LABELnoformat:
-    fprintf (qh ferr, "qhull internal error (qh_printbegin): can not use this format for dimension %d\n",
+    qh_fprintf(qh ferr, 6068, "qhull internal error (qh_printbegin): can not use this format for dimension %d\n",
          qh hull_dim);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
 } /* printbegin */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printcenter">-</a>
-  
+
   qh_printcenter( fp, string, facet )
     print facet->center as centrum or Voronoi center
     string may be NULL.  Don't include '%' codes.
@@ -1507,43 +1576,44 @@
   notes:
     defines facet->center if needed
     if format=PRINTgeom, adds a 0 if would otherwise be 2-d
+    Same as QhullFacet::printCenter
 */
-void qh_printcenter (FILE *fp, int format, char *string, facetT *facet) {
+void qh_printcenter(FILE *fp, qh_PRINT format, const char *string, facetT *facet) {
   int k, num;
 
   if (qh CENTERtype != qh_ASvoronoi && qh CENTERtype != qh_AScentrum)
     return;
   if (string)
-    fprintf (fp, string, facet->id);
+    qh_fprintf(fp, 9066, string);
   if (qh CENTERtype == qh_ASvoronoi) {
     num= qh hull_dim-1;
     if (!facet->normal || !facet->upperdelaunay || !qh ATinfinity) {
       if (!facet->center)
-        facet->center= qh_facetcenter (facet->vertices);
+        facet->center= qh_facetcenter(facet->vertices);
       for (k=0; k < num; k++)
-        fprintf (fp, qh_REAL_1, facet->center[k]);
+        qh_fprintf(fp, 9067, qh_REAL_1, facet->center[k]);
     }else {
       for (k=0; k < num; k++)
-        fprintf (fp, qh_REAL_1, qh_INFINITE);
+        qh_fprintf(fp, 9068, qh_REAL_1, qh_INFINITE);
     }
   }else /* qh CENTERtype == qh_AScentrum */ {
     num= qh hull_dim;
-    if (format == qh_PRINTtriangles && qh DELAUNAY) 
+    if (format == qh_PRINTtriangles && qh DELAUNAY)
       num--;
-    if (!facet->center) 
-      facet->center= qh_getcentrum (facet);
+    if (!facet->center)
+      facet->center= qh_getcentrum(facet);
     for (k=0; k < num; k++)
-      fprintf (fp, qh_REAL_1, facet->center[k]);
+      qh_fprintf(fp, 9069, qh_REAL_1, facet->center[k]);
   }
   if (format == qh_PRINTgeom && num == 2)
-    fprintf (fp, " 0\n");
+    qh_fprintf(fp, 9070, " 0\n");
   else
-    fprintf (fp, "\n");
+    qh_fprintf(fp, 9071, "\n");
 } /* printcenter */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printcentrum">-</a>
-  
+
   qh_printcentrum( fp, facet, radius )
     print centrum for a facet in OOGL format
     radius defines size of centrum
@@ -1552,36 +1622,36 @@
   returns:
     defines facet->center if needed
 */
-void qh_printcentrum (FILE *fp, facetT *facet, realT radius) {
+void qh_printcentrum(FILE *fp, facetT *facet, realT radius) {
   pointT *centrum, *projpt;
   boolT tempcentrum= False;
   realT xaxis[4], yaxis[4], normal[4], dist;
   realT green[3]={0, 1, 0};
   vertexT *apex;
   int k;
-  
+
   if (qh CENTERtype == qh_AScentrum) {
     if (!facet->center)
-      facet->center= qh_getcentrum (facet);
+      facet->center= qh_getcentrum(facet);
     centrum= facet->center;
   }else {
-    centrum= qh_getcentrum (facet);
+    centrum= qh_getcentrum(facet);
     tempcentrum= True;
   }
-  fprintf (fp, "{appearance {-normal -edge normscale 0} ");
+  qh_fprintf(fp, 9072, "{appearance {-normal -edge normscale 0} ");
   if (qh firstcentrum) {
     qh firstcentrum= False;
-    fprintf (fp, "{INST geom { define centrum CQUAD  # f%d\n\
+    qh_fprintf(fp, 9073, "{INST geom { define centrum CQUAD  # f%d\n\
 -0.3 -0.3 0.0001     0 0 1 1\n\
  0.3 -0.3 0.0001     0 0 1 1\n\
  0.3  0.3 0.0001     0 0 1 1\n\
 -0.3  0.3 0.0001     0 0 1 1 } transform { \n", facet->id);
   }else
-    fprintf (fp, "{INST geom { : centrum } transform { # f%d\n", facet->id);
+    qh_fprintf(fp, 9074, "{INST geom { : centrum } transform { # f%d\n", facet->id);
   apex= SETfirstt_(facet->vertices, vertexT);
   qh_distplane(apex->point, facet, &dist);
   projpt= qh_projectpoint(apex->point, facet, dist);
-  for (k= qh hull_dim; k--; ) {
+  for (k=qh hull_dim; k--; ) {
     xaxis[k]= projpt[k] - centrum[k];
     normal[k]= facet->normal[k];
   }
@@ -1593,78 +1663,80 @@
     qh_projectdim3 (normal, normal);
     qh_normalize2 (normal, qh PRINTdim, True, NULL, NULL);
   }
-  qh_crossproduct (3, xaxis, normal, yaxis);
-  fprintf (fp, "%8.4g %8.4g %8.4g 0\n", xaxis[0], xaxis[1], xaxis[2]);
-  fprintf (fp, "%8.4g %8.4g %8.4g 0\n", yaxis[0], yaxis[1], yaxis[2]);
-  fprintf (fp, "%8.4g %8.4g %8.4g 0\n", normal[0], normal[1], normal[2]);
+  qh_crossproduct(3, xaxis, normal, yaxis);
+  qh_fprintf(fp, 9075, "%8.4g %8.4g %8.4g 0\n", xaxis[0], xaxis[1], xaxis[2]);
+  qh_fprintf(fp, 9076, "%8.4g %8.4g %8.4g 0\n", yaxis[0], yaxis[1], yaxis[2]);
+  qh_fprintf(fp, 9077, "%8.4g %8.4g %8.4g 0\n", normal[0], normal[1], normal[2]);
   qh_printpoint3 (fp, centrum);
-  fprintf (fp, "1 }}}\n"); 
-  qh_memfree (projpt, qh normal_size);
-  qh_printpointvect (fp, centrum, facet->normal, NULL, radius, green);
+  qh_fprintf(fp, 9078, "1 }}}\n");
+  qh_memfree(projpt, qh normal_size);
+  qh_printpointvect(fp, centrum, facet->normal, NULL, radius, green);
   if (tempcentrum)
-    qh_memfree (centrum, qh normal_size);
+    qh_memfree(centrum, qh normal_size);
 } /* printcentrum */
-  
+
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printend">-</a>
-  
+
   qh_printend( fp, format )
     prints trailer for all output formats
 
   see:
     qh_printbegin() and qh_printafacet()
-      
+
 */
-void qh_printend (FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall) {
+void qh_printend(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
   int num;
   facetT *facet, **facetp;
 
   if (!qh printoutnum)
-    fprintf (qh ferr, "qhull warning: no facets printed\n");
+    qh_fprintf(qh ferr, 7055, "qhull warning: no facets printed\n");
   switch (format) {
   case qh_PRINTgeom:
     if (qh hull_dim == 4 && qh DROPdim < 0  && !qh PRINTnoplanes) {
       qh visit_id++;
       num= 0;
       FORALLfacet_(facetlist)
-        qh_printend4geom (fp, facet,&num, printall);
-      FOREACHfacet_(facets) 
-        qh_printend4geom (fp, facet, &num, printall);
+        qh_printend4geom(fp, facet,&num, printall);
+      FOREACHfacet_(facets)
+        qh_printend4geom(fp, facet, &num, printall);
       if (num != qh ridgeoutnum || qh printoutvar != qh ridgeoutnum) {
-	fprintf (qh ferr, "qhull internal error (qh_printend): number of ridges %d != number printed %d and at end %d\n", qh ridgeoutnum, qh printoutvar, num);
-	qh_errexit (qh_ERRqhull, NULL, NULL);
+        qh_fprintf(qh ferr, 6069, "qhull internal error (qh_printend): number of ridges %d != number printed %d and at end %d\n", qh ridgeoutnum, qh printoutvar, num);
+        qh_errexit(qh_ERRqhull, NULL, NULL);
       }
     }else
-      fprintf(fp, "}\n");
+      qh_fprintf(fp, 9079, "}\n");
     break;
   case qh_PRINTinner:
   case qh_PRINTnormals:
   case qh_PRINTouter:
-    if (qh CDDoutput) 
-      fprintf (fp, "end\n");
+    if (qh CDDoutput)
+      qh_fprintf(fp, 9080, "end\n");
     break;
   case qh_PRINTmaple:
-    fprintf(fp, "));\n");
+    qh_fprintf(fp, 9081, "));\n");
     break;
   case qh_PRINTmathematica:
-    fprintf(fp, "}\n");
+    qh_fprintf(fp, 9082, "}\n");
     break;
   case qh_PRINTpoints:
     if (qh CDDoutput)
-      fprintf (fp, "end\n");
+      qh_fprintf(fp, 9083, "end\n");
     break;
+  default:
+    break;
   }
 } /* printend */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printend4geom">-</a>
-  
+
   qh_printend4geom( fp, facet, numridges, printall )
     helper function for qh_printbegin/printend
 
   returns:
     number of printed ridges
-  
+
   notes:
     just counts printed ridges if fp=NULL
     uses facet->visitid
@@ -1672,14 +1744,14 @@
 
   design:
     computes color for facet from its normal
-    prints each ridge of facet 
+    prints each ridge of facet
 */
-void qh_printend4geom (FILE *fp, facetT *facet, int *nump, boolT printall) {
+void qh_printend4geom(FILE *fp, facetT *facet, int *nump, boolT printall) {
   realT color[3];
   int i, num= *nump;
   facetT *neighbor, **neighborp;
   ridgeT *ridge, **ridgep;
-  
+
   if (!printall && qh_skipfacet(facet))
     return;
   if (qh PRINTnoplanes || (facet->visible && qh NEWfacets))
@@ -1697,22 +1769,22 @@
   if (facet->simplicial) {
     FOREACHneighbor_(facet) {
       if (neighbor->visitid != qh visit_id) {
-	if (fp)
-          fprintf (fp, "3 %d %d %d %8.4g %8.4g %8.4g 1 # f%d f%d\n",
-		 3*num, 3*num+1, 3*num+2, color[0], color[1], color[2],
-		 facet->id, neighbor->id);
-	num++;
+        if (fp)
+          qh_fprintf(fp, 9084, "3 %d %d %d %8.4g %8.4g %8.4g 1 # f%d f%d\n",
+                 3*num, 3*num+1, 3*num+2, color[0], color[1], color[2],
+                 facet->id, neighbor->id);
+        num++;
       }
     }
   }else {
     FOREACHridge_(facet->ridges) {
       neighbor= otherfacet_(ridge, facet);
       if (neighbor->visitid != qh visit_id) {
-	if (fp)
-          fprintf (fp, "3 %d %d %d %8.4g %8.4g %8.4g 1 #r%d f%d f%d\n",
-		 3*num, 3*num+1, 3*num+2, color[0], color[1], color[2],
-		 ridge->id, facet->id, neighbor->id);
-	num++;
+        if (fp)
+          qh_fprintf(fp, 9085, "3 %d %d %d %8.4g %8.4g %8.4g 1 #r%d f%d f%d\n",
+                 3*num, 3*num+1, 3*num+2, color[0], color[1], color[2],
+                 ridge->id, facet->id, neighbor->id);
+        num++;
       }
     }
   }
@@ -1721,46 +1793,46 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printextremes">-</a>
-  
+
   qh_printextremes( fp, facetlist, facets, printall )
     print extreme points for convex hulls or halfspace intersections
 
   notes:
     #points, followed by ids, one per line
-    
+
     sorted by id
     same order as qh_printpoints_out if no coplanar/interior points
 */
-void qh_printextremes (FILE *fp, facetT *facetlist, setT *facets, int printall) {
+void qh_printextremes(FILE *fp, facetT *facetlist, setT *facets, boolT printall) {
   setT *vertices, *points;
   pointT *point;
   vertexT *vertex, **vertexp;
   int id;
   int numpoints=0, point_i, point_n;
-  int allpoints= qh num_points + qh_setsize (qh other_points);
+  int allpoints= qh num_points + qh_setsize(qh other_points);
 
-  points= qh_settemp (allpoints);
-  qh_setzero (points, 0, allpoints);
-  vertices= qh_facetvertices (facetlist, facets, printall);
+  points= qh_settemp(allpoints);
+  qh_setzero(points, 0, allpoints);
+  vertices= qh_facetvertices(facetlist, facets, printall);
   FOREACHvertex_(vertices) {
-    id= qh_pointid (vertex->point);
+    id= qh_pointid(vertex->point);
     if (id >= 0) {
       SETelem_(points, id)= vertex->point;
       numpoints++;
     }
   }
-  qh_settempfree (&vertices);
-  fprintf (fp, "%d\n", numpoints);
+  qh_settempfree(&vertices);
+  qh_fprintf(fp, 9086, "%d\n", numpoints);
   FOREACHpoint_i_(points) {
-    if (point) 
-      fprintf (fp, "%d\n", point_i);
+    if (point)
+      qh_fprintf(fp, 9087, "%d\n", point_i);
   }
-  qh_settempfree (&points);
+  qh_settempfree(&points);
 } /* printextremes */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printextremes_2d">-</a>
-  
+
   qh_printextremes_2d( fp, facetlist, facets, printall )
     prints point ids for facets in qh_ORIENTclock order
 
@@ -1770,17 +1842,17 @@
     errors if facets form a loop
     does not print coplanar points
 */
-void qh_printextremes_2d (FILE *fp, facetT *facetlist, setT *facets, int printall) {
+void qh_printextremes_2d(FILE *fp, facetT *facetlist, setT *facets, boolT printall) {
   int numfacets, numridges, totneighbors, numcoplanars, numsimplicial, numtricoplanars;
   setT *vertices;
   facetT *facet, *startfacet, *nextfacet;
   vertexT *vertexA, *vertexB;
 
-  qh_countfacets (facetlist, facets, printall, &numfacets, &numsimplicial, 
+  qh_countfacets(facetlist, facets, printall, &numfacets, &numsimplicial,
       &totneighbors, &numridges, &numcoplanars, &numtricoplanars); /* marks qh visit_id */
-  vertices= qh_facetvertices (facetlist, facets, printall);
-  fprintf(fp, "%d\n", qh_setsize (vertices));
-  qh_settempfree (&vertices);
+  vertices= qh_facetvertices(facetlist, facets, printall);
+  qh_fprintf(fp, 9088, "%d\n", qh_setsize(vertices));
+  qh_settempfree(&vertices);
   if (!numfacets)
     return;
   facet= startfacet= facetlist ? facetlist : SETfirstt_(facets, facetT);
@@ -1797,18 +1869,18 @@
       nextfacet= SETsecondt_(facet->neighbors, facetT);
     }
     if (facet->visitid == qh visit_id) {
-      fprintf(qh ferr, "qh_printextremes_2d: loop in facet list.  facet %d nextfacet %d\n",
+      qh_fprintf(qh ferr, 6218, "Qhull internal error (qh_printextremes_2d): loop in facet list.  facet %d nextfacet %d\n",
                  facet->id, nextfacet->id);
       qh_errexit2 (qh_ERRqhull, facet, nextfacet);
     }
     if (facet->visitid) {
       if (vertexA->visitid != qh vertex_visit) {
-	vertexA->visitid= qh vertex_visit;
-	fprintf(fp, "%d\n", qh_pointid (vertexA->point));
+        vertexA->visitid= qh vertex_visit;
+        qh_fprintf(fp, 9089, "%d\n", qh_pointid(vertexA->point));
       }
       if (vertexB->visitid != qh vertex_visit) {
-	vertexB->visitid= qh vertex_visit;
-	fprintf(fp, "%d\n", qh_pointid (vertexB->point));
+        vertexB->visitid= qh vertex_visit;
+        qh_fprintf(fp, 9090, "%d\n", qh_pointid(vertexB->point));
       }
     }
     facet->visitid= qh visit_id;
@@ -1818,23 +1890,23 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printextremes_d">-</a>
-  
+
   qh_printextremes_d( fp, facetlist, facets, printall )
     print extreme points of input sites for Delaunay triangulations
 
   notes:
     #points, followed by ids, one per line
-    
+
     unordered
 */
-void qh_printextremes_d (FILE *fp, facetT *facetlist, setT *facets, int printall) {
+void qh_printextremes_d(FILE *fp, facetT *facetlist, setT *facets, boolT printall) {
   setT *vertices;
   vertexT *vertex, **vertexp;
   boolT upperseen, lowerseen;
   facetT *neighbor, **neighborp;
   int numpoints=0;
 
-  vertices= qh_facetvertices (facetlist, facets, printall);
+  vertices= qh_facetvertices(facetlist, facets, printall);
   qh_vertexneighbors();
   FOREACHvertex_(vertices) {
     upperseen= lowerseen= False;
@@ -1850,17 +1922,17 @@
     }else
       vertex->seen= False;
   }
-  fprintf (fp, "%d\n", numpoints);
+  qh_fprintf(fp, 9091, "%d\n", numpoints);
   FOREACHvertex_(vertices) {
     if (vertex->seen)
-      fprintf (fp, "%d\n", qh_pointid (vertex->point));
+      qh_fprintf(fp, 9092, "%d\n", qh_pointid(vertex->point));
   }
-  qh_settempfree (&vertices);
+  qh_settempfree(&vertices);
 } /* printextremes_d */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet">-</a>
-  
+
   qh_printfacet( fp, facet )
     prints all fields of a facet to fp
 
@@ -1869,18 +1941,18 @@
 */
 void qh_printfacet(FILE *fp, facetT *facet) {
 
-  qh_printfacetheader (fp, facet);
+  qh_printfacetheader(fp, facet);
   if (facet->ridges)
-    qh_printfacetridges (fp, facet);
+    qh_printfacetridges(fp, facet);
 } /* printfacet */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet2geom">-</a>
-  
+
   qh_printfacet2geom( fp, facet, color )
     print facet as part of a 2-d VECT for Geomview
-  
+
     notes:
       assume precise calculations in io.c with roundoff covered by qh_GEOMepsilon
       mindist is calculated within io.c.  maxoutside is calculated elsewhere
@@ -1891,49 +1963,49 @@
   realT mindist, innerplane, outerplane;
   int k;
 
-  qh_facet2point (facet, &point0, &point1, &mindist);
-  qh_geomplanes (facet, &outerplane, &innerplane);
+  qh_facet2point(facet, &point0, &point1, &mindist);
+  qh_geomplanes(facet, &outerplane, &innerplane);
   if (qh PRINTouter || (!qh PRINTnoplanes && !qh PRINTinner))
     qh_printfacet2geom_points(fp, point0, point1, facet, outerplane, color);
   if (qh PRINTinner || (!qh PRINTnoplanes && !qh PRINTouter &&
                 outerplane - innerplane > 2 * qh MAXabs_coord * qh_GEOMepsilon)) {
-    for(k= 3; k--; )
+    for (k=3; k--; )
       color[k]= 1.0 - color[k];
     qh_printfacet2geom_points(fp, point0, point1, facet, innerplane, color);
   }
-  qh_memfree (point1, qh normal_size);
-  qh_memfree (point0, qh normal_size); 
+  qh_memfree(point1, qh normal_size);
+  qh_memfree(point0, qh normal_size);
 } /* printfacet2geom */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet2geom_points">-</a>
-  
+
   qh_printfacet2geom_points( fp, point1, point2, facet, offset, color )
-    prints a 2-d facet as a VECT with 2 points at some offset.   
+    prints a 2-d facet as a VECT with 2 points at some offset.
     The points are on the facet's plane.
 */
 void qh_printfacet2geom_points(FILE *fp, pointT *point1, pointT *point2,
-			       facetT *facet, realT offset, realT color[3]) {
+                               facetT *facet, realT offset, realT color[3]) {
   pointT *p1= point1, *p2= point2;
 
-  fprintf(fp, "VECT 1 2 1 2 1 # f%d\n", facet->id);
+  qh_fprintf(fp, 9093, "VECT 1 2 1 2 1 # f%d\n", facet->id);
   if (offset != 0.0) {
-    p1= qh_projectpoint (p1, facet, -offset);
-    p2= qh_projectpoint (p2, facet, -offset);
+    p1= qh_projectpoint(p1, facet, -offset);
+    p2= qh_projectpoint(p2, facet, -offset);
   }
-  fprintf(fp, "%8.4g %8.4g %8.4g\n%8.4g %8.4g %8.4g\n",
+  qh_fprintf(fp, 9094, "%8.4g %8.4g %8.4g\n%8.4g %8.4g %8.4g\n",
            p1[0], p1[1], 0.0, p2[0], p2[1], 0.0);
   if (offset != 0.0) {
-    qh_memfree (p1, qh normal_size);
-    qh_memfree (p2, qh normal_size);
+    qh_memfree(p1, qh normal_size);
+    qh_memfree(p2, qh normal_size);
   }
-  fprintf(fp, "%8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
+  qh_fprintf(fp, 9095, "%8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
 } /* printfacet2geom_points */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet2math">-</a>
-  
+
   qh_printfacet2math( fp, facet, format, notfirst )
     print 2-d Maple or Mathematica output for a facet
     may be non-simplicial
@@ -1942,30 +2014,30 @@
     use %16.8f since Mathematica 2.2 does not handle exponential format
     see qh_printfacet3math
 */
-void qh_printfacet2math(FILE *fp, facetT *facet, int format, int notfirst) {
+void qh_printfacet2math(FILE *fp, facetT *facet, qh_PRINT format, int notfirst) {
   pointT *point0, *point1;
   realT mindist;
-  char *pointfmt;
-  
-  qh_facet2point (facet, &point0, &point1, &mindist);
+  const char *pointfmt;
+
+  qh_facet2point(facet, &point0, &point1, &mindist);
   if (notfirst)
-    fprintf(fp, ",");
+    qh_fprintf(fp, 9096, ",");
   if (format == qh_PRINTmaple)
     pointfmt= "[[%16.8f, %16.8f], [%16.8f, %16.8f]]\n";
   else
     pointfmt= "Line[{{%16.8f, %16.8f}, {%16.8f, %16.8f}}]\n";
-  fprintf(fp, pointfmt, point0[0], point0[1], point1[0], point1[1]);
-  qh_memfree (point1, qh normal_size);
-  qh_memfree (point0, qh normal_size);
+  qh_fprintf(fp, 9097, pointfmt, point0[0], point0[1], point1[0], point1[1]);
+  qh_memfree(point1, qh normal_size);
+  qh_memfree(point0, qh normal_size);
 } /* printfacet2math */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet3geom_nonsimplicial">-</a>
-  
+
   qh_printfacet3geom_nonsimplicial( fp, facet, color )
     print Geomview OFF for a 3-d nonsimplicial facet.
-    if DOintersections, prints ridges to unvisited neighbors (qh visit_id) 
+    if DOintersections, prints ridges to unvisited neighbors(qh visit_id)
 
   notes
     uses facet->visitid for intersections and ridges
@@ -1980,15 +2052,15 @@
   int cntvertices, k;
   realT black[3]={0, 0, 0}, green[3]={0, 1, 0};
 
-  qh_geomplanes (facet, &outerplane, &innerplane); 
-  vertices= qh_facet3vertex (facet); /* oriented */
+  qh_geomplanes(facet, &outerplane, &innerplane);
+  vertices= qh_facet3vertex(facet); /* oriented */
   cntvertices= qh_setsize(vertices);
   projectedpoints= qh_settemp(cntvertices);
   FOREACHvertex_(vertices) {
     zinc_(Zdistio);
     qh_distplane(vertex->point, facet, &dist);
     projpt= qh_projectpoint(vertex->point, facet, dist);
-    qh_setappend (&projectedpoints, projpt);
+    qh_setappend(&projectedpoints, projpt);
   }
   if (qh PRINTouter || (!qh PRINTnoplanes && !qh PRINTinner))
     qh_printfacet3geom_points(fp, projectedpoints, facet, outerplane, color);
@@ -1999,7 +2071,7 @@
     qh_printfacet3geom_points(fp, projectedpoints, facet, innerplane, color);
   }
   FOREACHpoint_(projectedpoints)
-    qh_memfree (point, qh normal_size);
+    qh_memfree(point, qh normal_size);
   qh_settempfree(&projectedpoints);
   qh_settempfree(&vertices);
   if ((qh DOintersections || qh PRINTridges)
@@ -2013,7 +2085,7 @@
         if (qh PRINTridges) {
           vertexA= SETfirstt_(ridge->vertices, vertexT);
           vertexB= SETsecondt_(ridge->vertices, vertexT);
-          qh_printline3geom (fp, vertexA->point, vertexB->point, green);
+          qh_printline3geom(fp, vertexA->point, vertexB->point, green);
         }
       }
     }
@@ -2022,9 +2094,9 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet3geom_points">-</a>
-  
+
   qh_printfacet3geom_points( fp, points, facet, offset )
-    prints a 3-d facet as OFF Geomview object. 
+    prints a 3-d facet as OFF Geomview object.
     offset is relative to the facet's hyperplane
     Facet is determined as a list of points
 */
@@ -2033,36 +2105,36 @@
   pointT *point, **pointp;
   setT *printpoints;
 
-  fprintf(fp, "{ OFF %d 1 1 # f%d\n", n, facet->id);
+  qh_fprintf(fp, 9098, "{ OFF %d 1 1 # f%d\n", n, facet->id);
   if (offset != 0.0) {
-    printpoints= qh_settemp (n);
-    FOREACHpoint_(points) 
-      qh_setappend (&printpoints, qh_projectpoint(point, facet, -offset));
+    printpoints= qh_settemp(n);
+    FOREACHpoint_(points)
+      qh_setappend(&printpoints, qh_projectpoint(point, facet, -offset));
   }else
     printpoints= points;
   FOREACHpoint_(printpoints) {
     for (k=0; k < qh hull_dim; k++) {
       if (k == qh DROPdim)
-        fprintf(fp, "0 ");
+        qh_fprintf(fp, 9099, "0 ");
       else
-        fprintf(fp, "%8.4g ", point[k]);
+        qh_fprintf(fp, 9100, "%8.4g ", point[k]);
     }
     if (printpoints != points)
-      qh_memfree (point, qh normal_size);
-    fprintf (fp, "\n");
+      qh_memfree(point, qh normal_size);
+    qh_fprintf(fp, 9101, "\n");
   }
   if (printpoints != points)
-    qh_settempfree (&printpoints);
-  fprintf(fp, "%d ", n);
-  for(i= 0; i < n; i++)
-    fprintf(fp, "%d ", i);
-  fprintf(fp, "%8.4g %8.4g %8.4g 1.0 }\n", color[0], color[1], color[2]);
+    qh_settempfree(&printpoints);
+  qh_fprintf(fp, 9102, "%d ", n);
+  for (i=0; i < n; i++)
+    qh_fprintf(fp, 9103, "%d ", i);
+  qh_fprintf(fp, 9104, "%8.4g %8.4g %8.4g 1.0 }\n", color[0], color[1], color[2]);
 } /* printfacet3geom_points */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet3geom_simplicial">-</a>
-  
+
   qh_printfacet3geom_simplicial(  )
     print Geomview OFF for a 3-d simplicial facet.
 
@@ -2082,16 +2154,16 @@
   realT black[3]={0, 0, 0}, green[3]={0, 1, 0};
   int k;
 
-  qh_geomplanes (facet, &outerplane, &innerplane); 
-  vertices= qh_facet3vertex (facet);
-  points= qh_settemp (qh TEMPsize);
+  qh_geomplanes(facet, &outerplane, &innerplane);
+  vertices= qh_facet3vertex(facet);
+  points= qh_settemp(qh TEMPsize);
   FOREACHvertex_(vertices)
     qh_setappend(&points, vertex->point);
   if (qh PRINTouter || (!qh PRINTnoplanes && !qh PRINTinner))
     qh_printfacet3geom_points(fp, points, facet, outerplane, color);
   if (qh PRINTinner || (!qh PRINTnoplanes && !qh PRINTouter &&
               outerplane - innerplane > 2 * qh MAXabs_coord * qh_GEOMepsilon)) {
-    for (k= 3; k--; )
+    for (k=3; k--; )
       color[k]= 1.0 - color[k];
     qh_printfacet3geom_points(fp, points, facet, innerplane, color);
   }
@@ -2102,16 +2174,16 @@
     facet->visitid= qh visit_id;
     FOREACHneighbor_(facet) {
       if (neighbor->visitid != qh visit_id) {
-	vertices= qh_setnew_delnthsorted (facet->vertices, qh hull_dim,
-	                  SETindex_(facet->neighbors, neighbor), 0);
+        vertices= qh_setnew_delnthsorted(facet->vertices, qh hull_dim,
+                          SETindex_(facet->neighbors, neighbor), 0);
         if (qh DOintersections)
-	   qh_printhyperplaneintersection(fp, facet, neighbor, vertices, black); 
+           qh_printhyperplaneintersection(fp, facet, neighbor, vertices, black);
         if (qh PRINTridges) {
           vertexA= SETfirstt_(vertices, vertexT);
           vertexB= SETsecondt_(vertices, vertexT);
-          qh_printline3geom (fp, vertexA->point, vertexB->point, green);
+          qh_printline3geom(fp, vertexA->point, vertexB->point, green);
         }
-	qh_setfree(&vertices);
+        qh_setfree(&vertices);
       }
     }
   }
@@ -2119,7 +2191,7 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet3math">-</a>
-  
+
   qh_printfacet3math( fp, facet, notfirst )
     print 3-d Maple or Mathematica output for a facet
 
@@ -2128,30 +2200,30 @@
     use %16.8f since Mathematica 2.2 does not handle exponential format
     see qh_printfacet2math
 */
-void qh_printfacet3math (FILE *fp, facetT *facet, int format, int notfirst) {
+void qh_printfacet3math(FILE *fp, facetT *facet, qh_PRINT format, int notfirst) {
   vertexT *vertex, **vertexp;
   setT *points, *vertices;
   pointT *point, **pointp;
   boolT firstpoint= True;
   realT dist;
-  char *pointfmt, *endfmt;
-  
+  const char *pointfmt, *endfmt;
+
   if (notfirst)
-    fprintf(fp, ",\n");
-  vertices= qh_facet3vertex (facet);
-  points= qh_settemp (qh_setsize (vertices));
+    qh_fprintf(fp, 9105, ",\n");
+  vertices= qh_facet3vertex(facet);
+  points= qh_settemp(qh_setsize(vertices));
   FOREACHvertex_(vertices) {
     zinc_(Zdistio);
     qh_distplane(vertex->point, facet, &dist);
     point= qh_projectpoint(vertex->point, facet, dist);
-    qh_setappend (&points, point);
+    qh_setappend(&points, point);
   }
   if (format == qh_PRINTmaple) {
-    fprintf(fp, "[");
+    qh_fprintf(fp, 9106, "[");
     pointfmt= "[%16.8f, %16.8f, %16.8f]";
     endfmt= "]";
   }else {
-    fprintf(fp, "Polygon[{");
+    qh_fprintf(fp, 9107, "Polygon[{");
     pointfmt= "{%16.8f, %16.8f, %16.8f}";
     endfmt= "}]";
   }
@@ -2159,20 +2231,20 @@
     if (firstpoint)
       firstpoint= False;
     else
-      fprintf(fp, ",\n");
-    fprintf(fp, pointfmt, point[0], point[1], point[2]);
+      qh_fprintf(fp, 9108, ",\n");
+    qh_fprintf(fp, 9109, pointfmt, point[0], point[1], point[2]);
   }
   FOREACHpoint_(points)
-    qh_memfree (point, qh normal_size);
+    qh_memfree(point, qh normal_size);
   qh_settempfree(&points);
   qh_settempfree(&vertices);
-  fprintf(fp, endfmt);
+  qh_fprintf(fp, 9110, endfmt);
 } /* printfacet3math */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet3vertex">-</a>
-  
+
   qh_printfacet3vertex( fp, facet, format )
     print vertices in a 3-d facet as point ids
 
@@ -2180,29 +2252,29 @@
     prints number of vertices first if format == qh_PRINToff
     the facet may be non-simplicial
 */
-void qh_printfacet3vertex(FILE *fp, facetT *facet, int format) {
+void qh_printfacet3vertex(FILE *fp, facetT *facet, qh_PRINT format) {
   vertexT *vertex, **vertexp;
   setT *vertices;
 
-  vertices= qh_facet3vertex (facet);
+  vertices= qh_facet3vertex(facet);
   if (format == qh_PRINToff)
-    fprintf (fp, "%d ", qh_setsize (vertices));
-  FOREACHvertex_(vertices) 
-    fprintf (fp, "%d ", qh_pointid(vertex->point));
-  fprintf (fp, "\n");
+    qh_fprintf(fp, 9111, "%d ", qh_setsize(vertices));
+  FOREACHvertex_(vertices)
+    qh_fprintf(fp, 9112, "%d ", qh_pointid(vertex->point));
+  qh_fprintf(fp, 9113, "\n");
   qh_settempfree(&vertices);
 } /* printfacet3vertex */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet4geom_nonsimplicial">-</a>
-  
+
   qh_printfacet4geom_nonsimplicial(  )
     print Geomview 4OFF file for a 4d nonsimplicial facet
     prints all ridges to unvisited neighbors (qh.visit_id)
     if qh.DROPdim
       prints in OFF format
-  
+
   notes:
     must agree with printend4geom()
 */
@@ -2213,38 +2285,38 @@
   pointT *point;
   int k;
   realT dist;
-  
+
   facet->visitid= qh visit_id;
   if (qh PRINTnoplanes || (facet->visible && qh NEWfacets))
     return;
   FOREACHridge_(facet->ridges) {
     neighbor= otherfacet_(ridge, facet);
-    if (neighbor->visitid == qh visit_id) 
+    if (neighbor->visitid == qh visit_id)
       continue;
     if (qh PRINTtransparent && !neighbor->good)
-      continue;  
+      continue;
     if (qh DOintersections)
       qh_printhyperplaneintersection(fp, facet, neighbor, ridge->vertices, color);
     else {
-      if (qh DROPdim >= 0) 
-	fprintf(fp, "OFF 3 1 1 # f%d\n", facet->id);
+      if (qh DROPdim >= 0)
+        qh_fprintf(fp, 9114, "OFF 3 1 1 # f%d\n", facet->id);
       else {
-	qh printoutvar++;
-	fprintf (fp, "# r%d between f%d f%d\n", ridge->id, facet->id, neighbor->id);
+        qh printoutvar++;
+        qh_fprintf(fp, 9115, "# r%d between f%d f%d\n", ridge->id, facet->id, neighbor->id);
       }
       FOREACHvertex_(ridge->vertices) {
-	zinc_(Zdistio);
-	qh_distplane(vertex->point,facet, &dist);
-	point=qh_projectpoint(vertex->point,facet, dist);
-	for(k= 0; k < qh hull_dim; k++) {
-	  if (k != qh DROPdim)
-  	    fprintf(fp, "%8.4g ", point[k]);
-  	}
-	fprintf (fp, "\n");
-	qh_memfree (point, qh normal_size);
+        zinc_(Zdistio);
+        qh_distplane(vertex->point,facet, &dist);
+        point=qh_projectpoint(vertex->point,facet, dist);
+        for (k=0; k < qh hull_dim; k++) {
+          if (k != qh DROPdim)
+            qh_fprintf(fp, 9116, "%8.4g ", point[k]);
+        }
+        qh_fprintf(fp, 9117, "\n");
+        qh_memfree(point, qh normal_size);
       }
       if (qh DROPdim >= 0)
-        fprintf(fp, "3 0 1 2 %8.4g %8.4g %8.4g\n", color[0], color[1], color[2]);
+        qh_fprintf(fp, 9118, "3 0 1 2 %8.4g %8.4g %8.4g\n", color[0], color[1], color[2]);
     }
   }
 } /* printfacet4geom_nonsimplicial */
@@ -2252,7 +2324,7 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacet4geom_simplicial">-</a>
-  
+
   qh_printfacet4geom_simplicial( fp, facet, color )
     print Geomview 4OFF file for a 4d simplicial facet
     prints triangles for unvisited neighbors (qh.visit_id)
@@ -2265,7 +2337,7 @@
   facetT *neighbor, **neighborp;
   vertexT *vertex, **vertexp;
   int k;
-  
+
   facet->visitid= qh visit_id;
   if (qh PRINTnoplanes || (facet->visible && qh NEWfacets))
     return;
@@ -2273,28 +2345,28 @@
     if (neighbor->visitid == qh visit_id)
       continue;
     if (qh PRINTtransparent && !neighbor->good)
-      continue;  
-    vertices= qh_setnew_delnthsorted (facet->vertices, qh hull_dim,
-	                  SETindex_(facet->neighbors, neighbor), 0);
+      continue;
+    vertices= qh_setnew_delnthsorted(facet->vertices, qh hull_dim,
+                          SETindex_(facet->neighbors, neighbor), 0);
     if (qh DOintersections)
       qh_printhyperplaneintersection(fp, facet, neighbor, vertices, color);
     else {
-      if (qh DROPdim >= 0) 
-	fprintf(fp, "OFF 3 1 1 # ridge between f%d f%d\n",
-		facet->id, neighbor->id);
+      if (qh DROPdim >= 0)
+        qh_fprintf(fp, 9119, "OFF 3 1 1 # ridge between f%d f%d\n",
+                facet->id, neighbor->id);
       else {
-	qh printoutvar++;
-	fprintf (fp, "# ridge between f%d f%d\n", facet->id, neighbor->id);
+        qh printoutvar++;
+        qh_fprintf(fp, 9120, "# ridge between f%d f%d\n", facet->id, neighbor->id);
       }
       FOREACHvertex_(vertices) {
-	for(k= 0; k < qh hull_dim; k++) {
-	  if (k != qh DROPdim)
-  	    fprintf(fp, "%8.4g ", vertex->point[k]);
-  	}
-	fprintf (fp, "\n");
+        for (k=0; k < qh hull_dim; k++) {
+          if (k != qh DROPdim)
+            qh_fprintf(fp, 9121, "%8.4g ", vertex->point[k]);
+        }
+        qh_fprintf(fp, 9122, "\n");
       }
-      if (qh DROPdim >= 0) 
-        fprintf(fp, "3 0 1 2 %8.4g %8.4g %8.4g\n", color[0], color[1], color[2]);
+      if (qh DROPdim >= 0)
+        qh_fprintf(fp, 9123, "3 0 1 2 %8.4g %8.4g %8.4g\n", color[0], color[1], color[2]);
     }
     qh_setfree(&vertices);
   }
@@ -2303,12 +2375,12 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacetNvertex_nonsimplicial">-</a>
-  
+
   qh_printfacetNvertex_nonsimplicial( fp, facet, id, format )
     print vertices for an N-d non-simplicial facet
     triangulates each ridge to the id
 */
-void qh_printfacetNvertex_nonsimplicial(FILE *fp, facetT *facet, int id, int format) {
+void qh_printfacetNvertex_nonsimplicial(FILE *fp, facetT *facet, int id, qh_PRINT format) {
   vertexT *vertex, **vertexp;
   ridgeT *ridge, **ridgep;
 
@@ -2316,54 +2388,55 @@
     return;
   FOREACHridge_(facet->ridges) {
     if (format == qh_PRINTtriangles)
-      fprintf(fp, "%d ", qh hull_dim);
-    fprintf(fp, "%d ", id);
+      qh_fprintf(fp, 9124, "%d ", qh hull_dim);
+    qh_fprintf(fp, 9125, "%d ", id);
     if ((ridge->top == facet) ^ qh_ORIENTclock) {
       FOREACHvertex_(ridge->vertices)
-        fprintf(fp, "%d ", qh_pointid(vertex->point));
+        qh_fprintf(fp, 9126, "%d ", qh_pointid(vertex->point));
     }else {
       FOREACHvertexreverse12_(ridge->vertices)
-        fprintf(fp, "%d ", qh_pointid(vertex->point));
+        qh_fprintf(fp, 9127, "%d ", qh_pointid(vertex->point));
     }
-    fprintf(fp, "\n");
+    qh_fprintf(fp, 9128, "\n");
   }
 } /* printfacetNvertex_nonsimplicial */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacetNvertex_simplicial">-</a>
-  
+
   qh_printfacetNvertex_simplicial( fp, facet, format )
     print vertices for an N-d simplicial facet
     prints vertices for non-simplicial facets
       2-d facets (orientation preserved by qh_mergefacet2d)
       PRINToff ('o') for 4-d and higher
 */
-void qh_printfacetNvertex_simplicial(FILE *fp, facetT *facet, int format) {
+void qh_printfacetNvertex_simplicial(FILE *fp, facetT *facet, qh_PRINT format) {
   vertexT *vertex, **vertexp;
 
   if (format == qh_PRINToff || format == qh_PRINTtriangles)
-    fprintf (fp, "%d ", qh_setsize (facet->vertices));
-  if ((facet->toporient ^ qh_ORIENTclock) 
+    qh_fprintf(fp, 9129, "%d ", qh_setsize(facet->vertices));
+  if ((facet->toporient ^ qh_ORIENTclock)
   || (qh hull_dim > 2 && !facet->simplicial)) {
     FOREACHvertex_(facet->vertices)
-      fprintf(fp, "%d ", qh_pointid(vertex->point));
+      qh_fprintf(fp, 9130, "%d ", qh_pointid(vertex->point));
   }else {
     FOREACHvertexreverse12_(facet->vertices)
-      fprintf(fp, "%d ", qh_pointid(vertex->point));
+      qh_fprintf(fp, 9131, "%d ", qh_pointid(vertex->point));
   }
-  fprintf(fp, "\n");
+  qh_fprintf(fp, 9132, "\n");
 } /* printfacetNvertex_simplicial */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacetheader">-</a>
-  
+
   qh_printfacetheader( fp, facet )
     prints header fields of a facet to fp
-    
+
   notes:
     for 'f' output and debugging
+    Same as QhullFacet::printHeader()
 */
 void qh_printfacetheader(FILE *fp, facetT *facet) {
   pointT *point, **pointp, *furthest;
@@ -2371,134 +2444,134 @@
   realT dist;
 
   if (facet == qh_MERGEridge) {
-    fprintf (fp, " MERGEridge\n");
+    qh_fprintf(fp, 9133, " MERGEridge\n");
     return;
   }else if (facet == qh_DUPLICATEridge) {
-    fprintf (fp, " DUPLICATEridge\n");
+    qh_fprintf(fp, 9134, " DUPLICATEridge\n");
     return;
   }else if (!facet) {
-    fprintf (fp, " NULLfacet\n");
+    qh_fprintf(fp, 9135, " NULLfacet\n");
     return;
   }
   qh old_randomdist= qh RANDOMdist;
   qh RANDOMdist= False;
-  fprintf(fp, "- f%d\n", facet->id);
-  fprintf(fp, "    - flags:");
-  if (facet->toporient) 
-    fprintf(fp, " top");
+  qh_fprintf(fp, 9136, "- f%d\n", facet->id);
+  qh_fprintf(fp, 9137, "    - flags:");
+  if (facet->toporient)
+    qh_fprintf(fp, 9138, " top");
   else
-    fprintf(fp, " bottom");
+    qh_fprintf(fp, 9139, " bottom");
   if (facet->simplicial)
-    fprintf(fp, " simplicial");
+    qh_fprintf(fp, 9140, " simplicial");
   if (facet->tricoplanar)
-    fprintf(fp, " tricoplanar");
+    qh_fprintf(fp, 9141, " tricoplanar");
   if (facet->upperdelaunay)
-    fprintf(fp, " upperDelaunay");
+    qh_fprintf(fp, 9142, " upperDelaunay");
   if (facet->visible)
-    fprintf(fp, " visible");
+    qh_fprintf(fp, 9143, " visible");
   if (facet->newfacet)
-    fprintf(fp, " new");
+    qh_fprintf(fp, 9144, " new");
   if (facet->tested)
-    fprintf(fp, " tested");
+    qh_fprintf(fp, 9145, " tested");
   if (!facet->good)
-    fprintf(fp, " notG");
+    qh_fprintf(fp, 9146, " notG");
   if (facet->seen)
-    fprintf(fp, " seen");
+    qh_fprintf(fp, 9147, " seen");
   if (facet->coplanar)
-    fprintf(fp, " coplanar");
+    qh_fprintf(fp, 9148, " coplanar");
   if (facet->mergehorizon)
-    fprintf(fp, " mergehorizon");
+    qh_fprintf(fp, 9149, " mergehorizon");
   if (facet->keepcentrum)
-    fprintf(fp, " keepcentrum");
+    qh_fprintf(fp, 9150, " keepcentrum");
   if (facet->dupridge)
-    fprintf(fp, " dupridge");
+    qh_fprintf(fp, 9151, " dupridge");
   if (facet->mergeridge && !facet->mergeridge2)
-    fprintf(fp, " mergeridge1");
+    qh_fprintf(fp, 9152, " mergeridge1");
   if (facet->mergeridge2)
-    fprintf(fp, " mergeridge2");
+    qh_fprintf(fp, 9153, " mergeridge2");
   if (facet->newmerge)
-    fprintf(fp, " newmerge");
-  if (facet->flipped) 
-    fprintf(fp, " flipped");
-  if (facet->notfurthest) 
-    fprintf(fp, " notfurthest");
+    qh_fprintf(fp, 9154, " newmerge");
+  if (facet->flipped)
+    qh_fprintf(fp, 9155, " flipped");
+  if (facet->notfurthest)
+    qh_fprintf(fp, 9156, " notfurthest");
   if (facet->degenerate)
-    fprintf(fp, " degenerate");
+    qh_fprintf(fp, 9157, " degenerate");
   if (facet->redundant)
-    fprintf(fp, " redundant");
-  fprintf(fp, "\n");
+    qh_fprintf(fp, 9158, " redundant");
+  qh_fprintf(fp, 9159, "\n");
   if (facet->isarea)
-    fprintf(fp, "    - area: %2.2g\n", facet->f.area);
+    qh_fprintf(fp, 9160, "    - area: %2.2g\n", facet->f.area);
   else if (qh NEWfacets && facet->visible && facet->f.replace)
-    fprintf(fp, "    - replacement: f%d\n", facet->f.replace->id);
+    qh_fprintf(fp, 9161, "    - replacement: f%d\n", facet->f.replace->id);
   else if (facet->newfacet) {
     if (facet->f.samecycle && facet->f.samecycle != facet)
-      fprintf(fp, "    - shares same visible/horizon as f%d\n", facet->f.samecycle->id);
+      qh_fprintf(fp, 9162, "    - shares same visible/horizon as f%d\n", facet->f.samecycle->id);
   }else if (facet->tricoplanar /* !isarea */) {
     if (facet->f.triowner)
-      fprintf(fp, "    - owner of normal & centrum is facet f%d\n", facet->f.triowner->id);
+      qh_fprintf(fp, 9163, "    - owner of normal & centrum is facet f%d\n", facet->f.triowner->id);
   }else if (facet->f.newcycle)
-    fprintf(fp, "    - was horizon to f%d\n", facet->f.newcycle->id);
+    qh_fprintf(fp, 9164, "    - was horizon to f%d\n", facet->f.newcycle->id);
   if (facet->nummerge)
-    fprintf(fp, "    - merges: %d\n", facet->nummerge);
+    qh_fprintf(fp, 9165, "    - merges: %d\n", facet->nummerge);
   qh_printpointid(fp, "    - normal: ", qh hull_dim, facet->normal, -1);
-  fprintf(fp, "    - offset: %10.7g\n", facet->offset);
+  qh_fprintf(fp, 9166, "    - offset: %10.7g\n", facet->offset);
   if (qh CENTERtype == qh_ASvoronoi || facet->center)
-    qh_printcenter (fp, qh_PRINTfacets, "    - center: ", facet);
+    qh_printcenter(fp, qh_PRINTfacets, "    - center: ", facet);
 #if qh_MAXoutside
   if (facet->maxoutside > qh DISTround)
-    fprintf(fp, "    - maxoutside: %10.7g\n", facet->maxoutside);
+    qh_fprintf(fp, 9167, "    - maxoutside: %10.7g\n", facet->maxoutside);
 #endif
   if (!SETempty_(facet->outsideset)) {
     furthest= (pointT*)qh_setlast(facet->outsideset);
-    if (qh_setsize (facet->outsideset) < 6) {
-      fprintf(fp, "    - outside set (furthest p%d):\n", qh_pointid(furthest));
+    if (qh_setsize(facet->outsideset) < 6) {
+      qh_fprintf(fp, 9168, "    - outside set(furthest p%d):\n", qh_pointid(furthest));
       FOREACHpoint_(facet->outsideset)
-	qh_printpoint(fp, "     ", point);
-    }else if (qh_setsize (facet->outsideset) < 21) {
+        qh_printpoint(fp, "     ", point);
+    }else if (qh_setsize(facet->outsideset) < 21) {
       qh_printpoints(fp, "    - outside set:", facet->outsideset);
     }else {
-      fprintf(fp, "    - outside set:  %d points.", qh_setsize(facet->outsideset));
+      qh_fprintf(fp, 9169, "    - outside set:  %d points.", qh_setsize(facet->outsideset));
       qh_printpoint(fp, "  Furthest", furthest);
     }
 #if !qh_COMPUTEfurthest
-    fprintf(fp, "    - furthest distance= %2.2g\n", facet->furthestdist);
+    qh_fprintf(fp, 9170, "    - furthest distance= %2.2g\n", facet->furthestdist);
 #endif
   }
   if (!SETempty_(facet->coplanarset)) {
     furthest= (pointT*)qh_setlast(facet->coplanarset);
-    if (qh_setsize (facet->coplanarset) < 6) {
-      fprintf(fp, "    - coplanar set (furthest p%d):\n", qh_pointid(furthest));
+    if (qh_setsize(facet->coplanarset) < 6) {
+      qh_fprintf(fp, 9171, "    - coplanar set(furthest p%d):\n", qh_pointid(furthest));
       FOREACHpoint_(facet->coplanarset)
-	qh_printpoint(fp, "     ", point);
-    }else if (qh_setsize (facet->coplanarset) < 21) {
+        qh_printpoint(fp, "     ", point);
+    }else if (qh_setsize(facet->coplanarset) < 21) {
       qh_printpoints(fp, "    - coplanar set:", facet->coplanarset);
     }else {
-      fprintf(fp, "    - coplanar set:  %d points.", qh_setsize(facet->coplanarset));
+      qh_fprintf(fp, 9172, "    - coplanar set:  %d points.", qh_setsize(facet->coplanarset));
       qh_printpoint(fp, "  Furthest", furthest);
     }
     zinc_(Zdistio);
-    qh_distplane (furthest, facet, &dist);
-    fprintf(fp, "      furthest distance= %2.2g\n", dist);
+    qh_distplane(furthest, facet, &dist);
+    qh_fprintf(fp, 9173, "      furthest distance= %2.2g\n", dist);
   }
-  qh_printvertices (fp, "    - vertices:", facet->vertices);
-  fprintf(fp, "    - neighboring facets: ");
+  qh_printvertices(fp, "    - vertices:", facet->vertices);
+  qh_fprintf(fp, 9174, "    - neighboring facets:");
   FOREACHneighbor_(facet) {
     if (neighbor == qh_MERGEridge)
-      fprintf(fp, " MERGE");
+      qh_fprintf(fp, 9175, " MERGE");
     else if (neighbor == qh_DUPLICATEridge)
-      fprintf(fp, " DUP");
+      qh_fprintf(fp, 9176, " DUP");
     else
-      fprintf(fp, " f%d", neighbor->id);
+      qh_fprintf(fp, 9177, " f%d", neighbor->id);
   }
-  fprintf(fp, "\n");
+  qh_fprintf(fp, 9178, "\n");
   qh RANDOMdist= qh old_randomdist;
 } /* printfacetheader */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacetridges">-</a>
-  
+
   qh_printfacetridges( fp, facet )
     prints ridges of a facet to fp
 
@@ -2506,6 +2579,7 @@
     ridges printed in neighbor order
     assumes the ridges exist
     for 'f' output
+    same as QhullFacet::printRidges
 */
 void qh_printfacetridges(FILE *fp, facetT *facet) {
   facetT *neighbor, **neighborp;
@@ -2514,57 +2588,57 @@
 
 
   if (facet->visible && qh NEWfacets) {
-    fprintf(fp, "    - ridges (ids may be garbage):");
+    qh_fprintf(fp, 9179, "    - ridges(ids may be garbage):");
     FOREACHridge_(facet->ridges)
-      fprintf(fp, " r%d", ridge->id);
-    fprintf(fp, "\n");
+      qh_fprintf(fp, 9180, " r%d", ridge->id);
+    qh_fprintf(fp, 9181, "\n");
   }else {
-    fprintf(fp, "    - ridges:\n");
+    qh_fprintf(fp, 9182, "    - ridges:\n");
     FOREACHridge_(facet->ridges)
       ridge->seen= False;
     if (qh hull_dim == 3) {
       ridge= SETfirstt_(facet->ridges, ridgeT);
       while (ridge && !ridge->seen) {
-	ridge->seen= True;
-	qh_printridge(fp, ridge);
-	numridges++;
-	ridge= qh_nextridge3d (ridge, facet, NULL);
-	}
+        ridge->seen= True;
+        qh_printridge(fp, ridge);
+        numridges++;
+        ridge= qh_nextridge3d(ridge, facet, NULL);
+        }
     }else {
       FOREACHneighbor_(facet) {
-	FOREACHridge_(facet->ridges) {
-	  if (otherfacet_(ridge,facet) == neighbor) {
-	    ridge->seen= True;
-	    qh_printridge(fp, ridge);
-	    numridges++;
-	  }
-	}
+        FOREACHridge_(facet->ridges) {
+          if (otherfacet_(ridge,facet) == neighbor) {
+            ridge->seen= True;
+            qh_printridge(fp, ridge);
+            numridges++;
+          }
+        }
       }
     }
-    if (numridges != qh_setsize (facet->ridges)) {
-      fprintf (fp, "     - all ridges:");
-      FOREACHridge_(facet->ridges) 
-	fprintf (fp, " r%d", ridge->id);
-        fprintf (fp, "\n");
+    if (numridges != qh_setsize(facet->ridges)) {
+      qh_fprintf(fp, 9183, "     - all ridges:");
+      FOREACHridge_(facet->ridges)
+        qh_fprintf(fp, 9184, " r%d", ridge->id);
+        qh_fprintf(fp, 9185, "\n");
     }
     FOREACHridge_(facet->ridges) {
-      if (!ridge->seen) 
-	qh_printridge(fp, ridge);
+      if (!ridge->seen)
+        qh_printridge(fp, ridge);
     }
   }
 } /* printfacetridges */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printfacets">-</a>
-  
+
   qh_printfacets( fp, format, facetlist, facets, printall )
     prints facetlist and/or facet set in output format
-  
+
   notes:
     also used for specialized formats ('FO' and summary)
     turns off 'Rn' option since want actual numbers
 */
-void qh_printfacets(FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall) {
+void qh_printfacets(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
   int numfacets, numsimplicial, numridges, totneighbors, numcoplanars, numtricoplanars;
   facetT *facet, **facetp;
   setT *vertices;
@@ -2574,362 +2648,193 @@
   qh old_randomdist= qh RANDOMdist;
   qh RANDOMdist= False;
   if (qh CDDoutput && (format == qh_PRINTcentrums || format == qh_PRINTpointintersect || format == qh_PRINToff))
-    fprintf (qh ferr, "qhull warning: CDD format is not available for centrums, halfspace\nintersections, and OFF file format.\n");
+    qh_fprintf(qh ferr, 7056, "qhull warning: CDD format is not available for centrums, halfspace\nintersections, and OFF file format.\n");
   if (format == qh_PRINTnone)
     ; /* print nothing */
   else if (format == qh_PRINTaverage) {
-    vertices= qh_facetvertices (facetlist, facets, printall);
-    center= qh_getcenter (vertices);
-    fprintf (fp, "%d 1\n", qh hull_dim);
-    qh_printpointid (fp, NULL, qh hull_dim, center, -1);
-    qh_memfree (center, qh normal_size);
-    qh_settempfree (&vertices);
+    vertices= qh_facetvertices(facetlist, facets, printall);
+    center= qh_getcenter(vertices);
+    qh_fprintf(fp, 9186, "%d 1\n", qh hull_dim);
+    qh_printpointid(fp, NULL, qh hull_dim, center, -1);
+    qh_memfree(center, qh normal_size);
+    qh_settempfree(&vertices);
   }else if (format == qh_PRINTextremes) {
     if (qh DELAUNAY)
-      qh_printextremes_d (fp, facetlist, facets, printall);
+      qh_printextremes_d(fp, facetlist, facets, printall);
     else if (qh hull_dim == 2)
-      qh_printextremes_2d (fp, facetlist, facets, printall);
-    else 
-      qh_printextremes (fp, facetlist, facets, printall);
+      qh_printextremes_2d(fp, facetlist, facets, printall);
+    else
+      qh_printextremes(fp, facetlist, facets, printall);
   }else if (format == qh_PRINToptions)
-    fprintf(fp, "Options selected for Qhull %s:\n%s\n", qh_version, qh qhull_options);
+    qh_fprintf(fp, 9187, "Options selected for Qhull %s:\n%s\n", qh_version, qh qhull_options);
   else if (format == qh_PRINTpoints && !qh VORONOI)
-    qh_printpoints_out (fp, facetlist, facets, printall);
+    qh_printpoints_out(fp, facetlist, facets, printall);
   else if (format == qh_PRINTqhull)
-    fprintf (fp, "%s | %s\n", qh rbox_command, qh qhull_command);
+    qh_fprintf(fp, 9188, "%s | %s\n", qh rbox_command, qh qhull_command);
   else if (format == qh_PRINTsize) {
-    fprintf (fp, "0\n2 ");
-    fprintf (fp, qh_REAL_1, qh totarea);
-    fprintf (fp, qh_REAL_1, qh totvol);
-    fprintf (fp, "\n");
+    qh_fprintf(fp, 9189, "0\n2 ");
+    qh_fprintf(fp, 9190, qh_REAL_1, qh totarea);
+    qh_fprintf(fp, 9191, qh_REAL_1, qh totvol);
+    qh_fprintf(fp, 9192, "\n");
   }else if (format == qh_PRINTsummary) {
-    qh_countfacets (facetlist, facets, printall, &numfacets, &numsimplicial, 
+    qh_countfacets(facetlist, facets, printall, &numfacets, &numsimplicial,
       &totneighbors, &numridges, &numcoplanars, &numtricoplanars);
-    vertices= qh_facetvertices (facetlist, facets, printall); 
-    fprintf (fp, "10 %d %d %d %d %d %d %d %d %d %d\n2 ", qh hull_dim, 
-                qh num_points + qh_setsize (qh other_points),
+    vertices= qh_facetvertices(facetlist, facets, printall);
+    qh_fprintf(fp, 9193, "10 %d %d %d %d %d %d %d %d %d %d\n2 ", qh hull_dim,
+                qh num_points + qh_setsize(qh other_points),
                 qh num_vertices, qh num_facets - qh num_visible,
-                qh_setsize (vertices), numfacets, numcoplanars, 
-		numfacets - numsimplicial, zzval_(Zdelvertextot), 
-		numtricoplanars);
-    qh_settempfree (&vertices);
-    qh_outerinner (NULL, &outerplane, &innerplane);
-    fprintf (fp, qh_REAL_2n, outerplane, innerplane);
+                qh_setsize(vertices), numfacets, numcoplanars,
+                numfacets - numsimplicial, zzval_(Zdelvertextot),
+                numtricoplanars);
+    qh_settempfree(&vertices);
+    qh_outerinner(NULL, &outerplane, &innerplane);
+    qh_fprintf(fp, 9194, qh_REAL_2n, outerplane, innerplane);
   }else if (format == qh_PRINTvneighbors)
-    qh_printvneighbors (fp, facetlist, facets, printall);
+    qh_printvneighbors(fp, facetlist, facets, printall);
   else if (qh VORONOI && format == qh_PRINToff)
-    qh_printvoronoi (fp, format, facetlist, facets, printall);
+    qh_printvoronoi(fp, format, facetlist, facets, printall);
   else if (qh VORONOI && format == qh_PRINTgeom) {
-    qh_printbegin (fp, format, facetlist, facets, printall);
-    qh_printvoronoi (fp, format, facetlist, facets, printall);
-    qh_printend (fp, format, facetlist, facets, printall);
-  }else if (qh VORONOI 
+    qh_printbegin(fp, format, facetlist, facets, printall);
+    qh_printvoronoi(fp, format, facetlist, facets, printall);
+    qh_printend(fp, format, facetlist, facets, printall);
+  }else if (qh VORONOI
   && (format == qh_PRINTvertices || format == qh_PRINTinner || format == qh_PRINTouter))
-    qh_printvdiagram (fp, format, facetlist, facets, printall);
+    qh_printvdiagram(fp, format, facetlist, facets, printall);
   else {
-    qh_printbegin (fp, format, facetlist, facets, printall);
+    qh_printbegin(fp, format, facetlist, facets, printall);
     FORALLfacet_(facetlist)
-      qh_printafacet (fp, format, facet, printall);
-    FOREACHfacet_(facets) 
-      qh_printafacet (fp, format, facet, printall);
-    qh_printend (fp, format, facetlist, facets, printall);
+      qh_printafacet(fp, format, facet, printall);
+    FOREACHfacet_(facets)
+      qh_printafacet(fp, format, facet, printall);
+    qh_printend(fp, format, facetlist, facets, printall);
   }
   qh RANDOMdist= qh old_randomdist;
 } /* printfacets */
 
 
 /*-<a                             href="qh-io.htm#TOC"
-  >-------------------------------</a><a name="printhelp_degenerate">-</a>
-  
-  qh_printhelp_degenerate( fp )
-    prints descriptive message for precision error
-
-  notes:
-    no message if qh_QUICKhelp
-*/
-void qh_printhelp_degenerate(FILE *fp) {
-  
-  if (qh MERGEexact || qh PREmerge || qh JOGGLEmax < REALmax/2) 
-    fprintf(fp, "\n\
-A Qhull error has occurred.  Qhull should have corrected the above\n\
-precision error.  Please send the input and all of the output to\n\
-qhull_bug@qhull.org\n");
-  else if (!qh_QUICKhelp) {
-    fprintf(fp, "\n\
-Precision problems were detected during construction of the convex hull.\n\
-This occurs because convex hull algorithms assume that calculations are\n\
-exact, but floating-point arithmetic has roundoff errors.\n\
-\n\
-To correct for precision problems, do not use 'Q0'.  By default, Qhull\n\
-selects 'C-0' or 'Qx' and merges non-convex facets.  With option 'QJ',\n\
-Qhull joggles the input to prevent precision problems.  See \"Imprecision\n\
-in Qhull\" (qh-impre.htm).\n\
-\n\
-If you use 'Q0', the output may include\n\
-coplanar ridges, concave ridges, and flipped facets.  In 4-d and higher,\n\
-Qhull may produce a ridge with four neighbors or two facets with the same \n\
-vertices.  Qhull reports these events when they occur.  It stops when a\n\
-concave ridge, flipped facet, or duplicate facet occurs.\n");
-#if REALfloat
-    fprintf (fp, "\
-\n\
-Qhull is currently using single precision arithmetic.  The following\n\
-will probably remove the precision problems:\n\
-  - recompile qhull for double precision (#define REALfloat 0 in user.h).\n");
-#endif
-    if (qh DELAUNAY && !qh SCALElast && qh MAXabs_coord > 1e4)
-      fprintf( fp, "\
-\n\
-When computing the Delaunay triangulation of coordinates > 1.0,\n\
-  - use 'Qbb' to scale the last coordinate to [0,m] (max previous coordinate)\n");
-    if (qh DELAUNAY && !qh ATinfinity) 
-      fprintf( fp, "\
-When computing the Delaunay triangulation:\n\
-  - use 'Qz' to add a point at-infinity.  This reduces precision problems.\n");
- 
-    fprintf(fp, "\
-\n\
-If you need triangular output:\n\
-  - use option 'Qt' to triangulate the output\n\
-  - use option 'QJ' to joggle the input points and remove precision errors\n\
-  - use option 'Ft'.  It triangulates non-simplicial facets with added points.\n\
-\n\
-If you must use 'Q0',\n\
-try one or more of the following options.  They can not guarantee an output.\n\
-  - use 'QbB' to scale the input to a cube.\n\
-  - use 'Po' to produce output and prevent partitioning for flipped facets\n\
-  - use 'V0' to set min. distance to visible facet as 0 instead of roundoff\n\
-  - use 'En' to specify a maximum roundoff error less than %2.2g.\n\
-  - options 'Qf', 'Qbb', and 'QR0' may also help\n",
-               qh DISTround);
-    fprintf(fp, "\
-\n\
-To guarantee simplicial output:\n\
-  - use option 'Qt' to triangulate the output\n\
-  - use option 'QJ' to joggle the input points and remove precision errors\n\
-  - use option 'Ft' to triangulate the output by adding points\n\
-  - use exact arithmetic (see \"Imprecision in Qhull\", qh-impre.htm)\n\
-");
-  }
-} /* printhelp_degenerate */
-
-
-/*-<a                             href="qh-io.htm#TOC"
-  >-------------------------------</a><a name="printhelp_singular">-</a>
-  
-  qh_printhelp_singular( fp )
-    prints descriptive message for singular input
-*/
-void qh_printhelp_singular(FILE *fp) {
-  facetT *facet;
-  vertexT *vertex, **vertexp;
-  realT min, max, *coord, dist;
-  int i,k;
-  
-  fprintf(fp, "\n\
-The input to qhull appears to be less than %d dimensional, or a\n\
-computation has overflowed.\n\n\
-Qhull could not construct a clearly convex simplex from points:\n",
-           qh hull_dim);
-  qh_printvertexlist (fp, "", qh facet_list, NULL, qh_ALL);
-  if (!qh_QUICKhelp)
-    fprintf(fp, "\n\
-The center point is coplanar with a facet, or a vertex is coplanar\n\
-with a neighboring facet.  The maximum round off error for\n\
-computing distances is %2.2g.  The center point, facets and distances\n\
-to the center point are as follows:\n\n", qh DISTround);
-  qh_printpointid (fp, "center point", qh hull_dim, qh interior_point, -1);
-  fprintf (fp, "\n");
-  FORALLfacets {
-    fprintf (fp, "facet");
-    FOREACHvertex_(facet->vertices)
-      fprintf (fp, " p%d", qh_pointid(vertex->point));
-    zinc_(Zdistio);
-    qh_distplane(qh interior_point, facet, &dist);
-    fprintf (fp, " distance= %4.2g\n", dist);
-  }
-  if (!qh_QUICKhelp) {
-    if (qh HALFspace) 
-      fprintf (fp, "\n\
-These points are the dual of the given halfspaces.  They indicate that\n\
-the intersection is degenerate.\n");
-    fprintf (fp,"\n\
-These points either have a maximum or minimum x-coordinate, or\n\
-they maximize the determinant for k coordinates.  Trial points\n\
-are first selected from points that maximize a coordinate.\n");
-    if (qh hull_dim >= qh_INITIALmax)
-      fprintf (fp, "\n\
-Because of the high dimension, the min x-coordinate and max-coordinate\n\
-points are used if the determinant is non-zero.  Option 'Qs' will\n\
-do a better, though much slower, job.  Instead of 'Qs', you can change\n\
-the points by randomly rotating the input with 'QR0'.\n");
-  }
-  fprintf (fp, "\nThe min and max coordinates for each dimension are:\n");
-  for (k=0; k < qh hull_dim; k++) {
-    min= REALmax;
-    max= -REALmin;
-    for (i=qh num_points, coord= qh first_point+k; i--; coord += qh hull_dim) {
-      maximize_(max, *coord);
-      minimize_(min, *coord);
-    }
-    fprintf (fp, "  %d:  %8.4g  %8.4g  difference= %4.4g\n", k, min, max, max-min);
-  }
-  if (!qh_QUICKhelp) {
-    fprintf (fp, "\n\
-If the input should be full dimensional, you have several options that\n\
-may determine an initial simplex:\n\
-  - use 'QJ'  to joggle the input and make it full dimensional\n\
-  - use 'QbB' to scale the points to the unit cube\n\
-  - use 'QR0' to randomly rotate the input for different maximum points\n\
-  - use 'Qs'  to search all points for the initial simplex\n\
-  - use 'En'  to specify a maximum roundoff error less than %2.2g.\n\
-  - trace execution with 'T3' to see the determinant for each point.\n",
-                     qh DISTround);
-#if REALfloat
-    fprintf (fp, "\
-  - recompile qhull for double precision (#define REALfloat 0 in qhull.h).\n");
-#endif
-    fprintf (fp, "\n\
-If the input is lower dimensional:\n\
-  - use 'QJ' to joggle the input and make it full dimensional\n\
-  - use 'Qbk:0Bk:0' to delete coordinate k from the input.  You should\n\
-    pick the coordinate with the least range.  The hull will have the\n\
-    correct topology.\n\
-  - determine the flat containing the points, rotate the points\n\
-    into a coordinate plane, and delete the other coordinates.\n\
-  - add one or more points to make the input full dimensional.\n\
-");
-    if (qh DELAUNAY && !qh ATinfinity)
-      fprintf (fp, "\n\n\
-This is a Delaunay triangulation and the input is co-circular or co-spherical:\n\
-  - use 'Qz' to add a point \"at infinity\" (i.e., above the paraboloid)\n\
-  - or use 'QJ' to joggle the input and avoid co-circular data\n");
-  }
-} /* printhelp_singular */
-
-/*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printhyperplaneintersection">-</a>
-  
+
   qh_printhyperplaneintersection( fp, facet1, facet2, vertices, color )
     print Geomview OFF or 4OFF for the intersection of two hyperplanes in 3-d or 4-d
 */
 void qh_printhyperplaneintersection(FILE *fp, facetT *facet1, facetT *facet2,
-		   setT *vertices, realT color[3]) {
+                   setT *vertices, realT color[3]) {
   realT costheta, denominator, dist1, dist2, s, t, mindenom, p[4];
   vertexT *vertex, **vertexp;
   int i, k;
   boolT nearzero1, nearzero2;
-  
+
   costheta= qh_getangle(facet1->normal, facet2->normal);
   denominator= 1 - costheta * costheta;
   i= qh_setsize(vertices);
   if (qh hull_dim == 3)
-    fprintf(fp, "VECT 1 %d 1 %d 1 ", i, i);
+    qh_fprintf(fp, 9195, "VECT 1 %d 1 %d 1 ", i, i);
   else if (qh hull_dim == 4 && qh DROPdim >= 0)
-    fprintf(fp, "OFF 3 1 1 ");
+    qh_fprintf(fp, 9196, "OFF 3 1 1 ");
   else
     qh printoutvar++;
-  fprintf (fp, "# intersect f%d f%d\n", facet1->id, facet2->id);
+  qh_fprintf(fp, 9197, "# intersect f%d f%d\n", facet1->id, facet2->id);
   mindenom= 1 / (10.0 * qh MAXabs_coord);
   FOREACHvertex_(vertices) {
     zadd_(Zdistio, 2);
     qh_distplane(vertex->point, facet1, &dist1);
     qh_distplane(vertex->point, facet2, &dist2);
-    s= qh_divzero (-dist1 + costheta * dist2, denominator,mindenom,&nearzero1);
-    t= qh_divzero (-dist2 + costheta * dist1, denominator,mindenom,&nearzero2);
+    s= qh_divzero(-dist1 + costheta * dist2, denominator,mindenom,&nearzero1);
+    t= qh_divzero(-dist2 + costheta * dist1, denominator,mindenom,&nearzero2);
     if (nearzero1 || nearzero2)
       s= t= 0.0;
-    for(k= qh hull_dim; k--; )
+    for (k=qh hull_dim; k--; )
       p[k]= vertex->point[k] + facet1->normal[k] * s + facet2->normal[k] * t;
     if (qh PRINTdim <= 3) {
       qh_projectdim3 (p, p);
-      fprintf(fp, "%8.4g %8.4g %8.4g # ", p[0], p[1], p[2]);
-    }else 
-      fprintf(fp, "%8.4g %8.4g %8.4g %8.4g # ", p[0], p[1], p[2], p[3]);
+      qh_fprintf(fp, 9198, "%8.4g %8.4g %8.4g # ", p[0], p[1], p[2]);
+    }else
+      qh_fprintf(fp, 9199, "%8.4g %8.4g %8.4g %8.4g # ", p[0], p[1], p[2], p[3]);
     if (nearzero1+nearzero2)
-      fprintf (fp, "p%d (coplanar facets)\n", qh_pointid (vertex->point));
+      qh_fprintf(fp, 9200, "p%d(coplanar facets)\n", qh_pointid(vertex->point));
     else
-      fprintf (fp, "projected p%d\n", qh_pointid (vertex->point));
+      qh_fprintf(fp, 9201, "projected p%d\n", qh_pointid(vertex->point));
   }
   if (qh hull_dim == 3)
-    fprintf(fp, "%8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]); 
-  else if (qh hull_dim == 4 && qh DROPdim >= 0)  
-    fprintf(fp, "3 0 1 2 %8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
+    qh_fprintf(fp, 9202, "%8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
+  else if (qh hull_dim == 4 && qh DROPdim >= 0)
+    qh_fprintf(fp, 9203, "3 0 1 2 %8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
 } /* printhyperplaneintersection */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printline3geom">-</a>
-  
+
   qh_printline3geom( fp, pointA, pointB, color )
     prints a line as a VECT
     prints 0's for qh.DROPdim
-  
+
   notes:
-    if pointA == pointB, 
+    if pointA == pointB,
       it's a 1 point VECT
 */
-void qh_printline3geom (FILE *fp, pointT *pointA, pointT *pointB, realT color[3]) {
+void qh_printline3geom(FILE *fp, pointT *pointA, pointT *pointB, realT color[3]) {
   int k;
   realT pA[4], pB[4];
 
   qh_projectdim3(pointA, pA);
   qh_projectdim3(pointB, pB);
-  if ((fabs(pA[0] - pB[0]) > 1e-3) || 
-      (fabs(pA[1] - pB[1]) > 1e-3) || 
+  if ((fabs(pA[0] - pB[0]) > 1e-3) ||
+      (fabs(pA[1] - pB[1]) > 1e-3) ||
       (fabs(pA[2] - pB[2]) > 1e-3)) {
-    fprintf (fp, "VECT 1 2 1 2 1\n");
-    for (k= 0; k < 3; k++)
-       fprintf (fp, "%8.4g ", pB[k]);
-    fprintf (fp, " # p%d\n", qh_pointid (pointB));
+    qh_fprintf(fp, 9204, "VECT 1 2 1 2 1\n");
+    for (k=0; k < 3; k++)
+       qh_fprintf(fp, 9205, "%8.4g ", pB[k]);
+    qh_fprintf(fp, 9206, " # p%d\n", qh_pointid(pointB));
   }else
-    fprintf (fp, "VECT 1 1 1 1 1\n");
+    qh_fprintf(fp, 9207, "VECT 1 1 1 1 1\n");
   for (k=0; k < 3; k++)
-    fprintf (fp, "%8.4g ", pA[k]);
-  fprintf (fp, " # p%d\n", qh_pointid (pointA));
-  fprintf (fp, "%8.4g %8.4g %8.4g 1\n", color[0], color[1], color[2]);
+    qh_fprintf(fp, 9208, "%8.4g ", pA[k]);
+  qh_fprintf(fp, 9209, " # p%d\n", qh_pointid(pointA));
+  qh_fprintf(fp, 9210, "%8.4g %8.4g %8.4g 1\n", color[0], color[1], color[2]);
 }
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printneighborhood">-</a>
-  
+
   qh_printneighborhood( fp, format, facetA, facetB, printall )
     print neighborhood of one or two facets
 
   notes:
-    calls qh_findgood_all() 
+    calls qh_findgood_all()
     bumps qh.visit_id
 */
-void qh_printneighborhood (FILE *fp, int format, facetT *facetA, facetT *facetB, boolT printall) {
+void qh_printneighborhood(FILE *fp, qh_PRINT format, facetT *facetA, facetT *facetB, boolT printall) {
   facetT *neighbor, **neighborp, *facet;
   setT *facets;
 
   if (format == qh_PRINTnone)
     return;
-  qh_findgood_all (qh facet_list);
+  qh_findgood_all(qh facet_list);
   if (facetA == facetB)
     facetB= NULL;
-  facets= qh_settemp (2*(qh_setsize (facetA->neighbors)+1));
+  facets= qh_settemp(2*(qh_setsize(facetA->neighbors)+1));
   qh visit_id++;
   for (facet= facetA; facet; facet= ((facet == facetA) ? facetB : NULL)) {
     if (facet->visitid != qh visit_id) {
       facet->visitid= qh visit_id;
-      qh_setappend (&facets, facet);
+      qh_setappend(&facets, facet);
     }
     FOREACHneighbor_(facet) {
       if (neighbor->visitid == qh visit_id)
         continue;
       neighbor->visitid= qh visit_id;
-      if (printall || !qh_skipfacet (neighbor))
-        qh_setappend (&facets, neighbor);
+      if (printall || !qh_skipfacet(neighbor))
+        qh_setappend(&facets, neighbor);
     }
   }
-  qh_printfacets (fp, format, NULL, facets, printall);
-  qh_settempfree (&facets);
+  qh_printfacets(fp, format, NULL, facets, printall);
+  qh_settempfree(&facets);
 } /* printneighborhood */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printpoint">-</a>
-  
+
   qh_printpoint( fp, string, point )
   qh_printpointid( fp, string, dim, point, id )
     prints the coordinates of a point
@@ -2941,58 +2846,59 @@
   notes:
     nop if point is NULL
     prints id unless it is undefined (-1)
+    Same as QhullPoint's printPoint
 */
-void qh_printpoint(FILE *fp, char *string, pointT *point) {
+void qh_printpoint(FILE *fp, const char *string, pointT *point) {
   int id= qh_pointid( point);
 
   qh_printpointid( fp, string, qh hull_dim, point, id);
 } /* printpoint */
 
-void qh_printpointid(FILE *fp, char *string, int dim, pointT *point, int id) {
+void qh_printpointid(FILE *fp, const char *string, int dim, pointT *point, int id) {
   int k;
   realT r; /*bug fix*/
-  
+
   if (!point)
     return;
   if (string) {
-    fputs (string, fp);
+    qh_fprintf(fp, 9211, "%s", string);
    if (id != -1)
-      fprintf(fp, " p%d: ", id);
+      qh_fprintf(fp, 9212, " p%d: ", id);
   }
-  for(k= dim; k--; ) {
+  for (k=dim; k--; ) {
     r= *point++;
     if (string)
-      fprintf(fp, " %8.4g", r);
+      qh_fprintf(fp, 9213, " %8.4g", r);
     else
-      fprintf(fp, qh_REAL_1, r);
+      qh_fprintf(fp, 9214, qh_REAL_1, r);
   }
-  fprintf(fp, "\n");
+  qh_fprintf(fp, 9215, "\n");
 } /* printpointid */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printpoint3">-</a>
-  
+
   qh_printpoint3( fp, point )
     prints 2-d, 3-d, or 4-d point as Geomview 3-d coordinates
 */
 void qh_printpoint3 (FILE *fp, pointT *point) {
   int k;
   realT p[4];
-  
+
   qh_projectdim3 (point, p);
   for (k=0; k < 3; k++)
-    fprintf (fp, "%8.4g ", p[k]);
-  fprintf (fp, " # p%d\n", qh_pointid (point));
+    qh_fprintf(fp, 9216, "%8.4g ", p[k]);
+  qh_fprintf(fp, 9217, " # p%d\n", qh_pointid(point));
 } /* printpoint3 */
 
 /*----------------------------------------
--printpoints- print pointids for a set of points starting at index 
+-printpoints- print pointids for a set of points starting at index
    see geom.c
 */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printpoints_out">-</a>
-  
+
   qh_printpoints_out( fp, facetlist, facets, printall )
     prints vertices, coplanar/inside points, for facets by their point coordinates
     allows qh.CDDoutput
@@ -3002,8 +2908,8 @@
     if no coplanar/interior points,
       same order as qh_printextremes
 */
-void qh_printpoints_out (FILE *fp, facetT *facetlist, setT *facets, int printall) {
-  int allpoints= qh num_points + qh_setsize (qh other_points);
+void qh_printpoints_out(FILE *fp, facetT *facetlist, setT *facets, boolT printall) {
+  int allpoints= qh num_points + qh_setsize(qh other_points);
   int numpoints=0, point_i, point_n;
   setT *vertices, *points;
   facetT *facet, **facetp;
@@ -3011,11 +2917,11 @@
   vertexT *vertex, **vertexp;
   int id;
 
-  points= qh_settemp (allpoints);
-  qh_setzero (points, 0, allpoints);
-  vertices= qh_facetvertices (facetlist, facets, printall);
+  points= qh_settemp(allpoints);
+  qh_setzero(points, 0, allpoints);
+  vertices= qh_facetvertices(facetlist, facets, printall);
   FOREACHvertex_(vertices) {
-    id= qh_pointid (vertex->point);
+    id= qh_pointid(vertex->point);
     if (id >= 0)
       SETelem_(points, id)= vertex->point;
   }
@@ -3024,7 +2930,7 @@
       if (!printall && qh_skipfacet(facet))
         continue;
       FOREACHpoint_(facet->coplanarset) {
-        id= qh_pointid (point);
+        id= qh_pointid(point);
         if (id >= 0)
           SETelem_(points, id)= point;
       }
@@ -3033,99 +2939,100 @@
       if (!printall && qh_skipfacet(facet))
         continue;
       FOREACHpoint_(facet->coplanarset) {
-        id= qh_pointid (point);
+        id= qh_pointid(point);
         if (id >= 0)
           SETelem_(points, id)= point;
       }
     }
   }
-  qh_settempfree (&vertices);
+  qh_settempfree(&vertices);
   FOREACHpoint_i_(points) {
     if (point)
       numpoints++;
   }
   if (qh CDDoutput)
-    fprintf (fp, "%s | %s\nbegin\n%d %d real\n", qh rbox_command,
+    qh_fprintf(fp, 9218, "%s | %s\nbegin\n%d %d real\n", qh rbox_command,
              qh qhull_command, numpoints, qh hull_dim + 1);
   else
-    fprintf (fp, "%d\n%d\n", qh hull_dim, numpoints);
+    qh_fprintf(fp, 9219, "%d\n%d\n", qh hull_dim, numpoints);
   FOREACHpoint_i_(points) {
     if (point) {
       if (qh CDDoutput)
-	fprintf (fp, "1 ");
-      qh_printpoint (fp, NULL, point);
+        qh_fprintf(fp, 9220, "1 ");
+      qh_printpoint(fp, NULL, point);
     }
   }
   if (qh CDDoutput)
-    fprintf (fp, "end\n");
-  qh_settempfree (&points);
+    qh_fprintf(fp, 9221, "end\n");
+  qh_settempfree(&points);
 } /* printpoints_out */
-  
 
+
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printpointvect">-</a>
-  
+
   qh_printpointvect( fp, point, normal, center, radius, color )
     prints a 2-d, 3-d, or 4-d point as 3-d VECT's relative to normal or to center point
 */
-void qh_printpointvect (FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius, realT color[3]) {
+void qh_printpointvect(FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius, realT color[3]) {
   realT diff[4], pointA[4];
   int k;
-  
-  for (k= qh hull_dim; k--; ) {
+
+  for (k=qh hull_dim; k--; ) {
     if (center)
       diff[k]= point[k]-center[k];
-    else if (normal) 
+    else if (normal)
       diff[k]= normal[k];
     else
       diff[k]= 0;
   }
   if (center)
     qh_normalize2 (diff, qh hull_dim, True, NULL, NULL);
-  for (k= qh hull_dim; k--; ) 
+  for (k=qh hull_dim; k--; )
     pointA[k]= point[k]+diff[k] * radius;
-  qh_printline3geom (fp, point, pointA, color);
-} /* printpointvect */  
+  qh_printline3geom(fp, point, pointA, color);
+} /* printpointvect */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printpointvect2">-</a>
-  
+
   qh_printpointvect2( fp, point, normal, center, radius )
     prints a 2-d, 3-d, or 4-d point as 2 3-d VECT's for an imprecise point
 */
 void qh_printpointvect2 (FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius) {
   realT red[3]={1, 0, 0}, yellow[3]={1, 1, 0};
 
-  qh_printpointvect (fp, point, normal, center, radius, red);
-  qh_printpointvect (fp, point, normal, center, -radius, yellow);
+  qh_printpointvect(fp, point, normal, center, radius, red);
+  qh_printpointvect(fp, point, normal, center, -radius, yellow);
 } /* printpointvect2 */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printridge">-</a>
-  
+
   qh_printridge( fp, ridge )
     prints the information in a ridge
 
   notes:
     for qh_printfacetridges()
+    same as operator<< [QhullRidge.cpp]
 */
 void qh_printridge(FILE *fp, ridgeT *ridge) {
-  
-  fprintf(fp, "     - r%d", ridge->id);
+
+  qh_fprintf(fp, 9222, "     - r%d", ridge->id);
   if (ridge->tested)
-    fprintf (fp, " tested");
+    qh_fprintf(fp, 9223, " tested");
   if (ridge->nonconvex)
-    fprintf (fp, " nonconvex");
-  fprintf (fp, "\n");
-  qh_printvertices (fp, "           vertices:", ridge->vertices);
+    qh_fprintf(fp, 9224, " nonconvex");
+  qh_fprintf(fp, 9225, "\n");
+  qh_printvertices(fp, "           vertices:", ridge->vertices);
   if (ridge->top && ridge->bottom)
-    fprintf(fp, "           between f%d and f%d\n",
-	    ridge->top->id, ridge->bottom->id);
+    qh_fprintf(fp, 9226, "           between f%d and f%d\n",
+            ridge->top->id, ridge->bottom->id);
 } /* printridge */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printspheres">-</a>
-  
+
   qh_printspheres( fp, vertices, radius )
     prints 3-d vertices as OFF spheres
 
@@ -3136,7 +3043,7 @@
   vertexT *vertex, **vertexp;
 
   qh printoutnum++;
-  fprintf (fp, "{appearance {-edge -normal normscale 0} {\n\
+  qh_fprintf(fp, 9227, "{appearance {-edge -normal normscale 0} {\n\
 INST geom {define vsphere OFF\n\
 18 32 48\n\
 \n\
@@ -3160,10 +3067,10 @@
 0 -0.707107 -0.707107\n\
 \n\
 3 0 6 11\n\
-3 0 7 6	\n\
-3 0 9 7	\n\
+3 0 7 6 \n\
+3 0 9 7 \n\
 3 0 11 9\n\
-3 1 6 8	\n\
+3 1 6 8 \n\
 3 1 8 14\n\
 3 1 13 6\n\
 3 1 14 13\n\
@@ -3192,28 +3099,28 @@
 3 16 12 15\n\
 3 17 10 16\n} transforms { TLIST\n");
   FOREACHvertex_(vertices) {
-    fprintf(fp, "%8.4g 0 0 0 # v%d\n 0 %8.4g 0 0\n0 0 %8.4g 0\n",
+    qh_fprintf(fp, 9228, "%8.4g 0 0 0 # v%d\n 0 %8.4g 0 0\n0 0 %8.4g 0\n",
       radius, vertex->id, radius, radius);
     qh_printpoint3 (fp, vertex->point);
-    fprintf (fp, "1\n");
+    qh_fprintf(fp, 9229, "1\n");
   }
-  fprintf (fp, "}}}\n");
+  qh_fprintf(fp, 9230, "}}}\n");
 } /* printspheres */
 
 
 /*----------------------------------------------
 -printsummary-
-                see qhull.c
+                see libqhull.c
 */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvdiagram">-</a>
-  
+
   qh_printvdiagram( fp, format, facetlist, facets, printall )
     print voronoi diagram
       # of pairs of input sites
       #indices site1 site2 vertex1 ...
-    
+
     sites indexed by input point id
       point 0 is the first input point
     vertices indexed by 'o' and 'p' order
@@ -3225,13 +3132,13 @@
     qh_eachvoronoi_all()
 
   notes:
-    if all facets are upperdelaunay, 
+    if all facets are upperdelaunay,
       prints upper hull (furthest-site Voronoi diagram)
 */
-void qh_printvdiagram (FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall) {
+void qh_printvdiagram(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
   setT *vertices;
   int totcount, numcenters;
-  boolT islower;
+  boolT isLower;
   qh_RIDGE innerouter= qh_RIDGEall;
   printvridgeT printvridge= NULL;
 
@@ -3245,47 +3152,47 @@
     innerouter= qh_RIDGEouter;
     printvridge= qh_printvnorm;
   }else {
-    fprintf(qh ferr, "qh_printvdiagram: unknown print format %d.\n", format);
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_fprintf(qh ferr, 6219, "Qhull internal error (qh_printvdiagram): unknown print format %d.\n", format);
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
-  vertices= qh_markvoronoi (facetlist, facets, printall, &islower, &numcenters);
+  vertices= qh_markvoronoi(facetlist, facets, printall, &isLower, &numcenters);
   totcount= qh_printvdiagram2 (NULL, NULL, vertices, innerouter, False);
-  fprintf (fp, "%d\n", totcount);
+  qh_fprintf(fp, 9231, "%d\n", totcount);
   totcount= qh_printvdiagram2 (fp, printvridge, vertices, innerouter, True /* inorder*/);
-  qh_settempfree (&vertices);
+  qh_settempfree(&vertices);
 #if 0  /* for testing qh_eachvoronoi_all */
-  fprintf (fp, "\n");
+  qh_fprintf(fp, 9232, "\n");
   totcount= qh_eachvoronoi_all(fp, printvridge, qh UPPERdelaunay, innerouter, True /* inorder*/);
-  fprintf (fp, "%d\n", totcount);
+  qh_fprintf(fp, 9233, "%d\n", totcount);
 #endif
 } /* printvdiagram */
-  
+
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvdiagram2">-</a>
-  
+
   qh_printvdiagram2( fp, printvridge, vertices, innerouter, inorder )
     visit all pairs of input sites (vertices) for selected Voronoi vertices
     vertices may include NULLs
-  
+
   innerouter:
-    qh_RIDGEall   print inner ridges (bounded) and outer ridges (unbounded)
+    qh_RIDGEall   print inner ridges(bounded) and outer ridges(unbounded)
     qh_RIDGEinner print only inner ridges
     qh_RIDGEouter print only outer ridges
-  
+
   inorder:
     print 3-d Voronoi vertices in order
-  
+
   assumes:
     qh_markvoronoi marked facet->visitid for Voronoi vertices
     all facet->seen= False
     all facet->seen2= True
-  
+
   returns:
-    total number of Voronoi ridges 
+    total number of Voronoi ridges
     if printvridge,
       calls printvridge( fp, vertex, vertexA, centers) for each ridge
       [see qh_eachvoronoi()]
-  
+
   see:
     qh_eachvoronoi_all()
 */
@@ -3294,23 +3201,24 @@
   int vertex_i, vertex_n;
   vertexT *vertex;
 
-  FORALLvertices 
+  FORALLvertices
     vertex->seen= False;
   FOREACHvertex_i_(vertices) {
     if (vertex) {
       if (qh GOODvertex > 0 && qh_pointid(vertex->point)+1 != qh GOODvertex)
-	continue;
-      totcount += qh_eachvoronoi (fp, printvridge, vertex, !qh_ALL, innerouter, inorder);
+        continue;
+      totcount += qh_eachvoronoi(fp, printvridge, vertex, !qh_ALL, innerouter, inorder);
     }
   }
   return totcount;
 } /* printvdiagram2 */
-  
+
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvertex">-</a>
-  
+
   qh_printvertex( fp, vertex )
     prints the information in a vertex
+    Duplicated as operator<< [QhullVertex.cpp]
 */
 void qh_printvertex(FILE *fp, vertexT *vertex) {
   pointT *point;
@@ -3319,72 +3227,73 @@
   realT r; /*bug fix*/
 
   if (!vertex) {
-    fprintf (fp, "  NULLvertex\n");
+    qh_fprintf(fp, 9234, "  NULLvertex\n");
     return;
   }
-  fprintf(fp, "- p%d (v%d):", qh_pointid(vertex->point), vertex->id);
+  qh_fprintf(fp, 9235, "- p%d(v%d):", qh_pointid(vertex->point), vertex->id);
   point= vertex->point;
   if (point) {
-    for(k= qh hull_dim; k--; ) {
+    for (k=qh hull_dim; k--; ) {
       r= *point++;
-      fprintf(fp, " %5.2g", r);
+      qh_fprintf(fp, 9236, " %5.2g", r);
     }
   }
   if (vertex->deleted)
-    fprintf(fp, " deleted");
+    qh_fprintf(fp, 9237, " deleted");
   if (vertex->delridge)
-    fprintf (fp, " ridgedeleted");
-  fprintf(fp, "\n");
+    qh_fprintf(fp, 9238, " ridgedeleted");
+  qh_fprintf(fp, 9239, "\n");
   if (vertex->neighbors) {
-    fprintf(fp, "  neighbors:");
+    qh_fprintf(fp, 9240, "  neighbors:");
     FOREACHneighbor_(vertex) {
       if (++count % 100 == 0)
-	fprintf (fp, "\n     ");
-      fprintf(fp, " f%d", neighbor->id);
+        qh_fprintf(fp, 9241, "\n     ");
+      qh_fprintf(fp, 9242, " f%d", neighbor->id);
     }
-    fprintf(fp, "\n");
+    qh_fprintf(fp, 9243, "\n");
   }
 } /* printvertex */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvertexlist">-</a>
-  
+
   qh_printvertexlist( fp, string, facetlist, facets, printall )
     prints vertices used by a facetlist or facet set
     tests qh_skipfacet() if !printall
 */
-void qh_printvertexlist (FILE *fp, char* string, facetT *facetlist, 
+void qh_printvertexlist(FILE *fp, const char* string, facetT *facetlist,
                          setT *facets, boolT printall) {
   vertexT *vertex, **vertexp;
   setT *vertices;
-  
-  vertices= qh_facetvertices (facetlist, facets, printall);
-  fputs (string, fp);
+
+  vertices= qh_facetvertices(facetlist, facets, printall);
+  qh_fprintf(fp, 9244, "%s", string);
   FOREACHvertex_(vertices)
     qh_printvertex(fp, vertex);
-  qh_settempfree (&vertices);
+  qh_settempfree(&vertices);
 } /* printvertexlist */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvertices">-</a>
-  
+
   qh_printvertices( fp, string, vertices )
     prints vertices in a set
+    duplicated as printVertexSet [QhullVertex.cpp]
 */
-void qh_printvertices(FILE *fp, char* string, setT *vertices) {
+void qh_printvertices(FILE *fp, const char* string, setT *vertices) {
   vertexT *vertex, **vertexp;
-  
-  fputs (string, fp);
-  FOREACHvertex_(vertices) 
-    fprintf (fp, " p%d (v%d)", qh_pointid(vertex->point), vertex->id);
-  fprintf(fp, "\n");
+
+  qh_fprintf(fp, 9245, "%s", string);
+  FOREACHvertex_(vertices)
+    qh_fprintf(fp, 9246, " p%d(v%d)", qh_pointid(vertex->point), vertex->id);
+  qh_fprintf(fp, 9247, "\n");
 } /* printvertices */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvneighbors">-</a>
-  
+
   qh_printvneighbors( fp, facetlist, facets, printall )
     print vertex neighbors of vertices in facetlist and facets ('FN')
 
@@ -3399,61 +3308,61 @@
     for each point
       list vertex neighbors or coplanar facet
 */
-void qh_printvneighbors (FILE *fp, facetT* facetlist, setT *facets, boolT printall) {
+void qh_printvneighbors(FILE *fp, facetT* facetlist, setT *facets, boolT printall) {
   int numfacets, numsimplicial, numridges, totneighbors, numneighbors, numcoplanars, numtricoplanars;
   setT *vertices, *vertex_points, *coplanar_points;
-  int numpoints= qh num_points + qh_setsize (qh other_points);
+  int numpoints= qh num_points + qh_setsize(qh other_points);
   vertexT *vertex, **vertexp;
   int vertex_i, vertex_n;
   facetT *facet, **facetp, *neighbor, **neighborp;
   pointT *point, **pointp;
 
-  qh_countfacets (facetlist, facets, printall, &numfacets, &numsimplicial, 
+  qh_countfacets(facetlist, facets, printall, &numfacets, &numsimplicial,
       &totneighbors, &numridges, &numcoplanars, &numtricoplanars);  /* sets facet->visitid */
-  fprintf (fp, "%d\n", numpoints);
+  qh_fprintf(fp, 9248, "%d\n", numpoints);
   qh_vertexneighbors();
-  vertices= qh_facetvertices (facetlist, facets, printall);
-  vertex_points= qh_settemp (numpoints);
-  coplanar_points= qh_settemp (numpoints);
-  qh_setzero (vertex_points, 0, numpoints);
-  qh_setzero (coplanar_points, 0, numpoints);
+  vertices= qh_facetvertices(facetlist, facets, printall);
+  vertex_points= qh_settemp(numpoints);
+  coplanar_points= qh_settemp(numpoints);
+  qh_setzero(vertex_points, 0, numpoints);
+  qh_setzero(coplanar_points, 0, numpoints);
   FOREACHvertex_(vertices)
-    qh_point_add (vertex_points, vertex->point, vertex);
+    qh_point_add(vertex_points, vertex->point, vertex);
   FORALLfacet_(facetlist) {
     FOREACHpoint_(facet->coplanarset)
-      qh_point_add (coplanar_points, point, facet);
+      qh_point_add(coplanar_points, point, facet);
   }
   FOREACHfacet_(facets) {
     FOREACHpoint_(facet->coplanarset)
-      qh_point_add (coplanar_points, point, facet);
+      qh_point_add(coplanar_points, point, facet);
   }
   FOREACHvertex_i_(vertex_points) {
-    if (vertex) { 
-      numneighbors= qh_setsize (vertex->neighbors);
-      fprintf (fp, "%d", numneighbors);
+    if (vertex) {
+      numneighbors= qh_setsize(vertex->neighbors);
+      qh_fprintf(fp, 9249, "%d", numneighbors);
       if (qh hull_dim == 3)
-        qh_order_vertexneighbors (vertex);
+        qh_order_vertexneighbors(vertex);
       else if (qh hull_dim >= 4)
-        qsort (SETaddr_(vertex->neighbors, facetT), numneighbors,
-             sizeof (facetT *), qh_compare_facetvisit);
-      FOREACHneighbor_(vertex) 
-        fprintf (fp, " %d", 
-		 neighbor->visitid ? neighbor->visitid - 1 : - neighbor->id);
-      fprintf (fp, "\n");
+        qsort(SETaddr_(vertex->neighbors, facetT), (size_t)numneighbors,
+             sizeof(facetT *), qh_compare_facetvisit);
+      FOREACHneighbor_(vertex)
+        qh_fprintf(fp, 9250, " %d",
+                 neighbor->visitid ? neighbor->visitid - 1 : 0 - neighbor->id);
+      qh_fprintf(fp, 9251, "\n");
     }else if ((facet= SETelemt_(coplanar_points, vertex_i, facetT)))
-      fprintf (fp, "1 %d\n",
-                  facet->visitid ? facet->visitid - 1 : - facet->id);
+      qh_fprintf(fp, 9252, "1 %d\n",
+                  facet->visitid ? facet->visitid - 1 : 0 - facet->id);
     else
-      fprintf (fp, "0\n");
+      qh_fprintf(fp, 9253, "0\n");
   }
-  qh_settempfree (&coplanar_points);
-  qh_settempfree (&vertex_points);
-  qh_settempfree (&vertices);
+  qh_settempfree(&coplanar_points);
+  qh_settempfree(&vertex_points);
+  qh_settempfree(&vertices);
 } /* printvneighbors */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvoronoi">-</a>
-  
+
   qh_printvoronoi( fp, format, facetlist, facets, printall )
     print voronoi diagram in 'o' or 'G' format
     for 'o' format
@@ -3469,62 +3378,62 @@
     qh_printvdiagram()
 
   notes:
-    if 'o', 
+    if 'o',
       prints a line for each point except "at-infinity"
-    if all facets are upperdelaunay, 
+    if all facets are upperdelaunay,
       reverses lower and upper hull
 */
-void qh_printvoronoi (FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall) {
+void qh_printvoronoi(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
   int k, numcenters, numvertices= 0, numneighbors, numinf, vid=1, vertex_i, vertex_n;
   facetT *facet, **facetp, *neighbor, **neighborp;
   setT *vertices;
   vertexT *vertex;
-  boolT islower;
+  boolT isLower;
   unsigned int numfacets= (unsigned int) qh num_facets;
 
-  vertices= qh_markvoronoi (facetlist, facets, printall, &islower, &numcenters);
+  vertices= qh_markvoronoi(facetlist, facets, printall, &isLower, &numcenters);
   FOREACHvertex_i_(vertices) {
     if (vertex) {
       numvertices++;
       numneighbors = numinf = 0;
       FOREACHneighbor_(vertex) {
         if (neighbor->visitid == 0)
-	  numinf= 1;
+          numinf= 1;
         else if (neighbor->visitid < numfacets)
           numneighbors++;
       }
       if (numinf && !numneighbors) {
-	SETelem_(vertices, vertex_i)= NULL;
-	numvertices--;
+        SETelem_(vertices, vertex_i)= NULL;
+        numvertices--;
       }
     }
   }
-  if (format == qh_PRINTgeom) 
-    fprintf (fp, "{appearance {+edge -face} OFF %d %d 1 # Voronoi centers and cells\n", 
+  if (format == qh_PRINTgeom)
+    qh_fprintf(fp, 9254, "{appearance {+edge -face} OFF %d %d 1 # Voronoi centers and cells\n",
                 numcenters, numvertices);
   else
-    fprintf (fp, "%d\n%d %d 1\n", qh hull_dim-1, numcenters, qh_setsize(vertices));
+    qh_fprintf(fp, 9255, "%d\n%d %d 1\n", qh hull_dim-1, numcenters, qh_setsize(vertices));
   if (format == qh_PRINTgeom) {
-    for (k= qh hull_dim-1; k--; )
-      fprintf (fp, qh_REAL_1, 0.0);
-    fprintf (fp, " 0 # infinity not used\n");
+    for (k=qh hull_dim-1; k--; )
+      qh_fprintf(fp, 9256, qh_REAL_1, 0.0);
+    qh_fprintf(fp, 9257, " 0 # infinity not used\n");
   }else {
-    for (k= qh hull_dim-1; k--; )
-      fprintf (fp, qh_REAL_1, qh_INFINITE);
-    fprintf (fp, "\n");
+    for (k=qh hull_dim-1; k--; )
+      qh_fprintf(fp, 9258, qh_REAL_1, qh_INFINITE);
+    qh_fprintf(fp, 9259, "\n");
   }
   FORALLfacet_(facetlist) {
     if (facet->visitid && facet->visitid < numfacets) {
       if (format == qh_PRINTgeom)
-        fprintf (fp, "# %d f%d\n", vid++, facet->id);
-      qh_printcenter (fp, format, NULL, facet);
+        qh_fprintf(fp, 9260, "# %d f%d\n", vid++, facet->id);
+      qh_printcenter(fp, format, NULL, facet);
     }
   }
   FOREACHfacet_(facets) {
     if (facet->visitid && facet->visitid < numfacets) {
       if (format == qh_PRINTgeom)
-        fprintf (fp, "# %d f%d\n", vid++, facet->id);
-      qh_printcenter (fp, format, NULL, facet);
+        qh_fprintf(fp, 9261, "# %d f%d\n", vid++, facet->id);
+      qh_printcenter(fp, format, NULL, facet);
     }
   }
   FOREACHvertex_i_(vertices) {
@@ -3534,117 +3443,123 @@
       if (qh hull_dim == 3)
         qh_order_vertexneighbors(vertex);
       else if (qh hull_dim >= 4)
-        qsort (SETaddr_(vertex->neighbors, vertexT), 
-	     qh_setsize (vertex->neighbors),
-	     sizeof (facetT *), qh_compare_facetvisit);
+        qsort(SETaddr_(vertex->neighbors, vertexT),
+             (size_t)qh_setsize(vertex->neighbors),
+             sizeof(facetT *), qh_compare_facetvisit);
       FOREACHneighbor_(vertex) {
         if (neighbor->visitid == 0)
-	  numinf= 1;
-	else if (neighbor->visitid < numfacets)
+          numinf= 1;
+        else if (neighbor->visitid < numfacets)
           numneighbors++;
       }
     }
     if (format == qh_PRINTgeom) {
       if (vertex) {
-	fprintf (fp, "%d", numneighbors);
-	if (vertex) {
-	  FOREACHneighbor_(vertex) {
-	    if (neighbor->visitid && neighbor->visitid < numfacets)
-	      fprintf (fp, " %d", neighbor->visitid);
-	  }
-	}
-	fprintf (fp, " # p%d (v%d)\n", vertex_i, vertex->id);
+        qh_fprintf(fp, 9262, "%d", numneighbors);
+        if (vertex) {
+          FOREACHneighbor_(vertex) {
+            if (neighbor->visitid && neighbor->visitid < numfacets)
+              qh_fprintf(fp, 9263, " %d", neighbor->visitid);
+          }
+        }
+        qh_fprintf(fp, 9264, " # p%d(v%d)\n", vertex_i, vertex->id);
       }else
-	fprintf (fp, " # p%d is coplanar or isolated\n", vertex_i);
+        qh_fprintf(fp, 9265, " # p%d is coplanar or isolated\n", vertex_i);
     }else {
       if (numinf)
-	numneighbors++;
-      fprintf (fp, "%d", numneighbors);
+        numneighbors++;
+      qh_fprintf(fp, 9266, "%d", numneighbors);
       if (vertex) {
         FOREACHneighbor_(vertex) {
-  	  if (neighbor->visitid == 0) {
-  	    if (numinf) {
-  	      numinf= 0;
-	      fprintf (fp, " %d", neighbor->visitid);
-	    }
-	  }else if (neighbor->visitid < numfacets)
-	    fprintf (fp, " %d", neighbor->visitid);
-	}
+          if (neighbor->visitid == 0) {
+            if (numinf) {
+              numinf= 0;
+              qh_fprintf(fp, 9267, " %d", neighbor->visitid);
+            }
+          }else if (neighbor->visitid < numfacets)
+            qh_fprintf(fp, 9268, " %d", neighbor->visitid);
+        }
       }
-      fprintf (fp, "\n");
+      qh_fprintf(fp, 9269, "\n");
     }
   }
   if (format == qh_PRINTgeom)
-    fprintf (fp, "}\n");
-  qh_settempfree (&vertices);
+    qh_fprintf(fp, 9270, "}\n");
+  qh_settempfree(&vertices);
 } /* printvoronoi */
-  
+
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvnorm">-</a>
-  
+
   qh_printvnorm( fp, vertex, vertexA, centers, unbounded )
     print one separating plane of the Voronoi diagram for a pair of input sites
     unbounded==True if centers includes vertex-at-infinity
-  
+
   assumes:
     qh_ASvoronoi and qh_vertexneighbors() already set
-    
+
+  note:
+    parameter unbounded is UNUSED by this callback
+
   see:
     qh_printvdiagram()
     qh_eachvoronoi()
 */
-void qh_printvnorm (FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded) {
+void qh_printvnorm(FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded) {
   pointT *normal;
   realT offset;
   int k;
-  
-  normal= qh_detvnorm (vertex, vertexA, centers, &offset);
-  fprintf (fp, "%d %d %d ", 
-      2+qh hull_dim, qh_pointid (vertex->point), qh_pointid (vertexA->point));
-  for (k= 0; k< qh hull_dim-1; k++)
-    fprintf (fp, qh_REAL_1, normal[k]);
-  fprintf (fp, qh_REAL_1, offset);
-  fprintf (fp, "\n");
+  QHULL_UNUSED(unbounded);
+
+  normal= qh_detvnorm(vertex, vertexA, centers, &offset);
+  qh_fprintf(fp, 9271, "%d %d %d ",
+      2+qh hull_dim, qh_pointid(vertex->point), qh_pointid(vertexA->point));
+  for (k=0; k< qh hull_dim-1; k++)
+    qh_fprintf(fp, 9272, qh_REAL_1, normal[k]);
+  qh_fprintf(fp, 9273, qh_REAL_1, offset);
+  qh_fprintf(fp, 9274, "\n");
 } /* printvnorm */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="printvridge">-</a>
-  
+
   qh_printvridge( fp, vertex, vertexA, centers, unbounded )
     print one ridge of the Voronoi diagram for a pair of input sites
     unbounded==True if centers includes vertex-at-infinity
-  
+
   see:
     qh_printvdiagram()
-  
+
   notes:
     the user may use a different function
+    parameter unbounded is UNUSED
 */
-void qh_printvridge (FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded) {
+void qh_printvridge(FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded) {
   facetT *facet, **facetp;
+  QHULL_UNUSED(unbounded);
 
-  fprintf (fp, "%d %d %d", qh_setsize (centers)+2, 
-       qh_pointid (vertex->point), qh_pointid (vertexA->point));
-  FOREACHfacet_(centers) 
-    fprintf (fp, " %d", facet->visitid);
-  fprintf (fp, "\n");
+  qh_fprintf(fp, 9275, "%d %d %d", qh_setsize(centers)+2,
+       qh_pointid(vertex->point), qh_pointid(vertexA->point));
+  FOREACHfacet_(centers)
+    qh_fprintf(fp, 9276, " %d", facet->visitid);
+  qh_fprintf(fp, 9277, "\n");
 } /* printvridge */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="projectdim3">-</a>
-  
+
   qh_projectdim3( source, destination )
     project 2-d 3-d or 4-d point to a 3-d point
     uses qh.DROPdim and qh.hull_dim
     source and destination may be the same
-    
+
   notes:
     allocate 4 elements to destination just in case
 */
 void qh_projectdim3 (pointT *source, pointT *destination) {
   int i,k;
 
-  for (k= 0, i=0; k < qh hull_dim; k++) {
+  for (k=0, i=0; k < qh hull_dim; k++) {
     if (qh hull_dim == 4) {
       if (k != qh DROPdim)
         destination[i++]= source[k];
@@ -3659,10 +3574,10 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="readfeasible">-</a>
-  
-  qh_readfeasible( dim, remainder )
-    read feasible point from remainder string and qh.fin
 
+  qh_readfeasible( dim, curline )
+    read feasible point from current line and qh.fin
+
   returns:
     number of lines read from qh.fin
     sets qh.FEASIBLEpoint with malloc'd coordinates
@@ -3674,24 +3589,25 @@
   see:
     qh_setfeasible
 */
-int qh_readfeasible (int dim, char *remainder) {
+int qh_readfeasible(int dim, const char *curline) {
   boolT isfirst= True;
   int linecount= 0, tokcount= 0;
-  char *s, *t, firstline[qh_MAXfirst+1];
+  const char *s;
+  char *t, firstline[qh_MAXfirst+1];
   coordT *coords, value;
 
   if (!qh HALFspace) {
-    fprintf  (qh ferr, "qhull input error: feasible point (dim 1 coords) is only valid for halfspace intersection\n");
-    qh_errexit (qh_ERRinput, NULL, NULL);
-  }  
+    qh_fprintf(qh ferr, 6070, "qhull input error: feasible point(dim 1 coords) is only valid for halfspace intersection\n");
+    qh_errexit(qh_ERRinput, NULL, NULL);
+  }
   if (qh feasible_string)
-    fprintf  (qh ferr, "qhull input warning: feasible point (dim 1 coords) overrides 'Hn,n,n' feasible point for halfspace intersection\n");
-  if (!(qh feasible_point= (coordT*)malloc (dim* sizeof(coordT)))) {
-    fprintf(qh ferr, "qhull error: insufficient memory for feasible point\n");
+    qh_fprintf(qh ferr, 7057, "qhull input warning: feasible point(dim 1 coords) overrides 'Hn,n,n' feasible point for halfspace intersection\n");
+  if (!(qh feasible_point= (coordT*)qh_malloc(dim* sizeof(coordT)))) {
+    qh_fprintf(qh ferr, 6071, "qhull error: insufficient memory for feasible point\n");
     qh_errexit(qh_ERRmem, NULL, NULL);
   }
   coords= qh feasible_point;
-  while ((s= (isfirst ?  remainder : fgets(firstline, qh_MAXfirst, qh fin)))) {
+  while ((s= (isfirst ?  curline : fgets(firstline, qh_MAXfirst, qh fin)))) {
     if (isfirst)
       isfirst= False;
     else
@@ -3699,33 +3615,33 @@
     while (*s) {
       while (isspace(*s))
         s++;
-      value= qh_strtod (s, &t);
+      value= qh_strtod(s, &t);
       if (s == t)
         break;
       s= t;
       *(coords++)= value;
       if (++tokcount == dim) {
-        while (isspace (*s))
+        while (isspace(*s))
           s++;
-        qh_strtod (s, &t);
+        qh_strtod(s, &t);
         if (s != t) {
-          fprintf (qh ferr, "qhull input error: coordinates for feasible point do not finish out the line: %s\n",
+          qh_fprintf(qh ferr, 6072, "qhull input error: coordinates for feasible point do not finish out the line: %s\n",
                s);
-          qh_errexit (qh_ERRinput, NULL, NULL);
+          qh_errexit(qh_ERRinput, NULL, NULL);
         }
         return linecount;
       }
     }
   }
-  fprintf (qh ferr, "qhull input error: only %d coordinates.  Could not read %d-d feasible point.\n",
+  qh_fprintf(qh ferr, 6073, "qhull input error: only %d coordinates.  Could not read %d-d feasible point.\n",
            tokcount, dim);
-  qh_errexit (qh_ERRinput, NULL, NULL);
+  qh_errexit(qh_ERRinput, NULL, NULL);
   return 0;
 } /* readfeasible */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="readpoints">-</a>
-  
+
   qh_readpoints( numpoints, dimension, ismalloc )
     read points from qh.fin into qh.first_point, qh.num_points
     qh.fin is lines of coordinates, one per vertex, first line number of points
@@ -3753,13 +3669,13 @@
   notes:
     dimension will change in qh_initqhull_globals if qh.PROJECTinput
     uses malloc() since qh_mem not initialized
-    FIXUP: this routine needs rewriting
+    FIXUP QH10012: qh_readpoints needs rewriting, too long
 */
 coordT *qh_readpoints(int *numpoints, int *dimension, boolT *ismalloc) {
   coordT *points, *coords, *infinity= NULL;
   realT paraboloid, maxboloid= -REALmax, value;
   realT *coordp= NULL, *offsetp= NULL, *normalp= NULL;
-  char *s, *t, firstline[qh_MAXfirst+1];
+  char *s= 0, *t, firstline[qh_MAXfirst+1];
   int diminput=0, numinput=0, dimfeasible= 0, newnum, k, tempi;
   int firsttext=0, firstshort=0, firstlong=0, firstpoint=0;
   int tokcount= 0, linecount=0, maxcount, coordcount=0;
@@ -3770,26 +3686,26 @@
     while ((s= fgets(firstline, qh_MAXfirst, qh fin))) {
       linecount++;
       if (qh HALFspace && linecount == 1 && isdigit(*s)) {
-	dimfeasible= qh_strtol (s, &s);	
-	while (isspace(*s))
+        dimfeasible= qh_strtol(s, &s);
+        while (isspace(*s))
           s++;
-        if (qh_strtol (s, &s) == 1)
-          linecount += qh_readfeasible (dimfeasible, s);
+        if (qh_strtol(s, &s) == 1)
+          linecount += qh_readfeasible(dimfeasible, s);
         else
           dimfeasible= 0;
-      }else if (!memcmp (firstline, "begin", 5) || !memcmp (firstline, "BEGIN", 5))
+      }else if (!memcmp(firstline, "begin", (size_t)5) || !memcmp(firstline, "BEGIN", (size_t)5))
         break;
       else if (!*qh rbox_command)
-	strncat(qh rbox_command, s, sizeof (qh rbox_command)-1);
+        strncat(qh rbox_command, s, sizeof(qh rbox_command)-1);
     }
     if (!s) {
-      fprintf (qh ferr, "qhull input error: missing \"begin\" for cdd-formated input\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6074, "qhull input error: missing \"begin\" for cdd-formated input\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
   }
-  while(!numinput && (s= fgets(firstline, qh_MAXfirst, qh fin))) {
+  while (!numinput && (s= fgets(firstline, qh_MAXfirst, qh fin))) {
     linecount++;
-    if (!memcmp (s, "begin", 5) || !memcmp (s, "BEGIN", 5))
+    if (!memcmp(s, "begin", (size_t)5) || !memcmp(s, "BEGIN", (size_t)5))
       wasbegin= True;
     while (*s) {
       while (isspace(*s))
@@ -3798,36 +3714,36 @@
         break;
       if (!isdigit(*s)) {
         if (!*qh rbox_command) {
-          strncat(qh rbox_command, s, sizeof (qh rbox_command)-1);
-	  firsttext= linecount;
+          strncat(qh rbox_command, s, sizeof(qh rbox_command)-1);
+          firsttext= linecount;
         }
         break;
       }
-      if (!diminput) 
-        diminput= qh_strtol (s, &s);
+      if (!diminput)
+        diminput= qh_strtol(s, &s);
       else {
-        numinput= qh_strtol (s, &s);
+        numinput= qh_strtol(s, &s);
         if (numinput == 1 && diminput >= 2 && qh HALFspace && !qh CDDinput) {
-          linecount += qh_readfeasible (diminput, s); /* checks if ok */
+          linecount += qh_readfeasible(diminput, s); /* checks if ok */
           dimfeasible= diminput;
           diminput= numinput= 0;
-        }else 
+        }else
           break;
       }
     }
   }
   if (!s) {
-    fprintf(qh ferr, "qhull input error: short input file.  Did not find dimension and number of points\n");
+    qh_fprintf(qh ferr, 6075, "qhull input error: short input file.  Did not find dimension and number of points\n");
     qh_errexit(qh_ERRinput, NULL, NULL);
   }
   if (diminput > numinput) {
-    tempi= diminput;	/* exchange dim and n, e.g., for cdd input format */
+    tempi= diminput;    /* exchange dim and n, e.g., for cdd input format */
     diminput= numinput;
     numinput= tempi;
   }
   if (diminput < 2) {
-    fprintf(qh ferr,"qhull input error: dimension %d (first number) should be at least 2\n",
-	    diminput);
+    qh_fprintf(qh ferr, 6220,"qhull input error: dimension %d(first number) should be at least 2\n",
+            diminput);
     qh_errexit(qh_ERRinput, NULL, NULL);
   }
   if (isdelaunay) {
@@ -3843,20 +3759,20 @@
     *dimension= diminput - 1;
     *numpoints= numinput;
     if (diminput < 3) {
-      fprintf(qh ferr,"qhull input error: dimension %d (first number, includes offset) should be at least 3 for halfspaces\n",
-  	    diminput);
+      qh_fprintf(qh ferr, 6221,"qhull input error: dimension %d(first number, includes offset) should be at least 3 for halfspaces\n",
+            diminput);
       qh_errexit(qh_ERRinput, NULL, NULL);
     }
     if (dimfeasible) {
       if (dimfeasible != *dimension) {
-        fprintf(qh ferr,"qhull input error: dimension %d of feasible point is not one less than dimension %d for halfspaces\n",
+        qh_fprintf(qh ferr, 6222,"qhull input error: dimension %d of feasible point is not one less than dimension %d for halfspaces\n",
           dimfeasible, diminput);
         qh_errexit(qh_ERRinput, NULL, NULL);
       }
-    }else 
-      qh_setfeasible (*dimension);
+    }else
+      qh_setfeasible(*dimension);
   }else {
-    if (qh CDDinput) 
+    if (qh CDDinput)
       *dimension= diminput-1;
     else
       *dimension= diminput;
@@ -3864,7 +3780,7 @@
   }
   qh normal_size= *dimension * sizeof(coordT); /* for tracing with qh_printpoint */
   if (qh HALFspace) {
-    qh half_space= coordp= (coordT*) malloc (qh normal_size + sizeof(coordT));
+    qh half_space= coordp= (coordT*)qh_malloc(qh normal_size + sizeof(coordT));
     if (qh CDDinput) {
       offsetp= qh half_space;
       normalp= offsetp + 1;
@@ -3872,16 +3788,16 @@
       normalp= qh half_space;
       offsetp= normalp + *dimension;
     }
-  } 
+  }
   qh maxline= diminput * (qh_REALdigits + 5);
   maximize_(qh maxline, 500);
-  qh line= (char*)malloc ((qh maxline+1) * sizeof (char));
+  qh line= (char*)qh_malloc((qh maxline+1) * sizeof(char));
   *ismalloc= True;  /* use malloc since memory not setup */
-  coords= points= qh temp_malloc= 
-        (coordT*)malloc((*numpoints)*(*dimension)*sizeof(coordT));
+  coords= points= qh temp_malloc=
+        (coordT*)qh_malloc((*numpoints)*(*dimension)*sizeof(coordT));
   if (!coords || !qh line || (qh HALFspace && !qh half_space)) {
-    fprintf(qh ferr, "qhull error: insufficient memory to read %d points\n",
-	    numinput);
+    qh_fprintf(qh ferr, 6076, "qhull error: insufficient memory to read %d points\n",
+            numinput);
     qh_errexit(qh_ERRmem, NULL, NULL);
   }
   if (isdelaunay && qh ATinfinity) {
@@ -3895,56 +3811,56 @@
     if (!isfirst) {
       linecount++;
       if (*s == 'e' || *s == 'E') {
-	if (!memcmp (s, "end", 3) || !memcmp (s, "END", 3)) {
-	  if (qh CDDinput )
-	    break;
-	  else if (wasbegin) 
-	    fprintf (qh ferr, "qhull input warning: the input appears to be in cdd format.  If so, use 'Fd'\n");
-	}
+        if (!memcmp(s, "end", (size_t)3) || !memcmp(s, "END", (size_t)3)) {
+          if (qh CDDinput )
+            break;
+          else if (wasbegin)
+            qh_fprintf(qh ferr, 7058, "qhull input warning: the input appears to be in cdd format.  If so, use 'Fd'\n");
+        }
       }
     }
     islong= False;
     while (*s) {
       while (isspace(*s))
         s++;
-      value= qh_strtod (s, &t);
+      value= qh_strtod(s, &t);
       if (s == t) {
         if (!*qh rbox_command)
- 	 strncat(qh rbox_command, s, sizeof (qh rbox_command)-1);
-        if (*s && !firsttext) 
+         strncat(qh rbox_command, s, sizeof(qh rbox_command)-1);
+        if (*s && !firsttext)
           firsttext= linecount;
         if (!islong && !firstshort && coordcount)
           firstshort= linecount;
         break;
       }
       if (!firstpoint)
-	firstpoint= linecount;
+        firstpoint= linecount;
       s= t;
       if (++tokcount > maxcount)
         continue;
       if (qh HALFspace) {
-	if (qh CDDinput) 
-	  *(coordp++)= -value; /* both coefficients and offset */
-	else
-	  *(coordp++)= value;
+        if (qh CDDinput)
+          *(coordp++)= -value; /* both coefficients and offset */
+        else
+          *(coordp++)= value;
       }else {
         *(coords++)= value;
         if (qh CDDinput && !coordcount) {
           if (value != 1.0) {
-            fprintf (qh ferr, "qhull input error: for cdd format, point at line %d does not start with '1'\n",
+            qh_fprintf(qh ferr, 6077, "qhull input error: for cdd format, point at line %d does not start with '1'\n",
                    linecount);
-            qh_errexit (qh_ERRinput, NULL, NULL);
+            qh_errexit(qh_ERRinput, NULL, NULL);
           }
           coords--;
         }else if (isdelaunay) {
-	  paraboloid += value * value;
-	  if (qh ATinfinity) {
-	    if (qh CDDinput)
-	      infinity[coordcount-1] += value;
-	    else
-	      infinity[coordcount] += value;
-	  }
-	}
+          paraboloid += value * value;
+          if (qh ATinfinity) {
+            if (qh CDDinput)
+              infinity[coordcount-1] += value;
+            else
+              infinity[coordcount] += value;
+          }
+        }
       }
       if (++coordcount == diminput) {
         coordcount= 0;
@@ -3953,49 +3869,49 @@
           maximize_(maxboloid, paraboloid);
           paraboloid= 0.0;
         }else if (qh HALFspace) {
-          if (!qh_sethalfspace (*dimension, coords, &coords, normalp, offsetp, qh feasible_point)) {
-	    fprintf (qh ferr, "The halfspace was on line %d\n", linecount);
-	    if (wasbegin)
-	      fprintf (qh ferr, "The input appears to be in cdd format.  If so, you should use option 'Fd'\n");
-	    qh_errexit (qh_ERRinput, NULL, NULL);
-	  }
+          if (!qh_sethalfspace(*dimension, coords, &coords, normalp, offsetp, qh feasible_point)) {
+            qh_fprintf(qh ferr, 8048, "The halfspace was on line %d\n", linecount);
+            if (wasbegin)
+              qh_fprintf(qh ferr, 8049, "The input appears to be in cdd format.  If so, you should use option 'Fd'\n");
+            qh_errexit(qh_ERRinput, NULL, NULL);
+          }
           coordp= qh half_space;
-        }          
+        }
         while (isspace(*s))
           s++;
         if (*s) {
           islong= True;
           if (!firstlong)
             firstlong= linecount;
-	}
+        }
       }
     }
     if (!islong && !firstshort && coordcount)
       firstshort= linecount;
     if (!isfirst && s - qh line >= qh maxline) {
-      fprintf(qh ferr, "qhull input error: line %d contained more than %d characters\n", 
-	      linecount, (int) (s - qh line));
+      qh_fprintf(qh ferr, 6078, "qhull input error: line %d contained more than %d characters\n",
+              linecount, (int) (s - qh line));   /* WARN64 */
       qh_errexit(qh_ERRinput, NULL, NULL);
     }
     isfirst= False;
   }
   if (tokcount != maxcount) {
     newnum= fmin_(numinput, tokcount/diminput);
-    fprintf(qh ferr,"\
+    qh_fprintf(qh ferr, 7073,"\
 qhull warning: instead of %d %d-dimensional points, input contains\n\
 %d points and %d extra coordinates.  Line %d is the first\npoint",
        numinput, diminput, tokcount/diminput, tokcount % diminput, firstpoint);
     if (firsttext)
-      fprintf(qh ferr, ", line %d is the first comment", firsttext);
+      qh_fprintf(qh ferr, 8051, ", line %d is the first comment", firsttext);
     if (firstshort)
-      fprintf(qh ferr, ", line %d is the first short\nline", firstshort);
+      qh_fprintf(qh ferr, 8052, ", line %d is the first short\nline", firstshort);
     if (firstlong)
-      fprintf(qh ferr, ", line %d is the first long line", firstlong);
-    fprintf(qh ferr, ".  Continue with %d points.\n", newnum);
+      qh_fprintf(qh ferr, 8053, ", line %d is the first long line", firstlong);
+    qh_fprintf(qh ferr, 8054, ".  Continue with %d points.\n", newnum);
     numinput= newnum;
     if (isdelaunay && qh ATinfinity) {
       for (k= tokcount % diminput; k--; )
-	infinity[k] -= *(--coords);
+        infinity[k] -= *(--coords);
       *numpoints= newnum+1;
     }else {
       coords -= tokcount % diminput;
@@ -4008,15 +3924,15 @@
     if (coords == infinity)
       coords += (*dimension) -1;
     else {
-      for (k= 0; k < (*dimension) -1; k++)
-	*(coords++)= infinity[k];
+      for (k=0; k < (*dimension) -1; k++)
+        *(coords++)= infinity[k];
     }
     *(coords++)= maxboloid * 1.1;
   }
   if (qh rbox_command[0]) {
     qh rbox_command[strlen(qh rbox_command)-1]= '\0';
-    if (!strcmp (qh rbox_command, "./rbox D4")) 
-      fprintf (qh ferr, "\n\
+    if (!strcmp(qh rbox_command, "./rbox D4"))
+      qh_fprintf(qh ferr, 8055, "\n\
 This is the qhull test case.  If any errors or core dumps occur,\n\
 recompile qhull with 'make new'.  If errors still occur, there is\n\
 an incompatibility.  You should try a different compiler.  You can also\n\
@@ -4025,22 +3941,22 @@
 \n\
 Type 'qhull' for a short list of options.\n");
   }
-  free (qh line);
+  qh_free(qh line);
   qh line= NULL;
   if (qh half_space) {
-    free (qh half_space);
+    qh_free(qh half_space);
     qh half_space= NULL;
   }
   qh temp_malloc= NULL;
-  trace1((qh ferr,"qh_readpoints: read in %d %d-dimensional points\n",
-	  numinput, diminput));
+  trace1((qh ferr, 1008,"qh_readpoints: read in %d %d-dimensional points\n",
+          numinput, diminput));
   return(points);
 } /* readpoints */
 
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="setfeasible">-</a>
-  
+
   qh_setfeasible( dim )
     set qh.FEASIBLEpoint from qh.feasible_string in "n,n,n" or "n n n" format
 
@@ -4048,26 +3964,26 @@
     "n,n,n" already checked by qh_initflags()
     see qh_readfeasible()
 */
-void qh_setfeasible (int dim) {
+void qh_setfeasible(int dim) {
   int tokcount= 0;
   char *s;
   coordT *coords, value;
 
   if (!(s= qh feasible_string)) {
-    fprintf(qh ferr, "\
+    qh_fprintf(qh ferr, 6223, "\
 qhull input error: halfspace intersection needs a feasible point.\n\
 Either prepend the input with 1 point or use 'Hn,n,n'.  See manual.\n");
-    qh_errexit (qh_ERRinput, NULL, NULL);
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
-  if (!(qh feasible_point= (pointT*)malloc (dim* sizeof(coordT)))) {
-    fprintf(qh ferr, "qhull error: insufficient memory for 'Hn,n,n'\n");
+  if (!(qh feasible_point= (pointT*)qh_malloc(dim * sizeof(coordT)))) {
+    qh_fprintf(qh ferr, 6079, "qhull error: insufficient memory for 'Hn,n,n'\n");
     qh_errexit(qh_ERRmem, NULL, NULL);
   }
   coords= qh feasible_point;
   while (*s) {
-    value= qh_strtod (s, &s);
+    value= qh_strtod(s, &s);
     if (++tokcount > dim) {
-      fprintf (qh ferr, "qhull input warning: more coordinates for 'H%s' than dimension %d\n",
+      qh_fprintf(qh ferr, 7059, "qhull input warning: more coordinates for 'H%s' than dimension %d\n",
           qh feasible_string, dim);
       break;
     }
@@ -4075,15 +3991,15 @@
     if (*s)
       s++;
   }
-  while (++tokcount <= dim)    
+  while (++tokcount <= dim)
     *(coords++)= 0.0;
 } /* setfeasible */
 
 /*-<a                             href="qh-io.htm#TOC"
   >-------------------------------</a><a name="skipfacet">-</a>
-  
+
   qh_skipfacet( facet )
-    returns 'True' if this facet is not to be printed 
+    returns 'True' if this facet is not to be printed
 
   notes:
     based on the user provided slice thresholds and 'good' specifications
@@ -4096,13 +4012,51 @@
       return !qh PRINTgood;
     FOREACHneighbor_(facet) {
       if (neighbor->good)
-	return False;
+        return False;
     }
     return True;
   }else if (qh PRINTgood)
     return !facet->good;
   else if (!facet->normal)
     return True;
-  return (!qh_inthresholds (facet->normal, NULL));
+  return(!qh_inthresholds(facet->normal, NULL));
 } /* skipfacet */
 
+/*-<a                             href="qh-io.htm#TOC"
+  >-------------------------------</a><a name="skipfilename">-</a>
+
+  qh_skipfilename( string )
+    returns pointer to character after filename
+
+  notes:
+    skips leading spaces
+    ends with spacing or eol
+    if starts with ' or " ends with the same, skipping \' or \"
+    For qhull, qh_argv_to_command() only uses double quotes
+*/
+char *qh_skipfilename(char *filename) {
+  char *s= filename;  /* non-const due to return */
+  char c;
+
+  while (*s && isspace(*s))
+    s++;
+  c= *s++;
+  if (c == '\0') {
+    qh_fprintf(qh ferr, 6204, "qhull input error: filename expected, none found.\n");
+    qh_errexit(qh_ERRinput, NULL, NULL);
+  }
+  if (c == '\'' || c == '"') {
+    while (*s !=c || s[-1] == '\\') {
+      if (!*s) {
+        qh_fprintf(qh ferr, 6203, "qhull input error: missing quote after filename -- %s\n", filename);
+        qh_errexit(qh_ERRinput, NULL, NULL);
+      }
+      s++;
+    }
+    s++;
+  }
+  else while (*s && !isspace(*s))
+      s++;
+  return s;
+} /* skipfilename */
+

Modified: trunk/scipy/spatial/qhull/src/io.h
===================================================================
--- trunk/scipy/spatial/qhull/src/io.h	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/io.h	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,22 +1,26 @@
 /*<html><pre>  -<a                             href="qh-io.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-   io.h 
+   io.h
    declarations of Input/Output functions
 
-   see README, qhull.h and io.c
+   see README, libqhull.h and io.c
 
-   copyright (c) 1993-2003, The Geometry Center
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/io.h#25 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 */
 
 #ifndef qhDEFio
 #define qhDEFio 1
 
+#include "libqhull.h"
+
 /*============ constants and flags ==================*/
 
 /*-<a                             href="qh-io.htm#TOC"
   >--------------------------------</a><a name="qh_MAXfirst">-</a>
-  
+
   qh_MAXfirst
     maximum length of first two lines of stdin
 */
@@ -24,7 +28,7 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >--------------------------------</a><a name="qh_MINradius">-</a>
-  
+
   qh_MINradius
     min radius for Gp and Gv, fraction of maxcoord
 */
@@ -32,16 +36,16 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >--------------------------------</a><a name="qh_GEOMepsilon">-</a>
-  
+
   qh_GEOMepsilon
-    adjust outer planes for 'lines closer' and geomview roundoff.  
+    adjust outer planes for 'lines closer' and geomview roundoff.
     This prevents bleed through.
 */
 #define qh_GEOMepsilon 2e-3
 
 /*-<a                             href="qh-io.htm#TOC"
   >--------------------------------</a><a name="qh_WHITESPACE">-</a>
-  
+
   qh_WHITESPACE
     possible values of white space
 */
@@ -50,7 +54,7 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >--------------------------------</a><a name="RIDGE">-</a>
-  
+
   qh_RIDGE
     to select which ridges to print in qh_eachvoronoi
 */
@@ -62,7 +66,7 @@
 
 /*-<a                             href="qh-io.htm#TOC"
   >--------------------------------</a><a name="printvridgeT">-</a>
-  
+
   printvridgeT
     prints results of qh_printvdiagram
 
@@ -73,82 +77,83 @@
 
 /*============== -prototypes in alphabetical order =========*/
 
-void    dfacet( unsigned id);
-void    dvertex( unsigned id);
-int	qh_compare_facetarea(const void *p1, const void *p2);
-int	qh_compare_facetmerge(const void *p1, const void *p2);
-int	qh_compare_facetvisit(const void *p1, const void *p2);
-int	qh_compare_vertexpoint(const void *p1, const void *p2); /* not used */
-
-void    qh_countfacets (facetT *facetlist, setT *facets, boolT printall, 
-              int *numfacetsp, int *numsimplicialp, int *totneighborsp, 
+void    dfacet(unsigned id);
+void    dvertex(unsigned id);
+int     qh_compare_facetarea(const void *p1, const void *p2);
+int     qh_compare_facetmerge(const void *p1, const void *p2);
+int     qh_compare_facetvisit(const void *p1, const void *p2);
+int     qh_compare_vertexpoint(const void *p1, const void *p2); /* not used */
+void    qh_copyfilename(char *filename, int size, const char* source, int length);
+void    qh_countfacets(facetT *facetlist, setT *facets, boolT printall,
+              int *numfacetsp, int *numsimplicialp, int *totneighborsp,
               int *numridgesp, int *numcoplanarsp, int *numnumtricoplanarsp);
-pointT *qh_detvnorm (vertexT *vertex, vertexT *vertexA, setT *centers, realT *offsetp);
-setT   *qh_detvridge (vertexT *vertex);
+pointT *qh_detvnorm(vertexT *vertex, vertexT *vertexA, setT *centers, realT *offsetp);
+setT   *qh_detvridge(vertexT *vertex);
 setT   *qh_detvridge3 (vertexT *atvertex, vertexT *vertex);
-int     qh_eachvoronoi (FILE *fp, printvridgeT printvridge, vertexT *atvertex, boolT visitall, qh_RIDGE innerouter, boolT inorder);
-int     qh_eachvoronoi_all (FILE *fp, printvridgeT printvridge, boolT isupper, qh_RIDGE innerouter, boolT inorder);
-void	qh_facet2point(facetT *facet, pointT **point0, pointT **point1, realT *mindist);
-setT   *qh_facetvertices (facetT *facetlist, setT *facets, boolT allfacets);
-void    qh_geomplanes (facetT *facet, realT *outerplane, realT *innerplane);
-void    qh_markkeep (facetT *facetlist);
-setT   *qh_markvoronoi (facetT *facetlist, setT *facets, boolT printall, boolT *islowerp, int *numcentersp);
+int     qh_eachvoronoi(FILE *fp, printvridgeT printvridge, vertexT *atvertex, boolT visitall, qh_RIDGE innerouter, boolT inorder);
+int     qh_eachvoronoi_all(FILE *fp, printvridgeT printvridge, boolT isUpper, qh_RIDGE innerouter, boolT inorder);
+void    qh_facet2point(facetT *facet, pointT **point0, pointT **point1, realT *mindist);
+setT   *qh_facetvertices(facetT *facetlist, setT *facets, boolT allfacets);
+void    qh_geomplanes(facetT *facet, realT *outerplane, realT *innerplane);
+void    qh_markkeep(facetT *facetlist);
+setT   *qh_markvoronoi(facetT *facetlist, setT *facets, boolT printall, boolT *isLowerp, int *numcentersp);
 void    qh_order_vertexneighbors(vertexT *vertex);
-void	qh_printafacet(FILE *fp, int format, facetT *facet, boolT printall);
-void    qh_printbegin (FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall);
-void 	qh_printcenter (FILE *fp, int format, char *string, facetT *facet);
-void    qh_printcentrum (FILE *fp, facetT *facet, realT radius);
-void    qh_printend (FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall);
-void    qh_printend4geom (FILE *fp, facetT *facet, int *num, boolT printall);
-void    qh_printextremes (FILE *fp, facetT *facetlist, setT *facets, int printall);
-void    qh_printextremes_2d (FILE *fp, facetT *facetlist, setT *facets, int printall);
-void    qh_printextremes_d (FILE *fp, facetT *facetlist, setT *facets, int printall);
-void	qh_printfacet(FILE *fp, facetT *facet);
-void	qh_printfacet2math(FILE *fp, facetT *facet, int format, int notfirst);
-void	qh_printfacet2geom(FILE *fp, facetT *facet, realT color[3]);
+void    qh_prepare_output(void);
+void    qh_printafacet(FILE *fp, qh_PRINT format, facetT *facet, boolT printall);
+void    qh_printbegin(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printcenter(FILE *fp, qh_PRINT format, const char *string, facetT *facet);
+void    qh_printcentrum(FILE *fp, facetT *facet, realT radius);
+void    qh_printend(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printend4geom(FILE *fp, facetT *facet, int *num, boolT printall);
+void    qh_printextremes(FILE *fp, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printextremes_2d(FILE *fp, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printextremes_d(FILE *fp, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printfacet(FILE *fp, facetT *facet);
+void    qh_printfacet2math(FILE *fp, facetT *facet, qh_PRINT format, int notfirst);
+void    qh_printfacet2geom(FILE *fp, facetT *facet, realT color[3]);
 void    qh_printfacet2geom_points(FILE *fp, pointT *point1, pointT *point2,
-			       facetT *facet, realT offset, realT color[3]);
-void	qh_printfacet3math (FILE *fp, facetT *facet, int format, int notfirst);
-void	qh_printfacet3geom_nonsimplicial(FILE *fp, facetT *facet, realT color[3]);
-void	qh_printfacet3geom_points(FILE *fp, setT *points, facetT *facet, realT offset, realT color[3]);
-void	qh_printfacet3geom_simplicial(FILE *fp, facetT *facet, realT color[3]);
-void	qh_printfacet3vertex(FILE *fp, facetT *facet, int format);
-void	qh_printfacet4geom_nonsimplicial(FILE *fp, facetT *facet, realT color[3]);
-void	qh_printfacet4geom_simplicial(FILE *fp, facetT *facet, realT color[3]);
-void	qh_printfacetNvertex_nonsimplicial(FILE *fp, facetT *facet, int id, int format);
-void	qh_printfacetNvertex_simplicial(FILE *fp, facetT *facet, int format);
+                               facetT *facet, realT offset, realT color[3]);
+void    qh_printfacet3math(FILE *fp, facetT *facet, qh_PRINT format, int notfirst);
+void    qh_printfacet3geom_nonsimplicial(FILE *fp, facetT *facet, realT color[3]);
+void    qh_printfacet3geom_points(FILE *fp, setT *points, facetT *facet, realT offset, realT color[3]);
+void    qh_printfacet3geom_simplicial(FILE *fp, facetT *facet, realT color[3]);
+void    qh_printfacet3vertex(FILE *fp, facetT *facet, qh_PRINT format);
+void    qh_printfacet4geom_nonsimplicial(FILE *fp, facetT *facet, realT color[3]);
+void    qh_printfacet4geom_simplicial(FILE *fp, facetT *facet, realT color[3]);
+void    qh_printfacetNvertex_nonsimplicial(FILE *fp, facetT *facet, int id, qh_PRINT format);
+void    qh_printfacetNvertex_simplicial(FILE *fp, facetT *facet, qh_PRINT format);
 void    qh_printfacetheader(FILE *fp, facetT *facet);
 void    qh_printfacetridges(FILE *fp, facetT *facet);
-void	qh_printfacets(FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall);
-void	qh_printhelp_degenerate(FILE *fp);
-void	qh_printhelp_singular(FILE *fp);
-void	qh_printhyperplaneintersection(FILE *fp, facetT *facet1, facetT *facet2,
-  		   setT *vertices, realT color[3]);
-void	qh_printneighborhood (FILE *fp, int format, facetT *facetA, facetT *facetB, boolT printall);
-void    qh_printline3geom (FILE *fp, pointT *pointA, pointT *pointB, realT color[3]);
-void	qh_printpoint(FILE *fp, char *string, pointT *point);
-void	qh_printpointid(FILE *fp, char *string, int dim, pointT *point, int id);
+void    qh_printfacets(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printhyperplaneintersection(FILE *fp, facetT *facet1, facetT *facet2,
+                   setT *vertices, realT color[3]);
+void    qh_printneighborhood(FILE *fp, qh_PRINT format, facetT *facetA, facetT *facetB, boolT printall);
+void    qh_printline3geom(FILE *fp, pointT *pointA, pointT *pointB, realT color[3]);
+void    qh_printpoint(FILE *fp, const char *string, pointT *point);
+void    qh_printpointid(FILE *fp, const char *string, int dim, pointT *point, int id);
 void    qh_printpoint3 (FILE *fp, pointT *point);
-void    qh_printpoints_out (FILE *fp, facetT *facetlist, setT *facets, int printall);
-void    qh_printpointvect (FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius, realT color[3]);
+void    qh_printpoints_out(FILE *fp, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printpointvect(FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius, realT color[3]);
 void    qh_printpointvect2 (FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius);
-void	qh_printridge(FILE *fp, ridgeT *ridge);
+void    qh_printridge(FILE *fp, ridgeT *ridge);
 void    qh_printspheres(FILE *fp, setT *vertices, realT radius);
-void    qh_printvdiagram (FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printvdiagram(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
 int     qh_printvdiagram2 (FILE *fp, printvridgeT printvridge, setT *vertices, qh_RIDGE innerouter, boolT inorder);
-void	qh_printvertex(FILE *fp, vertexT *vertex);
-void	qh_printvertexlist (FILE *fp, char* string, facetT *facetlist,
+void    qh_printvertex(FILE *fp, vertexT *vertex);
+void    qh_printvertexlist(FILE *fp, const char* string, facetT *facetlist,
                          setT *facets, boolT printall);
-void	qh_printvertices (FILE *fp, char* string, setT *vertices);
-void    qh_printvneighbors (FILE *fp, facetT* facetlist, setT *facets, boolT printall);
-void    qh_printvoronoi (FILE *fp, int format, facetT *facetlist, setT *facets, boolT printall);
-void    qh_printvnorm (FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded);
-void    qh_printvridge (FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded);
-void	qh_produce_output(void);
+void    qh_printvertices(FILE *fp, const char* string, setT *vertices);
+void    qh_printvneighbors(FILE *fp, facetT* facetlist, setT *facets, boolT printall);
+void    qh_printvoronoi(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
+void    qh_printvnorm(FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded);
+void    qh_printvridge(FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded);
+void    qh_produce_output(void);
+void    qh_produce_output2(void);
 void    qh_projectdim3 (pointT *source, pointT *destination);
-int     qh_readfeasible (int dim, char *remainder);
+int     qh_readfeasible(int dim, const char *curline);
 coordT *qh_readpoints(int *numpoints, int *dimension, boolT *ismalloc);
-void    qh_setfeasible (int dim);
-boolT	qh_skipfacet(facetT *facet);
+void    qh_setfeasible(int dim);
+boolT   qh_skipfacet(facetT *facet);
+char   *qh_skipfilename(char *filename);
 
 #endif /* qhDEFio */

Copied: trunk/scipy/spatial/qhull/src/libqhull.c (from rev 6901, trunk/scipy/spatial/qhull/src/qhull.c)
===================================================================
--- trunk/scipy/spatial/qhull/src/libqhull.c	                        (rev 0)
+++ trunk/scipy/spatial/qhull/src/libqhull.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -0,0 +1,1401 @@
+/*<html><pre>  -<a                             href="qh-qhull.htm"
+  >-------------------------------</a><a name="TOP">-</a>
+
+   libqhull.c
+   Quickhull algorithm for convex hulls
+
+   qhull() and top-level routines
+
+   see qh-qhull.htm, libqhull.h, unix.c
+
+   see qhull_a.h for internal functions
+
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/libqhull.c#7 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
+*/
+
+#include "qhull_a.h"
+
+/*============= functions in alphabetic order after qhull() =======*/
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="qhull">-</a>
+
+  qh_qhull()
+    compute DIM3 convex hull of qh.num_points starting at qh.first_point
+    qh contains all global options and variables
+
+  returns:
+    returns polyhedron
+      qh.facet_list, qh.num_facets, qh.vertex_list, qh.num_vertices,
+
+    returns global variables
+      qh.hulltime, qh.max_outside, qh.interior_point, qh.max_vertex, qh.min_vertex
+
+    returns precision constants
+      qh.ANGLEround, centrum_radius, cos_max, DISTround, MAXabs_coord, ONEmerge
+
+  notes:
+    unless needed for output
+      qh.max_vertex and qh.min_vertex are max/min due to merges
+
+  see:
+    to add individual points to either qh.num_points
+      use qh_addpoint()
+
+    if qh.GETarea
+      qh_produceoutput() returns qh.totarea and qh.totvol via qh_getarea()
+
+  design:
+    record starting time
+    initialize hull and partition points
+    build convex hull
+    unless early termination
+      update facet->maxoutside for vertices, coplanar, and near-inside points
+    error if temporary sets exist
+    record end time
+*/
+
+void qh_qhull(void) {
+  int numoutside;
+
+  qh hulltime= qh_CPUclock;
+  if (qh RERUN || qh JOGGLEmax < REALmax/2)
+    qh_build_withrestart();
+  else {
+    qh_initbuild();
+    qh_buildhull();
+  }
+  if (!qh STOPpoint && !qh STOPcone) {
+    if (qh ZEROall_ok && !qh TESTvneighbors && qh MERGEexact)
+      qh_checkzero( qh_ALL);
+    if (qh ZEROall_ok && !qh TESTvneighbors && !qh WAScoplanar) {
+      trace2((qh ferr, 2055, "qh_qhull: all facets are clearly convex and no coplanar points.  Post-merging and check of maxout not needed.\n"));
+      qh DOcheckmax= False;
+    }else {
+      if (qh MERGEexact || (qh hull_dim > qh_DIMreduceBuild && qh PREmerge))
+        qh_postmerge("First post-merge", qh premerge_centrum, qh premerge_cos,
+             (qh POSTmerge ? False : qh TESTvneighbors));
+      else if (!qh POSTmerge && qh TESTvneighbors)
+        qh_postmerge("For testing vertex neighbors", qh premerge_centrum,
+             qh premerge_cos, True);
+      if (qh POSTmerge)
+        qh_postmerge("For post-merging", qh postmerge_centrum,
+             qh postmerge_cos, qh TESTvneighbors);
+      if (qh visible_list == qh facet_list) { /* i.e., merging done */
+        qh findbestnew= True;
+        qh_partitionvisible(/*visible_list, newfacet_list*/ !qh_ALL, &numoutside);
+        qh findbestnew= False;
+        qh_deletevisible(/*qh visible_list*/);
+        qh_resetlists(False, qh_RESETvisible /*qh visible_list newvertex_list newfacet_list */);
+      }
+    }
+    if (qh DOcheckmax){
+      if (qh REPORTfreq) {
+        qh_buildtracing(NULL, NULL);
+        qh_fprintf(qh ferr, 8115, "\nTesting all coplanar points.\n");
+      }
+      qh_check_maxout();
+    }
+    if (qh KEEPnearinside && !qh maxoutdone)
+      qh_nearcoplanar();
+  }
+  if (qh_setsize(qhmem.tempstack) != 0) {
+    qh_fprintf(qh ferr, 6164, "qhull internal error (qh_qhull): temporary sets not empty(%d)\n",
+             qh_setsize(qhmem.tempstack));
+    qh_errexit(qh_ERRqhull, NULL, NULL);
+  }
+  qh hulltime= qh_CPUclock - qh hulltime;
+  qh QHULLfinished= True;
+  trace1((qh ferr, 1036, "Qhull: algorithm completed\n"));
+} /* qhull */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="addpoint">-</a>
+
+  qh_addpoint( furthest, facet, checkdist )
+    add point (usually furthest point) above facet to hull
+    if checkdist,
+      check that point is above facet.
+      if point is not outside of the hull, uses qh_partitioncoplanar()
+      assumes that facet is defined by qh_findbestfacet()
+    else if facet specified,
+      assumes that point is above facet (major damage if below)
+    for Delaunay triangulations,
+      Use qh_setdelaunay() to lift point to paraboloid and scale by 'Qbb' if needed
+      Do not use options 'Qbk', 'QBk', or 'QbB' since they scale the coordinates.
+
+  returns:
+    returns False if user requested an early termination
+     qh.visible_list, newfacet_list, delvertex_list, NEWfacets may be defined
+    updates qh.facet_list, qh.num_facets, qh.vertex_list, qh.num_vertices
+    clear qh.maxoutdone (will need to call qh_check_maxout() for facet->maxoutside)
+    if unknown point, adds a pointer to qh.other_points
+      do not deallocate the point's coordinates
+
+  notes:
+    assumes point is near its best facet and not at a local minimum of a lens
+      distributions.  Use qh_findbestfacet to avoid this case.
+    uses qh.visible_list, qh.newfacet_list, qh.delvertex_list, qh.NEWfacets
+
+  see also:
+    qh_triangulate() -- triangulate non-simplicial facets
+
+  design:
+    add point to other_points if needed
+    if checkdist
+      if point not above facet
+        partition coplanar point
+        exit
+    exit if pre STOPpoint requested
+    find horizon and visible facets for point
+    make new facets for point to horizon
+    make hyperplanes for point
+    compute balance statistics
+    match neighboring new facets
+    update vertex neighbors and delete interior vertices
+    exit if STOPcone requested
+    merge non-convex new facets
+    if merge found, many merges, or 'Qf'
+       use qh_findbestnew() instead of qh_findbest()
+    partition outside points from visible facets
+    delete visible facets
+    check polyhedron if requested
+    exit if post STOPpoint requested
+    reset working lists of facets and vertices
+*/
+boolT qh_addpoint(pointT *furthest, facetT *facet, boolT checkdist) {
+  int goodvisible, goodhorizon;
+  vertexT *vertex;
+  facetT *newfacet;
+  realT dist, newbalance, pbalance;
+  boolT isoutside= False;
+  int numpart, numpoints, numnew, firstnew;
+
+  qh maxoutdone= False;
+  if (qh_pointid(furthest) == -1)
+    qh_setappend(&qh other_points, furthest);
+  if (!facet) {
+    qh_fprintf(qh ferr, 6213, "qhull internal error (qh_addpoint): NULL facet.  Need to call qh_findbestfacet first\n");
+    qh_errexit(qh_ERRqhull, NULL, NULL);
+  }
+  if (checkdist) {
+    facet= qh_findbest(furthest, facet, !qh_ALL, !qh_ISnewfacets, !qh_NOupper,
+                        &dist, &isoutside, &numpart);
+    zzadd_(Zpartition, numpart);
+    if (!isoutside) {
+      zinc_(Znotmax);  /* last point of outsideset is no longer furthest. */
+      facet->notfurthest= True;
+      qh_partitioncoplanar(furthest, facet, &dist);
+      return True;
+    }
+  }
+  qh_buildtracing(furthest, facet);
+  if (qh STOPpoint < 0 && qh furthest_id == -qh STOPpoint-1) {
+    facet->notfurthest= True;
+    return False;
+  }
+  qh_findhorizon(furthest, facet, &goodvisible, &goodhorizon);
+  if (qh ONLYgood && !(goodvisible+goodhorizon) && !qh GOODclosest) {
+    zinc_(Znotgood);
+    facet->notfurthest= True;
+    /* last point of outsideset is no longer furthest.  This is ok
+       since all points of the outside are likely to be bad */
+    qh_resetlists(False, qh_RESETvisible /*qh visible_list newvertex_list newfacet_list */);
+    return True;
+  }
+  zzinc_(Zprocessed);
+  firstnew= qh facet_id;
+  vertex= qh_makenewfacets(furthest /*visible_list, attaches if !ONLYgood */);
+  qh_makenewplanes(/* newfacet_list */);
+  numnew= qh facet_id - firstnew;
+  newbalance= numnew - (realT) (qh num_facets-qh num_visible)
+                         * qh hull_dim/qh num_vertices;
+  wadd_(Wnewbalance, newbalance);
+  wadd_(Wnewbalance2, newbalance * newbalance);
+  if (qh ONLYgood
+  && !qh_findgood(qh newfacet_list, goodhorizon) && !qh GOODclosest) {
+    FORALLnew_facets
+      qh_delfacet(newfacet);
+    qh_delvertex(vertex);
+    qh_resetlists(True, qh_RESETvisible /*qh visible_list newvertex_list newfacet_list */);
+    zinc_(Znotgoodnew);
+    facet->notfurthest= True;
+    return True;
+  }
+  if (qh ONLYgood)
+    qh_attachnewfacets(/*visible_list*/);
+  qh_matchnewfacets();
+  qh_updatevertices();
+  if (qh STOPcone && qh furthest_id == qh STOPcone-1) {
+    facet->notfurthest= True;
+    return False;  /* visible_list etc. still defined */
+  }
+  qh findbestnew= False;
+  if (qh PREmerge || qh MERGEexact) {
+    qh_premerge(vertex, qh premerge_centrum, qh premerge_cos);
+    if (qh_USEfindbestnew)
+      qh findbestnew= True;
+    else {
+      FORALLnew_facets {
+        if (!newfacet->simplicial) {
+          qh findbestnew= True;  /* use qh_findbestnew instead of qh_findbest*/
+          break;
+        }
+      }
+    }
+  }else if (qh BESToutside)
+    qh findbestnew= True;
+  qh_partitionvisible(/*visible_list, newfacet_list*/ !qh_ALL, &numpoints);
+  qh findbestnew= False;
+  qh findbest_notsharp= False;
+  zinc_(Zpbalance);
+  pbalance= numpoints - (realT) qh hull_dim /* assumes all points extreme */
+                * (qh num_points - qh num_vertices)/qh num_vertices;
+  wadd_(Wpbalance, pbalance);
+  wadd_(Wpbalance2, pbalance * pbalance);
+  qh_deletevisible(/*qh visible_list*/);
+  zmax_(Zmaxvertex, qh num_vertices);
+  qh NEWfacets= False;
+  if (qh IStracing >= 4) {
+    if (qh num_facets < 2000)
+      qh_printlists();
+    qh_printfacetlist(qh newfacet_list, NULL, True);
+    qh_checkpolygon(qh facet_list);
+  }else if (qh CHECKfrequently) {
+    if (qh num_facets < 50)
+      qh_checkpolygon(qh facet_list);
+    else
+      qh_checkpolygon(qh newfacet_list);
+  }
+  if (qh STOPpoint > 0 && qh furthest_id == qh STOPpoint-1)
+    return False;
+  qh_resetlists(True, qh_RESETvisible /*qh visible_list newvertex_list newfacet_list */);
+  /* qh_triangulate(); to test qh.TRInormals */
+  trace2((qh ferr, 2056, "qh_addpoint: added p%d new facets %d new balance %2.2g point balance %2.2g\n",
+    qh_pointid(furthest), numnew, newbalance, pbalance));
+  return True;
+} /* addpoint */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="build_withrestart">-</a>
+
+  qh_build_withrestart()
+    allow restarts due to qh.JOGGLEmax while calling qh_buildhull()
+    qh.FIRSTpoint/qh.NUMpoints is point array
+        it may be moved by qh_joggleinput()
+*/
+void qh_build_withrestart(void) {
+  int restart;
+
+  qh ALLOWrestart= True;
+  while (True) {
+    restart= setjmp(qh restartexit); /* simple statement for CRAY J916 */
+    if (restart) {       /* only from qh_precision() */
+      zzinc_(Zretry);
+      wmax_(Wretrymax, qh JOGGLEmax);
+      /* QH7078 warns about using 'TCn' with 'QJn' */
+      qh STOPcone= -1; /* if break from joggle, prevents normal output */
+    }
+    if (!qh RERUN && qh JOGGLEmax < REALmax/2) {
+      if (qh build_cnt > qh_JOGGLEmaxretry) {
+        qh_fprintf(qh ferr, 6229, "qhull precision error: %d attempts to construct a convex hull\n\
+        with joggled input.  Increase joggle above 'QJ%2.2g'\n\
+        or modify qh_JOGGLE... parameters in user.h\n",
+           qh build_cnt, qh JOGGLEmax);
+        qh_errexit(qh_ERRqhull, NULL, NULL);
+      }
+      if (qh build_cnt && !restart)
+        break;
+    }else if (qh build_cnt && qh build_cnt >= qh RERUN)
+      break;
+    qh STOPcone= 0;
+    qh_freebuild(True);  /* first call is a nop */
+    qh build_cnt++;
+    if (!qh qhull_optionsiz)
+      qh qhull_optionsiz= (int)strlen(qh qhull_options);   /* WARN64 */
+    else {
+      qh qhull_options [qh qhull_optionsiz]= '\0';
+      qh qhull_optionlen= qh_OPTIONline;  /* starts a new line */
+    }
+    qh_option("_run", &qh build_cnt, NULL);
+    if (qh build_cnt == qh RERUN) {
+      qh IStracing= qh TRACElastrun;  /* duplicated from qh_initqhull_globals */
+      if (qh TRACEpoint != -1 || qh TRACEdist < REALmax/2 || qh TRACEmerge) {
+        qh TRACElevel= (qh IStracing? qh IStracing : 3);
+        qh IStracing= 0;
+      }
+      qhmem.IStracing= qh IStracing;
+    }
+    if (qh JOGGLEmax < REALmax/2)
+      qh_joggleinput();
+    qh_initbuild();
+    qh_buildhull();
+    if (qh JOGGLEmax < REALmax/2 && !qh MERGING)
+      qh_checkconvex(qh facet_list, qh_ALGORITHMfault);
+  }
+  qh ALLOWrestart= False;
+} /* qh_build_withrestart */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="buildhull">-</a>
+
+  qh_buildhull()
+    construct a convex hull by adding outside points one at a time
+
+  returns:
+
+  notes:
+    may be called multiple times
+    checks facet and vertex lists for incorrect flags
+    to recover from STOPcone, call qh_deletevisible and qh_resetlists
+
+  design:
+    check visible facet and newfacet flags
+    check newlist vertex flags and qh.STOPcone/STOPpoint
+    for each facet with a furthest outside point
+      add point to facet
+      exit if qh.STOPcone or qh.STOPpoint requested
+    if qh.NARROWhull for initial simplex
+      partition remaining outside points to coplanar sets
+*/
+void qh_buildhull(void) {
+  facetT *facet;
+  pointT *furthest;
+  vertexT *vertex;
+  int id;
+
+  trace1((qh ferr, 1037, "qh_buildhull: start build hull\n"));
+  FORALLfacets {
+    if (facet->visible || facet->newfacet) {
+      qh_fprintf(qh ferr, 6165, "qhull internal error (qh_buildhull): visible or new facet f%d in facet list\n",
+                   facet->id);
+      qh_errexit(qh_ERRqhull, facet, NULL);
+    }
+  }
+  FORALLvertices {
+    if (vertex->newlist) {
+      qh_fprintf(qh ferr, 6166, "qhull internal error (qh_buildhull): new vertex f%d in vertex list\n",
+                   vertex->id);
+      qh_errprint("ERRONEOUS", NULL, NULL, NULL, vertex);
+      qh_errexit(qh_ERRqhull, NULL, NULL);
+    }
+    id= qh_pointid(vertex->point);
+    if ((qh STOPpoint>0 && id == qh STOPpoint-1) ||
+        (qh STOPpoint<0 && id == -qh STOPpoint-1) ||
+        (qh STOPcone>0 && id == qh STOPcone-1)) {
+      trace1((qh ferr, 1038,"qh_buildhull: stop point or cone P%d in initial hull\n", id));
+      return;
+    }
+  }
+  qh facet_next= qh facet_list;      /* advance facet when processed */
+  while ((furthest= qh_nextfurthest(&facet))) {
+    qh num_outside--;  /* if ONLYmax, furthest may not be outside */
+    if (!qh_addpoint(furthest, facet, qh ONLYmax))
+      break;
+  }
+  if (qh NARROWhull) /* move points from outsideset to coplanarset */
+    qh_outcoplanar( /* facet_list */ );
+  if (qh num_outside && !furthest) {
+    qh_fprintf(qh ferr, 6167, "qhull internal error (qh_buildhull): %d outside points were never processed.\n", qh num_outside);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
+  }
+  trace1((qh ferr, 1039, "qh_buildhull: completed the hull construction\n"));
+} /* buildhull */
+
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="buildtracing">-</a>
+
+  qh_buildtracing( furthest, facet )
+    trace an iteration of qh_buildhull() for furthest point and facet
+    if !furthest, prints progress message
+
+  returns:
+    tracks progress with qh.lastreport
+    updates qh.furthest_id (-3 if furthest is NULL)
+    also resets visit_id, vertext_visit on wrap around
+
+  see:
+    qh_tracemerging()
+
+  design:
+    if !furthest
+      print progress message
+      exit
+    if 'TFn' iteration
+      print progress message
+    else if tracing
+      trace furthest point and facet
+    reset qh.visit_id and qh.vertex_visit if overflow may occur
+    set qh.furthest_id for tracing
+*/
+void qh_buildtracing(pointT *furthest, facetT *facet) {
+  realT dist= 0;
+  float cpu;
+  int total, furthestid;
+  time_t timedata;
+  struct tm *tp;
+  vertexT *vertex;
+
+  qh old_randomdist= qh RANDOMdist;
+  qh RANDOMdist= False;
+  if (!furthest) {
+    time(&timedata);
+    tp= localtime(&timedata);
+    cpu= (float)qh_CPUclock - (float)qh hulltime;
+    cpu /= (float)qh_SECticks;
+    total= zzval_(Ztotmerge) - zzval_(Zcyclehorizon) + zzval_(Zcyclefacettot);
+    qh_fprintf(qh ferr, 8118, "\n\
+At %02d:%02d:%02d & %2.5g CPU secs, qhull has created %d facets and merged %d.\n\
+ The current hull contains %d facets and %d vertices.  Last point was p%d\n",
+      tp->tm_hour, tp->tm_min, tp->tm_sec, cpu, qh facet_id -1,
+      total, qh num_facets, qh num_vertices, qh furthest_id);
+    return;
+  }
+  furthestid= qh_pointid(furthest);
+  if (qh TRACEpoint == furthestid) {
+    qh IStracing= qh TRACElevel;
+    qhmem.IStracing= qh TRACElevel;
+  }else if (qh TRACEpoint != -1 && qh TRACEdist < REALmax/2) {
+    qh IStracing= 0;
+    qhmem.IStracing= 0;
+  }
+  if (qh REPORTfreq && (qh facet_id-1 > qh lastreport+qh REPORTfreq)) {
+    qh lastreport= qh facet_id-1;
+    time(&timedata);
+    tp= localtime(&timedata);
+    cpu= (float)qh_CPUclock - (float)qh hulltime;
+    cpu /= (float)qh_SECticks;
+    total= zzval_(Ztotmerge) - zzval_(Zcyclehorizon) + zzval_(Zcyclefacettot);
+    zinc_(Zdistio);
+    qh_distplane(furthest, facet, &dist);
+    qh_fprintf(qh ferr, 8119, "\n\
+At %02d:%02d:%02d & %2.5g CPU secs, qhull has created %d facets and merged %d.\n\
+ The current hull contains %d facets and %d vertices.  There are %d\n\
+ outside points.  Next is point p%d(v%d), %2.2g above f%d.\n",
+      tp->tm_hour, tp->tm_min, tp->tm_sec, cpu, qh facet_id -1,
+      total, qh num_facets, qh num_vertices, qh num_outside+1,
+      furthestid, qh vertex_id, dist, getid_(facet));
+  }else if (qh IStracing >=1) {
+    cpu= (float)qh_CPUclock - (float)qh hulltime;
+    cpu /= (float)qh_SECticks;
+    qh_distplane(furthest, facet, &dist);
+    qh_fprintf(qh ferr, 8120, "qh_addpoint: add p%d(v%d) to hull of %d facets(%2.2g above f%d) and %d outside at %4.4g CPU secs.  Previous was p%d.\n",
+      furthestid, qh vertex_id, qh num_facets, dist,
+      getid_(facet), qh num_outside+1, cpu, qh furthest_id);
+  }
+  zmax_(Zvisit2max, (int)qh visit_id/2);
+  if (qh visit_id > (unsigned) INT_MAX) {
+    zinc_(Zvisit);
+    qh visit_id= 0;
+    FORALLfacets
+      facet->visitid= 0;
+  }
+  zmax_(Zvvisit2max, (int)qh vertex_visit/2);
+  if (qh vertex_visit > (unsigned) INT_MAX/2) { /* 31 bits */
+    zinc_(Zvvisit);
+    qh vertex_visit= 0;
+    FORALLvertices
+      vertex->visitid= 0;
+  }
+  qh furthest_id= furthestid;
+  qh RANDOMdist= qh old_randomdist;
+} /* buildtracing */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="errexit2">-</a>
+
+  qh_errexit2( exitcode, facet, otherfacet )
+    return exitcode to system after an error
+    report two facets
+
+  returns:
+    assumes exitcode non-zero
+
+  see:
+    normally use qh_errexit() in user.c(reports a facet and a ridge)
+*/
+void qh_errexit2(int exitcode, facetT *facet, facetT *otherfacet) {
+
+  qh_errprint("ERRONEOUS", facet, otherfacet, NULL, NULL);
+  qh_errexit(exitcode, NULL, NULL);
+} /* errexit2 */
+
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="findhorizon">-</a>
+
+  qh_findhorizon( point, facet, goodvisible, goodhorizon )
+    given a visible facet, find the point's horizon and visible facets
+    for all facets, !facet-visible
+
+  returns:
+    returns qh.visible_list/num_visible with all visible facets
+      marks visible facets with ->visible
+    updates count of good visible and good horizon facets
+    updates qh.max_outside, qh.max_vertex, facet->maxoutside
+
+  see:
+    similar to qh_delpoint()
+
+  design:
+    move facet to qh.visible_list at end of qh.facet_list
+    for all visible facets
+     for each unvisited neighbor of a visible facet
+       compute distance of point to neighbor
+       if point above neighbor
+         move neighbor to end of qh.visible_list
+       else if point is coplanar with neighbor
+         update qh.max_outside, qh.max_vertex, neighbor->maxoutside
+         mark neighbor coplanar (will create a samecycle later)
+         update horizon statistics
+*/
+void qh_findhorizon(pointT *point, facetT *facet, int *goodvisible, int *goodhorizon) {
+  facetT *neighbor, **neighborp, *visible;
+  int numhorizon= 0, coplanar= 0;
+  realT dist;
+
+  trace1((qh ferr, 1040,"qh_findhorizon: find horizon for point p%d facet f%d\n",qh_pointid(point),facet->id));
+  *goodvisible= *goodhorizon= 0;
+  zinc_(Ztotvisible);
+  qh_removefacet(facet);  /* visible_list at end of qh facet_list */
+  qh_appendfacet(facet);
+  qh num_visible= 1;
+  if (facet->good)
+    (*goodvisible)++;
+  qh visible_list= facet;
+  facet->visible= True;
+  facet->f.replace= NULL;
+  if (qh IStracing >=4)
+    qh_errprint("visible", facet, NULL, NULL, NULL);
+  qh visit_id++;
+  FORALLvisible_facets {
+    if (visible->tricoplanar && !qh TRInormals) {
+      qh_fprintf(qh ferr, 6230, "Qhull internal error (qh_findhorizon): does not work for tricoplanar facets.  Use option 'Q11'\n");
+      qh_errexit(qh_ERRqhull, visible, NULL);
+    }
+    visible->visitid= qh visit_id;
+    FOREACHneighbor_(visible) {
+      if (neighbor->visitid == qh visit_id)
+        continue;
+      neighbor->visitid= qh visit_id;
+      zzinc_(Znumvisibility);
+      qh_distplane(point, neighbor, &dist);
+      if (dist > qh MINvisible) {
+        zinc_(Ztotvisible);
+        qh_removefacet(neighbor);  /* append to end of qh visible_list */
+        qh_appendfacet(neighbor);
+        neighbor->visible= True;
+        neighbor->f.replace= NULL;
+        qh num_visible++;
+        if (neighbor->good)
+          (*goodvisible)++;
+        if (qh IStracing >=4)
+          qh_errprint("visible", neighbor, NULL, NULL, NULL);
+      }else {
+        if (dist > - qh MAXcoplanar) {
+          neighbor->coplanar= True;
+          zzinc_(Zcoplanarhorizon);
+          qh_precision("coplanar horizon");
+          coplanar++;
+          if (qh MERGING) {
+            if (dist > 0) {
+              maximize_(qh max_outside, dist);
+              maximize_(qh max_vertex, dist);
+#if qh_MAXoutside
+              maximize_(neighbor->maxoutside, dist);
+#endif
+            }else
+              minimize_(qh min_vertex, dist);  /* due to merge later */
+          }
+          trace2((qh ferr, 2057, "qh_findhorizon: point p%d is coplanar to horizon f%d, dist=%2.7g < qh MINvisible(%2.7g)\n",
+              qh_pointid(point), neighbor->id, dist, qh MINvisible));
+        }else
+          neighbor->coplanar= False;
+        zinc_(Ztothorizon);
+        numhorizon++;
+        if (neighbor->good)
+          (*goodhorizon)++;
+        if (qh IStracing >=4)
+          qh_errprint("horizon", neighbor, NULL, NULL, NULL);
+      }
+    }
+  }
+  if (!numhorizon) {
+    qh_precision("empty horizon");
+    qh_fprintf(qh ferr, 6168, "qhull precision error (qh_findhorizon): empty horizon\n\
+QhullPoint p%d was above all facets.\n", qh_pointid(point));
+    qh_printfacetlist(qh facet_list, NULL, True);
+    qh_errexit(qh_ERRprec, NULL, NULL);
+  }
+  trace1((qh ferr, 1041, "qh_findhorizon: %d horizon facets(good %d), %d visible(good %d), %d coplanar\n",
+       numhorizon, *goodhorizon, qh num_visible, *goodvisible, coplanar));
+  if (qh IStracing >= 4 && qh num_facets < 50)
+    qh_printlists();
+} /* findhorizon */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="nextfurthest">-</a>
+
+  qh_nextfurthest( visible )
+    returns next furthest point and visible facet for qh_addpoint()
+    starts search at qh.facet_next
+
+  returns:
+    removes furthest point from outside set
+    NULL if none available
+    advances qh.facet_next over facets with empty outside sets
+
+  design:
+    for each facet from qh.facet_next
+      if empty outside set
+        advance qh.facet_next
+      else if qh.NARROWhull
+        determine furthest outside point
+        if furthest point is not outside
+          advance qh.facet_next(point will be coplanar)
+    remove furthest point from outside set
+*/
+pointT *qh_nextfurthest(facetT **visible) {
+  facetT *facet;
+  int size, idx;
+  realT randr, dist;
+  pointT *furthest;
+
+  while ((facet= qh facet_next) != qh facet_tail) {
+    if (!facet->outsideset) {
+      qh facet_next= facet->next;
+      continue;
+    }
+    SETreturnsize_(facet->outsideset, size);
+    if (!size) {
+      qh_setfree(&facet->outsideset);
+      qh facet_next= facet->next;
+      continue;
+    }
+    if (qh NARROWhull) {
+      if (facet->notfurthest)
+        qh_furthestout(facet);
+      furthest= (pointT*)qh_setlast(facet->outsideset);
+#if qh_COMPUTEfurthest
+      qh_distplane(furthest, facet, &dist);
+      zinc_(Zcomputefurthest);
+#else
+      dist= facet->furthestdist;
+#endif
+      if (dist < qh MINoutside) { /* remainder of outside set is coplanar for qh_outcoplanar */
+        qh facet_next= facet->next;
+        continue;
+      }
+    }
+    if (!qh RANDOMoutside && !qh VIRTUALmemory) {
+      if (qh PICKfurthest) {
+        qh_furthestnext(/* qh facet_list */);
+        facet= qh facet_next;
+      }
+      *visible= facet;
+      return((pointT*)qh_setdellast(facet->outsideset));
+    }
+    if (qh RANDOMoutside) {
+      int outcoplanar = 0;
+      if (qh NARROWhull) {
+        FORALLfacets {
+          if (facet == qh facet_next)
+            break;
+          if (facet->outsideset)
+            outcoplanar += qh_setsize( facet->outsideset);
+        }
+      }
+      randr= qh_RANDOMint;
+      randr= randr/(qh_RANDOMmax+1);
+      idx= (int)floor((qh num_outside - outcoplanar) * randr);
+      FORALLfacet_(qh facet_next) {
+        if (facet->outsideset) {
+          SETreturnsize_(facet->outsideset, size);
+          if (!size)
+            qh_setfree(&facet->outsideset);
+          else if (size > idx) {
+            *visible= facet;
+            return((pointT*)qh_setdelnth(facet->outsideset, idx));
+          }else
+            idx -= size;
+        }
+      }
+      qh_fprintf(qh ferr, 6169, "qhull internal error (qh_nextfurthest): num_outside %d is too low\nby at least %d, or a random real %g >= 1.0\n",
+              qh num_outside, idx+1, randr);
+      qh_errexit(qh_ERRqhull, NULL, NULL);
+    }else { /* VIRTUALmemory */
+      facet= qh facet_tail->previous;
+      if (!(furthest= (pointT*)qh_setdellast(facet->outsideset))) {
+        if (facet->outsideset)
+          qh_setfree(&facet->outsideset);
+        qh_removefacet(facet);
+        qh_prependfacet(facet, &qh facet_list);
+        continue;
+      }
+      *visible= facet;
+      return furthest;
+    }
+  }
+  return NULL;
+} /* nextfurthest */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="partitionall">-</a>
+
+  qh_partitionall( vertices, points, numpoints )
+    partitions all points in points/numpoints to the outsidesets of facets
+    vertices= vertices in qh.facet_list(!partitioned)
+
+  returns:
+    builds facet->outsideset
+    does not partition qh.GOODpoint
+    if qh.ONLYgood && !qh.MERGING,
+      does not partition qh.GOODvertex
+
+  notes:
+    faster if qh.facet_list sorted by anticipated size of outside set
+
+  design:
+    initialize pointset with all points
+    remove vertices from pointset
+    remove qh.GOODpointp from pointset (unless it's qh.STOPcone or qh.STOPpoint)
+    for all facets
+      for all remaining points in pointset
+        compute distance from point to facet
+        if point is outside facet
+          remove point from pointset (by not reappending)
+          update bestpoint
+          append point or old bestpoint to facet's outside set
+      append bestpoint to facet's outside set (furthest)
+    for all points remaining in pointset
+      partition point into facets' outside sets and coplanar sets
+*/
+void qh_partitionall(setT *vertices, pointT *points, int numpoints){
+  setT *pointset;
+  vertexT *vertex, **vertexp;
+  pointT *point, **pointp, *bestpoint;
+  int size, point_i, point_n, point_end, remaining, i, id;
+  facetT *facet;
+  realT bestdist= -REALmax, dist, distoutside;
+
+  trace1((qh ferr, 1042, "qh_partitionall: partition all points into outside sets\n"));
+  pointset= qh_settemp(numpoints);
+  qh num_outside= 0;
+  pointp= SETaddr_(pointset, pointT);
+  for (i=numpoints, point= points; i--; point += qh hull_dim)
+    *(pointp++)= point;
+  qh_settruncate(pointset, numpoints);
+  FOREACHvertex_(vertices) {
+    if ((id= qh_pointid(vertex->point)) >= 0)
+      SETelem_(pointset, id)= NULL;
+  }
+  id= qh_pointid(qh GOODpointp);
+  if (id >=0 && qh STOPcone-1 != id && -qh STOPpoint-1 != id)
+    SETelem_(pointset, id)= NULL;
+  if (qh GOODvertexp && qh ONLYgood && !qh MERGING) { /* matches qhull()*/
+    if ((id= qh_pointid(qh GOODvertexp)) >= 0)
+      SETelem_(pointset, id)= NULL;
+  }
+  if (!qh BESToutside) {  /* matches conditional for qh_partitionpoint below */
+    distoutside= qh_DISToutside; /* multiple of qh.MINoutside & qh.max_outside, see user.h */
+    zval_(Ztotpartition)= qh num_points - qh hull_dim - 1; /*misses GOOD... */
+    remaining= qh num_facets;
+    point_end= numpoints;
+    FORALLfacets {
+      size= point_end/(remaining--) + 100;
+      facet->outsideset= qh_setnew(size);
+      bestpoint= NULL;
+      point_end= 0;
+      FOREACHpoint_i_(pointset) {
+        if (point) {
+          zzinc_(Zpartitionall);
+          qh_distplane(point, facet, &dist);
+          if (dist < distoutside)
+            SETelem_(pointset, point_end++)= point;
+          else {
+            qh num_outside++;
+            if (!bestpoint) {
+              bestpoint= point;
+              bestdist= dist;
+            }else if (dist > bestdist) {
+              qh_setappend(&facet->outsideset, bestpoint);
+              bestpoint= point;
+              bestdist= dist;
+            }else
+              qh_setappend(&facet->outsideset, point);
+          }
+        }
+      }
+      if (bestpoint) {
+        qh_setappend(&facet->outsideset, bestpoint);
+#if !qh_COMPUTEfurthest
+        facet->furthestdist= bestdist;
+#endif
+      }else
+        qh_setfree(&facet->outsideset);
+      qh_settruncate(pointset, point_end);
+    }
+  }
+  /* if !qh BESToutside, pointset contains points not assigned to outsideset */
+  if (qh BESToutside || qh MERGING || qh KEEPcoplanar || qh KEEPinside) {
+    qh findbestnew= True;
+    FOREACHpoint_i_(pointset) {
+      if (point)
+        qh_partitionpoint(point, qh facet_list);
+    }
+    qh findbestnew= False;
+  }
+  zzadd_(Zpartitionall, zzval_(Zpartition));
+  zzval_(Zpartition)= 0;
+  qh_settempfree(&pointset);
+  if (qh IStracing >= 4)
+    qh_printfacetlist(qh facet_list, NULL, True);
+} /* partitionall */
+
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="partitioncoplanar">-</a>
+
+  qh_partitioncoplanar( point, facet, dist )
+    partition coplanar point to a facet
+    dist is distance from point to facet
+    if dist NULL,
+      searches for bestfacet and does nothing if inside
+    if qh.findbestnew set,
+      searches new facets instead of using qh_findbest()
+
+  returns:
+    qh.max_ouside updated
+    if qh.KEEPcoplanar or qh.KEEPinside
+      point assigned to best coplanarset
+
+  notes:
+    facet->maxoutside is updated at end by qh_check_maxout
+
+  design:
+    if dist undefined
+      find best facet for point
+      if point sufficiently below facet (depends on qh.NEARinside and qh.KEEPinside)
+        exit
+    if keeping coplanar/nearinside/inside points
+      if point is above furthest coplanar point
+        append point to coplanar set (it is the new furthest)
+        update qh.max_outside
+      else
+        append point one before end of coplanar set
+    else if point is clearly outside of qh.max_outside and bestfacet->coplanarset
+    and bestfacet is more than perpendicular to facet
+      repartition the point using qh_findbest() -- it may be put on an outsideset
+    else
+      update qh.max_outside
+*/
+void qh_partitioncoplanar(pointT *point, facetT *facet, realT *dist) {
+  facetT *bestfacet;
+  pointT *oldfurthest;
+  realT bestdist, dist2= 0, angle;
+  int numpart= 0, oldfindbest;
+  boolT isoutside;
+
+  qh WAScoplanar= True;
+  if (!dist) {
+    if (qh findbestnew)
+      bestfacet= qh_findbestnew(point, facet, &bestdist, qh_ALL, &isoutside, &numpart);
+    else
+      bestfacet= qh_findbest(point, facet, qh_ALL, !qh_ISnewfacets, qh DELAUNAY,
+                          &bestdist, &isoutside, &numpart);
+    zinc_(Ztotpartcoplanar);
+    zzadd_(Zpartcoplanar, numpart);
+    if (!qh DELAUNAY && !qh KEEPinside) { /*  for 'd', bestdist skips upperDelaunay facets */
+      if (qh KEEPnearinside) {
+        if (bestdist < -qh NEARinside) {
+          zinc_(Zcoplanarinside);
+          trace4((qh ferr, 4062, "qh_partitioncoplanar: point p%d is more than near-inside facet f%d dist %2.2g findbestnew %d\n",
+                  qh_pointid(point), bestfacet->id, bestdist, qh findbestnew));
+          return;
+        }
+      }else if (bestdist < -qh MAXcoplanar) {
+          trace4((qh ferr, 4063, "qh_partitioncoplanar: point p%d is inside facet f%d dist %2.2g findbestnew %d\n",
+                  qh_pointid(point), bestfacet->id, bestdist, qh findbestnew));
+        zinc_(Zcoplanarinside);
+        return;
+      }
+    }
+  }else {
+    bestfacet= facet;
+    bestdist= *dist;
+  }
+  if (bestdist > qh max_outside) {
+    if (!dist && facet != bestfacet) {
+      zinc_(Zpartangle);
+      angle= qh_getangle(facet->normal, bestfacet->normal);
+      if (angle < 0) {
+        /* typically due to deleted vertex and coplanar facets, e.g.,
+             RBOX 1000 s Z1 G1e-13 t1001185205 | QHULL Tv */
+        zinc_(Zpartflip);
+        trace2((qh ferr, 2058, "qh_partitioncoplanar: repartition point p%d from f%d.  It is above flipped facet f%d dist %2.2g\n",
+                qh_pointid(point), facet->id, bestfacet->id, bestdist));
+        oldfindbest= qh findbestnew;
+        qh findbestnew= False;
+        qh_partitionpoint(point, bestfacet);
+        qh findbestnew= oldfindbest;
+        return;
+      }
+    }
+    qh max_outside= bestdist;
+    if (bestdist > qh TRACEdist) {
+      qh_fprintf(qh ferr, 8122, "qh_partitioncoplanar: ====== p%d from f%d increases max_outside to %2.2g of f%d last p%d\n",
+                     qh_pointid(point), facet->id, bestdist, bestfacet->id, qh furthest_id);
+      qh_errprint("DISTANT", facet, bestfacet, NULL, NULL);
+    }
+  }
+  if (qh KEEPcoplanar + qh KEEPinside + qh KEEPnearinside) {
+    oldfurthest= (pointT*)qh_setlast(bestfacet->coplanarset);
+    if (oldfurthest) {
+      zinc_(Zcomputefurthest);
+      qh_distplane(oldfurthest, bestfacet, &dist2);
+    }
+    if (!oldfurthest || dist2 < bestdist)
+      qh_setappend(&bestfacet->coplanarset, point);
+    else
+      qh_setappend2ndlast(&bestfacet->coplanarset, point);
+  }
+  trace4((qh ferr, 4064, "qh_partitioncoplanar: point p%d is coplanar with facet f%d(or inside) dist %2.2g\n",
+          qh_pointid(point), bestfacet->id, bestdist));
+} /* partitioncoplanar */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="partitionpoint">-</a>
+
+  qh_partitionpoint( point, facet )
+    assigns point to an outside set, coplanar set, or inside set (i.e., dropt)
+    if qh.findbestnew
+      uses qh_findbestnew() to search all new facets
+    else
+      uses qh_findbest()
+
+  notes:
+    after qh_distplane(), this and qh_findbest() are most expensive in 3-d
+
+  design:
+    find best facet for point
+      (either exhaustive search of new facets or directed search from facet)
+    if qh.NARROWhull
+      retain coplanar and nearinside points as outside points
+    if point is outside bestfacet
+      if point above furthest point for bestfacet
+        append point to outside set (it becomes the new furthest)
+        if outside set was empty
+          move bestfacet to end of qh.facet_list (i.e., after qh.facet_next)
+        update bestfacet->furthestdist
+      else
+        append point one before end of outside set
+    else if point is coplanar to bestfacet
+      if keeping coplanar points or need to update qh.max_outside
+        partition coplanar point into bestfacet
+    else if near-inside point
+      partition as coplanar point into bestfacet
+    else is an inside point
+      if keeping inside points
+        partition as coplanar point into bestfacet
+*/
+void qh_partitionpoint(pointT *point, facetT *facet) {
+  realT bestdist;
+  boolT isoutside;
+  facetT *bestfacet;
+  int numpart;
+#if qh_COMPUTEfurthest
+  realT dist;
+#endif
+
+  if (qh findbestnew)
+    bestfacet= qh_findbestnew(point, facet, &bestdist, qh BESToutside, &isoutside, &numpart);
+  else
+    bestfacet= qh_findbest(point, facet, qh BESToutside, qh_ISnewfacets, !qh_NOupper,
+                          &bestdist, &isoutside, &numpart);
+  zinc_(Ztotpartition);
+  zzadd_(Zpartition, numpart);
+  if (qh NARROWhull) {
+    if (qh DELAUNAY && !isoutside && bestdist >= -qh MAXcoplanar)
+      qh_precision("nearly incident point(narrow hull)");
+    if (qh KEEPnearinside) {
+      if (bestdist >= -qh NEARinside)
+        isoutside= True;
+    }else if (bestdist >= -qh MAXcoplanar)
+      isoutside= True;
+  }
+
+  if (isoutside) {
+    if (!bestfacet->outsideset
+    || !qh_setlast(bestfacet->outsideset)) {
+      qh_setappend(&(bestfacet->outsideset), point);
+      if (!bestfacet->newfacet) {
+        qh_removefacet(bestfacet);  /* make sure it's after qh facet_next */
+        qh_appendfacet(bestfacet);
+      }
+#if !qh_COMPUTEfurthest
+      bestfacet->furthestdist= bestdist;
+#endif
+    }else {
+#if qh_COMPUTEfurthest
+      zinc_(Zcomputefurthest);
+      qh_distplane(oldfurthest, bestfacet, &dist);
+      if (dist < bestdist)
+        qh_setappend(&(bestfacet->outsideset), point);
+      else
+        qh_setappend2ndlast(&(bestfacet->outsideset), point);
+#else
+      if (bestfacet->furthestdist < bestdist) {
+        qh_setappend(&(bestfacet->outsideset), point);
+        bestfacet->furthestdist= bestdist;
+      }else
+        qh_setappend2ndlast(&(bestfacet->outsideset), point);
+#endif
+    }
+    qh num_outside++;
+    trace4((qh ferr, 4065, "qh_partitionpoint: point p%d is outside facet f%d new? %d(or narrowhull)\n",
+          qh_pointid(point), bestfacet->id, bestfacet->newfacet));
+  }else if (qh DELAUNAY || bestdist >= -qh MAXcoplanar) { /* for 'd', bestdist skips upperDelaunay facets */
+    zzinc_(Zcoplanarpart);
+    if (qh DELAUNAY)
+      qh_precision("nearly incident point");
+    if ((qh KEEPcoplanar + qh KEEPnearinside) || bestdist > qh max_outside)
+      qh_partitioncoplanar(point, bestfacet, &bestdist);
+    else {
+      trace4((qh ferr, 4066, "qh_partitionpoint: point p%d is coplanar to facet f%d(dropped)\n",
+          qh_pointid(point), bestfacet->id));
+    }
+  }else if (qh KEEPnearinside && bestdist > -qh NEARinside) {
+    zinc_(Zpartnear);
+    qh_partitioncoplanar(point, bestfacet, &bestdist);
+  }else {
+    zinc_(Zpartinside);
+    trace4((qh ferr, 4067, "qh_partitionpoint: point p%d is inside all facets, closest to f%d dist %2.2g\n",
+          qh_pointid(point), bestfacet->id, bestdist));
+    if (qh KEEPinside)
+      qh_partitioncoplanar(point, bestfacet, &bestdist);
+  }
+} /* partitionpoint */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="partitionvisible">-</a>
+
+  qh_partitionvisible( allpoints, numoutside )
+    partitions points in visible facets to qh.newfacet_list
+    qh.visible_list= visible facets
+    for visible facets
+      1st neighbor (if any) points to a horizon facet or a new facet
+    if allpoints(!used),
+      repartitions coplanar points
+
+  returns:
+    updates outside sets and coplanar sets of qh.newfacet_list
+    updates qh.num_outside (count of outside points)
+
+  notes:
+    qh.findbest_notsharp should be clear (extra work if set)
+
+  design:
+    for all visible facets with outside set or coplanar set
+      select a newfacet for visible facet
+      if outside set
+        partition outside set into new facets
+      if coplanar set and keeping coplanar/near-inside/inside points
+        if allpoints
+          partition coplanar set into new facets, may be assigned outside
+        else
+          partition coplanar set into coplanar sets of new facets
+    for each deleted vertex
+      if allpoints
+        partition vertex into new facets, may be assigned outside
+      else
+        partition vertex into coplanar sets of new facets
+*/
+void qh_partitionvisible(/*visible_list*/ boolT allpoints, int *numoutside) {
+  facetT *visible, *newfacet;
+  pointT *point, **pointp;
+  int coplanar=0, size;
+  unsigned count;
+  vertexT *vertex, **vertexp;
+
+  if (qh ONLYmax)
+    maximize_(qh MINoutside, qh max_vertex);
+  *numoutside= 0;
+  FORALLvisible_facets {
+    if (!visible->outsideset && !visible->coplanarset)
+      continue;
+    newfacet= visible->f.replace;
+    count= 0;
+    while (newfacet && newfacet->visible) {
+      newfacet= newfacet->f.replace;
+      if (count++ > qh facet_id)
+        qh_infiniteloop(visible);
+    }
+    if (!newfacet)
+      newfacet= qh newfacet_list;
+    if (newfacet == qh facet_tail) {
+      qh_fprintf(qh ferr, 6170, "qhull precision error (qh_partitionvisible): all new facets deleted as\n        degenerate facets. Can not continue.\n");
+      qh_errexit(qh_ERRprec, NULL, NULL);
+    }
+    if (visible->outsideset) {
+      size= qh_setsize(visible->outsideset);
+      *numoutside += size;
+      qh num_outside -= size;
+      FOREACHpoint_(visible->outsideset)
+        qh_partitionpoint(point, newfacet);
+    }
+    if (visible->coplanarset && (qh KEEPcoplanar + qh KEEPinside + qh KEEPnearinside)) {
+      size= qh_setsize(visible->coplanarset);
+      coplanar += size;
+      FOREACHpoint_(visible->coplanarset) {
+        if (allpoints) /* not used */
+          qh_partitionpoint(point, newfacet);
+        else
+          qh_partitioncoplanar(point, newfacet, NULL);
+      }
+    }
+  }
+  FOREACHvertex_(qh del_vertices) {
+    if (vertex->point) {
+      if (allpoints) /* not used */
+        qh_partitionpoint(vertex->point, qh newfacet_list);
+      else
+        qh_partitioncoplanar(vertex->point, qh newfacet_list, NULL);
+    }
+  }
+  trace1((qh ferr, 1043,"qh_partitionvisible: partitioned %d points from outsidesets and %d points from coplanarsets\n", *numoutside, coplanar));
+} /* partitionvisible */
+
+
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="precision">-</a>
+
+  qh_precision( reason )
+    restart on precision errors if not merging and if 'QJn'
+*/
+void qh_precision(const char *reason) {
+
+  if (qh ALLOWrestart && !qh PREmerge && !qh MERGEexact) {
+    if (qh JOGGLEmax < REALmax/2) {
+      trace0((qh ferr, 26, "qh_precision: qhull restart because of %s\n", reason));
+      longjmp(qh restartexit, qh_ERRprec);
+    }
+  }
+} /* qh_precision */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >-------------------------------</a><a name="printsummary">-</a>
+
+  qh_printsummary( fp )
+    prints summary to fp
+
+  notes:
+    not in io.c so that user_eg.c can prevent io.c from loading
+    qh_printsummary and qh_countfacets must match counts
+
+  design:
+    determine number of points, vertices, and coplanar points
+    print summary
+*/
+void qh_printsummary(FILE *fp) {
+  realT ratio, outerplane, innerplane;
+  float cpu;
+  int size, id, nummerged, numvertices, numcoplanars= 0, nonsimplicial=0;
+  int goodused;
+  facetT *facet;
+  const char *s;
+  int numdel= zzval_(Zdelvertextot);
+  int numtricoplanars= 0;
+
+  size= qh num_points + qh_setsize(qh other_points);
+  numvertices= qh num_vertices - qh_setsize(qh del_vertices);
+  id= qh_pointid(qh GOODpointp);
+  FORALLfacets {
+    if (facet->coplanarset)
+      numcoplanars += qh_setsize( facet->coplanarset);
+    if (facet->good) {
+      if (facet->simplicial) {
+        if (facet->keepcentrum && facet->tricoplanar)
+          numtricoplanars++;
+      }else if (qh_setsize(facet->vertices) != qh hull_dim)
+        nonsimplicial++;
+    }
+  }
+  if (id >=0 && qh STOPcone-1 != id && -qh STOPpoint-1 != id)
+    size--;
+  if (qh STOPcone || qh STOPpoint)
+      qh_fprintf(fp, 9288, "\nAt a premature exit due to 'TVn', 'TCn', 'TRn', or precision error with 'QJn'.");
+  if (qh UPPERdelaunay)
+    goodused= qh GOODvertex + qh GOODpoint + qh SPLITthresholds;
+  else if (qh DELAUNAY)
+    goodused= qh GOODvertex + qh GOODpoint + qh GOODthreshold;
+  else
+    goodused= qh num_good;
+  nummerged= zzval_(Ztotmerge) - zzval_(Zcyclehorizon) + zzval_(Zcyclefacettot);
+  if (qh VORONOI) {
+    if (qh UPPERdelaunay)
+      qh_fprintf(fp, 9289, "\n\
+Furthest-site Voronoi vertices by the convex hull of %d points in %d-d:\n\n", size, qh hull_dim);
+    else
+      qh_fprintf(fp, 9290, "\n\
+Voronoi diagram by the convex hull of %d points in %d-d:\n\n", size, qh hull_dim);
+    qh_fprintf(fp, 9291, "  Number of Voronoi regions%s: %d\n",
+              qh ATinfinity ? " and at-infinity" : "", numvertices);
+    if (numdel)
+      qh_fprintf(fp, 9292, "  Total number of deleted points due to merging: %d\n", numdel);
+    if (numcoplanars - numdel > 0)
+      qh_fprintf(fp, 9293, "  Number of nearly incident points: %d\n", numcoplanars - numdel);
+    else if (size - numvertices - numdel > 0)
+      qh_fprintf(fp, 9294, "  Total number of nearly incident points: %d\n", size - numvertices - numdel);
+    qh_fprintf(fp, 9295, "  Number of%s Voronoi vertices: %d\n",
+              goodused ? " 'good'" : "", qh num_good);
+    if (nonsimplicial)
+      qh_fprintf(fp, 9296, "  Number of%s non-simplicial Voronoi vertices: %d\n",
+              goodused ? " 'good'" : "", nonsimplicial);
+  }else if (qh DELAUNAY) {
+    if (qh UPPERdelaunay)
+      qh_fprintf(fp, 9297, "\n\
+Furthest-site Delaunay triangulation by the convex hull of %d points in %d-d:\n\n", size, qh hull_dim);
+    else
+      qh_fprintf(fp, 9298, "\n\
+Delaunay triangulation by the convex hull of %d points in %d-d:\n\n", size, qh hull_dim);
+    qh_fprintf(fp, 9299, "  Number of input sites%s: %d\n",
+              qh ATinfinity ? " and at-infinity" : "", numvertices);
+    if (numdel)
+      qh_fprintf(fp, 9300, "  Total number of deleted points due to merging: %d\n", numdel);
+    if (numcoplanars - numdel > 0)
+      qh_fprintf(fp, 9301, "  Number of nearly incident points: %d\n", numcoplanars - numdel);
+    else if (size - numvertices - numdel > 0)
+      qh_fprintf(fp, 9302, "  Total number of nearly incident points: %d\n", size - numvertices - numdel);
+    qh_fprintf(fp, 9303, "  Number of%s Delaunay regions: %d\n",
+              goodused ? " 'good'" : "", qh num_good);
+    if (nonsimplicial)
+      qh_fprintf(fp, 9304, "  Number of%s non-simplicial Delaunay regions: %d\n",
+              goodused ? " 'good'" : "", nonsimplicial);
+  }else if (qh HALFspace) {
+    qh_fprintf(fp, 9305, "\n\
+Halfspace intersection by the convex hull of %d points in %d-d:\n\n", size, qh hull_dim);
+    qh_fprintf(fp, 9306, "  Number of halfspaces: %d\n", size);
+    qh_fprintf(fp, 9307, "  Number of non-redundant halfspaces: %d\n", numvertices);
+    if (numcoplanars) {
+      if (qh KEEPinside && qh KEEPcoplanar)
+        s= "similar and redundant";
+      else if (qh KEEPinside)
+        s= "redundant";
+      else
+        s= "similar";
+      qh_fprintf(fp, 9308, "  Number of %s halfspaces: %d\n", s, numcoplanars);
+    }
+    qh_fprintf(fp, 9309, "  Number of intersection points: %d\n", qh num_facets - qh num_visible);
+    if (goodused)
+      qh_fprintf(fp, 9310, "  Number of 'good' intersection points: %d\n", qh num_good);
+    if (nonsimplicial)
+      qh_fprintf(fp, 9311, "  Number of%s non-simplicial intersection points: %d\n",
+              goodused ? " 'good'" : "", nonsimplicial);
+  }else {
+    qh_fprintf(fp, 9312, "\n\
+Convex hull of %d points in %d-d:\n\n", size, qh hull_dim);
+    qh_fprintf(fp, 9313, "  Number of vertices: %d\n", numvertices);
+    if (numcoplanars) {
+      if (qh KEEPinside && qh KEEPcoplanar)
+        s= "coplanar and interior";
+      else if (qh KEEPinside)
+        s= "interior";
+      else
+        s= "coplanar";
+      qh_fprintf(fp, 9314, "  Number of %s points: %d\n", s, numcoplanars);
+    }
+    qh_fprintf(fp, 9315, "  Number of facets: %d\n", qh num_facets - qh num_visible);
+    if (goodused)
+      qh_fprintf(fp, 9316, "  Number of 'good' facets: %d\n", qh num_good);
+    if (nonsimplicial)
+      qh_fprintf(fp, 9317, "  Number of%s non-simplicial facets: %d\n",
+              goodused ? " 'good'" : "", nonsimplicial);
+  }
+  if (numtricoplanars)
+      qh_fprintf(fp, 9318, "  Number of triangulated facets: %d\n", numtricoplanars);
+  qh_fprintf(fp, 9319, "\nStatistics for: %s | %s",
+                      qh rbox_command, qh qhull_command);
+  if (qh ROTATErandom != INT_MIN)
+    qh_fprintf(fp, 9320, " QR%d\n\n", qh ROTATErandom);
+  else
+    qh_fprintf(fp, 9321, "\n\n");
+  qh_fprintf(fp, 9322, "  Number of points processed: %d\n", zzval_(Zprocessed));
+  qh_fprintf(fp, 9323, "  Number of hyperplanes created: %d\n", zzval_(Zsetplane));
+  if (qh DELAUNAY)
+    qh_fprintf(fp, 9324, "  Number of facets in hull: %d\n", qh num_facets - qh num_visible);
+  qh_fprintf(fp, 9325, "  Number of distance tests for qhull: %d\n", zzval_(Zpartition)+
+      zzval_(Zpartitionall)+zzval_(Znumvisibility)+zzval_(Zpartcoplanar));
+#if 0  /* NOTE: must print before printstatistics() */
+  {realT stddev, ave;
+  qh_fprintf(fp, 9326, "  average new facet balance: %2.2g\n",
+          wval_(Wnewbalance)/zval_(Zprocessed));
+  stddev= qh_stddev(zval_(Zprocessed), wval_(Wnewbalance),
+                                 wval_(Wnewbalance2), &ave);
+  qh_fprintf(fp, 9327, "  new facet standard deviation: %2.2g\n", stddev);
+  qh_fprintf(fp, 9328, "  average partition balance: %2.2g\n",
+          wval_(Wpbalance)/zval_(Zpbalance));
+  stddev= qh_stddev(zval_(Zpbalance), wval_(Wpbalance),
+                                 wval_(Wpbalance2), &ave);
+  qh_fprintf(fp, 9329, "  partition standard deviation: %2.2g\n", stddev);
+  }
+#endif
+  if (nummerged) {
+    qh_fprintf(fp, 9330,"  Number of distance tests for merging: %d\n",zzval_(Zbestdist)+
+          zzval_(Zcentrumtests)+zzval_(Zdistconvex)+zzval_(Zdistcheck)+
+          zzval_(Zdistzero));
+    qh_fprintf(fp, 9331,"  Number of distance tests for checking: %d\n",zzval_(Zcheckpart));
+    qh_fprintf(fp, 9332,"  Number of merged facets: %d\n", nummerged);
+  }
+  if (!qh RANDOMoutside && qh QHULLfinished) {
+    cpu= (float)qh hulltime;
+    cpu /= (float)qh_SECticks;
+    wval_(Wcpu)= cpu;
+    qh_fprintf(fp, 9333, "  CPU seconds to compute hull (after input): %2.4g\n", cpu);
+  }
+  if (qh RERUN) {
+    if (!qh PREmerge && !qh MERGEexact)
+      qh_fprintf(fp, 9334, "  Percentage of runs with precision errors: %4.1f\n",
+           zzval_(Zretry)*100.0/qh build_cnt);  /* careful of order */
+  }else if (qh JOGGLEmax < REALmax/2) {
+    if (zzval_(Zretry))
+      qh_fprintf(fp, 9335, "  After %d retries, input joggled by: %2.2g\n",
+         zzval_(Zretry), qh JOGGLEmax);
+    else
+      qh_fprintf(fp, 9336, "  Input joggled by: %2.2g\n", qh JOGGLEmax);
+  }
+  if (qh totarea != 0.0)
+    qh_fprintf(fp, 9337, "  %s facet area:   %2.8g\n",
+            zzval_(Ztotmerge) ? "Approximate" : "Total", qh totarea);
+  if (qh totvol != 0.0)
+    qh_fprintf(fp, 9338, "  %s volume:       %2.8g\n",
+            zzval_(Ztotmerge) ? "Approximate" : "Total", qh totvol);
+  if (qh MERGING) {
+    qh_outerinner(NULL, &outerplane, &innerplane);
+    if (outerplane > 2 * qh DISTround) {
+      qh_fprintf(fp, 9339, "  Maximum distance of %spoint above facet: %2.2g",
+            (qh QHULLfinished ? "" : "merged "), outerplane);
+      ratio= outerplane/(qh ONEmerge + qh DISTround);
+      /* don't report ratio if MINoutside is large */
+      if (ratio > 0.05 && 2* qh ONEmerge > qh MINoutside && qh JOGGLEmax > REALmax/2)
+        qh_fprintf(fp, 9340, " (%.1fx)\n", ratio);
+      else
+        qh_fprintf(fp, 9341, "\n");
+    }
+    if (innerplane < -2 * qh DISTround) {
+      qh_fprintf(fp, 9342, "  Maximum distance of %svertex below facet: %2.2g",
+            (qh QHULLfinished ? "" : "merged "), innerplane);
+      ratio= -innerplane/(qh ONEmerge+qh DISTround);
+      if (ratio > 0.05 && qh JOGGLEmax > REALmax/2)
+        qh_fprintf(fp, 9343, " (%.1fx)\n", ratio);
+      else
+        qh_fprintf(fp, 9344, "\n");
+    }
+  }
+  qh_fprintf(fp, 9345, "\n");
+} /* printsummary */
+
+

Copied: trunk/scipy/spatial/qhull/src/libqhull.h (from rev 6901, trunk/scipy/spatial/qhull/src/qhull.h)
===================================================================
--- trunk/scipy/spatial/qhull/src/libqhull.h	                        (rev 0)
+++ trunk/scipy/spatial/qhull/src/libqhull.h	2010-11-16 21:18:37 UTC (rev 6902)
@@ -0,0 +1,1092 @@
+/*<html><pre>  -<a                             href="qh-qhull.htm"
+  >-------------------------------</a><a name="TOP">-</a>
+
+   libqhull.h
+   user-level header file for using qhull.a library
+
+   see qh-qhull.htm, qhull_a.h
+
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/libqhull.h#9 $$Change: 1172 $
+   $DateTime: 2010/01/09 21:42:16 $$Author: bbarber $
+
+   NOTE: access to qh_qh is via the 'qh' macro.  This allows
+   qh_qh to be either a pointer or a structure.  An example
+   of using qh is "qh DROPdim" which accesses the DROPdim
+   field of qh_qh.  Similarly, access to qh_qhstat is via
+   the 'qhstat' macro.
+
+   includes function prototypes for libqhull.c, geom.c, global.c, io.c, user.c
+
+   use mem.h for mem.c
+   use qset.h for qset.c
+
+   see unix.c for an example of using libqhull.h
+
+   recompile qhull if you change this file
+*/
+
+#ifndef qhDEFlibqhull
+#define qhDEFlibqhull 1
+
+/*=========================== -included files ==============*/
+
+#include "user.h"      /* user definable constants (e.g., qh_QHpointer) */
+
+#include <setjmp.h>
+#include <float.h>
+#include <time.h>
+#include <stdio.h>
+
+#if __MWERKS__ && __POWERPC__
+#include  <SIOUX.h>
+#include  <Files.h>
+#include        <Desk.h>
+#endif
+
+#ifndef __STDC__
+#ifndef __cplusplus
+#if     !_MSC_VER
+#error  Neither __STDC__ nor __cplusplus is defined.  Please use strict ANSI C or C++ to compile
+#error  Qhull.  You may need to turn off compiler extensions in your project configuration.  If
+#error  your compiler is a standard C compiler, you can delete this warning from libqhull.h
+#endif
+#endif
+#endif
+
+/*============ constants and basic types ====================*/
+
+extern const char *qh_version; /* defined in global.c */
+
+/*-<a                             href="qh-geom.htm#TOC"
+  >--------------------------------</a><a name="coordT">-</a>
+
+  coordT
+    coordinates and coefficients are stored as realT (i.e., double)
+
+  notes:
+    Qhull works well if realT is 'float'.  If so joggle (QJ) is not effective.
+
+    Could use 'float' for data and 'double' for calculations (realT vs. coordT)
+      This requires many type casts, and adjusted error bounds.
+      Also C compilers may do expressions in double anyway.
+*/
+#define coordT realT
+
+/*-<a                             href="qh-geom.htm#TOC"
+  >--------------------------------</a><a name="pointT">-</a>
+
+  pointT
+    a point is an array of coordinates, usually qh.hull_dim
+*/
+#define pointT coordT
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >--------------------------------</a><a name="flagT">-</a>
+
+  flagT
+    Boolean flag as a bit
+*/
+#define flagT unsigned int
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >--------------------------------</a><a name="boolT">-</a>
+
+  boolT
+    boolean value, either True or False
+
+  notes:
+    needed for portability
+*/
+#define boolT unsigned int
+#ifdef False
+#undef False
+#endif
+#ifdef True
+#undef True
+#endif
+#define False 0
+#define True 1
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >--------------------------------</a><a name="CENTERtype">-</a>
+
+  qh_CENTER
+    to distinguish facet->center
+*/
+typedef enum
+{
+    qh_ASnone = 0, qh_ASvoronoi, qh_AScentrum
+}
+qh_CENTER;
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >--------------------------------</a><a name="qh_PRINT">-</a>
+
+  qh_PRINT
+    output formats for printing (qh.PRINTout).
+    'Fa' 'FV' 'Fc' 'FC'
+
+
+   notes:
+   some of these names are similar to qh names.  The similar names are only
+   used in switch statements in qh_printbegin() etc.
+*/
+typedef enum {qh_PRINTnone= 0,
+  qh_PRINTarea, qh_PRINTaverage,           /* 'Fa' 'FV' 'Fc' 'FC' */
+  qh_PRINTcoplanars, qh_PRINTcentrums,
+  qh_PRINTfacets, qh_PRINTfacets_xridge,   /* 'f' 'FF' 'G' 'FI' 'Fi' 'Fn' */
+  qh_PRINTgeom, qh_PRINTids, qh_PRINTinner, qh_PRINTneighbors,
+  qh_PRINTnormals, qh_PRINTouter, qh_PRINTmaple, /* 'n' 'Fo' 'i' 'm' 'Fm' 'FM', 'o' */
+  qh_PRINTincidences, qh_PRINTmathematica, qh_PRINTmerges, qh_PRINToff,
+  qh_PRINToptions, qh_PRINTpointintersect, /* 'FO' 'Fp' 'FP' 'p' 'FQ' 'FS' */
+  qh_PRINTpointnearest, qh_PRINTpoints, qh_PRINTqhull, qh_PRINTsize,
+  qh_PRINTsummary, qh_PRINTtriangles,      /* 'Fs' 'Ft' 'Fv' 'FN' 'Fx' */
+  qh_PRINTvertices, qh_PRINTvneighbors, qh_PRINTextremes,
+  qh_PRINTEND} qh_PRINT;
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >--------------------------------</a><a name="qh_ALL">-</a>
+
+  qh_ALL
+    argument flag for selecting everything
+*/
+#define qh_ALL      True
+#define qh_NOupper  True     /* argument for qh_findbest */
+#define qh_IScheckmax  True     /* argument for qh_findbesthorizon */
+#define qh_ISnewfacets  True     /* argument for qh_findbest */
+#define qh_RESETvisible  True     /* argument for qh_resetlists */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+  >--------------------------------</a><a name="qh_ERR">-</a>
+
+  qh_ERR
+    Qhull exit codes, for indicating errors
+    See: MSG_ERROR and MSG_WARNING [user.h]
+*/
+#define qh_ERRnone  0    /* no error occurred during qhull */
+#define qh_ERRinput 1    /* input inconsistency */
+#define qh_ERRsingular 2 /* singular input data */
+#define qh_ERRprec  3    /* precision error */
+#define qh_ERRmem   4    /* insufficient memory, matches mem.h */
+#define qh_ERRqhull 5    /* internal error detected, matches mem.h */
+
+/*-<a                             href="qh-qhull.htm#TOC"
+>--------------------------------</a><a name="qh_FILEstderr">-</a>
+
+qh_FILEstderr
+Fake stderr to distinguish error output from normal output
+For C++ interface.  Must redefine qh_fprintf_qhull
+*/
+#define qh_FILEstderr (FILE*)1
+
+/* ============ -structures- ====================
+   each of the following structures is defined by a typedef
+   all realT and coordT fields occur at the beginning of a structure
+        (otherwise space may be wasted due to alignment)
+   define all flags together and pack into 32-bit number
+*/
+
+typedef struct vertexT vertexT;
+typedef struct ridgeT ridgeT;
+typedef struct facetT facetT;
+#ifndef DEFsetT
+#define DEFsetT 1
+typedef struct setT setT;          /* defined in qset.h */
+#endif
+
+#ifndef DEFqhstatT
+#define DEFqhstatT 1
+typedef struct qhstatT qhstatT;    /* defined in stat.h */
+#endif
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="facetT">-</a>
+
+  facetT
+    defines a facet
+
+  notes:
+   qhull() generates the hull as a list of facets.
+
+  topological information:
+    f.previous,next     doubly-linked list of facets
+    f.vertices          set of vertices
+    f.ridges            set of ridges
+    f.neighbors         set of neighbors
+    f.toporient         True if facet has top-orientation (else bottom)
+
+  geometric information:
+    f.offset,normal     hyperplane equation
+    f.maxoutside        offset to outer plane -- all points inside
+    f.center            centrum for testing convexity
+    f.simplicial        True if facet is simplicial
+    f.flipped           True if facet does not include qh.interior_point
+
+  for constructing hull:
+    f.visible           True if facet on list of visible facets (will be deleted)
+    f.newfacet          True if facet on list of newly created facets
+    f.coplanarset       set of points coplanar with this facet
+                        (includes near-inside points for later testing)
+    f.outsideset        set of points outside of this facet
+    f.furthestdist      distance to furthest point of outside set
+    f.visitid           marks visited facets during a loop
+    f.replace           replacement facet for to-be-deleted, visible facets
+    f.samecycle,newcycle cycle of facets for merging into horizon facet
+
+  see below for other flags and fields
+*/
+struct facetT {
+#if !qh_COMPUTEfurthest
+  coordT   furthestdist;/* distance to furthest point of outsideset */
+#endif
+#if qh_MAXoutside
+  coordT   maxoutside;  /* max computed distance of point to facet
+                        Before QHULLfinished this is an approximation
+                        since maxdist not always set for mergefacet
+                        Actual outer plane is +DISTround and
+                        computed outer plane is +2*DISTround */
+#endif
+  coordT   offset;      /* exact offset of hyperplane from origin */
+  coordT  *normal;      /* normal of hyperplane, hull_dim coefficients */
+                        /*   if tricoplanar, shared with a neighbor */
+  union {               /* in order of testing */
+   realT   area;        /* area of facet, only in io.c if  ->isarea */
+   facetT *replace;     /*  replacement facet if ->visible and NEWfacets
+                             is NULL only if qh_mergedegen_redundant or interior */
+   facetT *samecycle;   /*  cycle of facets from the same visible/horizon intersection,
+                             if ->newfacet */
+   facetT *newcycle;    /*  in horizon facet, current samecycle of new facets */
+   facetT *trivisible;  /* visible facet for ->tricoplanar facets during qh_triangulate() */
+   facetT *triowner;    /* owner facet for ->tricoplanar, !isarea facets w/ ->keepcentrum */
+  }f;
+  coordT  *center;      /*  centrum for convexity, qh CENTERtype == qh_AScentrum */
+                        /*  Voronoi center, qh CENTERtype == qh_ASvoronoi */
+                        /*   if tricoplanar, shared with a neighbor */
+  facetT  *previous;    /* previous facet in the facet_list */
+  facetT  *next;        /* next facet in the facet_list */
+  setT    *vertices;    /* vertices for this facet, inverse sorted by ID
+                           if simplicial, 1st vertex was apex/furthest */
+  setT    *ridges;      /* explicit ridges for nonsimplicial facets.
+                           for simplicial facets, neighbors defines ridge */
+  setT    *neighbors;   /* neighbors of the facet.  If simplicial, the kth
+                           neighbor is opposite the kth vertex, and the first
+                           neighbor is the horizon facet for the first vertex*/
+  setT    *outsideset;  /* set of points outside this facet
+                           if non-empty, last point is furthest
+                           if NARROWhull, includes coplanars for partitioning*/
+  setT    *coplanarset; /* set of points coplanar with this facet
+                           > qh.min_vertex and <= facet->max_outside
+                           a point is assigned to the furthest facet
+                           if non-empty, last point is furthest away */
+  unsigned visitid;     /* visit_id, for visiting all neighbors,
+                           all uses are independent */
+  unsigned id;          /* unique identifier from qh facet_id */
+  unsigned nummerge:9;  /* number of merges */
+#define qh_MAXnummerge 511 /*     2^9-1, 32 flags total, see "flags:" in io.c */
+  flagT    tricoplanar:1; /* True if TRIangulate and simplicial and coplanar with a neighbor */
+                          /*   all tricoplanars share the same ->center, ->normal, ->offset, ->maxoutside */
+                          /*   all tricoplanars share the same apex */
+                          /*   if ->degenerate, does not span facet (one logical ridge) */
+                          /*   one tricoplanar has ->keepcentrum and ->coplanarset */
+                          /*   during qh_triangulate, f.trivisible points to original facet */
+  flagT    newfacet:1;  /* True if facet on qh newfacet_list (new or merged) */
+  flagT    visible:1;   /* True if visible facet (will be deleted) */
+  flagT    toporient:1; /* True if created with top orientation
+                           after merging, use ridge orientation */
+  flagT    simplicial:1;/* True if simplicial facet, ->ridges may be implicit */
+  flagT    seen:1;      /* used to perform operations only once, like visitid */
+  flagT    seen2:1;     /* used to perform operations only once, like visitid */
+  flagT    flipped:1;   /* True if facet is flipped */
+  flagT    upperdelaunay:1; /* True if facet is upper envelope of Delaunay triangulation */
+  flagT    notfurthest:1; /* True if last point of outsideset is not furthest*/
+
+/*-------- flags primarily for output ---------*/
+  flagT    good:1;      /* True if a facet marked good for output */
+  flagT    isarea:1;    /* True if facet->f.area is defined */
+
+/*-------- flags for merging ------------------*/
+  flagT    dupridge:1;  /* True if duplicate ridge in facet */
+  flagT    mergeridge:1; /* True if facet or neighbor contains a qh_MERGEridge
+                            ->normal defined (also defined for mergeridge2) */
+  flagT    mergeridge2:1; /* True if neighbor contains a qh_MERGEridge (mark_dupridges */
+  flagT    coplanar:1;  /* True if horizon facet is coplanar at last use */
+  flagT     mergehorizon:1; /* True if will merge into horizon (->coplanar) */
+  flagT     cycledone:1;/* True if mergecycle_all already done */
+  flagT    tested:1;    /* True if facet convexity has been tested (false after merge */
+  flagT    keepcentrum:1; /* True if keep old centrum after a merge, or marks owner for ->tricoplanar */
+  flagT    newmerge:1;  /* True if facet is newly merged for reducevertices */
+  flagT    degenerate:1; /* True if facet is degenerate (degen_mergeset or ->tricoplanar) */
+  flagT    redundant:1;  /* True if facet is redundant (degen_mergeset) */
+};
+
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="ridgeT">-</a>
+
+  ridgeT
+    defines a ridge
+
+  notes:
+  a ridge is hull_dim-1 simplex between two neighboring facets.  If the
+  facets are non-simplicial, there may be more than one ridge between
+  two facets.  E.G. a 4-d hypercube has two triangles between each pair
+  of neighboring facets.
+
+  topological information:
+    vertices            a set of vertices
+    top,bottom          neighboring facets with orientation
+
+  geometric information:
+    tested              True if ridge is clearly convex
+    nonconvex           True if ridge is non-convex
+*/
+struct ridgeT {
+  setT    *vertices;    /* vertices belonging to this ridge, inverse sorted by ID
+                           NULL if a degen ridge (matchsame) */
+  facetT  *top;         /* top facet this ridge is part of */
+  facetT  *bottom;      /* bottom facet this ridge is part of */
+  unsigned id:24;       /* unique identifier, =>room for 8 flags, bit field matches qh.ridge_id */
+  flagT    seen:1;      /* used to perform operations only once */
+  flagT    tested:1;    /* True when ridge is tested for convexity */
+  flagT    nonconvex:1; /* True if getmergeset detected a non-convex neighbor
+                           only one ridge between neighbors may have nonconvex */
+};
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="vertexT">-</a>
+
+  vertexT
+     defines a vertex
+
+  topological information:
+    next,previous       doubly-linked list of all vertices
+    neighbors           set of adjacent facets (only if qh.VERTEXneighbors)
+
+  geometric information:
+    point               array of DIM3 coordinates
+*/
+struct vertexT {
+  vertexT *next;        /* next vertex in vertex_list */
+  vertexT *previous;    /* previous vertex in vertex_list */
+  pointT  *point;       /* hull_dim coordinates (coordT) */
+  setT    *neighbors;   /* neighboring facets of vertex, qh_vertexneighbors()
+                           inits in io.c or after first merge */
+  unsigned visitid:31;  /* for use with qh vertex_visit, size must match */
+  flagT    seen2:1;     /* another seen flag */
+  unsigned id:24;       /* unique identifier, bit field matches qh.vertex_id */
+  unsigned dim:4;       /* dimension of point if non-zero, used by cpp */
+                        /* =>room for 4 flags */
+  flagT    seen:1;      /* used to perform operations only once */
+  flagT    delridge:1;  /* vertex was part of a deleted ridge */
+  flagT    deleted:1;   /* true if vertex on qh del_vertices */
+  flagT    newlist:1;   /* true if vertex on qh newvertex_list */
+};
+
+#define MAX_vdim 15  /* Maximum size of vertex->dim */
+
+/*======= -global variables -qh ============================*/
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh">-</a>
+
+  qh
+   all global variables for qhull are in qh, qhmem, and qhstat
+
+  notes:
+   qhmem is defined in mem.h, qhstat is defined in stat.h, qhrbox is defined in rboxpoints.h
+   Access to qh_qh is via the "qh" macro.  See qh_QHpointer in user.h
+
+   All global variables for qhull are in qh, qhmem, and qhstat
+   qh must be unique for each instance of qhull
+   qhstat may be shared between qhull instances.
+   qhmem may be shared across multiple instances of Qhull.
+   Rbox uses global variables rbox_inuse and rbox, but does not persist data across calls.
+
+   notes:
+   Qhull is not multithreaded.  Global state could be stored in thread-local storage.
+*/
+
+extern int qhull_inuse;
+
+typedef struct qhT qhT;
+#if qh_QHpointer
+#define qh qh_qh->
+extern qhT *qh_qh;     /* allocated in global.c */
+#else
+#define qh qh_qh.
+extern qhT qh_qh;
+#endif
+
+struct qhT {
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh-const">-</a>
+
+  qh constants
+    configuration flags and constants for Qhull
+
+  notes:
+    The user configures Qhull by defining flags.  They are
+    copied into qh by qh_setflags().  qh-quick.htm#options defines the flags.
+*/
+  boolT ALLpoints;        /* true 'Qs' if search all points for initial simplex */
+  boolT ANGLEmerge;       /* true 'Qa' if sort potential merges by angle */
+  boolT APPROXhull;       /* true 'Wn' if MINoutside set */
+  realT   MINoutside;     /*   'Wn' min. distance for an outside point */
+  boolT ANNOTATEoutput;   /* true 'Ta' if annotate output with message codes */
+  boolT ATinfinity;       /* true 'Qz' if point num_points-1 is "at-infinity"
+                             for improving precision in Delaunay triangulations */
+  boolT AVOIDold;         /* true 'Q4' if avoid old->new merges */
+  boolT BESToutside;      /* true 'Qf' if partition points into best outsideset */
+  boolT CDDinput;         /* true 'Pc' if input uses CDD format (1.0/offset first) */
+  boolT CDDoutput;        /* true 'PC' if print normals in CDD format (offset first) */
+  boolT CHECKfrequently;  /* true 'Tc' if checking frequently */
+  realT premerge_cos;     /*   'A-n'   cos_max when pre merging */
+  realT postmerge_cos;    /*   'An'    cos_max when post merging */
+  boolT DELAUNAY;         /* true 'd' if computing DELAUNAY triangulation */
+  boolT DOintersections;  /* true 'Gh' if print hyperplane intersections */
+  int   DROPdim;          /* drops dim 'GDn' for 4-d -> 3-d output */
+  boolT FORCEoutput;      /* true 'Po' if forcing output despite degeneracies */
+  int   GOODpoint;        /* 1+n for 'QGn', good facet if visible/not(-) from point n*/
+  pointT *GOODpointp;     /*   the actual point */
+  boolT GOODthreshold;    /* true if qh lower_threshold/upper_threshold defined
+                             false if qh SPLITthreshold */
+  int   GOODvertex;       /* 1+n, good facet if vertex for point n */
+  pointT *GOODvertexp;     /*   the actual point */
+  boolT HALFspace;        /* true 'Hn,n,n' if halfspace intersection */
+  int   IStracing;        /* trace execution, 0=none, 1=least, 4=most, -1=events */
+  int   KEEParea;         /* 'PAn' number of largest facets to keep */
+  boolT KEEPcoplanar;     /* true 'Qc' if keeping nearest facet for coplanar points */
+  boolT KEEPinside;       /* true 'Qi' if keeping nearest facet for inside points
+                              set automatically if 'd Qc' */
+  int   KEEPmerge;        /* 'PMn' number of facets to keep with most merges */
+  realT KEEPminArea;      /* 'PFn' minimum facet area to keep */
+  realT MAXcoplanar;      /* 'Un' max distance below a facet to be coplanar*/
+  boolT MERGEexact;       /* true 'Qx' if exact merges (coplanar, degen, dupridge, flipped) */
+  boolT MERGEindependent; /* true 'Q2' if merging independent sets */
+  boolT MERGING;          /* true if exact-, pre- or post-merging, with angle and centrum tests */
+  realT   premerge_centrum;  /*   'C-n' centrum_radius when pre merging.  Default is round-off */
+  realT   postmerge_centrum; /*   'Cn' centrum_radius when post merging.  Default is round-off */
+  boolT MERGEvertices;    /* true 'Q3' if merging redundant vertices */
+  realT MINvisible;       /* 'Vn' min. distance for a facet to be visible */
+  boolT NOnarrow;         /* true 'Q10' if no special processing for narrow distributions */
+  boolT NOnearinside;     /* true 'Q8' if ignore near-inside points when partitioning */
+  boolT NOpremerge;       /* true 'Q0' if no defaults for C-0 or Qx */
+  boolT ONLYgood;         /* true 'Qg' if process points with good visible or horizon facets */
+  boolT ONLYmax;          /* true 'Qm' if only process points that increase max_outside */
+  boolT PICKfurthest;     /* true 'Q9' if process furthest of furthest points*/
+  boolT POSTmerge;        /* true if merging after buildhull (Cn or An) */
+  boolT PREmerge;         /* true if merging during buildhull (C-n or A-n) */
+                        /* NOTE: some of these names are similar to qh_PRINT names */
+  boolT PRINTcentrums;    /* true 'Gc' if printing centrums */
+  boolT PRINTcoplanar;    /* true 'Gp' if printing coplanar points */
+  int   PRINTdim;         /* print dimension for Geomview output */
+  boolT PRINTdots;        /* true 'Ga' if printing all points as dots */
+  boolT PRINTgood;        /* true 'Pg' if printing good facets */
+  boolT PRINTinner;       /* true 'Gi' if printing inner planes */
+  boolT PRINTneighbors;   /* true 'PG' if printing neighbors of good facets */
+  boolT PRINTnoplanes;    /* true 'Gn' if printing no planes */
+  boolT PRINToptions1st;  /* true 'FO' if printing options to stderr */
+  boolT PRINTouter;       /* true 'Go' if printing outer planes */
+  boolT PRINTprecision;   /* false 'Pp' if not reporting precision problems */
+  qh_PRINT PRINTout[qh_PRINTEND]; /* list of output formats to print */
+  boolT PRINTridges;      /* true 'Gr' if print ridges */
+  boolT PRINTspheres;     /* true 'Gv' if print vertices as spheres */
+  boolT PRINTstatistics;  /* true 'Ts' if printing statistics to stderr */
+  boolT PRINTsummary;     /* true 's' if printing summary to stderr */
+  boolT PRINTtransparent; /* true 'Gt' if print transparent outer ridges */
+  boolT PROJECTdelaunay;  /* true if DELAUNAY, no readpoints() and
+                             need projectinput() for Delaunay in qh_init_B */
+  int   PROJECTinput;     /* number of projected dimensions 'bn:0Bn:0' */
+  boolT QUICKhelp;        /* true if quick help message for degen input */
+  boolT RANDOMdist;       /* true if randomly change distplane and setfacetplane */
+  realT RANDOMfactor;     /*    maximum random perturbation */
+  realT RANDOMa;          /*    qh_randomfactor is randr * RANDOMa + RANDOMb */
+  realT RANDOMb;
+  boolT RANDOMoutside;    /* true if select a random outside point */
+  int   REPORTfreq;       /* buildtracing reports every n facets */
+  int   REPORTfreq2;      /* tracemerging reports every REPORTfreq/2 facets */
+  int   RERUN;            /* 'TRn' rerun qhull n times (qh.build_cnt) */
+  int   ROTATErandom;     /* 'QRn' seed, 0 time, >= rotate input */
+  boolT SCALEinput;       /* true 'Qbk' if scaling input */
+  boolT SCALElast;        /* true 'Qbb' if scale last coord to max prev coord */
+  boolT SETroundoff;      /* true 'E' if qh DISTround is predefined */
+  boolT SKIPcheckmax;     /* true 'Q5' if skip qh_check_maxout */
+  boolT SKIPconvex;       /* true 'Q6' if skip convexity testing during pre-merge */
+  boolT SPLITthresholds;  /* true if upper_/lower_threshold defines a region
+                               used only for printing (!for qh ONLYgood) */
+  int   STOPcone;         /* 'TCn' 1+n for stopping after cone for point n */
+                          /*       also used by qh_build_withresart for err exit*/
+  int   STOPpoint;        /* 'TVn' 'TV-n' 1+n for stopping after/before(-)
+                                        adding point n */
+  int   TESTpoints;       /* 'QTn' num of test points after qh.num_points.  Test points always coplanar. */
+  boolT TESTvneighbors;   /*  true 'Qv' if test vertex neighbors at end */
+  int   TRACElevel;       /* 'Tn' conditional IStracing level */
+  int   TRACElastrun;     /*  qh.TRACElevel applies to last qh.RERUN */
+  int   TRACEpoint;       /* 'TPn' start tracing when point n is a vertex */
+  realT TRACEdist;        /* 'TWn' start tracing when merge distance too big */
+  int   TRACEmerge;       /* 'TMn' start tracing before this merge */
+  boolT TRIangulate;      /* true 'Qt' if triangulate non-simplicial facets */
+  boolT TRInormals;       /* true 'Q11' if triangulate duplicates normals (sets Qt) */
+  boolT UPPERdelaunay;    /* true 'Qu' if computing furthest-site Delaunay */
+  boolT USEstdout;        /* true 'Tz' if using stdout instead of stderr */
+  boolT VERIFYoutput;     /* true 'Tv' if verify output at end of qhull */
+  boolT VIRTUALmemory;    /* true 'Q7' if depth-first processing in buildhull */
+  boolT VORONOI;          /* true 'v' if computing Voronoi diagram */
+
+  /*--------input constants ---------*/
+  realT AREAfactor;       /* 1/(hull_dim-1)! for converting det's to area */
+  boolT DOcheckmax;       /* true if calling qh_check_maxout (qh_initqhull_globals) */
+  char  *feasible_string;  /* feasible point 'Hn,n,n' for halfspace intersection */
+  coordT *feasible_point;  /*    as coordinates, both malloc'd */
+  boolT GETarea;          /* true 'Fa', 'FA', 'FS', 'PAn', 'PFn' if compute facet area/Voronoi volume in io.c */
+  boolT KEEPnearinside;   /* true if near-inside points in coplanarset */
+  int   hull_dim;         /* dimension of hull, set by initbuffers */
+  int   input_dim;        /* dimension of input, set by initbuffers */
+  int   num_points;       /* number of input points */
+  pointT *first_point;    /* array of input points, see POINTSmalloc */
+  boolT POINTSmalloc;     /*   true if qh first_point/num_points allocated */
+  pointT *input_points;   /* copy of original qh.first_point for input points for qh_joggleinput */
+  boolT input_malloc;     /* true if qh input_points malloc'd */
+  char  qhull_command[256];/* command line that invoked this program */
+  int   qhull_commandsiz2; /*    size of qhull_command at qh_clear_outputflags */
+  char  rbox_command[256]; /* command line that produced the input points */
+  char  qhull_options[512];/* descriptive list of options */
+  int   qhull_optionlen;  /*    length of last line */
+  int   qhull_optionsiz;  /*    size of qhull_options at qh_build_withrestart */
+  int   qhull_optionsiz2; /*    size of qhull_options at qh_clear_outputflags */
+  int   run_id;           /* non-zero, random identifier for this instance of qhull */
+  boolT VERTEXneighbors;  /* true if maintaining vertex neighbors */
+  boolT ZEROcentrum;      /* true if 'C-0' or 'C-0 Qx'.  sets ZEROall_ok */
+  realT *upper_threshold; /* don't print if facet->normal[k]>=upper_threshold[k]
+                             must set either GOODthreshold or SPLITthreshold
+                             if Delaunay, default is 0.0 for upper envelope */
+  realT *lower_threshold; /* don't print if facet->normal[k] <=lower_threshold[k] */
+  realT *upper_bound;     /* scale point[k] to new upper bound */
+  realT *lower_bound;     /* scale point[k] to new lower bound
+                             project if both upper_ and lower_bound == 0 */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh-prec">-</a>
+
+  qh precision constants
+    precision constants for Qhull
+
+  notes:
+    qh_detroundoff() computes the maximum roundoff error for distance
+    and other computations.  It also sets default values for the
+    qh constants above.
+*/
+  realT ANGLEround;       /* max round off error for angles */
+  realT centrum_radius;   /* max centrum radius for convexity (roundoff added) */
+  realT cos_max;          /* max cosine for convexity (roundoff added) */
+  realT DISTround;        /* max round off error for distances, 'E' overrides */
+  realT MAXabs_coord;     /* max absolute coordinate */
+  realT MAXlastcoord;     /* max last coordinate for qh_scalelast */
+  realT MAXsumcoord;      /* max sum of coordinates */
+  realT MAXwidth;         /* max rectilinear width of point coordinates */
+  realT MINdenom_1;       /* min. abs. value for 1/x */
+  realT MINdenom;         /*    use divzero if denominator < MINdenom */
+  realT MINdenom_1_2;     /* min. abs. val for 1/x that allows normalization */
+  realT MINdenom_2;       /*    use divzero if denominator < MINdenom_2 */
+  realT MINlastcoord;     /* min. last coordinate for qh_scalelast */
+  boolT NARROWhull;       /* set in qh_initialhull if angle < qh_MAXnarrow */
+  realT *NEARzero;        /* hull_dim array for near zero in gausselim */
+  realT NEARinside;       /* keep points for qh_check_maxout if close to facet */
+  realT ONEmerge;         /* max distance for merging simplicial facets */
+  realT outside_err;      /* application's epsilon for coplanar points
+                             qh_check_bestdist() qh_check_points() reports error if point outside */
+  realT WIDEfacet;        /* size of wide facet for skipping ridge in
+                             area computation and locking centrum */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh-codetern">-</a>
+
+  qh internal constants
+    internal constants for Qhull
+*/
+  char qhull[sizeof("qhull")]; /* "qhull" for checking ownership while debugging */
+  jmp_buf errexit;        /* exit label for qh_errexit, defined by setjmp() */
+  char jmpXtra[40];       /* extra bytes in case jmp_buf is defined wrong by compiler */
+  jmp_buf restartexit;    /* restart label for qh_errexit, defined by setjmp() */
+  char jmpXtra2[40];      /* extra bytes in case jmp_buf is defined wrong by compiler*/
+  FILE *fin;              /* pointer to input file, init by qh_meminit */
+  FILE *fout;             /* pointer to output file */
+  FILE *ferr;             /* pointer to error file */
+  pointT *interior_point; /* center point of the initial simplex*/
+  int normal_size;     /* size in bytes for facet normals and point coords*/
+  int center_size;     /* size in bytes for Voronoi centers */
+  int   TEMPsize;         /* size for small, temporary sets (in quick mem) */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh-lists">-</a>
+
+  qh facet and vertex lists
+    defines lists of facets, new facets, visible facets, vertices, and
+    new vertices.  Includes counts, next ids, and trace ids.
+  see:
+    qh_resetlists()
+*/
+  facetT *facet_list;     /* first facet */
+  facetT  *facet_tail;     /* end of facet_list (dummy facet) */
+  facetT *facet_next;     /* next facet for buildhull()
+                             previous facets do not have outside sets
+                             NARROWhull: previous facets may have coplanar outside sets for qh_outcoplanar */
+  facetT *newfacet_list;  /* list of new facets to end of facet_list */
+  facetT *visible_list;   /* list of visible facets preceeding newfacet_list,
+                             facet->visible set */
+  int       num_visible;  /* current number of visible facets */
+  unsigned tracefacet_id;  /* set at init, then can print whenever */
+  facetT *tracefacet;     /*   set in newfacet/mergefacet, undone in delfacet*/
+  unsigned tracevertex_id;  /* set at buildtracing, can print whenever */
+  vertexT *tracevertex;     /*   set in newvertex, undone in delvertex*/
+  vertexT *vertex_list;     /* list of all vertices, to vertex_tail */
+  vertexT  *vertex_tail;    /*      end of vertex_list (dummy vertex) */
+  vertexT *newvertex_list; /* list of vertices in newfacet_list, to vertex_tail
+                             all vertices have 'newlist' set */
+  int   num_facets;       /* number of facets in facet_list
+                             includes visble faces (num_visible) */
+  int   num_vertices;     /* number of vertices in facet_list */
+  int   num_outside;      /* number of points in outsidesets (for tracing and RANDOMoutside)
+                               includes coplanar outsideset points for NARROWhull/qh_outcoplanar() */
+  int   num_good;         /* number of good facets (after findgood_all) */
+  unsigned facet_id;      /* ID of next, new facet from newfacet() */
+  unsigned ridge_id:24;   /* ID of next, new ridge from newridge() */
+  unsigned vertex_id:24;  /* ID of next, new vertex from newvertex() */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh-var">-</a>
+
+  qh global variables
+    defines minimum and maximum distances, next visit ids, several flags,
+    and other global variables.
+    initialize in qh_initbuild or qh_maxmin if used in qh_buildhull
+*/
+  unsigned long hulltime; /* ignore time to set up input and randomize */
+                          /*   use unsigned to avoid wrap-around errors */
+  boolT ALLOWrestart;     /* true if qh_precision can use qh.restartexit */
+  int   build_cnt;        /* number of calls to qh_initbuild */
+  qh_CENTER CENTERtype;   /* current type of facet->center, qh_CENTER */
+  int   furthest_id;      /* pointid of furthest point, for tracing */
+  facetT *GOODclosest;    /* closest facet to GOODthreshold in qh_findgood */
+  boolT hasAreaVolume;    /* true if totarea, totvol was defined by qh_getarea */
+  boolT hasTriangulation; /* true if triangulation created by qh_triangulate */
+  realT JOGGLEmax;        /* set 'QJn' if randomly joggle input */
+  boolT maxoutdone;       /* set qh_check_maxout(), cleared by qh_addpoint() */
+  realT max_outside;      /* maximum distance from a point to a facet,
+                               before roundoff, not simplicial vertices
+                               actual outer plane is +DISTround and
+                               computed outer plane is +2*DISTround */
+  realT max_vertex;       /* maximum distance (>0) from vertex to a facet,
+                               before roundoff, due to a merge */
+  realT min_vertex;       /* minimum distance (<0) from vertex to a facet,
+                               before roundoff, due to a merge
+                               if qh.JOGGLEmax, qh_makenewplanes sets it
+                               recomputed if qh.DOcheckmax, default -qh.DISTround */
+  boolT NEWfacets;        /* true while visible facets invalid due to new or merge
+                              from makecone/attachnewfacets to deletevisible */
+  boolT findbestnew;      /* true if partitioning calls qh_findbestnew */
+  boolT findbest_notsharp; /* true if new facets are at least 90 degrees */
+  boolT NOerrexit;        /* true if qh.errexit is not available */
+  realT PRINTcradius;     /* radius for printing centrums */
+  realT PRINTradius;      /* radius for printing vertex spheres and points */
+  boolT POSTmerging;      /* true when post merging */
+  int   printoutvar;      /* temporary variable for qh_printbegin, etc. */
+  int   printoutnum;      /* number of facets printed */
+  boolT QHULLfinished;    /* True after qhull() is finished */
+  realT totarea;          /* 'FA': total facet area computed by qh_getarea, hasAreaVolume */
+  realT totvol;           /* 'FA': total volume computed by qh_getarea, hasAreaVolume */
+  unsigned int visit_id;  /* unique ID for searching neighborhoods, */
+  unsigned int vertex_visit:31; /* unique ID for searching vertices, reset with qh_buildtracing */
+  boolT ZEROall_ok;       /* True if qh_checkzero always succeeds */
+  boolT WAScoplanar;      /* True if qh_partitioncoplanar (qh_check_maxout) */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh-set">-</a>
+
+  qh global sets
+    defines sets for merging, initial simplex, hashing, extra input points,
+    and deleted vertices
+*/
+  setT *facet_mergeset;   /* temporary set of merges to be done */
+  setT *degen_mergeset;   /* temporary set of degenerate and redundant merges */
+  setT *hash_table;       /* hash table for matching ridges in qh_matchfacets
+                             size is setsize() */
+  setT *other_points;     /* additional points */
+  setT *del_vertices;     /* vertices to partition and delete with visible
+                             facets.  Have deleted set for checkfacet */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh-buf">-</a>
+
+  qh global buffers
+    defines buffers for maxtrix operations, input, and error messages
+*/
+  coordT *gm_matrix;      /* (dim+1)Xdim matrix for geom.c */
+  coordT **gm_row;        /* array of gm_matrix rows */
+  char* line;             /* malloc'd input line of maxline+1 chars */
+  int maxline;
+  coordT *half_space;     /* malloc'd input array for halfspace (qh normal_size+coordT) */
+  coordT *temp_malloc;    /* malloc'd input array for points */
+
+/*-<a                             href="qh-globa.htm#TOC"
+  >--------------------------------</a><a name="qh-static">-</a>
+
+  qh static variables
+    defines static variables for individual functions
+
+  notes:
+    do not use 'static' within a function.  Multiple instances of qhull
+    may exist.
+
+    do not assume zero initialization, 'QPn' may cause a restart
+*/
+  boolT ERREXITcalled;    /* true during qh_errexit (prevents duplicate calls */
+  boolT firstcentrum;     /* for qh_printcentrum */
+  boolT old_randomdist;   /* save RANDOMdist flag during io, tracing, or statistics */
+  setT *coplanarfacetset;  /* set of coplanar facets for searching qh_findbesthorizon() */
+  realT last_low;         /* qh_scalelast parameters for qh_setdelaunay */
+  realT last_high;
+  realT last_newhigh;
+  unsigned lastreport;    /* for qh_buildtracing */
+  int mergereport;        /* for qh_tracemerging */
+  qhstatT *old_qhstat;    /* for saving qh_qhstat in save_qhull() and UsingLibQhull.  Free with qh_free() */
+  setT *old_tempstack;    /* for saving qhmem.tempstack in save_qhull */
+  int   ridgeoutnum;      /* number of ridges for 4OFF output (qh_printbegin,etc) */
+};
+
+/*=========== -macros- =========================*/
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="otherfacet_">-</a>
+
+  otherfacet_(ridge, facet)
+    return neighboring facet for a ridge in facet
+*/
+#define otherfacet_(ridge, facet) \
+                        (((ridge)->top == (facet)) ? (ridge)->bottom : (ridge)->top)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="getid_">-</a>
+
+  getid_(p)
+    return int ID for facet, ridge, or vertex
+    return -1 if NULL
+*/
+#define getid_(p)       ((p) ? (int)((p)->id) : -1)
+
+/*============== FORALL macros ===================*/
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FORALLfacets">-</a>
+
+  FORALLfacets { ... }
+    assign 'facet' to each facet in qh.facet_list
+
+  notes:
+    uses 'facetT *facet;'
+    assumes last facet is a sentinel
+
+  see:
+    FORALLfacet_( facetlist )
+*/
+#define FORALLfacets for (facet=qh facet_list;facet && facet->next;facet=facet->next)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FORALLpoints">-</a>
+
+  FORALLpoints { ... }
+    assign 'point' to each point in qh.first_point, qh.num_points
+
+  declare:
+    coordT *point, *pointtemp;
+*/
+#define FORALLpoints FORALLpoint_(qh first_point, qh num_points)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FORALLpoint_">-</a>
+
+  FORALLpoint_( points, num) { ... }
+    assign 'point' to each point in points array of num points
+
+  declare:
+    coordT *point, *pointtemp;
+*/
+#define FORALLpoint_(points, num) for (point= (points), \
+      pointtemp= (points)+qh hull_dim*(num); point < pointtemp; point += qh hull_dim)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FORALLvertices">-</a>
+
+  FORALLvertices { ... }
+    assign 'vertex' to each vertex in qh.vertex_list
+
+  declare:
+    vertexT *vertex;
+
+  notes:
+    assumes qh.vertex_list terminated with a sentinel
+*/
+#define FORALLvertices for (vertex=qh vertex_list;vertex && vertex->next;vertex= vertex->next)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHfacet_">-</a>
+
+  FOREACHfacet_( facets ) { ... }
+    assign 'facet' to each facet in facets
+
+  declare:
+    facetT *facet, **facetp;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
+*/
+#define FOREACHfacet_(facets)    FOREACHsetelement_(facetT, facets, facet)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHneighbor_">-</a>
+
+  FOREACHneighbor_( facet ) { ... }
+    assign 'neighbor' to each neighbor in facet->neighbors
+
+  FOREACHneighbor_( vertex ) { ... }
+    assign 'neighbor' to each neighbor in vertex->neighbors
+
+  declare:
+    facetT *neighbor, **neighborp;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
+*/
+#define FOREACHneighbor_(facet)  FOREACHsetelement_(facetT, facet->neighbors, neighbor)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHpoint_">-</a>
+
+  FOREACHpoint_( points ) { ... }
+    assign 'point' to each point in points set
+
+  declare:
+    pointT *point, **pointp;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
+*/
+#define FOREACHpoint_(points)    FOREACHsetelement_(pointT, points, point)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHridge_">-</a>
+
+  FOREACHridge_( ridges ) { ... }
+    assign 'ridge' to each ridge in ridges set
+
+  declare:
+    ridgeT *ridge, **ridgep;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
+*/
+#define FOREACHridge_(ridges)    FOREACHsetelement_(ridgeT, ridges, ridge)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHvertex_">-</a>
+
+  FOREACHvertex_( vertices ) { ... }
+    assign 'vertex' to each vertex in vertices set
+
+  declare:
+    vertexT *vertex, **vertexp;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
+*/
+#define FOREACHvertex_(vertices) FOREACHsetelement_(vertexT, vertices,vertex)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHfacet_i_">-</a>
+
+  FOREACHfacet_i_( facets ) { ... }
+    assign 'facet' and 'facet_i' for each facet in facets set
+
+  declare:
+    facetT *facet;
+    int     facet_n, facet_i;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_i_">FOREACHsetelement_i_</a>
+*/
+#define FOREACHfacet_i_(facets)    FOREACHsetelement_i_(facetT, facets, facet)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHneighbor_i_">-</a>
+
+  FOREACHneighbor_i_( facet ) { ... }
+    assign 'neighbor' and 'neighbor_i' for each neighbor in facet->neighbors
+
+  FOREACHneighbor_i_( vertex ) { ... }
+    assign 'neighbor' and 'neighbor_i' for each neighbor in vertex->neighbors
+
+  declare:
+    facetT *neighbor;
+    int     neighbor_n, neighbor_i;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_i_">FOREACHsetelement_i_</a>
+*/
+#define FOREACHneighbor_i_(facet)  FOREACHsetelement_i_(facetT, facet->neighbors, neighbor)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHpoint_i_">-</a>
+
+  FOREACHpoint_i_( points ) { ... }
+    assign 'point' and 'point_i' for each point in points set
+
+  declare:
+    pointT *point;
+    int     point_n, point_i;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_i_">FOREACHsetelement_i_</a>
+*/
+#define FOREACHpoint_i_(points)    FOREACHsetelement_i_(pointT, points, point)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHridge_i_">-</a>
+
+  FOREACHridge_i_( ridges ) { ... }
+    assign 'ridge' and 'ridge_i' for each ridge in ridges set
+
+  declare:
+    ridgeT *ridge;
+    int     ridge_n, ridge_i;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_i_">FOREACHsetelement_i_</a>
+*/
+#define FOREACHridge_i_(ridges)    FOREACHsetelement_i_(ridgeT, ridges, ridge)
+
+/*-<a                             href="qh-poly.htm#TOC"
+  >--------------------------------</a><a name="FOREACHvertex_i_">-</a>
+
+  FOREACHvertex_i_( vertices ) { ... }
+    assign 'vertex' and 'vertex_i' for each vertex in vertices set
+
+  declare:
+    vertexT *vertex;
+    int     vertex_n, vertex_i;
+
+  see:
+    <a href="qset.h#FOREACHsetelement_i_">FOREACHsetelement_i_</a>
+*/
+#define FOREACHvertex_i_(vertices) FOREACHsetelement_i_(vertexT, vertices,vertex)
+
+/********* -libqhull.c prototypes (duplicated from qhull_a.h) **********************/
+
+void    qh_qhull(void);
+boolT   qh_addpoint(pointT *furthest, facetT *facet, boolT checkdist);
+void    qh_printsummary(FILE *fp);
+
+/********* -user.c prototypes (alphabetical) **********************/
+
+void    qh_errexit(int exitcode, facetT *facet, ridgeT *ridge);
+void    qh_errprint(const char* string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex);
+int     qh_new_qhull(int dim, int numpoints, coordT *points, boolT ismalloc,
+                char *qhull_cmd, FILE *outfile, FILE *errfile);
+void    qh_printfacetlist(facetT *facetlist, setT *facets, boolT printall);
+void    qh_printhelp_degenerate(FILE *fp);
+void    qh_printhelp_narrowhull(FILE *fp, realT minangle);
+void    qh_printhelp_singular(FILE *fp);
+void    qh_user_memsizes(void);
+
+/********* -usermem.c prototypes (alphabetical) **********************/
+void    qh_exit(int exitcode);
+void    qh_free(void *mem);
+void   *qh_malloc(size_t size);
+
+/********* -userprintf.c prototypes (alphabetical) **********************/
+void    qh_fprintf(FILE *fp, int msgcode, const char *fmt, ... );
+void    qh_fprintf_rbox(FILE *fp, int msgcode, const char *fmt, ... );
+
+/***** -geom.c/geom2.c/random.c prototypes (duplicated from geom.h, random.h) ****************/
+
+facetT *qh_findbest(pointT *point, facetT *startfacet,
+                     boolT bestoutside, boolT newfacets, boolT noupper,
+                     realT *dist, boolT *isoutside, int *numpart);
+facetT *qh_findbestnew(pointT *point, facetT *startfacet,
+                     realT *dist, boolT bestoutside, boolT *isoutside, int *numpart);
+boolT   qh_gram_schmidt(int dim, realT **rows);
+void    qh_outerinner(facetT *facet, realT *outerplane, realT *innerplane);
+void    qh_printsummary(FILE *fp);
+void    qh_projectinput(void);
+void    qh_randommatrix(realT *buffer, int dim, realT **row);
+void    qh_rotateinput(realT **rows);
+void    qh_scaleinput(void);
+void    qh_setdelaunay(int dim, int count, pointT *points);
+coordT  *qh_sethalfspace_all(int dim, int count, coordT *halfspaces, pointT *feasible);
+
+/***** -global.c prototypes (alphabetical) ***********************/
+
+unsigned long qh_clock(void);
+void    qh_checkflags(char *command, char *hiddenflags);
+void    qh_clear_outputflags(void);
+void    qh_freebuffers(void);
+void    qh_freeqhull(boolT allmem);
+void    qh_freeqhull2(boolT allmem);
+void    qh_init_A(FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[]);
+void    qh_init_B(coordT *points, int numpoints, int dim, boolT ismalloc);
+void    qh_init_qhull_command(int argc, char *argv[]);
+void    qh_initbuffers(coordT *points, int numpoints, int dim, boolT ismalloc);
+void    qh_initflags(char *command);
+void    qh_initqhull_buffers(void);
+void    qh_initqhull_globals(coordT *points, int numpoints, int dim, boolT ismalloc);
+void    qh_initqhull_mem(void);
+void    qh_initqhull_outputflags(void);
+void    qh_initqhull_start(FILE *infile, FILE *outfile, FILE *errfile);
+void    qh_initqhull_start2(FILE *infile, FILE *outfile, FILE *errfile);
+void    qh_initthresholds(char *command);
+void    qh_option(const char *option, int *i, realT *r);
+#if qh_QHpointer
+void    qh_restore_qhull(qhT **oldqh);
+qhT    *qh_save_qhull(void);
+#endif
+
+/***** -io.c prototypes (duplicated from io.h) ***********************/
+
+void    dfacet( unsigned id);
+void    dvertex( unsigned id);
+void    qh_printneighborhood(FILE *fp, qh_PRINT format, facetT *facetA, facetT *facetB, boolT printall);
+void    qh_produce_output(void);
+coordT *qh_readpoints(int *numpoints, int *dimension, boolT *ismalloc);
+
+
+/********* -mem.c prototypes (duplicated from mem.h) **********************/
+
+void qh_meminit(FILE *ferr);
+void qh_memfreeshort(int *curlong, int *totlong);
+
+/********* -poly.c/poly2.c prototypes (duplicated from poly.h) **********************/
+
+void    qh_check_output(void);
+void    qh_check_points(void);
+setT   *qh_facetvertices(facetT *facetlist, setT *facets, boolT allfacets);
+facetT *qh_findbestfacet(pointT *point, boolT bestoutside,
+           realT *bestdist, boolT *isoutside);
+vertexT *qh_nearvertex(facetT *facet, pointT *point, realT *bestdistp);
+pointT *qh_point(int id);
+setT   *qh_pointfacet(void /*qh.facet_list*/);
+int     qh_pointid(pointT *point);
+setT   *qh_pointvertex(void /*qh.facet_list*/);
+void    qh_setvoronoi_all(void);
+void    qh_triangulate(void /*qh facet_list*/);
+
+/********* -rboxpoints.c prototypes **********************/
+int     qh_rboxpoints(FILE* fout, FILE* ferr, char* rbox_command);
+void    qh_errexit_rbox(int exitcode);
+
+/********* -stat.c prototypes (duplicated from stat.h) **********************/
+
+void    qh_collectstatistics(void);
+void    qh_printallstatistics(FILE *fp, const char *string);
+
+#endif /* qhDEFlibqhull */

Modified: trunk/scipy/spatial/qhull/src/mem.c
===================================================================
--- trunk/scipy/spatial/qhull/src/mem.c	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/mem.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,82 +1,94 @@
 /*<html><pre>  -<a                             href="qh-mem.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-  mem.c 
+  mem.c
     memory management routines for qhull
 
   This is a standalone program.
-   
+
   To initialize memory:
 
-    qh_meminit (stderr);  
-    qh_meminitbuffers (qh IStracing, qh_MEMalign, 7, qh_MEMbufsize,qh_MEMinitbuf);
-    qh_memsize(sizeof(facetT));
-    qh_memsize(sizeof(facetT));
+    qh_meminit(stderr);
+    qh_meminitbuffers(qh IStracing, qh_MEMalign, 7, qh_MEMbufsize,qh_MEMinitbuf);
+    qh_memsize((int)sizeof(facetT));
+    qh_memsize((int)sizeof(facetT));
     ...
     qh_memsetup();
-    
+
   To free up all memory buffers:
-    qh_memfreeshort (&curlong, &totlong);
-         
-  if qh_NOmem, 
+    qh_memfreeshort(&curlong, &totlong);
+
+  if qh_NOmem,
     malloc/free is used instead of mem.c
 
-  notes: 
+  notes:
     uses Quickfit algorithm (freelists for commonly allocated sizes)
     assumes small sizes for freelists (it discards the tail of memory buffers)
-   
+
   see:
     qh-mem.htm and mem.h
-    global.c (qh_initbuffers) for an example of using mem.c 
-   
-  copyright (c) 1993-2003 The Geometry Center
+    global.c (qh_initbuffers) for an example of using mem.c
+
+  copyright (c) 1993-2010 The Geometry Center.
+  $Id: //product/qhull/main/rel/src/mem.c#32 $$Change: 1164 $
+  $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 */
 
+#include "mem.h"
+#include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include "mem.h"
 
-#ifndef qhDEFqhull
+#ifndef qhDEFlibqhull
 typedef struct ridgeT ridgeT;
 typedef struct facetT facetT;
+#ifdef _MSC_VER  /* Microsoft Visual C++ -- warning level 4 */
+#pragma warning( disable : 4127)  /* conditional expression is constant */
+#pragma warning( disable : 4706)  /* assignment within conditional function */
+#endif
 void    qh_errexit(int exitcode, facetT *, ridgeT *);
+void    qh_exit(int exitcode);
+void    qh_fprintf(FILE *fp, int msgcode, const char *fmt, ... );
+void    qh_free(void *mem);
+void   *qh_malloc(size_t size);
 #endif
 
 /*============ -global data structure ==============
     see mem.h for definition
 */
 
-qhmemT qhmem= {0};     /* remove "= {0}" if this causes a compiler error */
+qhmemT qhmem= {0,0,0,0,0,0,0,0,0,0,0,
+               0,0,0,0,0,0,0,0,0,0,0,
+               0,0,0,0,0,0,0};     /* remove "= {0}" if this causes a compiler error */
 
 #ifndef qh_NOmem
 
 /*============= internal functions ==============*/
-  
+
 static int qh_intcompare(const void *i, const void *j);
 
 /*========== functions in alphabetical order ======== */
 
 /*-<a                             href="qh-mem.htm#TOC"
   >-------------------------------</a><a name="intcompare">-</a>
-  
+
   qh_intcompare( i, j )
     used by qsort and bsearch to compare two integers
 */
 static int qh_intcompare(const void *i, const void *j) {
-  return(*((int *)i) - *((int *)j));
+  return(*((const int *)i) - *((const int *)j));
 } /* intcompare */
 
 
 /*-<a                             href="qh-mem.htm#TOC"
   >--------------------------------</a><a name="memalloc">-</a>
-   
-  qh_memalloc( insize )  
+
+  qh_memalloc( insize )
     returns object of insize bytes
-    qhmem is the global memory structure 
-    
+    qhmem is the global memory structure
+
   returns:
-    pointer to allocated memory 
+    pointer to allocated memory
     errors if insufficient memory
 
   notes:
@@ -84,7 +96,7 @@
     actual object may be larger than insize
     use qh_memalloc_() for inline code for quick allocations
     logs allocations if 'T5'
-  
+
   design:
     if size < qhmem.LASTsize
       if qhmem.freelists[size] non-empty
@@ -94,72 +106,91 @@
         allocate new allocation buffer if necessary
         allocate object from allocation buffer
     else
-      allocate object with malloc()
+      allocate object with qh_malloc() in user.c
 */
 void *qh_memalloc(int insize) {
   void **freelistp, *newbuffer;
-  int index, size;
+  int idx, size, n;
   int outsize, bufsize;
   void *object;
 
-  if ((unsigned) insize <= (unsigned) qhmem.LASTsize) {
-    index= qhmem.indextable[insize];
-    freelistp= qhmem.freelists+index;
+  if (insize <= qhmem.LASTsize) {
+    idx= qhmem.indextable[insize];
+    outsize= qhmem.sizetable[idx];
+    qhmem.totshort += outsize;
+    freelistp= qhmem.freelists+idx;
     if ((object= *freelistp)) {
-      qhmem.cntquick++;  
+      qhmem.cntquick++;
+      qhmem.totfree -= outsize;
       *freelistp= *((void **)*freelistp);  /* replace freelist with next object */
-      return (object);
+#ifdef qh_TRACEshort
+      n= qhmem.cntshort+qhmem.cntquick+qhmem.freeshort;
+      if (qhmem.IStracing >= 5)
+          qh_fprintf(qhmem.ferr, 8141, "qh_mem %p n %8d alloc quick: %d bytes (tot %d cnt %d)\n", object, n, outsize, qhmem.totshort, qhmem.cntshort+qhmem.cntquick-qhmem.freeshort);
+#endif
+      return(object);
     }else {
-      outsize= qhmem.sizetable[index];
       qhmem.cntshort++;
       if (outsize > qhmem .freesize) {
-	if (!qhmem.curbuffer)
-	  bufsize= qhmem.BUFinit;
+        qhmem .totdropped += qhmem .freesize;
+        if (!qhmem.curbuffer)
+          bufsize= qhmem.BUFinit;
         else
-	  bufsize= qhmem.BUFsize;
-        qhmem.totshort += bufsize;
-	if (!(newbuffer= malloc(bufsize))) {
-	  fprintf(qhmem.ferr, "qhull error (qh_memalloc): insufficient memory\n");
-	  qh_errexit(qhmem_ERRmem, NULL, NULL);
-	} 
-	*((void **)newbuffer)= qhmem.curbuffer;  /* prepend newbuffer to curbuffer 
-						    list */
-	qhmem.curbuffer= newbuffer;
+          bufsize= qhmem.BUFsize;
+        if (!(newbuffer= qh_malloc((size_t)bufsize))) {
+          qh_fprintf(qhmem.ferr, 6080, "qhull error (qh_memalloc): insufficient memory to allocate short memory buffer (%d bytes)\n", bufsize);
+          qh_errexit(qhmem_ERRmem, NULL, NULL);
+        }
+        *((void **)newbuffer)= qhmem.curbuffer;  /* prepend newbuffer to curbuffer
+                                                    list */
+        qhmem.curbuffer= newbuffer;
         size= (sizeof(void **) + qhmem.ALIGNmask) & ~qhmem.ALIGNmask;
-	qhmem.freemem= (void *)((char *)newbuffer+size);
-	qhmem.freesize= bufsize - size;
+        qhmem.freemem= (void *)((char *)newbuffer+size);
+        qhmem.freesize= bufsize - size;
+        qhmem.totbuffer += bufsize - size; /* easier to check */
+        /* Periodically test totbuffer.  It matches at beginning and exit of every call */
+        n = qhmem.totshort + qhmem.totfree + qhmem.totdropped + qhmem.freesize - outsize;
+        if (qhmem.totbuffer != n) {
+            qh_fprintf(qhmem.ferr, 6212, "qh_memalloc internal error: short totbuffer %d != totshort+totfree... %d\n", qhmem.totbuffer, n);
+            qh_errexit(qhmem_ERRmem, NULL, NULL);
+        }
       }
       object= qhmem.freemem;
       qhmem.freemem= (void *)((char *)qhmem.freemem + outsize);
       qhmem.freesize -= outsize;
+      qhmem.totunused += outsize - insize;
+#ifdef qh_TRACEshort
+      n= qhmem.cntshort+qhmem.cntquick+qhmem.freeshort;
+      if (qhmem.IStracing >= 5)
+          qh_fprintf(qhmem.ferr, 8140, "qh_mem %p n %8d alloc short: %d bytes (tot %d cnt %d)\n", object, n, outsize, qhmem.totshort, qhmem.cntshort+qhmem.cntquick-qhmem.freeshort);
+#endif
       return object;
     }
   }else {                     /* long allocation */
     if (!qhmem.indextable) {
-      fprintf (qhmem.ferr, "qhull internal error (qh_memalloc): qhmem has not been initialized.\n");
+      qh_fprintf(qhmem.ferr, 6081, "qhull internal error (qh_memalloc): qhmem has not been initialized.\n");
       qh_errexit(qhmem_ERRqhull, NULL, NULL);
     }
     outsize= insize;
     qhmem .cntlong++;
-    qhmem .curlong++;
     qhmem .totlong += outsize;
     if (qhmem.maxlong < qhmem.totlong)
       qhmem.maxlong= qhmem.totlong;
-    if (!(object= malloc(outsize))) {
-      fprintf(qhmem.ferr, "qhull error (qh_memalloc): insufficient memory\n");
+    if (!(object= qh_malloc((size_t)outsize))) {
+      qh_fprintf(qhmem.ferr, 6082, "qhull error (qh_memalloc): insufficient memory to allocate %d bytes\n", outsize);
       qh_errexit(qhmem_ERRmem, NULL, NULL);
     }
     if (qhmem.IStracing >= 5)
-      fprintf (qhmem.ferr, "qh_memalloc long: %d bytes at %p\n", outsize, object);
+      qh_fprintf(qhmem.ferr, 8057, "qh_mem %p n %8d alloc long: %d bytes (tot %d cnt %d)\n", object, qhmem.cntlong+qhmem.freelong, outsize, qhmem.totlong, qhmem.cntlong-qhmem.freelong);
   }
-  return (object);
+  return(object);
 } /* memalloc */
 
 
 /*-<a                             href="qh-mem.htm#TOC"
   >--------------------------------</a><a name="memfree">-</a>
-   
-  qh_memfree( object, size ) 
+
+  qh_memfree( object, insize )
     free up an object of size bytes
     size is insize from qh_memalloc
 
@@ -167,83 +198,101 @@
     object may be NULL
     type checking warns if using (void **)object
     use qh_memfree_() for quick free's of small objects
- 
+
   design:
     if size <= qhmem.LASTsize
       append object to corresponding freelist
     else
-      call free(object)
+      call qh_free(object)
 */
-void qh_memfree(void *object, int size) {
+void qh_memfree(void *object, int insize) {
   void **freelistp;
+  int idx, outsize;
 
   if (!object)
     return;
-  if (size <= qhmem.LASTsize) {
+  if (insize <= qhmem.LASTsize) {
     qhmem .freeshort++;
-    freelistp= qhmem.freelists + qhmem.indextable[size];
+    idx= qhmem.indextable[insize];
+    outsize= qhmem.sizetable[idx];
+    qhmem .totfree += outsize;
+    qhmem .totshort -= outsize;
+    freelistp= qhmem.freelists + idx;
     *((void **)object)= *freelistp;
     *freelistp= object;
+#ifdef qh_TRACEshort
+    idx= qhmem.cntshort+qhmem.cntquick+qhmem.freeshort;
+    if (qhmem.IStracing >= 5)
+        qh_fprintf(qhmem.ferr, 8142, "qh_mem %p n %8d free short: %d bytes (tot %d cnt %d)\n", object, idx, outsize, qhmem.totshort, qhmem.cntshort+qhmem.cntquick-qhmem.freeshort);
+#endif
   }else {
     qhmem .freelong++;
-    qhmem .totlong -= size;
-    free (object);
+    qhmem .totlong -= insize;
+    qh_free(object);
     if (qhmem.IStracing >= 5)
-      fprintf (qhmem.ferr, "qh_memfree long: %d bytes at %p\n", size, object);
+      qh_fprintf(qhmem.ferr, 8058, "qh_mem %p n %8d free long: %d bytes (tot %d cnt %d)\n", object, qhmem.cntlong+qhmem.freelong, insize, qhmem.totlong, qhmem.cntlong-qhmem.freelong);
   }
 } /* memfree */
 
 
 /*-<a                             href="qh-mem.htm#TOC"
   >-------------------------------</a><a name="memfreeshort">-</a>
-  
+
   qh_memfreeshort( curlong, totlong )
     frees up all short and qhmem memory allocations
 
   returns:
     number and size of current long allocations
+
+  see:
+    qh_freeqhull(allMem)
+    qh_memtotal(curlong, totlong, curshort, totshort, maxlong, totbuffer);
 */
-void qh_memfreeshort (int *curlong, int *totlong) {
+void qh_memfreeshort(int *curlong, int *totlong) {
   void *buffer, *nextbuffer;
   FILE *ferr;
 
   *curlong= qhmem .cntlong - qhmem .freelong;
   *totlong= qhmem .totlong;
-  for(buffer= qhmem.curbuffer; buffer; buffer= nextbuffer) {
+  for (buffer= qhmem.curbuffer; buffer; buffer= nextbuffer) {
     nextbuffer= *((void **) buffer);
-    free(buffer);
+    qh_free(buffer);
   }
   qhmem.curbuffer= NULL;
   if (qhmem .LASTsize) {
-    free (qhmem .indextable);
-    free (qhmem .freelists);
-    free (qhmem .sizetable);
+    qh_free(qhmem .indextable);
+    qh_free(qhmem .freelists);
+    qh_free(qhmem .sizetable);
   }
   ferr= qhmem.ferr;
-  memset((char *)&qhmem, 0, sizeof qhmem);  /* every field is 0, FALSE, NULL */
+  memset((char *)&qhmem, 0, sizeof(qhmem));  /* every field is 0, FALSE, NULL */
   qhmem.ferr= ferr;
 } /* memfreeshort */
 
 
 /*-<a                             href="qh-mem.htm#TOC"
   >--------------------------------</a><a name="meminit">-</a>
-   
+
   qh_meminit( ferr )
     initialize qhmem and test sizeof( void*)
 */
-void qh_meminit (FILE *ferr) {
-  
-  memset((char *)&qhmem, 0, sizeof qhmem);  /* every field is 0, FALSE, NULL */
+void qh_meminit(FILE *ferr) {
+
+  memset((char *)&qhmem, 0, sizeof(qhmem));  /* every field is 0, FALSE, NULL */
   qhmem.ferr= ferr;
   if (sizeof(void*) < sizeof(int)) {
-    fprintf (ferr, "qhull internal error (qh_meminit): sizeof(void*) < sizeof(int).  qset.c will not work\n");
-    exit (1);  /* can not use qh_errexit() */
+    qh_fprintf(ferr, 6083, "qhull internal error (qh_meminit): sizeof(void*) %d < sizeof(int) %d.  qset.c will not work\n", (int)sizeof(void*), (int)sizeof(int));
+    qh_exit(qhmem_ERRqhull);  /* can not use qh_errexit() */
   }
+  if (sizeof(void*) > sizeof(ptr_intT)) {
+      qh_fprintf(ferr, 6084, "qhull internal error (qh_meminit): sizeof(void*) %d > sizeof(ptr_intT) %d. Change ptr_intT in mem.h to 'long long'\n", (int)sizeof(void*), (int)sizeof(ptr_intT));
+      qh_exit(qhmem_ERRqhull);  /* can not use qh_errexit() */
+  }
 } /* meminit */
 
 /*-<a                             href="qh-mem.htm#TOC"
   >-------------------------------</a><a name="meminitbuffers">-</a>
-  
+
   qh_meminitbuffers( tracelevel, alignment, numsizes, bufsize, bufinit )
     initialize qhmem
     if tracelevel >= 5, trace memory allocations
@@ -252,7 +301,7 @@
     bufsize=  size of additional memory buffers for short allocations
     bufinit=  size of initial memory buffer for short allocations
 */
-void qh_meminitbuffers (int tracelevel, int alignment, int numsizes, int bufsize, int bufinit) {
+void qh_meminitbuffers(int tracelevel, int alignment, int numsizes, int bufsize, int bufinit) {
 
   qhmem.IStracing= tracelevel;
   qhmem.NUMsizes= numsizes;
@@ -260,43 +309,43 @@
   qhmem.BUFinit= bufinit;
   qhmem.ALIGNmask= alignment-1;
   if (qhmem.ALIGNmask & ~qhmem.ALIGNmask) {
-    fprintf (qhmem.ferr, "qhull internal error (qh_meminit): memory alignment %d is not a power of 2\n", alignment);
-    qh_errexit (qhmem_ERRqhull, NULL, NULL);
+    qh_fprintf(qhmem.ferr, 6085, "qhull internal error (qh_meminit): memory alignment %d is not a power of 2\n", alignment);
+    qh_errexit(qhmem_ERRqhull, NULL, NULL);
   }
-  qhmem.sizetable= (int *) calloc (numsizes, sizeof(int));
-  qhmem.freelists= (void **) calloc (numsizes, sizeof(void *));
+  qhmem.sizetable= (int *) calloc((size_t)numsizes, sizeof(int));
+  qhmem.freelists= (void **) calloc((size_t)numsizes, sizeof(void *));
   if (!qhmem.sizetable || !qhmem.freelists) {
-    fprintf(qhmem.ferr, "qhull error (qh_meminit): insufficient memory\n");
-    qh_errexit (qhmem_ERRmem, NULL, NULL);
+    qh_fprintf(qhmem.ferr, 6086, "qhull error (qh_meminit): insufficient memory\n");
+    qh_errexit(qhmem_ERRmem, NULL, NULL);
   }
   if (qhmem.IStracing >= 1)
-    fprintf (qhmem.ferr, "qh_meminitbuffers: memory initialized with alignment %d\n", alignment);
+    qh_fprintf(qhmem.ferr, 8059, "qh_meminitbuffers: memory initialized with alignment %d\n", alignment);
 } /* meminitbuffers */
 
 /*-<a                             href="qh-mem.htm#TOC"
   >-------------------------------</a><a name="memsetup">-</a>
-  
+
   qh_memsetup()
     set up memory after running memsize()
 */
-void qh_memsetup (void) {
+void qh_memsetup(void) {
   int k,i;
 
-  qsort(qhmem.sizetable, qhmem.TABLEsize, sizeof(int), qh_intcompare);
+  qsort(qhmem.sizetable, (size_t)qhmem.TABLEsize, sizeof(int), qh_intcompare);
   qhmem.LASTsize= qhmem.sizetable[qhmem.TABLEsize-1];
   if (qhmem .LASTsize >= qhmem .BUFsize || qhmem.LASTsize >= qhmem .BUFinit) {
-    fprintf (qhmem.ferr, "qhull error (qh_memsetup): largest mem size %d is >= buffer size %d or initial buffer size %d\n",
+    qh_fprintf(qhmem.ferr, 6087, "qhull error (qh_memsetup): largest mem size %d is >= buffer size %d or initial buffer size %d\n",
             qhmem .LASTsize, qhmem .BUFsize, qhmem .BUFinit);
     qh_errexit(qhmem_ERRmem, NULL, NULL);
   }
-  if (!(qhmem.indextable= (int *)malloc((qhmem.LASTsize+1) * sizeof(int)))) {
-    fprintf(qhmem.ferr, "qhull error (qh_memsetup): insufficient memory\n");
+  if (!(qhmem.indextable= (int *)qh_malloc((qhmem.LASTsize+1) * sizeof(int)))) {
+    qh_fprintf(qhmem.ferr, 6088, "qhull error (qh_memsetup): insufficient memory\n");
     qh_errexit(qhmem_ERRmem, NULL, NULL);
   }
-  for(k=qhmem.LASTsize+1; k--; )
+  for (k=qhmem.LASTsize+1; k--; )
     qhmem.indextable[k]= k;
   i= 0;
-  for(k= 0; k <= qhmem.LASTsize; k++) {
+  for (k=0; k <= qhmem.LASTsize; k++) {
     if (qhmem.indextable[k] <= qhmem.sizetable[i])
       qhmem.indextable[k]= i;
     else
@@ -306,7 +355,7 @@
 
 /*-<a                             href="qh-mem.htm#TOC"
   >-------------------------------</a><a name="memsize">-</a>
-  
+
   qh_memsize( size )
     define a free list for this size
 */
@@ -314,41 +363,44 @@
   int k;
 
   if (qhmem .LASTsize) {
-    fprintf (qhmem .ferr, "qhull error (qh_memsize): called after qhmem_setup\n");
-    qh_errexit (qhmem_ERRqhull, NULL, NULL);
+    qh_fprintf(qhmem.ferr, 6089, "qhull error (qh_memsize): called after qhmem_setup\n");
+    qh_errexit(qhmem_ERRqhull, NULL, NULL);
   }
   size= (size + qhmem.ALIGNmask) & ~qhmem.ALIGNmask;
-  for(k= qhmem.TABLEsize; k--; ) {
+  for (k=qhmem.TABLEsize; k--; ) {
     if (qhmem.sizetable[k] == size)
       return;
   }
   if (qhmem.TABLEsize < qhmem.NUMsizes)
     qhmem.sizetable[qhmem.TABLEsize++]= size;
   else
-    fprintf(qhmem.ferr, "qhull warning (memsize): free list table has room for only %d sizes\n", qhmem.NUMsizes);
+    qh_fprintf(qhmem.ferr, 7060, "qhull warning (memsize): free list table has room for only %d sizes\n", qhmem.NUMsizes);
 } /* memsize */
 
 
 /*-<a                             href="qh-mem.htm#TOC"
   >-------------------------------</a><a name="memstatistics">-</a>
-  
+
   qh_memstatistics( fp )
     print out memory statistics
 
-  notes:
-    does not account for wasted memory at the end of each block
+    Verifies that qhmem.totfree == sum of freelists
 */
-void qh_memstatistics (FILE *fp) {
+void qh_memstatistics(FILE *fp) {
   int i, count, totfree= 0;
   void *object;
-  
+
   for (i=0; i < qhmem.TABLEsize; i++) {
     count=0;
     for (object= qhmem .freelists[i]; object; object= *((void **)object))
       count++;
     totfree += qhmem.sizetable[i] * count;
   }
-  fprintf (fp, "\nmemory statistics:\n\
+  if (totfree != qhmem .totfree) {
+      qh_fprintf(qhmem.ferr, 6211, "qh_memstatistics internal error: totfree %d not equal to freelist total %d\n", qhmem.totfree, totfree);
+      qh_errexit(qhmem_ERRqhull, NULL, NULL);
+  }
+  qh_fprintf(fp, 9278, "\nmemory statistics:\n\
 %7d quick allocations\n\
 %7d short allocations\n\
 %7d long allocations\n\
@@ -356,86 +408,93 @@
 %7d long frees\n\
 %7d bytes of short memory in use\n\
 %7d bytes of short memory in freelists\n\
-%7d bytes of long memory allocated (except for input)\n\
+%7d bytes of dropped short memory\n\
+%7d bytes of unused short memory (estimated)\n\
+%7d bytes of long memory allocated (max, except for input)\n\
 %7d bytes of long memory in use (in %d pieces)\n\
-%7d bytes per memory buffer (initially %d bytes)\n",
-	   qhmem .cntquick, qhmem.cntshort, qhmem.cntlong,
-	   qhmem .freeshort, qhmem.freelong, 
-	   qhmem .totshort - qhmem .freesize - totfree,
-	   totfree,
-	   qhmem .maxlong, qhmem .totlong, qhmem .cntlong - qhmem .freelong,
-	   qhmem .BUFsize, qhmem .BUFinit);
+%7d bytes of short memory buffers (minus links)\n\
+%7d bytes per short memory buffer (initially %d bytes)\n",
+           qhmem .cntquick, qhmem .cntshort, qhmem .cntlong,
+           qhmem .freeshort, qhmem .freelong,
+           qhmem .totshort, qhmem .totfree,
+           qhmem .totdropped + qhmem .freesize, qhmem .totunused,
+           qhmem .maxlong, qhmem .totlong, qhmem .cntlong - qhmem .freelong,
+           qhmem .totbuffer, qhmem .BUFsize, qhmem .BUFinit);
   if (qhmem.cntlarger) {
-    fprintf (fp, "%7d calls to qh_setlarger\n%7.2g     average copy size\n",
-	   qhmem.cntlarger, ((float) qhmem.totlarger)/ qhmem.cntlarger);
-    fprintf (fp, "  freelists (bytes->count):");
+    qh_fprintf(fp, 9279, "%7d calls to qh_setlarger\n%7.2g     average copy size\n",
+           qhmem.cntlarger, ((float)qhmem.totlarger)/(float)qhmem.cntlarger);
+    qh_fprintf(fp, 9280, "  freelists(bytes->count):");
   }
   for (i=0; i < qhmem.TABLEsize; i++) {
     count=0;
     for (object= qhmem .freelists[i]; object; object= *((void **)object))
       count++;
-    fprintf (fp, " %d->%d", qhmem.sizetable[i], count);
+    qh_fprintf(fp, 9281, " %d->%d", qhmem.sizetable[i], count);
   }
-  fprintf (fp, "\n\n");
+  qh_fprintf(fp, 9282, "\n\n");
 } /* memstatistics */
 
 
 /*-<a                             href="qh-mem.htm#TOC"
   >-------------------------------</a><a name="NOmem">-</a>
-  
+
   qh_NOmem
     turn off quick-fit memory allocation
 
   notes:
-    uses malloc() and free() instead
+    uses qh_malloc() and qh_free() instead
 */
 #else /* qh_NOmem */
 
 void *qh_memalloc(int insize) {
   void *object;
 
-  if (!(object= malloc(insize))) {
-    fprintf(qhmem.ferr, "qhull error (qh_memalloc): insufficient memory\n");
+  if (!(object= qh_malloc((size_t)insize))) {
+    qh_fprintf(qhmem.ferr, 6090, "qhull error (qh_memalloc): insufficient memory\n");
     qh_errexit(qhmem_ERRmem, NULL, NULL);
   }
+  qhmem .cntlong++;
+  qhmem .totlong += insize;
+  if (qhmem.maxlong < qhmem.totlong)
+      qhmem.maxlong= qhmem.totlong;
   if (qhmem.IStracing >= 5)
-    fprintf (qhmem.ferr, "qh_memalloc long: %d bytes at %p\n", insize, object);
+    qh_fprintf(qhmem.ferr, 8060, "qh_mem %p n %8d alloc long: %d bytes (tot %d cnt %d)\n", object, qhmem.cntlong+qhmem.freelong, insize, qhmem.totlong, qhmem.cntlong-qhmem.freelong);
   return object;
 }
 
-void qh_memfree(void *object, int size) {
+void qh_memfree(void *object, int insize) {
 
   if (!object)
     return;
-  free (object);
+  qh_free(object);
+  qhmem .freelong++;
+  qhmem .totlong -= insize;
   if (qhmem.IStracing >= 5)
-    fprintf (qhmem.ferr, "qh_memfree long: %d bytes at %p\n", size, object);
+    qh_fprintf(qhmem.ferr, 8061, "qh_mem %p n %8d free long: %d bytes (tot %d cnt %d)\n", object, qhmem.cntlong+qhmem.freelong, insize, qhmem.totlong, qhmem.cntlong-qhmem.freelong);
 }
 
-void qh_memfreeshort (int *curlong, int *totlong) {
-
-  memset((char *)&qhmem, 0, sizeof qhmem);  /* every field is 0, FALSE, NULL */
-  *curlong= 0;
-  *totlong= 0;
+void qh_memfreeshort(int *curlong, int *totlong) {
+  *totlong= qhmem .totlong;
+  *curlong= qhmem .cntlong - qhmem .freelong;
+  memset((char *)&qhmem, 0, sizeof(qhmem));  /* every field is 0, FALSE, NULL */
 }
 
-void qh_meminit (FILE *ferr) {
+void qh_meminit(FILE *ferr) {
 
-  memset((char *)&qhmem, 0, sizeof qhmem);  /* every field is 0, FALSE, NULL */
+  memset((char *)&qhmem, 0, sizeof(qhmem));  /* every field is 0, FALSE, NULL */
   qhmem.ferr= ferr;
   if (sizeof(void*) < sizeof(int)) {
-    fprintf (ferr, "qhull internal error (qh_meminit): sizeof(void*) < sizeof(int).  qset.c will not work\n");
-    qh_errexit (qhmem_ERRqhull, NULL, NULL);
+    qh_fprintf(ferr, 6091, "qhull internal error (qh_meminit): sizeof(void*) %d < sizeof(int) %d.  qset.c will not work\n", (int)sizeof(void*), (int)sizeof(int));
+    qh_errexit(qhmem_ERRqhull, NULL, NULL);
   }
 }
 
-void qh_meminitbuffers (int tracelevel, int alignment, int numsizes, int bufsize, int bufinit) {
+void qh_meminitbuffers(int tracelevel, int alignment, int numsizes, int bufsize, int bufinit) {
 
   qhmem.IStracing= tracelevel;
-
 }
 
-void qh_memsetup (void) {
+void qh_memsetup(void) {
 
 }
 
@@ -443,8 +502,38 @@
 
 }
 
-void qh_memstatistics (FILE *fp) {
+void qh_memstatistics(FILE *fp) {
 
+  qh_fprintf(fp, 9409, "\nmemory statistics:\n\
+%7d long allocations\n\
+%7d long frees\n\
+%7d bytes of long memory allocated (max, except for input)\n\
+%7d bytes of long memory in use (in %d pieces)\n",
+           qhmem .cntlong,
+           qhmem .freelong,
+           qhmem .maxlong, qhmem .totlong, qhmem .cntlong - qhmem .freelong);
 }
 
 #endif /* qh_NOmem */
+
+/*-<a                             href="qh-mem.htm#TOC"
+>-------------------------------</a><a name="memtotlong">-</a>
+
+  qh_memtotal( totlong, curlong, totshort, curshort, maxlong, totbuffer )
+    Return the total, allocated long and short memory
+
+  returns:
+    Returns the total current bytes of long and short allocations
+    Returns the current count of long and short allocations
+    Returns the maximum long memory and total short buffer (minus one link per buffer)
+    Does not error (UsingLibQhull.cpp)
+*/
+void qh_memtotal(int *totlong, int *curlong, int *totshort, int *curshort, int *maxlong, int *totbuffer) {
+    *totlong= qhmem .totlong;
+    *curlong= qhmem .cntlong - qhmem .freelong;
+    *totshort= qhmem .totshort;
+    *curshort= qhmem .cntshort + qhmem .cntquick - qhmem .freeshort;
+    *maxlong= qhmem .maxlong;
+    *totbuffer= qhmem .totbuffer;
+} /* memtotlong */
+

Modified: trunk/scipy/spatial/qhull/src/mem.h
===================================================================
--- trunk/scipy/spatial/qhull/src/mem.h	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/mem.h	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,25 +1,29 @@
 /*<html><pre>  -<a                             href="qh-mem.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-   mem.h 
+   mem.h
      prototypes for memory management functions
 
    see qh-mem.htm, mem.c and qset.h
 
    for error handling, writes message and calls
-     qh_errexit (qhmem_ERRmem, NULL, NULL) if insufficient memory
+     qh_errexit(qhmem_ERRmem, NULL, NULL) if insufficient memory
        and
-     qh_errexit (qhmem_ERRqhull, NULL, NULL) otherwise
+     qh_errexit(qhmem_ERRqhull, NULL, NULL) otherwise
 
-   copyright (c) 1993-2003, The Geometry Center
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/mem.h#28 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 */
 
 #ifndef qhDEFmem
-#define qhDEFmem
+#define qhDEFmem 1
 
+#include <stdio.h>
+
 /*-<a                             href="qh-mem.htm#TOC"
   >-------------------------------</a><a name="NOmem">-</a>
-  
+
   qh_NOmem
     turn off quick-fit memory allocation
 
@@ -32,47 +36,63 @@
    #define qh_NOmem
 */
 
+/*-<a                             href="qh-mem.htm#TOC"
+>-------------------------------</a><a name="TRACEshort">-</a>
+
+qh_TRACEshort
+Trace short and quick memory allocations at T5
+
+*/
+#define qh_TRACEshort
+
 /*-------------------------------------------
     to avoid bus errors, memory allocation must consider alignment requirements.
     malloc() automatically takes care of alignment.   Since mem.c manages
     its own memory, we need to explicitly specify alignment in
     qh_meminitbuffers().
 
-    A safe choice is sizeof(double).  sizeof(float) may be used if doubles 
+    A safe choice is sizeof(double).  sizeof(float) may be used if doubles
     do not occur in data structures and pointers are the same size.  Be careful
-    of machines (e.g., DEC Alpha) with large pointers.  If gcc is available, 
+    of machines (e.g., DEC Alpha) with large pointers.  If gcc is available,
     use __alignof__(double) or fmax_(__alignof__(float), __alignof__(void *)).
 
    see <a href="user.h#MEMalign">qh_MEMalign</a> in user.h for qhull's alignment
 */
 
-#define qhmem_ERRmem 4    /* matches qh_ERRmem in qhull.h */
-#define qhmem_ERRqhull 5  /* matches qh_ERRqhull in qhull.h */
+#define qhmem_ERRmem 4    /* matches qh_ERRmem in libqhull.h */
+#define qhmem_ERRqhull 5  /* matches qh_ERRqhull in libqhull.h */
 
 /*-<a                             href="qh-mem.htm#TOC"
   >--------------------------------</a><a name="ptr_intT">-</a>
-  
+
   ptr_intT
-    for casting a void* to an integer-type
-  
+    for casting a void * to an integer-type that holds a pointer
+    Used for integer expressions (e.g., computing qh_gethash() in poly.c)
+
   notes:
-    On 64-bit machines, a pointer may be larger than an 'int'.  
-    qh_meminit() checks that 'long' holds a 'void*'
+    WARN64 -- these notes indicate 64-bit issues
+    On 64-bit machines, a pointer may be larger than an 'int'.
+    qh_meminit()/mem.c checks that 'ptr_intT' holds a 'void*'
+    ptr_intT is not defined as 'long long' for portability to older compilers
+    ptr_intT is typically a signed value, but not necessarily so
+    size_t is typically unsigned, but should match the parameter type
+    Qhull uses int instead of size_t except for system calls such as malloc, qsort, qh_malloc, etc.
+    This matches Qt convention and is easier to work with.  
 */
-typedef unsigned long ptr_intT;
+typedef long ptr_intT;
 
 /*-<a                             href="qh-mem.htm#TOC"
   >--------------------------------</a><a name="qhmemT">-</a>
- 
+
   qhmemT
     global memory structure for mem.c
- 
+
  notes:
    users should ignore qhmem except for writing extensions
-   qhmem is allocated in mem.c 
-   
+   qhmem is allocated in mem.c
+
    qhmem could be swapable like qh and qhstat, but then
-   multiple qh's and qhmem's would need to keep in synch.  
+   multiple qh's and qhmem's would need to keep in synch.
    A swapable qhmem would also waste memory buffers.  As long
    as memory operations are atomic, there is no problem with
    multiple qh structures being active at the same time.
@@ -80,34 +100,43 @@
    contents of qhmem.
 */
 typedef struct qhmemT qhmemT;
-extern qhmemT qhmem; 
+extern qhmemT qhmem;
 
+#ifndef DEFsetT
+#define DEFsetT 1
+typedef struct setT setT;          /* defined in qset.h */
+#endif
+
+/* Update qhmem in mem.c if add or remove fields */
 struct qhmemT {               /* global memory management variables */
-  int      BUFsize;	      /* size of memory allocation buffer */
-  int      BUFinit;	      /* initial size of memory allocation buffer */
+  int      BUFsize;           /* size of memory allocation buffer */
+  int      BUFinit;           /* initial size of memory allocation buffer */
   int      TABLEsize;         /* actual number of sizes in free list table */
   int      NUMsizes;          /* maximum number of sizes in free list table */
   int      LASTsize;          /* last size in free list table */
   int      ALIGNmask;         /* worst-case alignment, must be 2^n-1 */
-  void	 **freelists;          /* free list table, linked by offset 0 */
+  void   **freelists;          /* free list table, linked by offset 0 */
   int     *sizetable;         /* size of each freelist */
   int     *indextable;        /* size->index table */
   void    *curbuffer;         /* current buffer, linked by offset 0 */
   void    *freemem;           /*   free memory in curbuffer */
-  int 	   freesize;          /*   size of free memory in bytes */
-  void 	  *tempstack;         /* stack of temporary memory, managed by users */
-  FILE    *ferr;              /* file for reporting errors */
+  int      freesize;          /*   size of freemem in bytes */
+  setT    *tempstack;         /* stack of temporary memory, managed by users */
+  FILE    *ferr;              /* file for reporting errors, only user is qh_fprintf() */
   int      IStracing;         /* =5 if tracing memory allocations */
   int      cntquick;          /* count of quick allocations */
-                              /* remove statistics doesn't effect speed */
+                              /* Note: removing statistics doesn't effect speed */
   int      cntshort;          /* count of short allocations */
   int      cntlong;           /* count of long allocations */
-  int      curlong;           /* current count of inuse, long allocations */
-  int      freeshort;	      /* count of short memfrees */
-  int      freelong;	      /* count of long memfrees */
-  int      totshort;          /* total size of short allocations */
-  int      totlong;           /* total size of long allocations */
-  int      maxlong;           /* maximum totlong */
+  int      freeshort;         /* count of short memfrees */
+  int      freelong;          /* count of long memfrees */
+  int      totbuffer;         /* total short memory buffers minus buffer links */
+  int      totdropped;        /* total dropped memory at end of short memory buffers (e.g., freesize) */
+  int      totfree;           /* total size of free, short memory on freelists */
+  int      totlong;           /* total size of long memory in use */
+  int      maxlong;           /*   maximum totlong */
+  int      totshort;          /* total size of short memory in use */
+  int      totunused;         /* total unused short memory (estimated, short size - request size of first allocations) */
   int      cntlarger;         /* count of setlarger's */
   int      totlarger;         /* total copied by setlarger */
 };
@@ -117,44 +146,56 @@
 
 /*-<a                             href="qh-mem.htm#TOC"
   >--------------------------------</a><a name="memalloc_">-</a>
-   
-  qh_memalloc_(size, object, type)  
-    returns object of size bytes 
-	assumes size<=qhmem.LASTsize and void **freelistp is a temp
+
+  qh_memalloc_(insize, object, type)
+    returns object of size bytes
+        assumes size<=qhmem.LASTsize and void **freelistp is a temp
 */
 
-#ifdef qh_NOmem
-#define qh_memalloc_(size, freelistp, object, type) {\
-  object= (type*)qh_memalloc (size); }
+#if defined qh_NOmem
+#define qh_memalloc_(insize, freelistp, object, type) {\
+  object= (type*)qh_memalloc(insize); }
+#elif defined qh_TRACEshort
+#define qh_memalloc_(insize, freelistp, object, type) {\
+    freelistp= NULL; /* Avoid warnings */ \
+    object= (type*)qh_memalloc(insize); }
 #else /* !qh_NOmem */
 
-#define qh_memalloc_(size, freelistp, object, type) {\
-  freelistp= qhmem.freelists + qhmem.indextable[size];\
+#define qh_memalloc_(insize, freelistp, object, type) {\
+  freelistp= qhmem.freelists + qhmem.indextable[insize];\
   if ((object= (type*)*freelistp)) {\
+    qhmem.totshort += qhmem.sizetable[qhmem.indextable[insize]]; \
+    qhmem.totfree -= qhmem.sizetable[qhmem.indextable[insize]]; \
     qhmem.cntquick++;  \
     *freelistp= *((void **)*freelistp);\
-  }else object= (type*)qh_memalloc (size);}
+  }else object= (type*)qh_memalloc(insize);}
 #endif
 
 /*-<a                             href="qh-mem.htm#TOC"
   >--------------------------------</a><a name="memfree_">-</a>
-   
-  qh_memfree_(object, size) 
+
+  qh_memfree_(object, insize)
     free up an object
 
   notes:
     object may be NULL
     assumes size<=qhmem.LASTsize and void **freelistp is a temp
 */
-#ifdef qh_NOmem
-#define qh_memfree_(object, size, freelistp) {\
-  qh_memfree (object, size); }
+#if defined qh_NOmem
+#define qh_memfree_(object, insize, freelistp) {\
+  qh_memfree(object, insize); }
+#elif defined qh_TRACEshort
+#define qh_memfree_(object, insize, freelistp) {\
+    freelistp= NULL; /* Avoid warnings */ \
+    qh_memfree(object, insize); }
 #else /* !qh_NOmem */
 
-#define qh_memfree_(object, size, freelistp) {\
+#define qh_memfree_(object, insize, freelistp) {\
   if (object) { \
     qhmem .freeshort++;\
-    freelistp= qhmem.freelists + qhmem.indextable[size];\
+    freelistp= qhmem.freelists + qhmem.indextable[insize];\
+    qhmem.totshort -= qhmem.sizetable[qhmem.indextable[insize]]; \
+    qhmem.totfree += qhmem.sizetable[qhmem.indextable[insize]]; \
     *((void **)object)= *freelistp;\
     *freelistp= object;}}
 #endif
@@ -162,13 +203,14 @@
 /*=============== prototypes in alphabetical order ============*/
 
 void *qh_memalloc(int insize);
-void qh_memfree (void *object, int size);
-void qh_memfreeshort (int *curlong, int *totlong);
-void qh_meminit (FILE *ferr);
-void qh_meminitbuffers (int tracelevel, int alignment, int numsizes,
-			int bufsize, int bufinit);
-void qh_memsetup (void);
+void qh_memfree(void *object, int insize);
+void qh_memfreeshort(int *curlong, int *totlong);
+void qh_meminit(FILE *ferr);
+void qh_meminitbuffers(int tracelevel, int alignment, int numsizes,
+                        int bufsize, int bufinit);
+void qh_memsetup(void);
 void qh_memsize(int size);
-void qh_memstatistics (FILE *fp);
+void qh_memstatistics(FILE *fp);
+void qh_memtotal(int *totlong, int *curlong, int *totshort, int *curshort, int *maxlong, int *totbuffer);
 
 #endif /* qhDEFmem */

Modified: trunk/scipy/spatial/qhull/src/merge.c
===================================================================
--- trunk/scipy/spatial/qhull/src/merge.c	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/merge.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,7 +1,7 @@
 /*<html><pre>  -<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="TOP">-</a>
 
-   merge.c 
+   merge.c
    merges non-convex facets
 
    see qh-merge.htm and merge.h
@@ -10,28 +10,30 @@
 
    the user may call qh_postmerge() to perform additional merges.
 
-   To remove deleted facets and vertices (qhull() in qhull.c):
-     qh_partitionvisible (!qh_ALL, &numoutside);  // visible_list, newfacet_list
-     qh_deletevisible ();         // qh.visible_list
-     qh_resetlists (False, qh_RESETvisible);       // qh.visible_list newvertex_list newfacet_list 
+   To remove deleted facets and vertices (qhull() in libqhull.c):
+     qh_partitionvisible(!qh_ALL, &numoutside);  // visible_list, newfacet_list
+     qh_deletevisible();         // qh.visible_list
+     qh_resetlists(False, qh_RESETvisible);       // qh.visible_list newvertex_list newfacet_list
 
    assumes qh.CENTERtype= centrum
 
    merges occur in qh_mergefacet and in qh_mergecycle
    vertex->neighbors not set until the first merge occurs
 
-   copyright (c) 1993-2003 The Geometry Center        
+   copyright (c) 1993-2010 C.B. Barber.
+   $Id: //product/qhull/main/rel/src/merge.c#27 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 */
 
 #include "qhull_a.h"
 
 #ifndef qh_NOmerge
 
-/*===== functions (alphabetical after premerge and postmerge) ======*/
+/*===== functions(alphabetical after premerge and postmerge) ======*/
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="premerge">-</a>
-  
+
   qh_premerge( apex, maxcentrum )
     pre-merge nonconvex facets in qh.newfacet_list for apex
     maxcentrum defines coplanar and concave (qh_test_appendmerge)
@@ -51,56 +53,56 @@
     collect coplanar and concave facets
     merge concave, coplanar, degenerate, and redundant facets
 */
-void qh_premerge (vertexT *apex, realT maxcentrum, realT maxangle) {
+void qh_premerge(vertexT *apex, realT maxcentrum, realT maxangle) {
   boolT othermerge= False;
   facetT *newfacet;
-  
+
   if (qh ZEROcentrum && qh_checkzero(!qh_ALL))
-    return;    
-  trace2((qh ferr, "qh_premerge: premerge centrum %2.2g angle %2.2g for apex v%d facetlist f%d\n",
-	    maxcentrum, maxangle, apex->id, getid_(qh newfacet_list)));
+    return;
+  trace2((qh ferr, 2008, "qh_premerge: premerge centrum %2.2g angle %2.2g for apex v%d facetlist f%d\n",
+            maxcentrum, maxangle, apex->id, getid_(qh newfacet_list)));
   if (qh IStracing >= 4 && qh num_facets < 50)
     qh_printlists();
   qh centrum_radius= maxcentrum;
   qh cos_max= maxangle;
-  qh degen_mergeset= qh_settemp (qh TEMPsize);
-  qh facet_mergeset= qh_settemp (qh TEMPsize);
-  if (qh hull_dim >=3) { 
-    qh_mark_dupridges (qh newfacet_list); /* facet_mergeset */
-    qh_mergecycle_all (qh newfacet_list, &othermerge);
-    qh_forcedmerges (&othermerge /* qh facet_mergeset */); 
+  qh degen_mergeset= qh_settemp(qh TEMPsize);
+  qh facet_mergeset= qh_settemp(qh TEMPsize);
+  if (qh hull_dim >=3) {
+    qh_mark_dupridges(qh newfacet_list); /* facet_mergeset */
+    qh_mergecycle_all(qh newfacet_list, &othermerge);
+    qh_forcedmerges(&othermerge /* qh facet_mergeset */);
     FORALLnew_facets {  /* test samecycle merges */
       if (!newfacet->simplicial && !newfacet->mergeridge)
-	qh_degen_redundant_neighbors (newfacet, NULL);
+        qh_degen_redundant_neighbors(newfacet, NULL);
     }
     if (qh_merge_degenredundant())
       othermerge= True;
   }else /* qh hull_dim == 2 */
-    qh_mergecycle_all (qh newfacet_list, &othermerge);
-  qh_flippedmerges (qh newfacet_list, &othermerge);
+    qh_mergecycle_all(qh newfacet_list, &othermerge);
+  qh_flippedmerges(qh newfacet_list, &othermerge);
   if (!qh MERGEexact || zzval_(Ztotmerge)) {
     zinc_(Zpremergetot);
     qh POSTmerging= False;
-    qh_getmergeset_initial (qh newfacet_list);
-    qh_all_merges (othermerge, False);
+    qh_getmergeset_initial(qh newfacet_list);
+    qh_all_merges(othermerge, False);
   }
   qh_settempfree(&qh facet_mergeset);
   qh_settempfree(&qh degen_mergeset);
 } /* premerge */
-  
+
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="postmerge">-</a>
-  
+
   qh_postmerge( reason, maxcentrum, maxangle, vneighbors )
     post-merge nonconvex facets as defined by maxcentrum and maxangle
     'reason' is for reporting progress
-    if vneighbors, 
-      calls qh_test_vneighbors at end of qh_all_merge 
-    if firstmerge, 
+    if vneighbors,
+      calls qh_test_vneighbors at end of qh_all_merge
+    if firstmerge,
       calls qh_reducevertices before qh_getmergeset
 
   returns:
-    if first call (qh.visible_list != qh.facet_list), 
+    if first call (qh.visible_list != qh.facet_list),
       builds qh.facet_newlist, qh.newvertex_list
     deleted facets added to qh.visible_list with facet->visible
     qh.visible_list == qh.facet_list
@@ -119,32 +121,32 @@
         set vertex->delridge {will retest the ridge}
         if qh.MERGEexact
           call qh_reducevertices()
-      if no pre-merging 
+      if no pre-merging
         merge flipped facets
     determine non-convex facets
     merge all non-convex facets
 */
-void qh_postmerge (char *reason, realT maxcentrum, realT maxangle, 
+void qh_postmerge(const char *reason, realT maxcentrum, realT maxangle,
                       boolT vneighbors) {
   facetT *newfacet;
   boolT othermerges= False;
   vertexT *vertex;
 
   if (qh REPORTfreq || qh IStracing) {
-    qh_buildtracing (NULL, NULL);
-    qh_printsummary (qh ferr);
-    if (qh PRINTstatistics) 
-      qh_printallstatistics (qh ferr, "reason");
-    fprintf (qh ferr, "\n%s with 'C%.2g' and 'A%.2g'\n", 
+    qh_buildtracing(NULL, NULL);
+    qh_printsummary(qh ferr);
+    if (qh PRINTstatistics)
+      qh_printallstatistics(qh ferr, "reason");
+    qh_fprintf(qh ferr, 8062, "\n%s with 'C%.2g' and 'A%.2g'\n",
         reason, maxcentrum, maxangle);
   }
-  trace2((qh ferr, "qh_postmerge: postmerge.  test vneighbors? %d\n",
-	    vneighbors));
+  trace2((qh ferr, 2009, "qh_postmerge: postmerge.  test vneighbors? %d\n",
+            vneighbors));
   qh centrum_radius= maxcentrum;
   qh cos_max= maxangle;
   qh POSTmerging= True;
-  qh degen_mergeset= qh_settemp (qh TEMPsize);
-  qh facet_mergeset= qh_settemp (qh TEMPsize);
+  qh degen_mergeset= qh_settemp(qh TEMPsize);
+  qh facet_mergeset= qh_settemp(qh TEMPsize);
   if (qh visible_list != qh facet_list) {  /* first call */
     qh NEWfacets= True;
     qh visible_list= qh newfacet_list= qh facet_list;
@@ -159,41 +161,41 @@
       vertex->newlist= True;
     if (qh VERTEXneighbors) { /* a merge has occurred */
       FORALLvertices
-	vertex->delridge= True; /* test for redundant, needed? */
+        vertex->delridge= True; /* test for redundant, needed? */
       if (qh MERGEexact) {
-	if (qh hull_dim <= qh_DIMreduceBuild)
-	  qh_reducevertices(); /* was skipped during pre-merging */
+        if (qh hull_dim <= qh_DIMreduceBuild)
+          qh_reducevertices(); /* was skipped during pre-merging */
       }
     }
-    if (!qh PREmerge && !qh MERGEexact) 
-      qh_flippedmerges (qh newfacet_list, &othermerges);
+    if (!qh PREmerge && !qh MERGEexact)
+      qh_flippedmerges(qh newfacet_list, &othermerges);
   }
-  qh_getmergeset_initial (qh newfacet_list);
-  qh_all_merges (False, vneighbors);
+  qh_getmergeset_initial(qh newfacet_list);
+  qh_all_merges(False, vneighbors);
   qh_settempfree(&qh facet_mergeset);
   qh_settempfree(&qh degen_mergeset);
 } /* post_merge */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="all_merges">-</a>
-  
+
   qh_all_merges( othermerge, vneighbors )
     merge all non-convex facets
-    
+
     set othermerge if already merged facets (for qh_reducevertices)
     if vneighbors
       tests vertex neighbors for convexity at end
     qh.facet_mergeset lists the non-convex ridges in qh_newfacet_list
     qh.degen_mergeset is defined
-    if qh.MERGEexact && !qh.POSTmerging, 
+    if qh.MERGEexact && !qh.POSTmerging,
       does not merge coplanar facets
 
   returns:
     deleted facets added to qh.visible_list with facet->visible
     deleted vertices added qh.delvertex_list with vertex->delvertex
-  
+
   notes:
-    unless !qh.MERGEindependent, 
+    unless !qh.MERGEindependent,
       merges facets in independent sets
     uses qh.newfacet_list as argument since merges call qh_removefacet()
 
@@ -210,7 +212,7 @@
     if vneighbors ??
       tests vertex neighbors for convexity at end
 */
-void qh_all_merges (boolT othermerge, boolT vneighbors) {
+void qh_all_merges(boolT othermerge, boolT vneighbors) {
   facetT *facet1, *facet2;
   mergeT *merge;
   boolT wasmerge= True, isreduce;
@@ -218,80 +220,80 @@
   vertexT *vertex;
   mergeType mergetype;
   int numcoplanar=0, numconcave=0, numdegenredun= 0, numnewmerges= 0;
-  
-  trace2((qh ferr, "qh_all_merges: starting to merge facets beginning from f%d\n",
-	    getid_(qh newfacet_list)));
+
+  trace2((qh ferr, 2010, "qh_all_merges: starting to merge facets beginning from f%d\n",
+            getid_(qh newfacet_list)));
   while (True) {
     wasmerge= False;
-    while (qh_setsize (qh facet_mergeset)) {
+    while (qh_setsize(qh facet_mergeset)) {
       while ((merge= (mergeT*)qh_setdellast(qh facet_mergeset))) {
-	facet1= merge->facet1;
-	facet2= merge->facet2;
-	mergetype= merge->type;
-	qh_memfree_(merge, sizeof(mergeT), freelistp);
-	if (facet1->visible || facet2->visible) /*deleted facet*/
-	  continue;  
-	if ((facet1->newfacet && !facet1->tested)
-	        || (facet2->newfacet && !facet2->tested)) {
-	  if (qh MERGEindependent && mergetype <= MRGanglecoplanar)
-	    continue;      /* perform independent sets of merges */
-	}
-	qh_merge_nonconvex (facet1, facet2, mergetype);
+        facet1= merge->facet1;
+        facet2= merge->facet2;
+        mergetype= merge->type;
+        qh_memfree_(merge, (int)sizeof(mergeT), freelistp);
+        if (facet1->visible || facet2->visible) /*deleted facet*/
+          continue;
+        if ((facet1->newfacet && !facet1->tested)
+                || (facet2->newfacet && !facet2->tested)) {
+          if (qh MERGEindependent && mergetype <= MRGanglecoplanar)
+            continue;      /* perform independent sets of merges */
+        }
+        qh_merge_nonconvex(facet1, facet2, mergetype);
         numdegenredun += qh_merge_degenredundant();
         numnewmerges++;
         wasmerge= True;
-	if (mergetype == MRGconcave)
-	  numconcave++;
-	else /* MRGcoplanar or MRGanglecoplanar */
-	  numcoplanar++;
+        if (mergetype == MRGconcave)
+          numconcave++;
+        else /* MRGcoplanar or MRGanglecoplanar */
+          numcoplanar++;
       } /* while setdellast */
-      if (qh POSTmerging && qh hull_dim <= qh_DIMreduceBuild 
+      if (qh POSTmerging && qh hull_dim <= qh_DIMreduceBuild
       && numnewmerges > qh_MAXnewmerges) {
-	numnewmerges= 0;
-	qh_reducevertices();  /* otherwise large post merges too slow */
+        numnewmerges= 0;
+        qh_reducevertices();  /* otherwise large post merges too slow */
       }
-      qh_getmergeset (qh newfacet_list); /* facet_mergeset */
+      qh_getmergeset(qh newfacet_list); /* facet_mergeset */
     } /* while mergeset */
     if (qh VERTEXneighbors) {
       isreduce= False;
       if (qh hull_dim >=4 && qh POSTmerging) {
-	FORALLvertices  
-	  vertex->delridge= True;
-	isreduce= True;
+        FORALLvertices
+          vertex->delridge= True;
+        isreduce= True;
       }
-      if ((wasmerge || othermerge) && (!qh MERGEexact || qh POSTmerging) 
-	  && qh hull_dim <= qh_DIMreduceBuild) {
-	othermerge= False;
-	isreduce= True;
+      if ((wasmerge || othermerge) && (!qh MERGEexact || qh POSTmerging)
+          && qh hull_dim <= qh_DIMreduceBuild) {
+        othermerge= False;
+        isreduce= True;
       }
       if (isreduce) {
-	if (qh_reducevertices()) {
-	  qh_getmergeset (qh newfacet_list); /* facet_mergeset */
-	  continue;
-	}
+        if (qh_reducevertices()) {
+          qh_getmergeset(qh newfacet_list); /* facet_mergeset */
+          continue;
+        }
       }
     }
-    if (vneighbors && qh_test_vneighbors(/* qh newfacet_list */)) 
+    if (vneighbors && qh_test_vneighbors(/* qh newfacet_list */))
       continue;
     break;
   } /* while (True) */
   if (qh CHECKfrequently && !qh MERGEexact) {
     qh old_randomdist= qh RANDOMdist;
     qh RANDOMdist= False;
-    qh_checkconvex (qh newfacet_list, qh_ALGORITHMfault);
-    /* qh_checkconnect (); [this is slow and it changes the facet order] */
+    qh_checkconvex(qh newfacet_list, qh_ALGORITHMfault);
+    /* qh_checkconnect(); [this is slow and it changes the facet order] */
     qh RANDOMdist= qh old_randomdist;
   }
-  trace1((qh ferr, "qh_all_merges: merged %d coplanar facets %d concave facets and %d degen or redundant facets.\n",
+  trace1((qh ferr, 1009, "qh_all_merges: merged %d coplanar facets %d concave facets and %d degen or redundant facets.\n",
     numcoplanar, numconcave, numdegenredun));
   if (qh IStracing >= 4 && qh num_facets < 50)
-    qh_printlists ();
+    qh_printlists();
 } /* all_merges */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="appendmergeset">-</a>
-  
+
   qh_appendmergeset( facet, neighbor, mergetype, angle )
     appends an entry to qh.facet_mergeset or qh.degen_mergeset
 
@@ -300,7 +302,7 @@
   returns:
     merge appended to facet_mergeset or degen_mergeset
       sets ->degenerate or ->redundant if degen_mergeset
-  
+
   see:
     qh_test_appendmerge()
 
@@ -309,11 +311,11 @@
     if regular merge
       append to qh.facet_mergeset
     else if degenerate merge and qh.facet_mergeset is all degenerate
-      append to qh.degen_mergeset 
+      append to qh.degen_mergeset
     else if degenerate merge
-      prepend to qh.degen_mergeset 
+      prepend to qh.degen_mergeset
     else if redundant merge
-      append to qh.degen_mergeset 
+      append to qh.degen_mergeset
 */
 void qh_appendmergeset(facetT *facet, facetT *neighbor, mergeType mergetype, realT *angle) {
   mergeT *merge, *lastmerge;
@@ -323,52 +325,52 @@
     return;
   if (facet->degenerate && mergetype == MRGdegen)
     return;
-  qh_memalloc_(sizeof(mergeT), freelistp, merge, mergeT);
+  qh_memalloc_((int)sizeof(mergeT), freelistp, merge, mergeT);
   merge->facet1= facet;
   merge->facet2= neighbor;
   merge->type= mergetype;
   if (angle && qh ANGLEmerge)
     merge->angle= *angle;
   if (mergetype < MRGdegen)
-    qh_setappend (&(qh facet_mergeset), merge);
+    qh_setappend(&(qh facet_mergeset), merge);
   else if (mergetype == MRGdegen) {
     facet->degenerate= True;
-    if (!(lastmerge= (mergeT*)qh_setlast (qh degen_mergeset)) 
+    if (!(lastmerge= (mergeT*)qh_setlast(qh degen_mergeset))
     || lastmerge->type == MRGdegen)
-      qh_setappend (&(qh degen_mergeset), merge);
+      qh_setappend(&(qh degen_mergeset), merge);
     else
-      qh_setaddnth (&(qh degen_mergeset), 0, merge);
+      qh_setaddnth(&(qh degen_mergeset), 0, merge);
   }else if (mergetype == MRGredundant) {
     facet->redundant= True;
-    qh_setappend (&(qh degen_mergeset), merge);
+    qh_setappend(&(qh degen_mergeset), merge);
   }else /* mergetype == MRGmirror */ {
     if (facet->redundant || neighbor->redundant) {
-      fprintf(qh ferr, "qhull error (qh_appendmergeset): facet f%d or f%d is already a mirrored facet\n",
-	   facet->id, neighbor->id);
+      qh_fprintf(qh ferr, 6092, "qhull error (qh_appendmergeset): facet f%d or f%d is already a mirrored facet\n",
+           facet->id, neighbor->id);
       qh_errexit2 (qh_ERRqhull, facet, neighbor);
     }
-    if (!qh_setequal (facet->vertices, neighbor->vertices)) {
-      fprintf(qh ferr, "qhull error (qh_appendmergeset): mirrored facets f%d and f%d do not have the same vertices\n",
-	   facet->id, neighbor->id);
+    if (!qh_setequal(facet->vertices, neighbor->vertices)) {
+      qh_fprintf(qh ferr, 6093, "qhull error (qh_appendmergeset): mirrored facets f%d and f%d do not have the same vertices\n",
+           facet->id, neighbor->id);
       qh_errexit2 (qh_ERRqhull, facet, neighbor);
     }
     facet->redundant= True;
     neighbor->redundant= True;
-    qh_setappend (&(qh degen_mergeset), merge);
+    qh_setappend(&(qh degen_mergeset), merge);
   }
 } /* appendmergeset */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="basevertices">-</a>
-  
+
   qh_basevertices( samecycle )
     return temporary set of base vertices for samecycle
     samecycle is first facet in the cycle
     assumes apex is SETfirst_( samecycle->vertices )
 
   returns:
-    vertices (settemp)
+    vertices(settemp)
     all ->seen are cleared
 
   notes:
@@ -377,13 +379,13 @@
   design:
     for each facet in samecycle
       for each unseen vertex in facet->vertices
-        append to result  
+        append to result
 */
-setT *qh_basevertices (facetT *samecycle) {
+setT *qh_basevertices(facetT *samecycle) {
   facetT *same;
   vertexT *apex, *vertex, **vertexp;
-  setT *vertices= qh_settemp (qh TEMPsize);
-  
+  setT *vertices= qh_settemp(qh TEMPsize);
+
   apex= SETfirstt_(samecycle->vertices, vertexT);
   apex->visitid= ++qh vertex_visit;
   FORALLsame_cycle_(samecycle) {
@@ -391,24 +393,24 @@
       continue;
     FOREACHvertex_(same->vertices) {
       if (vertex->visitid != qh vertex_visit) {
-        qh_setappend (&vertices, vertex);
+        qh_setappend(&vertices, vertex);
         vertex->visitid= qh vertex_visit;
         vertex->seen= False;
       }
     }
   }
-  trace4((qh ferr, "qh_basevertices: found %d vertices\n", 
-         qh_setsize (vertices)));
+  trace4((qh ferr, 4019, "qh_basevertices: found %d vertices\n",
+         qh_setsize(vertices)));
   return vertices;
 } /* basevertices */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="checkconnect">-</a>
-  
+
   qh_checkconnect()
     check that new facets are connected
     new facets are on qh.newfacet_list
-    
+
   notes:
     this is slow and it changes the order of the facets
     uses qh.visit_id
@@ -420,18 +422,18 @@
     for all new facets
       report error if unvisited
 */
-void qh_checkconnect (void /* qh newfacet_list */) {
+void qh_checkconnect(void /* qh newfacet_list */) {
   facetT *facet, *newfacet, *errfacet= NULL, *neighbor, **neighborp;
 
   facet= qh newfacet_list;
-  qh_removefacet (facet);
-  qh_appendfacet (facet);
+  qh_removefacet(facet);
+  qh_appendfacet(facet);
   facet->visitid= ++qh visit_id;
   FORALLfacet_(facet) {
     FOREACHneighbor_(facet) {
       if (neighbor->visitid != qh visit_id) {
-        qh_removefacet (neighbor);
-        qh_appendfacet (neighbor);
+        qh_removefacet(neighbor);
+        qh_appendfacet(neighbor);
         neighbor->visitid= qh visit_id;
       }
     }
@@ -439,26 +441,26 @@
   FORALLnew_facets {
     if (newfacet->visitid == qh visit_id)
       break;
-    fprintf(qh ferr, "qhull error: f%d is not attached to the new facets\n",
+    qh_fprintf(qh ferr, 6094, "qhull error: f%d is not attached to the new facets\n",
          newfacet->id);
     errfacet= newfacet;
   }
   if (errfacet)
-    qh_errexit (qh_ERRqhull, errfacet, NULL);
+    qh_errexit(qh_ERRqhull, errfacet, NULL);
 } /* checkconnect */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="checkzero">-</a>
-  
+
   qh_checkzero( testall )
     check that facets are clearly convex for qh.DISTround with qh.MERGEexact
 
-    if testall, 
+    if testall,
       test all facets for qh.MERGEexact post-merging
-    else 
+    else
       test qh.newfacet_list
-      
-    if qh.MERGEexact, 
+
+    if qh.MERGEexact,
       allows coplanar ridges
       skips convexity test while qh.ZEROall_ok
 
@@ -466,7 +468,7 @@
     True if all facets !flipped, !dupridge, normal
          if all horizon facets are simplicial
          if all vertices are clearly below neighbor
-         if all opposite vertices of horizon are below 
+         if all opposite vertices of horizon are below
     clears qh.ZEROall_ok if any problems or coplanar facets
 
   notes:
@@ -483,14 +485,14 @@
       if qh.newfacet_list
         test the other vertices in the facet's horizon facet
 */
-boolT qh_checkzero (boolT testall) {
+boolT qh_checkzero(boolT testall) {
   facetT *facet, *neighbor, **neighborp;
   facetT *horizon, *facetlist;
   int neighbor_i;
   vertexT *vertex, **vertexp;
   realT dist;
 
-  if (testall) 
+  if (testall)
     facetlist= qh facet_list;
   else {
     facetlist= qh newfacet_list;
@@ -502,7 +504,7 @@
         goto LABELproblem;
     }
     if (qh MERGEexact && qh ZEROall_ok) {
-      trace2((qh ferr, "qh_checkzero: skip convexity check until first pre-merge\n"));
+      trace2((qh ferr, 2011, "qh_checkzero: skip convexity check until first pre-merge\n"));
       return True;
     }
   }
@@ -513,13 +515,13 @@
     FOREACHneighbor_(facet) {
       if (!neighbor_i && !testall) {
         horizon= neighbor;
-	neighbor_i++;
+        neighbor_i++;
         continue; /* horizon facet tested in qh_findhorizon */
       }
       vertex= SETelemt_(facet->vertices, neighbor_i++, vertexT);
       vertex->visitid= qh vertex_visit;
       zzinc_(Zdistzero);
-      qh_distplane (vertex->point, neighbor, &dist);
+      qh_distplane(vertex->point, neighbor, &dist);
       if (dist >= -qh DISTround) {
         qh ZEROall_ok= False;
         if (!qh MERGEexact || testall || dist > qh DISTround)
@@ -528,75 +530,75 @@
     }
     if (!testall) {
       FOREACHvertex_(horizon->vertices) {
-	if (vertex->visitid != qh vertex_visit) {
-	  zzinc_(Zdistzero);
-	  qh_distplane (vertex->point, facet, &dist);
-	  if (dist >= -qh DISTround) {
-	    qh ZEROall_ok= False;
-	    if (!qh MERGEexact || dist > qh DISTround)
-	      goto LABELnonconvex;
-	  }
-	  break;
-	}
+        if (vertex->visitid != qh vertex_visit) {
+          zzinc_(Zdistzero);
+          qh_distplane(vertex->point, facet, &dist);
+          if (dist >= -qh DISTround) {
+            qh ZEROall_ok= False;
+            if (!qh MERGEexact || dist > qh DISTround)
+              goto LABELnonconvex;
+          }
+          break;
+        }
       }
     }
   }
-  trace2((qh ferr, "qh_checkzero: testall %d, facets are %s\n", testall,
-        (qh MERGEexact && !testall) ? 
+  trace2((qh ferr, 2012, "qh_checkzero: testall %d, facets are %s\n", testall,
+        (qh MERGEexact && !testall) ?
            "not concave, flipped, or duplicate ridged" : "clearly convex"));
   return True;
 
  LABELproblem:
   qh ZEROall_ok= False;
-  trace2((qh ferr, "qh_checkzero: facet f%d needs pre-merging\n",
+  trace2((qh ferr, 2013, "qh_checkzero: facet f%d needs pre-merging\n",
        facet->id));
   return False;
 
  LABELnonconvex:
-  trace2((qh ferr, "qh_checkzero: facet f%d and f%d are not clearly convex.  v%d dist %.2g\n",
+  trace2((qh ferr, 2014, "qh_checkzero: facet f%d and f%d are not clearly convex.  v%d dist %.2g\n",
          facet->id, neighbor->id, vertex->id, dist));
   return False;
 } /* checkzero */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="compareangle">-</a>
-  
+
   qh_compareangle( angle1, angle2 )
     used by qsort() to order merges by angle
 */
 int qh_compareangle(const void *p1, const void *p2) {
-  mergeT *a= *((mergeT **)p1), *b= *((mergeT **)p2);
- 
-  return ((a->angle > b->angle) ? 1 : -1);
+  const mergeT *a= *((mergeT *const*)p1), *b= *((mergeT *const*)p2);
+
+  return((a->angle > b->angle) ? 1 : -1);
 } /* compareangle */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="comparemerge">-</a>
-  
+
   qh_comparemerge( merge1, merge2 )
     used by qsort() to order merges
 */
 int qh_comparemerge(const void *p1, const void *p2) {
-  mergeT *a= *((mergeT **)p1), *b= *((mergeT **)p2);
- 
-  return (a->type - b->type);
+  const mergeT *a= *((mergeT *const*)p1), *b= *((mergeT *const*)p2);
+
+  return(a->type - b->type);
 } /* comparemerge */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="comparevisit">-</a>
-  
+
   qh_comparevisit( vertex1, vertex2 )
     used by qsort() to order vertices by their visitid
 */
-int qh_comparevisit (const void *p1, const void *p2) {
-  vertexT *a= *((vertexT **)p1), *b= *((vertexT **)p2);
- 
-  return (a->visitid - b->visitid);
+int qh_comparevisit(const void *p1, const void *p2) {
+  const vertexT *a= *((vertexT *const*)p1), *b= *((vertexT *const*)p2);
+
+  return(a->visitid - b->visitid);
 } /* comparevisit */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="copynonconvex">-</a>
-  
+
   qh_copynonconvex( atridge )
     set non-convex flag on other ridges (if any) between same neighbors
 
@@ -608,7 +610,7 @@
       if ridge shares the same neighbor
         set nonconvex flag
 */
-void qh_copynonconvex (ridgeT *atridge) {
+void qh_copynonconvex(ridgeT *atridge) {
   facetT *facet, *otherfacet;
   ridgeT *ridge, **ridgep;
 
@@ -617,8 +619,8 @@
   FOREACHridge_(facet->ridges) {
     if (otherfacet == otherfacet_(ridge, facet) && ridge != atridge) {
       ridge->nonconvex= True;
-      trace4((qh ferr, "qh_copynonconvex: moved nonconvex flag from r%d to r%d\n",
-	      atridge->id, ridge->id));
+      trace4((qh ferr, 4020, "qh_copynonconvex: moved nonconvex flag from r%d to r%d\n",
+              atridge->id, ridge->id));
       break;
     }
   }
@@ -626,7 +628,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="degen_redundant_facet">-</a>
-  
+
   qh_degen_redundant_facet( facet )
     check facet for degen. or redundancy
 
@@ -642,39 +644,39 @@
     test for redundant neighbor
     test for degenerate facet
 */
-void qh_degen_redundant_facet (facetT *facet) {
+void qh_degen_redundant_facet(facetT *facet) {
   vertexT *vertex, **vertexp;
   facetT *neighbor, **neighborp;
 
-  trace4((qh ferr, "qh_degen_redundant_facet: test facet f%d for degen/redundant\n",
-	  facet->id));
+  trace4((qh ferr, 4021, "qh_degen_redundant_facet: test facet f%d for degen/redundant\n",
+          facet->id));
   FOREACHneighbor_(facet) {
     qh vertex_visit++;
     FOREACHvertex_(neighbor->vertices)
       vertex->visitid= qh vertex_visit;
     FOREACHvertex_(facet->vertices) {
       if (vertex->visitid != qh vertex_visit)
-	break;
+        break;
     }
     if (!vertex) {
-      qh_appendmergeset (facet, neighbor, MRGredundant, NULL);
-      trace2((qh ferr, "qh_degen_redundant_facet: f%d is contained in f%d.  merge\n", facet->id, neighbor->id)); 
+      qh_appendmergeset(facet, neighbor, MRGredundant, NULL);
+      trace2((qh ferr, 2015, "qh_degen_redundant_facet: f%d is contained in f%d.  merge\n", facet->id, neighbor->id));
       return;
     }
   }
-  if (qh_setsize (facet->neighbors) < qh hull_dim) {
-    qh_appendmergeset (facet, facet, MRGdegen, NULL);
-    trace2((qh ferr, "qh_degen_redundant_neighbors: f%d is degenerate.\n", facet->id));
+  if (qh_setsize(facet->neighbors) < qh hull_dim) {
+    qh_appendmergeset(facet, facet, MRGdegen, NULL);
+    trace2((qh ferr, 2016, "qh_degen_redundant_neighbors: f%d is degenerate.\n", facet->id));
   }
 } /* degen_redundant_facet */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="degen_redundant_neighbors">-</a>
-  
+
   qh_degen_redundant_neighbors( facet, delfacet,  )
     append degenerate and redundant neighbors to facet_mergeset
-    if delfacet, 
+    if delfacet,
       only checks neighbors of both delfacet and facet
     also checks current facet for degeneracy
 
@@ -689,7 +691,7 @@
     a redundant facet's vertices is a subset of its neighbor's vertices
     tests for redundant merges first (appendmergeset is nop for others)
     in a merge, only needs to test neighbors of merged facet
-  
+
   see:
     qh_merge_degenredundant() and qh_degen_redundant_facet()
 
@@ -698,16 +700,16 @@
     test for redundant neighbor
     test for degenerate neighbor
 */
-void qh_degen_redundant_neighbors (facetT *facet, facetT *delfacet) {
+void qh_degen_redundant_neighbors(facetT *facet, facetT *delfacet) {
   vertexT *vertex, **vertexp;
   facetT *neighbor, **neighborp;
   int size;
 
-  trace4((qh ferr, "qh_degen_redundant_neighbors: test neighbors of f%d with delfacet f%d\n", 
-	  facet->id, getid_(delfacet)));
-  if ((size= qh_setsize (facet->neighbors)) < qh hull_dim) {
-    qh_appendmergeset (facet, facet, MRGdegen, NULL);
-    trace2((qh ferr, "qh_degen_redundant_neighbors: f%d is degenerate with %d neighbors.\n", facet->id, size));
+  trace4((qh ferr, 4022, "qh_degen_redundant_neighbors: test neighbors of f%d with delfacet f%d\n",
+          facet->id, getid_(delfacet)));
+  if ((size= qh_setsize(facet->neighbors)) < qh hull_dim) {
+    qh_appendmergeset(facet, facet, MRGdegen, NULL);
+    trace2((qh ferr, 2017, "qh_degen_redundant_neighbors: f%d is degenerate with %d neighbors.\n", facet->id, size));
   }
   if (!delfacet)
     delfacet= facet;
@@ -723,16 +725,16 @@
         break;
     }
     if (!vertex) {
-      qh_appendmergeset (neighbor, facet, MRGredundant, NULL);
-      trace2((qh ferr, "qh_degen_redundant_neighbors: f%d is contained in f%d.  merge\n", neighbor->id, facet->id)); 
+      qh_appendmergeset(neighbor, facet, MRGredundant, NULL);
+      trace2((qh ferr, 2018, "qh_degen_redundant_neighbors: f%d is contained in f%d.  merge\n", neighbor->id, facet->id));
     }
   }
   FOREACHneighbor_(delfacet) {   /* redundant merges occur first */
     if (neighbor == facet)
       continue;
-    if ((size= qh_setsize (neighbor->neighbors)) < qh hull_dim) {
-      qh_appendmergeset (neighbor, neighbor, MRGdegen, NULL);
-      trace2((qh ferr, "qh_degen_redundant_neighbors: f%d is degenerate with %d neighbors.  Neighbor of f%d.\n", neighbor->id, size, facet->id)); 
+    if ((size= qh_setsize(neighbor->neighbors)) < qh hull_dim) {
+      qh_appendmergeset(neighbor, neighbor, MRGdegen, NULL);
+      trace2((qh ferr, 2019, "qh_degen_redundant_neighbors: f%d is degenerate with %d neighbors.  Neighbor of f%d.\n", neighbor->id, size, facet->id));
     }
   }
 } /* degen_redundant_neighbors */
@@ -740,7 +742,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="find_newvertex">-</a>
-  
+
   qh_find_newvertex( oldvertex, vertices, ridges )
     locate new vertex for renaming old vertex
     vertices is a set of possible new vertices
@@ -750,7 +752,7 @@
     newvertex or NULL
       each ridge includes both vertex and oldvertex
     vertices sorted by number of deleted ridges
-      
+
   notes:
     modifies vertex->visitid
     new vertex is in one of the ridges
@@ -761,14 +763,14 @@
   design:
     for each vertex in vertices
       set vertex->visitid to number of references in ridges
-    remove unvisited vertices 
+    remove unvisited vertices
     set qh.vertex_visit above all possible values
     sort vertices by number of references in ridges
     add each ridge to qh.hash_table
     for each vertex in vertices
       look for a vertex that would not cause a duplicate ridge after a rename
 */
-vertexT *qh_find_newvertex (vertexT *oldvertex, setT *vertices, setT *ridges) {
+vertexT *qh_find_newvertex(vertexT *oldvertex, setT *vertices, setT *ridges) {
   vertexT *vertex, **vertexp;
   setT *newridges;
   ridgeT *ridge, **ridgep;
@@ -777,85 +779,85 @@
 
 #ifndef qh_NOtrace
   if (qh IStracing >= 4) {
-    fprintf (qh ferr, "qh_find_newvertex: find new vertex for v%d from ",
-	     oldvertex->id);
-    FOREACHvertex_(vertices) 
-      fprintf (qh ferr, "v%d ", vertex->id);
+    qh_fprintf(qh ferr, 8063, "qh_find_newvertex: find new vertex for v%d from ",
+             oldvertex->id);
+    FOREACHvertex_(vertices)
+      qh_fprintf(qh ferr, 8064, "v%d ", vertex->id);
     FOREACHridge_(ridges)
-      fprintf (qh ferr, "r%d ", ridge->id);
-    fprintf (qh ferr, "\n");
+      qh_fprintf(qh ferr, 8065, "r%d ", ridge->id);
+    qh_fprintf(qh ferr, 8066, "\n");
   }
 #endif
-  FOREACHvertex_(vertices) 
+  FOREACHvertex_(vertices)
     vertex->visitid= 0;
   FOREACHridge_(ridges) {
-    FOREACHvertex_(ridge->vertices) 
+    FOREACHvertex_(ridge->vertices)
       vertex->visitid++;
   }
   FOREACHvertex_(vertices) {
     if (!vertex->visitid) {
-      qh_setdelnth (vertices, SETindex_(vertices,vertex));
+      qh_setdelnth(vertices, SETindex_(vertices,vertex));
       vertexp--; /* repeat since deleted this vertex */
     }
   }
-  qh vertex_visit += qh_setsize (ridges);
-  if (!qh_setsize (vertices)) {
-    trace4((qh ferr, "qh_find_newvertex: vertices not in ridges for v%d\n",
-	    oldvertex->id));
+  qh vertex_visit += (unsigned int)qh_setsize(ridges);
+  if (!qh_setsize(vertices)) {
+    trace4((qh ferr, 4023, "qh_find_newvertex: vertices not in ridges for v%d\n",
+            oldvertex->id));
     return NULL;
   }
-  qsort (SETaddr_(vertices, vertexT), qh_setsize (vertices),
-	        sizeof (vertexT *), qh_comparevisit);
+  qsort(SETaddr_(vertices, vertexT), (size_t)qh_setsize(vertices),
+                sizeof(vertexT *), qh_comparevisit);
   /* can now use qh vertex_visit */
   if (qh PRINTstatistics) {
-    size= qh_setsize (vertices);
+    size= qh_setsize(vertices);
     zinc_(Zintersect);
     zadd_(Zintersecttot, size);
     zmax_(Zintersectmax, size);
   }
-  hashsize= qh_newhashtable (qh_setsize (ridges));
+  hashsize= qh_newhashtable(qh_setsize(ridges));
   FOREACHridge_(ridges)
-    qh_hashridge (qh hash_table, hashsize, ridge, oldvertex);
+    qh_hashridge(qh hash_table, hashsize, ridge, oldvertex);
   FOREACHvertex_(vertices) {
-    newridges= qh_vertexridges (vertex);
+    newridges= qh_vertexridges(vertex);
     FOREACHridge_(newridges) {
-      if (qh_hashridge_find (qh hash_table, hashsize, ridge, vertex, oldvertex, &hash)) {
-	zinc_(Zdupridge);
-	break;
+      if (qh_hashridge_find(qh hash_table, hashsize, ridge, vertex, oldvertex, &hash)) {
+        zinc_(Zdupridge);
+        break;
       }
     }
-    qh_settempfree (&newridges);
+    qh_settempfree(&newridges);
     if (!ridge)
       break;  /* found a rename */
   }
   if (vertex) {
     /* counted in qh_renamevertex */
-    trace2((qh ferr, "qh_find_newvertex: found v%d for old v%d from %d vertices and %d ridges.\n",
-      vertex->id, oldvertex->id, qh_setsize (vertices), qh_setsize (ridges)));
+    trace2((qh ferr, 2020, "qh_find_newvertex: found v%d for old v%d from %d vertices and %d ridges.\n",
+      vertex->id, oldvertex->id, qh_setsize(vertices), qh_setsize(ridges)));
   }else {
     zinc_(Zfindfail);
-    trace0((qh ferr, "qh_find_newvertex: no vertex for renaming v%d (all duplicated ridges) during p%d\n",
+    trace0((qh ferr, 14, "qh_find_newvertex: no vertex for renaming v%d(all duplicated ridges) during p%d\n",
       oldvertex->id, qh furthest_id));
   }
-  qh_setfree (&qh hash_table);
+  qh_setfree(&qh hash_table);
   return vertex;
 } /* find_newvertex */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="findbest_test">-</a>
-  
+
   qh_findbest_test( testcentrum, facet, neighbor, bestfacet, dist, mindist, maxdist )
     test neighbor of facet for qh_findbestneighbor()
     if testcentrum,
       tests centrum (assumes it is defined)
-    else 
+    else
       tests vertices
 
   returns:
     if a better facet (i.e., vertices/centrum of facet closer to neighbor)
       updates bestfacet, dist, mindist, and maxdist
 */
-void qh_findbest_test (boolT testcentrum, facetT *facet, facetT *neighbor,
+void qh_findbest_test(boolT testcentrum, facetT *facet, facetT *neighbor,
       facetT **bestfacet, realT *distp, realT *mindistp, realT *maxdistp) {
   realT dist, mindist, maxdist;
 
@@ -867,10 +869,12 @@
       maxdist= 0;
       mindist= dist;
       dist= -dist;
-    }else
+    }else {
+      mindist= 0;
       maxdist= dist;
+    }
   }else
-    dist= qh_getdistance (facet, neighbor, &mindist, &maxdist);
+    dist= qh_getdistance(facet, neighbor, &mindist, &maxdist);
   if (dist < *distp) {
     *bestfacet= neighbor;
     *mindistp= mindist;
@@ -881,13 +885,13 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="findbestneighbor">-</a>
-  
+
   qh_findbestneighbor( facet, dist, mindist, maxdist )
     finds best neighbor (least dist) of a facet for merging
 
   returns:
     returns min and max distances and their max absolute value
-  
+
   notes:
     avoids merging old into new
     assumes ridge->nonconvex only set on one ridge between a pair of facets
@@ -909,38 +913,38 @@
   facetT *neighbor, **neighborp, *bestfacet= NULL;
   ridgeT *ridge, **ridgep;
   boolT nonconvex= True, testcentrum= False;
-  int size= qh_setsize (facet->vertices);
+  int size= qh_setsize(facet->vertices);
 
   *distp= REALmax;
   if (size > qh_BESTcentrum2 * qh hull_dim + qh_BESTcentrum) {
     testcentrum= True;
     zinc_(Zbestcentrum);
     if (!facet->center)
-       facet->center= qh_getcentrum (facet);
+       facet->center= qh_getcentrum(facet);
   }
   if (size > qh hull_dim + qh_BESTnonconvex) {
     FOREACHridge_(facet->ridges) {
       if (ridge->nonconvex) {
         neighbor= otherfacet_(ridge, facet);
-	qh_findbest_test (testcentrum, facet, neighbor,
-			  &bestfacet, distp, mindistp, maxdistp);
+        qh_findbest_test(testcentrum, facet, neighbor,
+                          &bestfacet, distp, mindistp, maxdistp);
       }
     }
   }
-  if (!bestfacet) {     
+  if (!bestfacet) {
     nonconvex= False;
     FOREACHneighbor_(facet)
-      qh_findbest_test (testcentrum, facet, neighbor,
-			&bestfacet, distp, mindistp, maxdistp);
+      qh_findbest_test(testcentrum, facet, neighbor,
+                        &bestfacet, distp, mindistp, maxdistp);
   }
   if (!bestfacet) {
-    fprintf (qh ferr, "qhull internal error (qh_findbestneighbor): no neighbors for f%d\n", facet->id);
-    
-    qh_errexit (qh_ERRqhull, facet, NULL);
+    qh_fprintf(qh ferr, 6095, "qhull internal error (qh_findbestneighbor): no neighbors for f%d\n", facet->id);
+
+    qh_errexit(qh_ERRqhull, facet, NULL);
   }
-  if (testcentrum) 
-    qh_getdistance (facet, bestfacet, mindistp, maxdistp);
-  trace3((qh ferr, "qh_findbestneighbor: f%d is best neighbor for f%d testcentrum? %d nonconvex? %d dist %2.2g min %2.2g max %2.2g\n",
+  if (testcentrum)
+    qh_getdistance(facet, bestfacet, mindistp, maxdistp);
+  trace3((qh ferr, 3002, "qh_findbestneighbor: f%d is best neighbor for f%d testcentrum? %d nonconvex? %d dist %2.2g min %2.2g max %2.2g\n",
      bestfacet->id, facet->id, testcentrum, nonconvex, *distp, *mindistp, *maxdistp));
   return(bestfacet);
 } /* findbestneighbor */
@@ -948,7 +952,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="flippedmerges">-</a>
-  
+
   qh_flippedmerges( facetlist, wasmerge )
     merge flipped facets into best neighbor
     assumes qh.facet_mergeset at top of temporary stack
@@ -977,24 +981,24 @@
   setT *othermerges;
   int nummerge=0;
 
-  trace4((qh ferr, "qh_flippedmerges: begin\n"));
+  trace4((qh ferr, 4024, "qh_flippedmerges: begin\n"));
   FORALLfacet_(facetlist) {
-    if (facet->flipped && !facet->visible) 
-      qh_appendmergeset (facet, facet, MRGflip, NULL);
+    if (facet->flipped && !facet->visible)
+      qh_appendmergeset(facet, facet, MRGflip, NULL);
   }
   othermerges= qh_settemppop(); /* was facet_mergeset */
-  qh facet_mergeset= qh_settemp (qh TEMPsize);
-  qh_settemppush (othermerges);
+  qh facet_mergeset= qh_settemp(qh TEMPsize);
+  qh_settemppush(othermerges);
   FOREACHmerge_(othermerges) {
     facet1= merge->facet1;
-    if (merge->type != MRGflip || facet1->visible) 
+    if (merge->type != MRGflip || facet1->visible)
       continue;
     if (qh TRACEmerge-1 == zzval_(Ztotmerge))
       qhmem.IStracing= qh IStracing= qh TRACElevel;
-    neighbor= qh_findbestneighbor (facet1, &dist, &mindist, &maxdist);
-    trace0((qh ferr, "qh_flippedmerges: merge flipped f%d into f%d dist %2.2g during p%d\n",
+    neighbor= qh_findbestneighbor(facet1, &dist, &mindist, &maxdist);
+    trace0((qh ferr, 15, "qh_flippedmerges: merge flipped f%d into f%d dist %2.2g during p%d\n",
       facet1->id, neighbor->id, dist, qh furthest_id));
-    qh_mergefacet (facet1, neighbor, &mindist, &maxdist, !qh_MERGEapex);
+    qh_mergefacet(facet1, neighbor, &mindist, &maxdist, !qh_MERGEapex);
     nummerge++;
     if (qh PRINTstatistics) {
       zinc_(Zflipped);
@@ -1005,30 +1009,30 @@
   }
   FOREACHmerge_(othermerges) {
     if (merge->facet1->visible || merge->facet2->visible)
-      qh_memfree (merge, sizeof(mergeT));
+      qh_memfree(merge, (int)sizeof(mergeT));
     else
-      qh_setappend (&qh facet_mergeset, merge);
+      qh_setappend(&qh facet_mergeset, merge);
   }
-  qh_settempfree (&othermerges);
+  qh_settempfree(&othermerges);
   if (nummerge)
     *wasmerge= True;
-  trace1((qh ferr, "qh_flippedmerges: merged %d flipped facets into a good neighbor\n", nummerge));
+  trace1((qh ferr, 1010, "qh_flippedmerges: merged %d flipped facets into a good neighbor\n", nummerge));
 } /* flippedmerges */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="forcedmerges">-</a>
-  
+
   qh_forcedmerges( wasmerge )
     merge duplicated ridges
 
   returns:
     removes all duplicate ridges on facet_mergeset
     wasmerge set if merge
-    qh.facet_mergeset may include non-forced merges (none for now)
+    qh.facet_mergeset may include non-forced merges(none for now)
     qh.degen_mergeset includes degen/redun merges
 
-  notes: 
+  notes:
     duplicate ridges occur when the horizon is pinched,
         i.e. a subridge occurs in more than two horizon ridges.
      could rename vertices that pinch the horizon
@@ -1052,36 +1056,36 @@
 
   if (qh TRACEmerge-1 == zzval_(Ztotmerge))
     qhmem.IStracing= qh IStracing= qh TRACElevel;
-  trace4((qh ferr, "qh_forcedmerges: begin\n"));  
+  trace4((qh ferr, 4025, "qh_forcedmerges: begin\n"));
   othermerges= qh_settemppop(); /* was facet_mergeset */
-  qh facet_mergeset= qh_settemp (qh TEMPsize);
-  qh_settemppush (othermerges);
+  qh facet_mergeset= qh_settemp(qh TEMPsize);
+  qh_settemppush(othermerges);
   FOREACHmerge_(othermerges) {
-    if (merge->type != MRGridge) 
-    	continue;
+    if (merge->type != MRGridge)
+        continue;
     facet1= merge->facet1;
     facet2= merge->facet2;
-    while (facet1->visible)    	 /* must exist, no qh_merge_degenredunant */
+    while (facet1->visible)      /* must exist, no qh_merge_degenredunant */
       facet1= facet1->f.replace; /* previously merged facet */
     while (facet2->visible)
       facet2= facet2->f.replace; /* previously merged facet */
     if (facet1 == facet2)
       continue;
-    if (!qh_setin (facet2->neighbors, facet1)) {
-      fprintf (qh ferr, "qhull internal error (qh_forcedmerges): f%d and f%d had a duplicate ridge but as f%d and f%d they are no longer neighbors\n",
-	       merge->facet1->id, merge->facet2->id, facet1->id, facet2->id);
+    if (!qh_setin(facet2->neighbors, facet1)) {
+      qh_fprintf(qh ferr, 6096, "qhull internal error (qh_forcedmerges): f%d and f%d had a duplicate ridge but as f%d and f%d they are no longer neighbors\n",
+               merge->facet1->id, merge->facet2->id, facet1->id, facet2->id);
       qh_errexit2 (qh_ERRqhull, facet1, facet2);
     }
     if (qh TRACEmerge-1 == zzval_(Ztotmerge))
       qhmem.IStracing= qh IStracing= qh TRACElevel;
-    dist1= qh_getdistance (facet1, facet2, &mindist1, &maxdist1);
-    dist2= qh_getdistance (facet2, facet1, &mindist2, &maxdist2);
-    trace0((qh ferr, "qh_forcedmerges: duplicate ridge between f%d and f%d, dist %2.2g and reverse dist %2.2g during p%d\n",
-	    facet1->id, facet2->id, dist1, dist2, qh furthest_id));
-    if (dist1 < dist2) 
-      qh_mergefacet (facet1, facet2, &mindist1, &maxdist1, !qh_MERGEapex);
+    dist1= qh_getdistance(facet1, facet2, &mindist1, &maxdist1);
+    dist2= qh_getdistance(facet2, facet1, &mindist2, &maxdist2);
+    trace0((qh ferr, 16, "qh_forcedmerges: duplicate ridge between f%d and f%d, dist %2.2g and reverse dist %2.2g during p%d\n",
+            facet1->id, facet2->id, dist1, dist2, qh furthest_id));
+    if (dist1 < dist2)
+      qh_mergefacet(facet1, facet2, &mindist1, &maxdist1, !qh_MERGEapex);
     else {
-      qh_mergefacet (facet2, facet1, &mindist2, &maxdist2, !qh_MERGEapex);
+      qh_mergefacet(facet2, facet1, &mindist2, &maxdist2, !qh_MERGEapex);
       dist1= dist2;
       facet1= facet2;
     }
@@ -1098,21 +1102,21 @@
   }
   FOREACHmerge_(othermerges) {
     if (merge->type == MRGridge)
-      qh_memfree (merge, sizeof(mergeT));
+      qh_memfree(merge, (int)sizeof(mergeT));
     else
-      qh_setappend (&qh facet_mergeset, merge);
+      qh_setappend(&qh facet_mergeset, merge);
   }
-  qh_settempfree (&othermerges);
+  qh_settempfree(&othermerges);
   if (nummerge)
     *wasmerge= True;
-  trace1((qh ferr, "qh_forcedmerges: merged %d facets and %d flipped facets across duplicated ridges\n", 
+  trace1((qh ferr, 1011, "qh_forcedmerges: merged %d facets and %d flipped facets across duplicated ridges\n",
                 nummerge, numflip));
 } /* forcedmerges */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="getmergeset">-</a>
-  
+
   qh_getmergeset( facetlist )
     determines nonconvex facets on facetlist
     tests !tested ridges and nonconvex ridges of !tested facets
@@ -1120,13 +1124,13 @@
   returns:
     returns sorted qh.facet_mergeset of facet-neighbor pairs to be merged
     all ridges tested
-  
+
   notes:
     assumes no nonconvex ridges with both facets tested
     uses facet->tested/ridge->tested to prevent duplicate tests
     can not limit tests to modified ridges since the centrum changed
     uses qh.visit_id
-  
+
   see:
     qh_getmergeset_initial()
 
@@ -1137,15 +1141,15 @@
           test ridge for convexity
           if non-convex
             append ridge to qh.facet_mergeset
-    sort qh.facet_mergeset by angle  
+    sort qh.facet_mergeset by angle
 */
 void qh_getmergeset(facetT *facetlist) {
   facetT *facet, *neighbor, **neighborp;
   ridgeT *ridge, **ridgep;
   int nummerges;
-  
-  nummerges= qh_setsize (qh facet_mergeset);
-  trace4((qh ferr, "qh_getmergeset: started.\n"));
+
+  nummerges= qh_setsize(qh facet_mergeset);
+  trace4((qh ferr, 4026, "qh_getmergeset: started.\n"));
   qh visit_id++;
   FORALLfacet_(facetlist) {
     if (facet->tested)
@@ -1156,39 +1160,39 @@
       neighbor->seen= False;
     FOREACHridge_(facet->ridges) {
       if (ridge->tested && !ridge->nonconvex)
-	continue;
+        continue;
       /* if tested & nonconvex, need to append merge */
       neighbor= otherfacet_(ridge, facet);
       if (neighbor->seen) {
-	ridge->tested= True;
-	ridge->nonconvex= False;
+        ridge->tested= True;
+        ridge->nonconvex= False;
       }else if (neighbor->visitid != qh visit_id) {
         ridge->tested= True;
         ridge->nonconvex= False;
-	neighbor->seen= True;      /* only one ridge is marked nonconvex */
-	if (qh_test_appendmerge (facet, neighbor))
-	  ridge->nonconvex= True;
+        neighbor->seen= True;      /* only one ridge is marked nonconvex */
+        if (qh_test_appendmerge(facet, neighbor))
+          ridge->nonconvex= True;
       }
     }
   }
-  nummerges= qh_setsize (qh facet_mergeset);
+  nummerges= qh_setsize(qh facet_mergeset);
   if (qh ANGLEmerge)
-    qsort(SETaddr_(qh facet_mergeset, mergeT), nummerges,sizeof(mergeT *),qh_compareangle);
+    qsort(SETaddr_(qh facet_mergeset, mergeT), (size_t)nummerges, sizeof(mergeT *), qh_compareangle);
   else
-    qsort(SETaddr_(qh facet_mergeset, mergeT), nummerges,sizeof(mergeT *),qh_comparemerge);
+    qsort(SETaddr_(qh facet_mergeset, mergeT), (size_t)nummerges, sizeof(mergeT *), qh_comparemerge);
   if (qh POSTmerging) {
     zadd_(Zmergesettot2, nummerges);
   }else {
     zadd_(Zmergesettot, nummerges);
     zmax_(Zmergesetmax, nummerges);
   }
-  trace2((qh ferr, "qh_getmergeset: %d merges found\n", nummerges));
+  trace2((qh ferr, 2021, "qh_getmergeset: %d merges found\n", nummerges));
 } /* getmergeset */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="getmergeset_initial">-</a>
-  
+
   qh_getmergeset_initial( facetlist )
     determine initial qh.facet_mergeset for facets
     tests all facet/neighbor pairs on facetlist
@@ -1212,7 +1216,7 @@
           mark one of the ridges as nonconvex
     sort qh.facet_mergeset by angle
 */
-void qh_getmergeset_initial (facetT *facetlist) {
+void qh_getmergeset_initial(facetT *facetlist) {
   facetT *facet, *neighbor, **neighborp;
   ridgeT *ridge, **ridgep;
   int nummerges;
@@ -1223,11 +1227,11 @@
     facet->tested= True;
     FOREACHneighbor_(facet) {
       if (neighbor->visitid != qh visit_id) {
-        if (qh_test_appendmerge (facet, neighbor)) {
+        if (qh_test_appendmerge(facet, neighbor)) {
           FOREACHridge_(neighbor->ridges) {
             if (facet == otherfacet_(ridge, neighbor)) {
               ridge->nonconvex= True;
-              break;	/* only one ridge is marked nonconvex */
+              break;    /* only one ridge is marked nonconvex */
             }
           }
         }
@@ -1236,24 +1240,24 @@
     FOREACHridge_(facet->ridges)
       ridge->tested= True;
   }
-  nummerges= qh_setsize (qh facet_mergeset);
+  nummerges= qh_setsize(qh facet_mergeset);
   if (qh ANGLEmerge)
-    qsort(SETaddr_(qh facet_mergeset, mergeT), nummerges,sizeof(mergeT *),qh_compareangle);
+    qsort(SETaddr_(qh facet_mergeset, mergeT), (size_t)nummerges, sizeof(mergeT *), qh_compareangle);
   else
-    qsort(SETaddr_(qh facet_mergeset, mergeT), nummerges,sizeof(mergeT *),qh_comparemerge);
+    qsort(SETaddr_(qh facet_mergeset, mergeT), (size_t)nummerges, sizeof(mergeT *), qh_comparemerge);
   if (qh POSTmerging) {
     zadd_(Zmergeinittot2, nummerges);
   }else {
     zadd_(Zmergeinittot, nummerges);
     zmax_(Zmergeinitmax, nummerges);
   }
-  trace2((qh ferr, "qh_getmergeset_initial: %d merges found\n", nummerges));
+  trace2((qh ferr, 2022, "qh_getmergeset_initial: %d merges found\n", nummerges));
 } /* getmergeset_initial */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="hashridge">-</a>
-  
+
   qh_hashridge( hashtable, hashsize, ridge, oldvertex )
     add ridge to hashtable without oldvertex
 
@@ -1264,11 +1268,11 @@
     determine hash value for ridge without oldvertex
     find next empty slot for ridge
 */
-void qh_hashridge (setT *hashtable, int hashsize, ridgeT *ridge, vertexT *oldvertex) {
+void qh_hashridge(setT *hashtable, int hashsize, ridgeT *ridge, vertexT *oldvertex) {
   int hash;
   ridgeT *ridgeA;
 
-  hash= (int)qh_gethash (hashsize, ridge->vertices, qh hull_dim-1, 0, oldvertex);
+  hash= qh_gethash(hashsize, ridge->vertices, qh hull_dim-1, 0, oldvertex);
   while (True) {
     if (!(ridgeA= SETelemt_(hashtable, hash, ridgeT))) {
       SETelem_(hashtable, hash)= ridge;
@@ -1283,21 +1287,21 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="hashridge_find">-</a>
-  
+
   qh_hashridge_find( hashtable, hashsize, ridge, vertex, oldvertex, hashslot )
-    returns matching ridge without oldvertex in hashtable 
+    returns matching ridge without oldvertex in hashtable
       for ridge without vertex
-    if oldvertex is NULL 
+    if oldvertex is NULL
       matches with any one skip
 
   returns:
     matching ridge or NULL
     if no match,
       if ridge already in   table
-        hashslot= -1 
-      else 
+        hashslot= -1
+      else
         hashslot= next NULL index
-        
+
   notes:
     assumes hashtable is large enough
     can't match ridge to itself
@@ -1307,20 +1311,20 @@
     for each hashslot
       return match if ridge matches ridgeA without oldvertex
 */
-ridgeT *qh_hashridge_find (setT *hashtable, int hashsize, ridgeT *ridge, 
+ridgeT *qh_hashridge_find(setT *hashtable, int hashsize, ridgeT *ridge,
               vertexT *vertex, vertexT *oldvertex, int *hashslot) {
   int hash;
   ridgeT *ridgeA;
 
   *hashslot= 0;
   zinc_(Zhashridge);
-  hash= (int)qh_gethash (hashsize, ridge->vertices, qh hull_dim-1, 0, vertex);
+  hash= qh_gethash(hashsize, ridge->vertices, qh hull_dim-1, 0, vertex);
   while ((ridgeA= SETelemt_(hashtable, hash, ridgeT))) {
     if (ridgeA == ridge)
-      *hashslot= -1;      
+      *hashslot= -1;
     else {
       zinc_(Zhashridgetest);
-      if (qh_setequal_except (ridge->vertices, vertex, ridgeA->vertices, oldvertex))
+      if (qh_setequal_except(ridge->vertices, vertex, ridgeA->vertices, oldvertex))
         return ridgeA;
     }
     if (++hash == hashsize)
@@ -1334,14 +1338,14 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="makeridges">-</a>
-  
+
   qh_makeridges( facet )
     creates explicit ridges between simplicial facets
 
   returns:
     facet with ridges and without qh_MERGEridge
     ->simplicial is False
-  
+
   notes:
     allows qh_MERGEridge flag
     uses existing ridges
@@ -1353,7 +1357,7 @@
   design:
     look for qh_MERGEridge neighbors
     mark neighbors that already have ridges
-    for each unprocessed neighbor of facet    
+    for each unprocessed neighbor of facet
       create a ridge for neighbor and facet
     if any qh_MERGEridge neighbors
       delete qh_MERGEridge flags (already handled by qh_mark_dupridges)
@@ -1363,10 +1367,10 @@
   ridgeT *ridge, **ridgep;
   int neighbor_i, neighbor_n;
   boolT toporient, mergeridge= False;
-  
+
   if (!facet->simplicial)
     return;
-  trace4((qh ferr, "qh_makeridges: make ridges for f%d\n", facet->id));
+  trace4((qh ferr, 4027, "qh_makeridges: make ridges for f%d\n", facet->id));
   facet->simplicial= False;
   FOREACHneighbor_(facet) {
     if (neighbor == qh_MERGEridge)
@@ -1381,8 +1385,8 @@
       continue;  /* fixed by qh_mark_dupridges */
     else if (!neighbor->seen) {  /* no current ridges */
       ridge= qh_newridge();
-      ridge->vertices= qh_setnew_delnthsorted (facet->vertices, qh hull_dim,
-					                  neighbor_i, 0);
+      ridge->vertices= qh_setnew_delnthsorted(facet->vertices, qh hull_dim,
+                                                          neighbor_i, 0);
       toporient= facet->toporient ^ (neighbor_i & 0x1);
       if (toporient) {
         ridge->top= facet;
@@ -1406,7 +1410,7 @@
     }
   }
   if (mergeridge) {
-    while (qh_setdel (facet->neighbors, qh_MERGEridge))
+    while (qh_setdel(facet->neighbors, qh_MERGEridge))
       ; /* delete each one */
   }
 } /* makeridges */
@@ -1414,7 +1418,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mark_dupridges">-</a>
-  
+
   qh_mark_dupridges( facetlist )
     add duplicated ridges to qh.facet_mergeset
     facet->dupridge is true
@@ -1424,7 +1428,7 @@
     ->mergeridge/->mergeridge2 set
     duplicate ridges marked by qh_MERGEridge and both sides facet->dupridge
     no MERGEridges in neighbor sets
-    
+
   notes:
     duplicate ridges occur when the horizon is pinched,
         i.e. a subridge occurs in more than two horizon ridges.
@@ -1436,9 +1440,9 @@
       if facet contains a duplicate ridge
         for each neighbor of facet
           if neighbor marked qh_MERGEridge (one side of the merge)
-            set facet->mergeridge      
+            set facet->mergeridge
           else
-            if neighbor contains a duplicate ridge 
+            if neighbor contains a duplicate ridge
             and the back link is qh_MERGEridge
               append duplicate ridge to qh.facet_mergeset
    for each duplicate ridge
@@ -1452,52 +1456,52 @@
   facetT *facet, *neighbor, **neighborp;
   int nummerge=0;
   mergeT *merge, **mergep;
-  
 
-  trace4((qh ferr, "qh_mark_dupridges: identify duplicate ridges\n"));  
+
+  trace4((qh ferr, 4028, "qh_mark_dupridges: identify duplicate ridges\n"));
   FORALLfacet_(facetlist) {
     if (facet->dupridge) {
       FOREACHneighbor_(facet) {
         if (neighbor == qh_MERGEridge) {
-	  facet->mergeridge= True;
-	  continue;
-	}
+          facet->mergeridge= True;
+          continue;
+        }
         if (neighbor->dupridge
-	&& !qh_setin (neighbor->neighbors, facet)) { /* qh_MERGEridge */
-	  qh_appendmergeset (facet, neighbor, MRGridge, NULL);
-	  facet->mergeridge2= True;
-	  facet->mergeridge= True;
-	  nummerge++;
-	}
+        && !qh_setin(neighbor->neighbors, facet)) { /* qh_MERGEridge */
+          qh_appendmergeset(facet, neighbor, MRGridge, NULL);
+          facet->mergeridge2= True;
+          facet->mergeridge= True;
+          nummerge++;
+        }
       }
     }
   }
   if (!nummerge)
     return;
   FORALLfacet_(facetlist) {            /* gets rid of qh_MERGEridge */
-    if (facet->mergeridge && !facet->mergeridge2)   
-      qh_makeridges (facet);
+    if (facet->mergeridge && !facet->mergeridge2)
+      qh_makeridges(facet);
   }
   FOREACHmerge_(qh facet_mergeset) {   /* restore the missing neighbors */
     if (merge->type == MRGridge) {
-      qh_setappend (&merge->facet2->neighbors, merge->facet1);
-      qh_makeridges (merge->facet1);   /* and the missing ridges */
+      qh_setappend(&merge->facet2->neighbors, merge->facet1);
+      qh_makeridges(merge->facet1);   /* and the missing ridges */
     }
   }
-  trace1((qh ferr, "qh_mark_dupridges: found %d duplicated ridges\n", 
+  trace1((qh ferr, 1012, "qh_mark_dupridges: found %d duplicated ridges\n",
                 nummerge));
 } /* mark_dupridges */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="maydropneighbor">-</a>
-  
+
   qh_maydropneighbor( facet )
     drop neighbor relationship if no ridge between facet and neighbor
 
   returns:
     neighbor sets updated
     appends degenerate facets to qh.facet_mergeset
-  
+
   notes:
     won't cause redundant facets since vertex inclusion is the same
     may drop vertex and neighbor if no ridge
@@ -1512,44 +1516,44 @@
     if facet is degenerate
       append facet to qh.degen_mergeset
 */
-void qh_maydropneighbor (facetT *facet) {
+void qh_maydropneighbor(facetT *facet) {
   ridgeT *ridge, **ridgep;
   realT angledegen= qh_ANGLEdegen;
   facetT *neighbor, **neighborp;
 
   qh visit_id++;
-  trace4((qh ferr, "qh_maydropneighbor: test f%d for no ridges to a neighbor\n",
-	  facet->id));
+  trace4((qh ferr, 4029, "qh_maydropneighbor: test f%d for no ridges to a neighbor\n",
+          facet->id));
   FOREACHridge_(facet->ridges) {
     ridge->top->visitid= qh visit_id;
     ridge->bottom->visitid= qh visit_id;
   }
   FOREACHneighbor_(facet) {
     if (neighbor->visitid != qh visit_id) {
-      trace0((qh ferr, "qh_maydropneighbor: facets f%d and f%d are no longer neighbors during p%d\n",
-	    facet->id, neighbor->id, qh furthest_id));
+      trace0((qh ferr, 17, "qh_maydropneighbor: facets f%d and f%d are no longer neighbors during p%d\n",
+            facet->id, neighbor->id, qh furthest_id));
       zinc_(Zdropneighbor);
-      qh_setdel (facet->neighbors, neighbor);
+      qh_setdel(facet->neighbors, neighbor);
       neighborp--;  /* repeat, deleted a neighbor */
-      qh_setdel (neighbor->neighbors, facet);
-      if (qh_setsize (neighbor->neighbors) < qh hull_dim) {
+      qh_setdel(neighbor->neighbors, facet);
+      if (qh_setsize(neighbor->neighbors) < qh hull_dim) {
         zinc_(Zdropdegen);
-        qh_appendmergeset (neighbor, neighbor, MRGdegen, &angledegen);
-        trace2((qh ferr, "qh_maydropneighbors: f%d is degenerate.\n", neighbor->id));
+        qh_appendmergeset(neighbor, neighbor, MRGdegen, &angledegen);
+        trace2((qh ferr, 2023, "qh_maydropneighbors: f%d is degenerate.\n", neighbor->id));
       }
     }
   }
-  if (qh_setsize (facet->neighbors) < qh hull_dim) {
+  if (qh_setsize(facet->neighbors) < qh hull_dim) {
     zinc_(Zdropdegen);
-    qh_appendmergeset (facet, facet, MRGdegen, &angledegen);
-    trace2((qh ferr, "qh_maydropneighbors: f%d is degenerate.\n", facet->id));
+    qh_appendmergeset(facet, facet, MRGdegen, &angledegen);
+    trace2((qh ferr, 2024, "qh_maydropneighbors: f%d is degenerate.\n", facet->id));
   }
 } /* maydropneighbor */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="merge_degenredundant">-</a>
-  
+
   qh_merge_degenredundant()
     merge all degenerate and redundant facets
     qh.degen_mergeset contains merges from qh_degen_redundant_neighbors()
@@ -1572,7 +1576,7 @@
         else
           merge redundant facet into other facet
 */
-int qh_merge_degenredundant (void) {
+int qh_merge_degenredundant(void) {
   int size;
   mergeT *merge;
   facetT *bestneighbor, *facet1, *facet2;
@@ -1581,64 +1585,64 @@
   int nummerges= 0;
   mergeType mergetype;
 
-  while ((merge= (mergeT*)qh_setdellast (qh degen_mergeset))) {
+  while ((merge= (mergeT*)qh_setdellast(qh degen_mergeset))) {
     facet1= merge->facet1;
     facet2= merge->facet2;
     mergetype= merge->type;
-    qh_memfree (merge, sizeof(mergeT));
+    qh_memfree(merge, (int)sizeof(mergeT));
     if (facet1->visible)
       continue;
-    facet1->degenerate= False; 
-    facet1->redundant= False; 
+    facet1->degenerate= False;
+    facet1->redundant= False;
     if (qh TRACEmerge-1 == zzval_(Ztotmerge))
       qhmem.IStracing= qh IStracing= qh TRACElevel;
     if (mergetype == MRGredundant) {
       zinc_(Zneighbor);
       while (facet2->visible) {
         if (!facet2->f.replace) {
-          fprintf (qh ferr, "qhull internal error (qh_merge_degenredunant): f%d redundant but f%d has no replacement\n",
-	       facet1->id, facet2->id);
+          qh_fprintf(qh ferr, 6097, "qhull internal error (qh_merge_degenredunant): f%d redundant but f%d has no replacement\n",
+               facet1->id, facet2->id);
           qh_errexit2 (qh_ERRqhull, facet1, facet2);
         }
         facet2= facet2->f.replace;
       }
       if (facet1 == facet2) {
-	qh_degen_redundant_facet (facet1); /* in case of others */
-	continue;
+        qh_degen_redundant_facet(facet1); /* in case of others */
+        continue;
       }
-      trace2((qh ferr, "qh_merge_degenredundant: facet f%d is contained in f%d, will merge\n",
-	    facet1->id, facet2->id));
+      trace2((qh ferr, 2025, "qh_merge_degenredundant: facet f%d is contained in f%d, will merge\n",
+            facet1->id, facet2->id));
       qh_mergefacet(facet1, facet2, NULL, NULL, !qh_MERGEapex);
       /* merge distance is already accounted for */
       nummerges++;
     }else {  /* mergetype == MRGdegen, other merges may have fixed */
-      if (!(size= qh_setsize (facet1->neighbors))) {
+      if (!(size= qh_setsize(facet1->neighbors))) {
         zinc_(Zdelfacetdup);
-        trace2((qh ferr, "qh_merge_degenredundant: facet f%d has no neighbors.  Deleted\n", facet1->id));
-        qh_willdelete (facet1, NULL);
+        trace2((qh ferr, 2026, "qh_merge_degenredundant: facet f%d has no neighbors.  Deleted\n", facet1->id));
+        qh_willdelete(facet1, NULL);
         FOREACHvertex_(facet1->vertices) {
-  	  qh_setdel (vertex->neighbors, facet1);
-	  if (!SETfirst_(vertex->neighbors)) {
-	    zinc_(Zdegenvertex);
-	    trace2((qh ferr, "qh_merge_degenredundant: deleted v%d because f%d has no neighbors\n",
-         	 vertex->id, facet1->id));
-	    vertex->deleted= True;
-	    qh_setappend (&qh del_vertices, vertex);
-	  }
+          qh_setdel(vertex->neighbors, facet1);
+          if (!SETfirst_(vertex->neighbors)) {
+            zinc_(Zdegenvertex);
+            trace2((qh ferr, 2027, "qh_merge_degenredundant: deleted v%d because f%d has no neighbors\n",
+                 vertex->id, facet1->id));
+            vertex->deleted= True;
+            qh_setappend(&qh del_vertices, vertex);
+          }
         }
         nummerges++;
       }else if (size < qh hull_dim) {
         bestneighbor= qh_findbestneighbor(facet1, &dist, &mindist, &maxdist);
-        trace2((qh ferr, "qh_merge_degenredundant: facet f%d has %d neighbors, merge into f%d dist %2.2g\n",
-	      facet1->id, size, bestneighbor->id, dist));
+        trace2((qh ferr, 2028, "qh_merge_degenredundant: facet f%d has %d neighbors, merge into f%d dist %2.2g\n",
+              facet1->id, size, bestneighbor->id, dist));
         qh_mergefacet(facet1, bestneighbor, &mindist, &maxdist, !qh_MERGEapex);
         nummerges++;
         if (qh PRINTstatistics) {
-	  zinc_(Zdegen);
-	  wadd_(Wdegentot, dist);
-	  wmax_(Wdegenmax, dist);
+          zinc_(Zdegen);
+          wadd_(Wdegentot, dist);
+          wmax_(Wdegenmax, dist);
         }
-      }	/* else, another merge fixed the degeneracy and redundancy tested */
+      } /* else, another merge fixed the degeneracy and redundancy tested */
     }
   }
   return nummerges;
@@ -1646,14 +1650,14 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="merge_nonconvex">-</a>
-  
+
   qh_merge_nonconvex( facet1, facet2, mergetype )
-    remove non-convex ridge between facet1 into facet2 
+    remove non-convex ridge between facet1 into facet2
     mergetype gives why the facet's are non-convex
 
   returns:
     merges one of the facets into the best neighbor
-    
+
   design:
     if one of the facets is a new facet
       prefer merging new facet into old facet
@@ -1661,13 +1665,13 @@
     merge the nearest facet into its best neighbor
     update the statistics
 */
-void qh_merge_nonconvex (facetT *facet1, facetT *facet2, mergeType mergetype) {
+void qh_merge_nonconvex(facetT *facet1, facetT *facet2, mergeType mergetype) {
   facetT *bestfacet, *bestneighbor, *neighbor;
   realT dist, dist2, mindist, mindist2, maxdist, maxdist2;
 
   if (qh TRACEmerge-1 == zzval_(Ztotmerge))
     qhmem.IStracing= qh IStracing= qh TRACElevel;
-  trace3((qh ferr, "qh_merge_nonconvex: merge #%d for f%d and f%d type %d\n",
+  trace3((qh ferr, 3003, "qh_merge_nonconvex: merge #%d for f%d and f%d type %d\n",
       zzval_(Ztotmerge) + 1, facet1->id, facet2->id, mergetype));
   /* concave or coplanar */
   if (!facet1->newfacet) {
@@ -1686,7 +1690,7 @@
     zinc_(Zavoidold);
     wadd_(Wavoidoldtot, dist);
     wmax_(Wavoidoldmax, dist);
-    trace2((qh ferr, "qh_merge_nonconvex: avoid merging old facet f%d dist %2.2g.  Use f%d dist %2.2g instead\n",
+    trace2((qh ferr, 2029, "qh_merge_nonconvex: avoid merging old facet f%d dist %2.2g.  Use f%d dist %2.2g instead\n",
            facet2->id, dist2, facet1->id, dist2));
     qh_mergefacet(bestfacet, bestneighbor, &mindist, &maxdist, !qh_MERGEapex);
   }else {
@@ -1712,9 +1716,9 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergecycle">-</a>
-  
+
   qh_mergecycle( samecycle, newfacet )
-    merge a cycle of facets starting at samecycle into a newfacet 
+    merge a cycle of facets starting at samecycle into a newfacet
     newfacet is a horizon facet with ->normal
     samecycle facets are simplicial from an apex
 
@@ -1739,7 +1743,7 @@
       add its vertices to qh.newvertex_list
     delete samecycle facets a make newfacet a newfacet
 */
-void qh_mergecycle (facetT *samecycle, facetT *newfacet) {
+void qh_mergecycle(facetT *samecycle, facetT *newfacet) {
   int traceonce= False, tracerestore= 0;
   vertexT *apex;
 #ifndef qh_NOtrace
@@ -1748,8 +1752,8 @@
 
   if (newfacet->tricoplanar) {
     if (!qh TRInormals) {
-      fprintf (qh ferr, "qh_mergecycle: does not work for tricoplanar facets.  Use option 'Q11'\n");
-      qh_errexit (qh_ERRqhull, newfacet, NULL);
+      qh_fprintf(qh ferr, 6224, "Qhull internal error (qh_mergecycle): does not work for tricoplanar facets.  Use option 'Q11'\n");
+      qh_errexit(qh_ERRqhull, newfacet, NULL);
     }
     newfacet->tricoplanar= False;
     newfacet->keepcentrum= False;
@@ -1764,45 +1768,45 @@
 #ifndef qh_NOtrace
   if (qh TRACEmerge == zzval_(Ztotmerge))
     qhmem.IStracing= qh IStracing= qh TRACElevel;
-  trace2((qh ferr, "qh_mergecycle: merge #%d for facets from cycle f%d into coplanar horizon f%d\n", 
+  trace2((qh ferr, 2030, "qh_mergecycle: merge #%d for facets from cycle f%d into coplanar horizon f%d\n",
         zzval_(Ztotmerge), samecycle->id, newfacet->id));
   if (newfacet == qh tracefacet) {
     tracerestore= qh IStracing;
     qh IStracing= 4;
-    fprintf (qh ferr, "qh_mergecycle: ========= trace merge %d of samecycle %d into trace f%d, furthest is p%d\n",
-	       zzval_(Ztotmerge), samecycle->id, newfacet->id,  qh furthest_id);
+    qh_fprintf(qh ferr, 8068, "qh_mergecycle: ========= trace merge %d of samecycle %d into trace f%d, furthest is p%d\n",
+               zzval_(Ztotmerge), samecycle->id, newfacet->id,  qh furthest_id);
     traceonce= True;
   }
   if (qh IStracing >=4) {
-    fprintf (qh ferr, "  same cycle:");
+    qh_fprintf(qh ferr, 8069, "  same cycle:");
     FORALLsame_cycle_(samecycle)
-      fprintf(qh ferr, " f%d", same->id);
-    fprintf (qh ferr, "\n");
+      qh_fprintf(qh ferr, 8070, " f%d", same->id);
+    qh_fprintf(qh ferr, 8071, "\n");
   }
   if (qh IStracing >=4)
-    qh_errprint ("MERGING CYCLE", samecycle, newfacet, NULL, NULL);
+    qh_errprint("MERGING CYCLE", samecycle, newfacet, NULL, NULL);
 #endif /* !qh_NOtrace */
   apex= SETfirstt_(samecycle->vertices, vertexT);
-  qh_makeridges (newfacet);
-  qh_mergecycle_neighbors (samecycle, newfacet);
-  qh_mergecycle_ridges (samecycle, newfacet);
-  qh_mergecycle_vneighbors (samecycle, newfacet);
-  if (SETfirstt_(newfacet->vertices, vertexT) != apex) 
-    qh_setaddnth (&newfacet->vertices, 0, apex);  /* apex has last id */
+  qh_makeridges(newfacet);
+  qh_mergecycle_neighbors(samecycle, newfacet);
+  qh_mergecycle_ridges(samecycle, newfacet);
+  qh_mergecycle_vneighbors(samecycle, newfacet);
+  if (SETfirstt_(newfacet->vertices, vertexT) != apex)
+    qh_setaddnth(&newfacet->vertices, 0, apex);  /* apex has last id */
   if (!newfacet->newfacet)
-    qh_newvertices (newfacet->vertices);
-  qh_mergecycle_facets (samecycle, newfacet);
-  qh_tracemerge (samecycle, newfacet);
+    qh_newvertices(newfacet->vertices);
+  qh_mergecycle_facets(samecycle, newfacet);
+  qh_tracemerge(samecycle, newfacet);
   /* check for degen_redundant_neighbors after qh_forcedmerges() */
   if (traceonce) {
-    fprintf (qh ferr, "qh_mergecycle: end of trace facet\n");
+    qh_fprintf(qh ferr, 8072, "qh_mergecycle: end of trace facet\n");
     qh IStracing= tracerestore;
   }
 } /* mergecycle */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergecycle_all">-</a>
-  
+
   qh_mergecycle_all( facetlist, wasmerge )
     merge all samecycles of coplanar facets into horizon
     don't merge facets with ->mergeridge (these already have ->normal)
@@ -1822,65 +1826,65 @@
       skip facets with duplicate ridges and normals
       check that facet is in a samecycle (->mergehorizon)
       if facet only member of samecycle
-	sets vertex->delridge for all vertices except apex
+        sets vertex->delridge for all vertices except apex
         merge facet into horizon
       else
         mark all facets in samecycle
         remove facets with duplicate ridges from samecycle
         merge samecycle into horizon (deletes facets from facetlist)
 */
-void qh_mergecycle_all (facetT *facetlist, boolT *wasmerge) {
+void qh_mergecycle_all(facetT *facetlist, boolT *wasmerge) {
   facetT *facet, *same, *prev, *horizon;
   facetT *samecycle= NULL, *nextfacet, *nextsame;
   vertexT *apex, *vertex, **vertexp;
   int cycles=0, total=0, facets, nummerge;
 
-  trace2((qh ferr, "qh_mergecycle_all: begin\n"));
+  trace2((qh ferr, 2031, "qh_mergecycle_all: begin\n"));
   for (facet= facetlist; facet && (nextfacet= facet->next); facet= nextfacet) {
     if (facet->normal)
       continue;
     if (!facet->mergehorizon) {
-      fprintf (qh ferr, "qh_mergecycle_all: f%d without normal\n", facet->id);
-      qh_errexit (qh_ERRqhull, facet, NULL);
+      qh_fprintf(qh ferr, 6225, "Qhull internal error (qh_mergecycle_all): f%d without normal\n", facet->id);
+      qh_errexit(qh_ERRqhull, facet, NULL);
     }
     horizon= SETfirstt_(facet->neighbors, facetT);
     if (facet->f.samecycle == facet) {
-      zinc_(Zonehorizon);  
+      zinc_(Zonehorizon);
       /* merge distance done in qh_findhorizon */
       apex= SETfirstt_(facet->vertices, vertexT);
       FOREACHvertex_(facet->vertices) {
-	if (vertex != apex)
+        if (vertex != apex)
           vertex->delridge= True;
       }
       horizon->f.newcycle= NULL;
-      qh_mergefacet (facet, horizon, NULL, NULL, qh_MERGEapex);
+      qh_mergefacet(facet, horizon, NULL, NULL, qh_MERGEapex);
     }else {
       samecycle= facet;
       facets= 0;
       prev= facet;
       for (same= facet->f.samecycle; same;  /* FORALLsame_cycle_(facet) */
-	   same= (same == facet ? NULL :nextsame)) { /* ends at facet */
-	nextsame= same->f.samecycle;
+           same= (same == facet ? NULL :nextsame)) { /* ends at facet */
+        nextsame= same->f.samecycle;
         if (same->cycledone || same->visible)
-          qh_infiniteloop (same);
+          qh_infiniteloop(same);
         same->cycledone= True;
-        if (same->normal) { 
+        if (same->normal) {
           prev->f.samecycle= same->f.samecycle; /* unlink ->mergeridge */
-	  same->f.samecycle= NULL;
+          same->f.samecycle= NULL;
         }else {
           prev= same;
-	  facets++;
-	}
+          facets++;
+        }
       }
       while (nextfacet && nextfacet->cycledone)  /* will delete samecycle */
-	nextfacet= nextfacet->next;
+        nextfacet= nextfacet->next;
       horizon->f.newcycle= NULL;
-      qh_mergecycle (samecycle, horizon);
+      qh_mergecycle(samecycle, horizon);
       nummerge= horizon->nummerge + facets;
-      if (nummerge > qh_MAXnummerge) 
-      	horizon->nummerge= qh_MAXnummerge;
+      if (nummerge > qh_MAXnummerge)
+        horizon->nummerge= qh_MAXnummerge;
       else
-        horizon->nummerge= nummerge;
+        horizon->nummerge= (short unsigned int)nummerge;
       zzinc_(Zcyclehorizon);
       total += facets;
       zzadd_(Zcyclefacettot, facets);
@@ -1890,25 +1894,25 @@
   }
   if (cycles)
     *wasmerge= True;
-  trace1((qh ferr, "qh_mergecycle_all: merged %d same cycles or facets into coplanar horizons\n", cycles));
+  trace1((qh ferr, 1013, "qh_mergecycle_all: merged %d same cycles or facets into coplanar horizons\n", cycles));
 } /* mergecycle_all */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergecycle_facets">-</a>
-  
+
   qh_mergecycle_facets( samecycle, newfacet )
     finish merge of samecycle into newfacet
 
   returns:
     samecycle prepended to visible_list for later deletion and partitioning
       each facet->f.replace == newfacet
-      
+
     newfacet moved to end of qh.facet_list
       makes newfacet a newfacet (get's facet1->id if it was old)
       sets newfacet->newmerge
       clears newfacet->center (unless merging into a large facet)
       clears newfacet->tested and ridge->tested for facet1
-      
+
     adds neighboring facets to facet_mergeset if redundant or degenerate
 
   design:
@@ -1917,32 +1921,32 @@
     unless newfacet is large
       remove its centrum
 */
-void qh_mergecycle_facets (facetT *samecycle, facetT *newfacet) {
+void qh_mergecycle_facets(facetT *samecycle, facetT *newfacet) {
   facetT *same, *next;
-  
-  trace4((qh ferr, "qh_mergecycle_facets: make newfacet new and samecycle deleted\n"));  
+
+  trace4((qh ferr, 4030, "qh_mergecycle_facets: make newfacet new and samecycle deleted\n"));
   qh_removefacet(newfacet);  /* append as a newfacet to end of qh facet_list */
   qh_appendfacet(newfacet);
   newfacet->newfacet= True;
   newfacet->simplicial= False;
   newfacet->newmerge= True;
-  
+
   for (same= samecycle->f.samecycle; same; same= (same == samecycle ?  NULL : next)) {
     next= same->f.samecycle;  /* reused by willdelete */
-    qh_willdelete (same, newfacet);
+    qh_willdelete(same, newfacet);
   }
-  if (newfacet->center 
-      && qh_setsize (newfacet->vertices) <= qh hull_dim + qh_MAXnewcentrum) {
-    qh_memfree (newfacet->center, qh normal_size);
+  if (newfacet->center
+      && qh_setsize(newfacet->vertices) <= qh hull_dim + qh_MAXnewcentrum) {
+    qh_memfree(newfacet->center, qh normal_size);
     newfacet->center= NULL;
   }
-  trace3((qh ferr, "qh_mergecycle_facets: merged facets from cycle f%d into f%d\n", 
+  trace3((qh ferr, 3004, "qh_mergecycle_facets: merged facets from cycle f%d into f%d\n",
              samecycle->id, newfacet->id));
 } /* mergecycle_facets */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergecycle_neighbors">-</a>
-  
+
   qh_mergecycle_neighbors( samecycle, newfacet )
     add neighbors for samecycle facets to newfacet
 
@@ -1955,9 +1959,9 @@
 
   notes:
     assumes newfacet not in samecycle
-    usually, samecycle facets are new, simplicial facets without internal ridges 
+    usually, samecycle facets are new, simplicial facets without internal ridges
       not so if horizon facet is coplanar to two different samecycles
-  
+
   see:
     qh_mergeneighbors()
 
@@ -1984,11 +1988,11 @@
   samevisitid= ++qh visit_id;
   FORALLsame_cycle_(samecycle) {
     if (same->visitid == samevisitid || same->visible)
-      qh_infiniteloop (samecycle);
+      qh_infiniteloop(samecycle);
     same->visitid= samevisitid;
   }
   newfacet->visitid= ++qh visit_id;
-  trace4((qh ferr, "qh_mergecycle_neighbors: delete shared neighbors from newfacet\n"));  
+  trace4((qh ferr, 4031, "qh_mergecycle_neighbors: delete shared neighbors from newfacet\n"));
   FOREACHneighbor_(newfacet) {
     if (neighbor->visitid == samevisitid) {
       SETref_(neighbor)= NULL;  /* samecycle neighbors deleted */
@@ -1996,51 +2000,51 @@
     }else
       neighbor->visitid= qh visit_id;
   }
-  qh_setcompact (newfacet->neighbors);
+  qh_setcompact(newfacet->neighbors);
 
-  trace4((qh ferr, "qh_mergecycle_neighbors: update neighbors\n"));  
+  trace4((qh ferr, 4032, "qh_mergecycle_neighbors: update neighbors\n"));
   FORALLsame_cycle_(samecycle) {
     FOREACHneighbor_(same) {
       if (neighbor->visitid == samevisitid)
-	continue;
+        continue;
       if (neighbor->simplicial) {
-	if (neighbor->visitid != qh visit_id) {
-	  qh_setappend (&newfacet->neighbors, neighbor);
-	  qh_setreplace (neighbor->neighbors, same, newfacet);
-	  newneighbors++;
-	  neighbor->visitid= qh visit_id;
-	  FOREACHridge_(neighbor->ridges) { /* update ridge in case of qh_makeridges */
-	    if (ridge->top == same) {
-	      ridge->top= newfacet;
-	      break;
-	    }else if (ridge->bottom == same) {
-	      ridge->bottom= newfacet;
-	      break;
-	    }
-	  }
-	}else {
-	  qh_makeridges (neighbor);
-	  qh_setdel (neighbor->neighbors, same);
-	  /* same can't be horizon facet for neighbor */
-	}
+        if (neighbor->visitid != qh visit_id) {
+          qh_setappend(&newfacet->neighbors, neighbor);
+          qh_setreplace(neighbor->neighbors, same, newfacet);
+          newneighbors++;
+          neighbor->visitid= qh visit_id;
+          FOREACHridge_(neighbor->ridges) { /* update ridge in case of qh_makeridges */
+            if (ridge->top == same) {
+              ridge->top= newfacet;
+              break;
+            }else if (ridge->bottom == same) {
+              ridge->bottom= newfacet;
+              break;
+            }
+          }
+        }else {
+          qh_makeridges(neighbor);
+          qh_setdel(neighbor->neighbors, same);
+          /* same can't be horizon facet for neighbor */
+        }
       }else { /* non-simplicial neighbor */
-        qh_setdel (neighbor->neighbors, same);
+        qh_setdel(neighbor->neighbors, same);
         if (neighbor->visitid != qh visit_id) {
-          qh_setappend (&neighbor->neighbors, newfacet);
-          qh_setappend (&newfacet->neighbors, neighbor);
+          qh_setappend(&neighbor->neighbors, newfacet);
+          qh_setappend(&newfacet->neighbors, neighbor);
           neighbor->visitid= qh visit_id;
           newneighbors++;
-        } 
+        }
       }
     }
   }
-  trace2((qh ferr, "qh_mergecycle_neighbors: deleted %d neighbors and added %d\n", 
+  trace2((qh ferr, 2032, "qh_mergecycle_neighbors: deleted %d neighbors and added %d\n",
              delneighbors, newneighbors));
 } /* mergecycle_neighbors */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergecycle_ridges">-</a>
-  
+
   qh_mergecycle_ridges( samecycle, newfacet )
     add ridges/neighbors for facets in samecycle to newfacet
     all new/old neighbors of newfacet marked with qh.visit_id
@@ -2049,7 +2053,7 @@
 
   returns:
     newfacet has merged ridges
-  
+
   notes:
     ridge already updated for simplicial neighbors of samecycle with a ridge
 
@@ -2081,55 +2085,55 @@
   boolT toporient;
   void **freelistp; /* used !qh_NOmem */
 
-  trace4((qh ferr, "qh_mergecycle_ridges: delete shared ridges from newfacet\n"));  
+  trace4((qh ferr, 4033, "qh_mergecycle_ridges: delete shared ridges from newfacet\n"));
   samevisitid= qh visit_id -1;
   FOREACHridge_(newfacet->ridges) {
     neighbor= otherfacet_(ridge, newfacet);
     if (neighbor->visitid == samevisitid)
-      SETref_(ridge)= NULL; /* ridge free'd below */  
+      SETref_(ridge)= NULL; /* ridge free'd below */
   }
-  qh_setcompact (newfacet->ridges);
-  
-  trace4((qh ferr, "qh_mergecycle_ridges: add ridges to newfacet\n"));  
+  qh_setcompact(newfacet->ridges);
+
+  trace4((qh ferr, 4034, "qh_mergecycle_ridges: add ridges to newfacet\n"));
   FORALLsame_cycle_(samecycle) {
     FOREACHridge_(same->ridges) {
       if (ridge->top == same) {
         ridge->top= newfacet;
-	neighbor= ridge->bottom;
+        neighbor= ridge->bottom;
       }else if (ridge->bottom == same) {
-	ridge->bottom= newfacet;
-	neighbor= ridge->top;
+        ridge->bottom= newfacet;
+        neighbor= ridge->top;
       }else if (ridge->top == newfacet || ridge->bottom == newfacet) {
-        qh_setappend (&newfacet->ridges, ridge);
+        qh_setappend(&newfacet->ridges, ridge);
         numold++;  /* already set by qh_mergecycle_neighbors */
-	continue;  
+        continue;
       }else {
-	fprintf (qh ferr, "qhull internal error (qh_mergecycle_ridges): bad ridge r%d\n", ridge->id);
-	qh_errexit (qh_ERRqhull, NULL, ridge);
+        qh_fprintf(qh ferr, 6098, "qhull internal error (qh_mergecycle_ridges): bad ridge r%d\n", ridge->id);
+        qh_errexit(qh_ERRqhull, NULL, ridge);
       }
       if (neighbor == newfacet) {
-        qh_setfree(&(ridge->vertices)); 
-        qh_memfree_(ridge, sizeof(ridgeT), freelistp);
+        qh_setfree(&(ridge->vertices));
+        qh_memfree_(ridge, (int)sizeof(ridgeT), freelistp);
         numold++;
       }else if (neighbor->visitid == samevisitid) {
-	qh_setdel (neighbor->ridges, ridge);
-	qh_setfree(&(ridge->vertices)); 
-	qh_memfree_(ridge, sizeof(ridgeT), freelistp);
-	numold++;
+        qh_setdel(neighbor->ridges, ridge);
+        qh_setfree(&(ridge->vertices));
+        qh_memfree_(ridge, (int)sizeof(ridgeT), freelistp);
+        numold++;
       }else {
-        qh_setappend (&newfacet->ridges, ridge);
+        qh_setappend(&newfacet->ridges, ridge);
         numold++;
       }
     }
     if (same->ridges)
-      qh_settruncate (same->ridges, 0);
+      qh_settruncate(same->ridges, 0);
     if (!same->simplicial)
       continue;
     FOREACHneighbor_i_(same) {       /* note: !newfact->simplicial */
       if (neighbor->visitid != samevisitid && neighbor->simplicial) {
         ridge= qh_newridge();
-        ridge->vertices= qh_setnew_delnthsorted (same->vertices, qh hull_dim,
-  					                  neighbor_i, 0);
+        ridge->vertices= qh_setnew_delnthsorted(same->vertices, qh hull_dim,
+                                                          neighbor_i, 0);
         toporient= same->toporient ^ (neighbor_i & 0x1);
         if (toporient) {
           ridge->top= newfacet;
@@ -2145,13 +2149,13 @@
     }
   }
 
-  trace2((qh ferr, "qh_mergecycle_ridges: found %d old ridges and %d new ones\n", 
+  trace2((qh ferr, 2033, "qh_mergecycle_ridges: found %d old ridges and %d new ones\n",
              numold, numnew));
 } /* mergecycle_ridges */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergecycle_vneighbors">-</a>
-  
+
   qh_mergecycle_vneighbors( samecycle, newfacet )
     create vertex neighbors for newfacet from vertices of facets in samecycle
     samecycle marked with visitid == qh.visit_id - 1
@@ -2174,47 +2178,47 @@
         delete it from newfacet
         add it to qh.del_vertices for later deletion
 */
-void qh_mergecycle_vneighbors (facetT *samecycle, facetT *newfacet) {
+void qh_mergecycle_vneighbors(facetT *samecycle, facetT *newfacet) {
   facetT *neighbor, **neighborp;
   unsigned int mergeid;
   vertexT *vertex, **vertexp, *apex;
   setT *vertices;
-  
-  trace4((qh ferr, "qh_mergecycle_vneighbors: update vertex neighbors for newfacet\n"));  
+
+  trace4((qh ferr, 4035, "qh_mergecycle_vneighbors: update vertex neighbors for newfacet\n"));
   mergeid= qh visit_id - 1;
   newfacet->visitid= mergeid;
-  vertices= qh_basevertices (samecycle); /* temp */
+  vertices= qh_basevertices(samecycle); /* temp */
   apex= SETfirstt_(samecycle->vertices, vertexT);
-  qh_setappend (&vertices, apex);
+  qh_setappend(&vertices, apex);
   FOREACHvertex_(vertices) {
     vertex->delridge= True;
     FOREACHneighbor_(vertex) {
       if (neighbor->visitid == mergeid)
         SETref_(neighbor)= NULL;
     }
-    qh_setcompact (vertex->neighbors);
-    qh_setappend (&vertex->neighbors, newfacet);
+    qh_setcompact(vertex->neighbors);
+    qh_setappend(&vertex->neighbors, newfacet);
     if (!SETsecond_(vertex->neighbors)) {
       zinc_(Zcyclevertex);
-      trace2((qh ferr, "qh_mergecycle_vneighbors: deleted v%d when merging cycle f%d into f%d\n",
+      trace2((qh ferr, 2034, "qh_mergecycle_vneighbors: deleted v%d when merging cycle f%d into f%d\n",
         vertex->id, samecycle->id, newfacet->id));
-      qh_setdelsorted (newfacet->vertices, vertex);
+      qh_setdelsorted(newfacet->vertices, vertex);
       vertex->deleted= True;
-      qh_setappend (&qh del_vertices, vertex);
+      qh_setappend(&qh del_vertices, vertex);
     }
   }
-  qh_settempfree (&vertices);
-  trace3((qh ferr, "qh_mergecycle_vneighbors: merged vertices from cycle f%d into f%d\n", 
+  qh_settempfree(&vertices);
+  trace3((qh ferr, 3005, "qh_mergecycle_vneighbors: merged vertices from cycle f%d into f%d\n",
              samecycle->id, newfacet->id));
 } /* mergecycle_vneighbors */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergefacet">-</a>
-  
+
   qh_mergefacet( facet1, facet2, mindist, maxdist, mergeapex )
     merges facet1 into facet2
     mergeapex==qh_MERGEapex if merging new facet into coplanar horizon
-    
+
   returns:
     qh.max_outside and qh.min_vertex updated
     initializes vertex neighbors on first merge
@@ -2232,11 +2236,11 @@
 
     adds neighboring facets to facet_mergeset if redundant or degenerate
 
-  notes: 
-    mindist/maxdist may be NULL
+  notes:
+    mindist/maxdist may be NULL (only if both NULL)
     traces merge if fmax_(maxdist,-mindist) > TRACEdist
 
-  see: 
+  see:
     qh_mergecycle()
 
   design:
@@ -2266,7 +2270,7 @@
 
   if (facet1->tricoplanar || facet2->tricoplanar) {
     if (!qh TRInormals) {
-      fprintf (qh ferr, "qh_mergefacet: does not work for tricoplanar facets.  Use option 'Q11'\n");
+      qh_fprintf(qh ferr, 6226, "Qhull internal error (qh_mergefacet): does not work for tricoplanar facets.  Use option 'Q11'\n");
       qh_errexit2 (qh_ERRqhull, facet1, facet2);
     }
     if (facet2->tricoplanar) {
@@ -2285,40 +2289,40 @@
       tracerestore= 0;
       qh IStracing= qh TRACElevel;
       traceonce= True;
-      fprintf (qh ferr, "qh_mergefacet: ========= trace wide merge #%d (%2.2g) for f%d into f%d, last point was p%d\n", zzval_(Ztotmerge),
-	     fmax_(-*mindist, *maxdist), facet1->id, facet2->id, qh furthest_id);
+      qh_fprintf(qh ferr, 8075, "qh_mergefacet: ========= trace wide merge #%d(%2.2g) for f%d into f%d, last point was p%d\n", zzval_(Ztotmerge),
+             fmax_(-*mindist, *maxdist), facet1->id, facet2->id, qh furthest_id);
     }else if (facet1 == qh tracefacet || facet2 == qh tracefacet) {
       tracerestore= qh IStracing;
       qh IStracing= 4;
       traceonce= True;
-      fprintf (qh ferr, "qh_mergefacet: ========= trace merge #%d involving f%d, furthest is p%d\n",
-		 zzval_(Ztotmerge), qh tracefacet_id,  qh furthest_id);
+      qh_fprintf(qh ferr, 8076, "qh_mergefacet: ========= trace merge #%d involving f%d, furthest is p%d\n",
+                 zzval_(Ztotmerge), qh tracefacet_id,  qh furthest_id);
     }
   }
   if (qh IStracing >= 2) {
     realT mergemin= -2;
     realT mergemax= -2;
-    
+
     if (mindist) {
       mergemin= *mindist;
       mergemax= *maxdist;
     }
-    fprintf (qh ferr, "qh_mergefacet: #%d merge f%d into f%d, mindist= %2.2g, maxdist= %2.2g\n", 
+    qh_fprintf(qh ferr, 8077, "qh_mergefacet: #%d merge f%d into f%d, mindist= %2.2g, maxdist= %2.2g\n",
     zzval_(Ztotmerge), facet1->id, facet2->id, mergemin, mergemax);
   }
 #endif /* !qh_NOtrace */
   if (facet1 == facet2 || facet1->visible || facet2->visible) {
-    fprintf (qh ferr, "qhull internal error (qh_mergefacet): either f%d and f%d are the same or one is a visible facet\n",
-	     facet1->id, facet2->id);
+    qh_fprintf(qh ferr, 6099, "qhull internal error (qh_mergefacet): either f%d and f%d are the same or one is a visible facet\n",
+             facet1->id, facet2->id);
     qh_errexit2 (qh_ERRqhull, facet1, facet2);
   }
   if (qh num_facets - qh num_visible <= qh hull_dim + 1) {
-    fprintf(qh ferr, "\n\
+    qh_fprintf(qh ferr, 6227, "\n\
 qhull precision error: Only %d facets remain.  Can not merge another\n\
 pair.  The input is too degenerate or the convexity constraints are\n\
 too strong.\n", qh hull_dim+1);
     if (qh hull_dim >= 5 && !qh MERGEexact)
-      fprintf(qh ferr, "Option 'Qx' may avoid this problem.\n");
+      qh_fprintf(qh ferr, 8079, "Option 'Qx' may avoid this problem.\n");
     qh_errexit(qh_ERRinput, NULL, NULL);
   }
   if (!qh VERTEXneighbors)
@@ -2326,7 +2330,7 @@
   qh_makeridges(facet1);
   qh_makeridges(facet2);
   if (qh IStracing >=4)
-    qh_errprint ("MERGING", facet1, facet2, NULL, NULL);
+    qh_errprint("MERGING", facet1, facet2, NULL, NULL);
   if (mindist) {
     maximize_(qh max_outside, *maxdist);
     maximize_(qh max_vertex, *maxdist);
@@ -2334,27 +2338,27 @@
     maximize_(facet2->maxoutside, *maxdist);
 #endif
     minimize_(qh min_vertex, *mindist);
-    if (!facet2->keepcentrum 
+    if (!facet2->keepcentrum
     && (*maxdist > qh WIDEfacet || *mindist < -qh WIDEfacet)) {
       facet2->keepcentrum= True;
       zinc_(Zwidefacet);
     }
   }
   nummerge= facet1->nummerge + facet2->nummerge + 1;
-  if (nummerge >= qh_MAXnummerge) 
+  if (nummerge >= qh_MAXnummerge)
     facet2->nummerge= qh_MAXnummerge;
   else
-    facet2->nummerge= nummerge;
+    facet2->nummerge= (short unsigned int)nummerge;
   facet2->newmerge= True;
   facet2->dupridge= False;
   qh_updatetested  (facet1, facet2);
-  if (qh hull_dim > 2 && qh_setsize (facet1->vertices) == qh hull_dim)
-    qh_mergesimplex (facet1, facet2, mergeapex);
+  if (qh hull_dim > 2 && qh_setsize(facet1->vertices) == qh hull_dim)
+    qh_mergesimplex(facet1, facet2, mergeapex);
   else {
     qh vertex_visit++;
     FOREACHvertex_(facet2->vertices)
       vertex->visitid= qh vertex_visit;
-    if (qh hull_dim == 2) 
+    if (qh hull_dim == 2)
       qh_mergefacet2d(facet1, facet2);
     else {
       qh_mergeneighbors(facet1, facet2);
@@ -2363,10 +2367,10 @@
     qh_mergeridges(facet1, facet2);
     qh_mergevertex_neighbors(facet1, facet2);
     if (!facet2->newfacet)
-      qh_newvertices (facet2->vertices);
+      qh_newvertices(facet2->vertices);
   }
   if (!mergeapex)
-    qh_degen_redundant_neighbors (facet2, facet1);
+    qh_degen_redundant_neighbors(facet2, facet1);
   if (facet2->coplanar || !facet2->newfacet) {
     zinc_(Zmergeintohorizon);
   }else if (!facet1->newfacet && facet2->newfacet) {
@@ -2374,14 +2378,14 @@
   }else {
     zinc_(Zmergenew);
   }
-  qh_willdelete (facet1, facet2);
+  qh_willdelete(facet1, facet2);
   qh_removefacet(facet2);  /* append as a newfacet to end of qh facet_list */
   qh_appendfacet(facet2);
   facet2->newfacet= True;
   facet2->tested= False;
-  qh_tracemerge (facet1, facet2);
+  qh_tracemerge(facet1, facet2);
   if (traceonce) {
-    fprintf (qh ferr, "qh_mergefacet: end of wide tracing\n");
+    qh_fprintf(qh ferr, 8080, "qh_mergefacet: end of wide tracing\n");
     qh IStracing= tracerestore;
   }
 } /* mergefacet */
@@ -2389,10 +2393,10 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergefacet2d">-</a>
-  
+
   qh_mergefacet2d( facet1, facet2 )
     in 2d, merges neighbors and vertices of facet1 into facet2
-    
+
   returns:
     build ridges for neighbors if necessary
     facet2 looks like a simplicial facet except for centrum, ridges
@@ -2403,14 +2407,14 @@
     qh_mergefacet() retains non-simplicial structures
       they are not needed in 2d, but later routines may use them
     preserves qh.vertex_visit for qh_mergevertex_neighbors()
-  
+
   design:
     get vertices and neighbors
     determine new vertices and neighbors
     set new vertices and neighbors and adjust orientation
     make ridges for new neighbor if needed
 */
-void qh_mergefacet2d (facetT *facet1, facetT *facet2) {
+void qh_mergefacet2d(facetT *facet1, facetT *facet2) {
   vertexT *vertex1A, *vertex1B, *vertex2A, *vertex2B, *vertexA, *vertexB;
   facetT *neighbor1A, *neighbor1B, *neighbor2A, *neighbor2B, *neighborA, *neighborB;
 
@@ -2459,20 +2463,20 @@
     SETfirst_(facet2->neighbors)= neighborB;
     SETsecond_(facet2->neighbors)= neighborA;
   }
-  qh_makeridges (neighborB);
+  qh_makeridges(neighborB);
   qh_setreplace(neighborB->neighbors, facet1, facet2);
-  trace4((qh ferr, "qh_mergefacet2d: merged v%d and neighbor f%d of f%d into f%d\n",
+  trace4((qh ferr, 4036, "qh_mergefacet2d: merged v%d and neighbor f%d of f%d into f%d\n",
        vertexA->id, neighborB->id, facet1->id, facet2->id));
 } /* mergefacet2d */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergeneighbors">-</a>
-  
+
   qh_mergeneighbors( facet1, facet2 )
     merges the neighbors of facet1 into facet2
 
-  see: 
+  see:
     qh_mergecycle_neighbors()
 
   design:
@@ -2488,8 +2492,8 @@
 void qh_mergeneighbors(facetT *facet1, facetT *facet2) {
   facetT *neighbor, **neighborp;
 
-  trace4((qh ferr, "qh_mergeneighbors: merge neighbors of f%d and f%d\n",
-	  facet1->id, facet2->id));
+  trace4((qh ferr, 4037, "qh_mergeneighbors: merge neighbors of f%d and f%d\n",
+          facet1->id, facet2->id));
   qh visit_id++;
   FOREACHneighbor_(facet2) {
     neighbor->visitid= qh visit_id;
@@ -2497,9 +2501,9 @@
   FOREACHneighbor_(facet1) {
     if (neighbor->visitid == qh visit_id) {
       if (neighbor->simplicial)    /* is degen, needs ridges */
-	qh_makeridges (neighbor);
+        qh_makeridges(neighbor);
       if (SETfirstt_(neighbor->neighbors, facetT) != facet1) /*keep newfacet->horizon*/
-	qh_setdel (neighbor->neighbors, facet1);
+        qh_setdel(neighbor->neighbors, facet1);
       else {
         qh_setdel(neighbor->neighbors, facet2);
         qh_setreplace(neighbor->neighbors, facet1, facet2);
@@ -2516,7 +2520,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergeridges">-</a>
-  
+
   qh_mergeridges( facet1, facet2 )
     merges the ridge set of facet1 into facet2
 
@@ -2529,16 +2533,16 @@
 
   design:
     delete ridges between facet1 and facet2
-      mark (delridge) vertices on these ridges for later testing   
+      mark (delridge) vertices on these ridges for later testing
     for each remaining ridge
-      rename facet1 to facet2  
+      rename facet1 to facet2
 */
 void qh_mergeridges(facetT *facet1, facetT *facet2) {
   ridgeT *ridge, **ridgep;
   vertexT *vertex, **vertexp;
 
-  trace4((qh ferr, "qh_mergeridges: merge ridges of f%d and f%d\n",
-	  facet1->id, facet2->id));
+  trace4((qh ferr, 4038, "qh_mergeridges: merge ridges of f%d and f%d\n",
+          facet1->id, facet2->id));
   FOREACHridge_(facet2->ridges) {
     if ((ridge->top == facet1) || (ridge->bottom == facet1)) {
       FOREACHvertex_(ridge->vertices)
@@ -2559,7 +2563,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergesimplex">-</a>
-  
+
   qh_mergesimplex( facet1, facet2, mergeapex )
     merge simplicial facet1 into facet2
     mergeapex==qh_MERGEapex if merging samecycle into horizon facet
@@ -2572,7 +2576,7 @@
     updated neighbors for facet1's vertices
     facet1 not deleted
     sets vertex->delridge on deleted ridges
-  
+
   notes:
     special case code since this is the most common merge
     called from qh_mergefacet()
@@ -2609,10 +2613,10 @@
 
   if (mergeapex) {
     if (!facet2->newfacet)
-      qh_newvertices (facet2->vertices);  /* apex is new */
+      qh_newvertices(facet2->vertices);  /* apex is new */
     apex= SETfirstt_(facet1->vertices, vertexT);
-    if (SETfirstt_(facet2->vertices, vertexT) != apex) 
-      qh_setaddnth (&facet2->vertices, 0, apex);  /* apex has last id */
+    if (SETfirstt_(facet2->vertices, vertexT) != apex)
+      qh_setaddnth(&facet2->vertices, 0, apex);  /* apex has last id */
     else
       issubset= True;
   }else {
@@ -2621,110 +2625,110 @@
       vertex->seen= False;
     FOREACHridge_(facet1->ridges) {
       if (otherfacet_(ridge, facet1) == facet2) {
-	FOREACHvertex_(ridge->vertices) {
-	  vertex->seen= True;
-	  vertex->delridge= True;
-	}
-	break;
+        FOREACHvertex_(ridge->vertices) {
+          vertex->seen= True;
+          vertex->delridge= True;
+        }
+        break;
       }
     }
     FOREACHvertex_(facet1->vertices) {
       if (!vertex->seen)
-	break;  /* must occur */
+        break;  /* must occur */
     }
     apex= vertex;
-    trace4((qh ferr, "qh_mergesimplex: merge apex v%d of f%d into facet f%d\n",
-	  apex->id, facet1->id, facet2->id));
+    trace4((qh ferr, 4039, "qh_mergesimplex: merge apex v%d of f%d into facet f%d\n",
+          apex->id, facet1->id, facet2->id));
     FOREACHvertex_i_(facet2->vertices) {
       if (vertex->id < apex->id) {
-	break;
+        break;
       }else if (vertex->id == apex->id) {
-	issubset= True;
-	break;
+        issubset= True;
+        break;
       }
     }
     if (!issubset)
-      qh_setaddnth (&facet2->vertices, vertex_i, apex);
+      qh_setaddnth(&facet2->vertices, vertex_i, apex);
     if (!facet2->newfacet)
-      qh_newvertices (facet2->vertices);
+      qh_newvertices(facet2->vertices);
     else if (!apex->newlist) {
-      qh_removevertex (apex);
-      qh_appendvertex (apex);
+      qh_removevertex(apex);
+      qh_appendvertex(apex);
     }
   }
-  trace4((qh ferr, "qh_mergesimplex: update vertex neighbors of f%d\n",
-	  facet1->id));
+  trace4((qh ferr, 4040, "qh_mergesimplex: update vertex neighbors of f%d\n",
+          facet1->id));
   FOREACHvertex_(facet1->vertices) {
     if (vertex == apex && !issubset)
-      qh_setreplace (vertex->neighbors, facet1, facet2);
+      qh_setreplace(vertex->neighbors, facet1, facet2);
     else {
-      qh_setdel (vertex->neighbors, facet1);
+      qh_setdel(vertex->neighbors, facet1);
       if (!SETsecond_(vertex->neighbors))
-	qh_mergevertex_del (vertex, facet1, facet2);
+        qh_mergevertex_del(vertex, facet1, facet2);
     }
   }
-  trace4((qh ferr, "qh_mergesimplex: merge ridges and neighbors of f%d into f%d\n",
-	  facet1->id, facet2->id));
+  trace4((qh ferr, 4041, "qh_mergesimplex: merge ridges and neighbors of f%d into f%d\n",
+          facet1->id, facet2->id));
   qh visit_id++;
   FOREACHneighbor_(facet2)
     neighbor->visitid= qh visit_id;
   FOREACHridge_(facet1->ridges) {
     otherfacet= otherfacet_(ridge, facet1);
     if (otherfacet == facet2) {
-      qh_setdel (facet2->ridges, ridge);
-      qh_setfree(&(ridge->vertices)); 
-      qh_memfree (ridge, sizeof(ridgeT));
-      qh_setdel (facet2->neighbors, facet1);
+      qh_setdel(facet2->ridges, ridge);
+      qh_setfree(&(ridge->vertices));
+      qh_memfree(ridge, (int)sizeof(ridgeT));
+      qh_setdel(facet2->neighbors, facet1);
     }else {
-      qh_setappend (&facet2->ridges, ridge);
+      qh_setappend(&facet2->ridges, ridge);
       if (otherfacet->visitid != qh visit_id) {
-	qh_setappend (&facet2->neighbors, otherfacet);
-	qh_setreplace (otherfacet->neighbors, facet1, facet2);
-	otherfacet->visitid= qh visit_id;
+        qh_setappend(&facet2->neighbors, otherfacet);
+        qh_setreplace(otherfacet->neighbors, facet1, facet2);
+        otherfacet->visitid= qh visit_id;
       }else {
-	if (otherfacet->simplicial)    /* is degen, needs ridges */
-	  qh_makeridges (otherfacet);
-	if (SETfirstt_(otherfacet->neighbors, facetT) != facet1)
-	  qh_setdel (otherfacet->neighbors, facet1);
-	else {   /*keep newfacet->neighbors->horizon*/
-	  qh_setdel(otherfacet->neighbors, facet2);
-	  qh_setreplace(otherfacet->neighbors, facet1, facet2);
-	}
+        if (otherfacet->simplicial)    /* is degen, needs ridges */
+          qh_makeridges(otherfacet);
+        if (SETfirstt_(otherfacet->neighbors, facetT) != facet1)
+          qh_setdel(otherfacet->neighbors, facet1);
+        else {   /*keep newfacet->neighbors->horizon*/
+          qh_setdel(otherfacet->neighbors, facet2);
+          qh_setreplace(otherfacet->neighbors, facet1, facet2);
+        }
       }
       if (ridge->top == facet1) /* wait until after qh_makeridges */
-	ridge->top= facet2;
-      else 
-	ridge->bottom= facet2;
+        ridge->top= facet2;
+      else
+        ridge->bottom= facet2;
     }
   }
   SETfirst_(facet1->ridges)= NULL; /* it will be deleted */
-  trace3((qh ferr, "qh_mergesimplex: merged simplex f%d apex v%d into facet f%d\n",
-	  facet1->id, getid_(apex), facet2->id));
+  trace3((qh ferr, 3006, "qh_mergesimplex: merged simplex f%d apex v%d into facet f%d\n",
+          facet1->id, getid_(apex), facet2->id));
 } /* mergesimplex */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergevertex_del">-</a>
-  
+
   qh_mergevertex_del( vertex, facet1, facet2 )
     delete a vertex because of merging facet1 into facet2
 
   returns:
     deletes vertex from facet2
-    adds vertex to qh.del_vertices for later deletion 
+    adds vertex to qh.del_vertices for later deletion
 */
-void qh_mergevertex_del (vertexT *vertex, facetT *facet1, facetT *facet2) {
+void qh_mergevertex_del(vertexT *vertex, facetT *facet1, facetT *facet2) {
 
   zinc_(Zmergevertex);
-  trace2((qh ferr, "qh_mergevertex_del: deleted v%d when merging f%d into f%d\n",
+  trace2((qh ferr, 2035, "qh_mergevertex_del: deleted v%d when merging f%d into f%d\n",
           vertex->id, facet1->id, facet2->id));
-  qh_setdelsorted (facet2->vertices, vertex);
+  qh_setdelsorted(facet2->vertices, vertex);
   vertex->deleted= True;
-  qh_setappend (&qh del_vertices, vertex);
+  qh_setappend(&qh del_vertices, vertex);
 } /* mergevertex_del */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergevertex_neighbors">-</a>
-  
+
   qh_mergevertex_neighbors( facet1, facet2 )
     merge the vertex neighbors of facet1 to facet2
 
@@ -2732,39 +2736,39 @@
     if vertex is current qh.vertex_visit
       deletes facet1 from vertex->neighbors
     else
-      renames facet1 to facet2 in vertex->neighbors 
+      renames facet1 to facet2 in vertex->neighbors
     deletes vertices if only one neighbor
-  
+
   notes:
     assumes vertex neighbor sets are good
 */
 void qh_mergevertex_neighbors(facetT *facet1, facetT *facet2) {
   vertexT *vertex, **vertexp;
 
-  trace4((qh ferr, "qh_mergevertex_neighbors: merge vertex neighbors of f%d and f%d\n",
-	  facet1->id, facet2->id));
+  trace4((qh ferr, 4042, "qh_mergevertex_neighbors: merge vertex neighbors of f%d and f%d\n",
+          facet1->id, facet2->id));
   if (qh tracevertex) {
-    fprintf (qh ferr, "qh_mergevertex_neighbors: of f%d and f%d at furthest p%d f0= %p\n",
-	     facet1->id, facet2->id, qh furthest_id, qh tracevertex->neighbors->e[0].p);
-    qh_errprint ("TRACE", NULL, NULL, NULL, qh tracevertex);
+    qh_fprintf(qh ferr, 8081, "qh_mergevertex_neighbors: of f%d and f%d at furthest p%d f0= %p\n",
+             facet1->id, facet2->id, qh furthest_id, qh tracevertex->neighbors->e[0].p);
+    qh_errprint("TRACE", NULL, NULL, NULL, qh tracevertex);
   }
   FOREACHvertex_(facet1->vertices) {
-    if (vertex->visitid != qh vertex_visit) 
+    if (vertex->visitid != qh vertex_visit)
       qh_setreplace(vertex->neighbors, facet1, facet2);
     else {
       qh_setdel(vertex->neighbors, facet1);
       if (!SETsecond_(vertex->neighbors))
-	qh_mergevertex_del (vertex, facet1, facet2);
+        qh_mergevertex_del(vertex, facet1, facet2);
     }
   }
-  if (qh tracevertex) 
-    qh_errprint ("TRACE", NULL, NULL, NULL, qh tracevertex);
+  if (qh tracevertex)
+    qh_errprint("TRACE", NULL, NULL, NULL, qh tracevertex);
 } /* mergevertex_neighbors */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="mergevertices">-</a>
-  
+
   qh_mergevertices( vertices1, vertices2 )
     merges the vertex set of facet1 into facet2
 
@@ -2781,34 +2785,34 @@
   setT *mergedvertices;
   vertexT *vertex, **vertexp, **vertex2= SETaddr_(*vertices2, vertexT);
 
-  mergedvertices= qh_settemp (newsize);
+  mergedvertices= qh_settemp(newsize);
   FOREACHvertex_(vertices1) {
     if (!*vertex2 || vertex->id > (*vertex2)->id)
-      qh_setappend (&mergedvertices, vertex);
+      qh_setappend(&mergedvertices, vertex);
     else {
       while (*vertex2 && (*vertex2)->id > vertex->id)
-	qh_setappend (&mergedvertices, *vertex2++);
+        qh_setappend(&mergedvertices, *vertex2++);
       if (!*vertex2 || (*vertex2)->id < vertex->id)
-	qh_setappend (&mergedvertices, vertex);
+        qh_setappend(&mergedvertices, vertex);
       else
-	qh_setappend (&mergedvertices, *vertex2++);
+        qh_setappend(&mergedvertices, *vertex2++);
     }
   }
   while (*vertex2)
-    qh_setappend (&mergedvertices, *vertex2++);
-  if (newsize < qh_setsize (mergedvertices)) {
-    fprintf (qh ferr, "qhull internal error (qh_mergevertices): facets did not share a ridge\n");
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_setappend(&mergedvertices, *vertex2++);
+  if (newsize < qh_setsize(mergedvertices)) {
+    qh_fprintf(qh ferr, 6100, "qhull internal error (qh_mergevertices): facets did not share a ridge\n");
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   qh_setfree(vertices2);
   *vertices2= mergedvertices;
-  qh_settemppop ();
+  qh_settemppop();
 } /* mergevertices */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="neighbor_intersections">-</a>
-  
+
   qh_neighbor_intersections( vertex )
     return intersection of all vertices in vertex->neighbors except for vertex
 
@@ -2817,7 +2821,7 @@
     does not include vertex
     NULL if a neighbor is simplicial
     NULL if empty set
-    
+
   notes:
     used for renaming vertices
 
@@ -2827,9 +2831,9 @@
     for each remaining neighbor
       intersect its vertex set with the intersection set
       return NULL if empty
-    return the intersection set  
+    return the intersection set
 */
-setT *qh_neighbor_intersections (vertexT *vertex) {
+setT *qh_neighbor_intersections(vertexT *vertex) {
   facetT *neighbor, **neighborp, *neighborA, *neighborB;
   setT *intersect;
   int neighbor_i, neighbor_n;
@@ -2844,30 +2848,30 @@
   if (!neighborA)
     return NULL;
   if (!neighborB)
-    intersect= qh_setcopy (neighborA->vertices, 0);
+    intersect= qh_setcopy(neighborA->vertices, 0);
   else
-    intersect= qh_vertexintersect_new (neighborA->vertices, neighborB->vertices);
-  qh_settemppush (intersect);
-  qh_setdelsorted (intersect, vertex);
+    intersect= qh_vertexintersect_new(neighborA->vertices, neighborB->vertices);
+  qh_settemppush(intersect);
+  qh_setdelsorted(intersect, vertex);
   FOREACHneighbor_i_(vertex) {
     if (neighbor_i >= 2) {
       zinc_(Zintersectnum);
-      qh_vertexintersect (&intersect, neighbor->vertices);
+      qh_vertexintersect(&intersect, neighbor->vertices);
       if (!SETfirst_(intersect)) {
         zinc_(Zintersectfail);
-        qh_settempfree (&intersect);
+        qh_settempfree(&intersect);
         return NULL;
       }
     }
   }
-  trace3((qh ferr, "qh_neighbor_intersections: %d vertices in neighbor intersection of v%d\n", 
-          qh_setsize (intersect), vertex->id));
+  trace3((qh ferr, 3007, "qh_neighbor_intersections: %d vertices in neighbor intersection of v%d\n",
+          qh_setsize(intersect), vertex->id));
   return intersect;
 } /* neighbor_intersections */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="newvertices">-</a>
-  
+
   qh_newvertices( vertices )
     add vertices to end of qh.vertex_list (marks as new vertices)
 
@@ -2875,20 +2879,20 @@
     vertices on qh.newvertex_list
     vertex->newlist set
 */
-void qh_newvertices (setT *vertices) {
+void qh_newvertices(setT *vertices) {
   vertexT *vertex, **vertexp;
 
   FOREACHvertex_(vertices) {
     if (!vertex->newlist) {
-      qh_removevertex (vertex);
-      qh_appendvertex (vertex);
+      qh_removevertex(vertex);
+      qh_appendvertex(vertex);
     }
   }
 } /* newvertices */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="reducevertices">-</a>
-  
+
   qh_reducevertices()
     reduce extra vertices, shared vertices, and redundant vertices
     facet->newmerge is set if merged since last call
@@ -2913,22 +2917,22 @@
             rename vertex if it is shared
       remove delridge flag from new vertices
 */
-boolT qh_reducevertices (void) {
+boolT qh_reducevertices(void) {
   int numshare=0, numrename= 0;
   boolT degenredun= False;
   facetT *newfacet;
   vertexT *vertex, **vertexp;
 
-  if (qh hull_dim == 2) 
+  if (qh hull_dim == 2)
     return False;
   if (qh_merge_degenredundant())
     degenredun= True;
  LABELrestart:
   FORALLnew_facets {
-    if (newfacet->newmerge) { 
+    if (newfacet->newmerge) {
       if (!qh MERGEvertices)
         newfacet->newmerge= False;
-      qh_remove_extravertices (newfacet);
+      qh_remove_extravertices(newfacet);
     }
   }
   if (!qh MERGEvertices)
@@ -2937,11 +2941,11 @@
     if (newfacet->newmerge) {
       newfacet->newmerge= False;
       FOREACHvertex_(newfacet->vertices) {
-	if (vertex->delridge) {
-	  if (qh_rename_sharedvertex (vertex, newfacet)) {
-	    numshare++;
-	    vertexp--; /* repeat since deleted vertex */
-	  }
+        if (vertex->delridge) {
+          if (qh_rename_sharedvertex(vertex, newfacet)) {
+            numshare++;
+            vertexp--; /* repeat since deleted vertex */
+          }
         }
       }
     }
@@ -2949,31 +2953,31 @@
   FORALLvertex_(qh newvertex_list) {
     if (vertex->delridge && !vertex->deleted) {
       vertex->delridge= False;
-      if (qh hull_dim >= 4 && qh_redundant_vertex (vertex)) {
-	numrename++;
-	if (qh_merge_degenredundant()) {
-	  degenredun= True;
-	  goto LABELrestart;
-	}
+      if (qh hull_dim >= 4 && qh_redundant_vertex(vertex)) {
+        numrename++;
+        if (qh_merge_degenredundant()) {
+          degenredun= True;
+          goto LABELrestart;
+        }
       }
     }
   }
-  trace1((qh ferr, "qh_reducevertices: renamed %d shared vertices and %d redundant vertices. Degen? %d\n",
-	  numshare, numrename, degenredun));
+  trace1((qh ferr, 1014, "qh_reducevertices: renamed %d shared vertices and %d redundant vertices. Degen? %d\n",
+          numshare, numrename, degenredun));
   return degenredun;
 } /* reducevertices */
-      
+
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="redundant_vertex">-</a>
-  
+
   qh_redundant_vertex( vertex )
     detect and rename a redundant vertex
-    vertices have full vertex->neighbors 
+    vertices have full vertex->neighbors
 
   returns:
     returns true if find a redundant vertex
-      deletes vertex (vertex->deleted)
-  
+      deletes vertex(vertex->deleted)
+
   notes:
     only needed if vertex->delridge and hull_dim >= 4
     may add degenerate facets to qh.facet_mergeset
@@ -2985,24 +2989,24 @@
     if find a new vertex for vertex amoung these ridges and vertices
       rename vertex to the new vertex
 */
-vertexT *qh_redundant_vertex (vertexT *vertex) {
+vertexT *qh_redundant_vertex(vertexT *vertex) {
   vertexT *newvertex= NULL;
   setT *vertices, *ridges;
 
-  trace3((qh ferr, "qh_redundant_vertex: check if v%d can be renamed\n", vertex->id));  
-  if ((vertices= qh_neighbor_intersections (vertex))) {
-    ridges= qh_vertexridges (vertex);
-    if ((newvertex= qh_find_newvertex (vertex, vertices, ridges)))
-      qh_renamevertex (vertex, newvertex, ridges, NULL, NULL);
-    qh_settempfree (&ridges);
-    qh_settempfree (&vertices);
+  trace3((qh ferr, 3008, "qh_redundant_vertex: check if v%d can be renamed\n", vertex->id));
+  if ((vertices= qh_neighbor_intersections(vertex))) {
+    ridges= qh_vertexridges(vertex);
+    if ((newvertex= qh_find_newvertex(vertex, vertices, ridges)))
+      qh_renamevertex(vertex, newvertex, ridges, NULL, NULL);
+    qh_settempfree(&ridges);
+    qh_settempfree(&vertices);
   }
   return newvertex;
 } /* redundant_vertex */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="remove_extravertices">-</a>
-  
+
   qh_remove_extravertices( facet )
     remove extra vertices from non-simplicial facets
 
@@ -3017,16 +3021,16 @@
         unless vertex in another facet
           add vertex to qh.del_vertices for later deletion
 */
-boolT qh_remove_extravertices (facetT *facet) {
+boolT qh_remove_extravertices(facetT *facet) {
   ridgeT *ridge, **ridgep;
   vertexT *vertex, **vertexp;
   boolT foundrem= False;
 
-  trace4((qh ferr, "qh_remove_extravertices: test f%d for extra vertices\n",
-	  facet->id));
+  trace4((qh ferr, 4043, "qh_remove_extravertices: test f%d for extra vertices\n",
+          facet->id));
   FOREACHvertex_(facet->vertices)
     vertex->seen= False;
-  FOREACHridge_(facet->ridges) { 
+  FOREACHridge_(facet->ridges) {
     FOREACHvertex_(ridge->vertices)
       vertex->seen= True;
   }
@@ -3034,15 +3038,15 @@
     if (!vertex->seen) {
       foundrem= True;
       zinc_(Zremvertex);
-      qh_setdelsorted (facet->vertices, vertex);
-      qh_setdel (vertex->neighbors, facet);
-      if (!qh_setsize (vertex->neighbors)) {
-	vertex->deleted= True;
-	qh_setappend (&qh del_vertices, vertex);
-	zinc_(Zremvertexdel);
-	trace2((qh ferr, "qh_remove_extravertices: v%d deleted because it's lost all ridges\n", vertex->id));
+      qh_setdelsorted(facet->vertices, vertex);
+      qh_setdel(vertex->neighbors, facet);
+      if (!qh_setsize(vertex->neighbors)) {
+        vertex->deleted= True;
+        qh_setappend(&qh del_vertices, vertex);
+        zinc_(Zremvertexdel);
+        trace2((qh ferr, 2036, "qh_remove_extravertices: v%d deleted because it's lost all ridges\n", vertex->id));
       }else
-	trace3((qh ferr, "qh_remove_extravertices: v%d removed from f%d because it's lost all ridges\n", vertex->id, facet->id));
+        trace3((qh ferr, 3009, "qh_remove_extravertices: v%d removed from f%d because it's lost all ridges\n", vertex->id, facet->id));
       vertexp--; /*repeat*/
     }
   }
@@ -3051,7 +3055,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="rename_sharedvertex">-</a>
-  
+
   qh_rename_sharedvertex( vertex, facet )
     detect and rename if shared vertex in facet
     vertices have full ->neighbors
@@ -3061,11 +3065,11 @@
     the vertex may still exist in other facets (i.e., a neighbor was pinched)
     does not change facet->neighbors
     updates vertex->neighbors
-  
+
   notes:
     a shared vertex for a facet is only in ridges to one neighbor
     this may undo a pinched facet
- 
+
     it does not catch pinches involving multiple facets.  These appear
       to be difficult to detect, since an exhaustive search is too expensive.
 
@@ -3076,12 +3080,12 @@
       if can find a new vertex in this set
         rename the vertex to the new vertex
 */
-vertexT *qh_rename_sharedvertex (vertexT *vertex, facetT *facet) {
+vertexT *qh_rename_sharedvertex(vertexT *vertex, facetT *facet) {
   facetT *neighbor, **neighborp, *neighborA= NULL;
   setT *vertices, *ridges;
   vertexT *newvertex;
 
-  if (qh_setsize (vertex->neighbors) == 2) {
+  if (qh_setsize(vertex->neighbors) == 2) {
     neighborA= SETfirstt_(vertex->neighbors, facetT);
     if (neighborA == facet)
       neighborA= SETsecondt_(vertex->neighbors, facetT);
@@ -3099,37 +3103,37 @@
       }
     }
     if (!neighborA) {
-      fprintf (qh ferr, "qhull internal error (qh_rename_sharedvertex): v%d's neighbors not in f%d\n",
+      qh_fprintf(qh ferr, 6101, "qhull internal error (qh_rename_sharedvertex): v%d's neighbors not in f%d\n",
         vertex->id, facet->id);
-      qh_errprint ("ERRONEOUS", facet, NULL, NULL, vertex);
-      qh_errexit (qh_ERRqhull, NULL, NULL);
+      qh_errprint("ERRONEOUS", facet, NULL, NULL, vertex);
+      qh_errexit(qh_ERRqhull, NULL, NULL);
     }
   }
   /* the vertex is shared by facet and neighborA */
-  ridges= qh_settemp (qh TEMPsize);
+  ridges= qh_settemp(qh TEMPsize);
   neighborA->visitid= ++qh visit_id;
-  qh_vertexridges_facet (vertex, facet, &ridges);
-  trace2((qh ferr, "qh_rename_sharedvertex: p%d (v%d) is shared by f%d (%d ridges) and f%d\n",
-    qh_pointid(vertex->point), vertex->id, facet->id, qh_setsize (ridges), neighborA->id));
+  qh_vertexridges_facet(vertex, facet, &ridges);
+  trace2((qh ferr, 2037, "qh_rename_sharedvertex: p%d(v%d) is shared by f%d(%d ridges) and f%d\n",
+    qh_pointid(vertex->point), vertex->id, facet->id, qh_setsize(ridges), neighborA->id));
   zinc_(Zintersectnum);
-  vertices= qh_vertexintersect_new (facet->vertices, neighborA->vertices);
-  qh_setdel (vertices, vertex);
-  qh_settemppush (vertices);
-  if ((newvertex= qh_find_newvertex (vertex, vertices, ridges))) 
-    qh_renamevertex (vertex, newvertex, ridges, facet, neighborA);
-  qh_settempfree (&vertices);
-  qh_settempfree (&ridges);
+  vertices= qh_vertexintersect_new(facet->vertices, neighborA->vertices);
+  qh_setdel(vertices, vertex);
+  qh_settemppush(vertices);
+  if ((newvertex= qh_find_newvertex(vertex, vertices, ridges)))
+    qh_renamevertex(vertex, newvertex, ridges, facet, neighborA);
+  qh_settempfree(&vertices);
+  qh_settempfree(&ridges);
   return newvertex;
 } /* rename_sharedvertex */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="renameridgevertex">-</a>
-  
+
   qh_renameridgevertex( ridge, oldvertex, newvertex )
     renames oldvertex as newvertex in ridge
 
   returns:
-  
+
   design:
     delete oldvertex from ridge
     if newvertex already in ridge
@@ -3144,15 +3148,15 @@
   facetT *temp;
   vertexT *vertex, **vertexp;
 
-  oldnth= qh_setindex (ridge->vertices, oldvertex);
-  qh_setdelnthsorted (ridge->vertices, oldnth);
+  oldnth= qh_setindex(ridge->vertices, oldvertex);
+  qh_setdelnthsorted(ridge->vertices, oldnth);
   FOREACHvertex_(ridge->vertices) {
     if (vertex == newvertex) {
       zinc_(Zdelridge);
       if (ridge->nonconvex) /* only one ridge has nonconvex set */
-	qh_copynonconvex (ridge);
-      qh_delridge (ridge);
-      trace2((qh ferr, "qh_renameridgevertex: ridge r%d deleted.  It contained both v%d and v%d\n",
+        qh_copynonconvex(ridge);
+      qh_delridge(ridge);
+      trace2((qh ferr, 2038, "qh_renameridgevertex: ridge r%d deleted.  It contained both v%d and v%d\n",
         ridge->id, oldvertex->id, newvertex->id));
       return;
     }
@@ -3162,8 +3166,8 @@
   }
   qh_setaddnth(&ridge->vertices, nth, newvertex);
   if (abs(oldnth - nth)%2) {
-    trace3((qh ferr, "qh_renameridgevertex: swapped the top and bottom of ridge r%d\n", 
-	    ridge->id));
+    trace3((qh ferr, 3010, "qh_renameridgevertex: swapped the top and bottom of ridge r%d\n",
+            ridge->id));
     temp= ridge->top;
     ridge->top= ridge->bottom;
     ridge->bottom= temp;
@@ -3173,15 +3177,15 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="renamevertex">-</a>
-  
+
   qh_renamevertex( oldvertex, newvertex, ridges, oldfacet, neighborA )
-    renames oldvertex as newvertex in ridges 
+    renames oldvertex as newvertex in ridges
     gives oldfacet/neighborA if oldvertex is shared between two facets
 
   returns:
     oldvertex may still exist afterwards
-    
 
+
   notes:
     can not change neighbors of newvertex (since it's a subset)
 
@@ -3207,53 +3211,53 @@
   boolT istrace= False;
 
   if (qh IStracing >= 2 || oldvertex->id == qh tracevertex_id ||
-	newvertex->id == qh tracevertex_id)
+        newvertex->id == qh tracevertex_id)
     istrace= True;
-  FOREACHridge_(ridges) 
-    qh_renameridgevertex (ridge, oldvertex, newvertex);
+  FOREACHridge_(ridges)
+    qh_renameridgevertex(ridge, oldvertex, newvertex);
   if (!oldfacet) {
     zinc_(Zrenameall);
     if (istrace)
-      fprintf (qh ferr, "qh_renamevertex: renamed v%d to v%d in several facets\n",
+      qh_fprintf(qh ferr, 8082, "qh_renamevertex: renamed v%d to v%d in several facets\n",
                oldvertex->id, newvertex->id);
     FOREACHneighbor_(oldvertex) {
-      qh_maydropneighbor (neighbor);
-      qh_setdelsorted (neighbor->vertices, oldvertex);
-      if (qh_remove_extravertices (neighbor))
+      qh_maydropneighbor(neighbor);
+      qh_setdelsorted(neighbor->vertices, oldvertex);
+      if (qh_remove_extravertices(neighbor))
         neighborp--; /* neighbor may be deleted */
     }
     if (!oldvertex->deleted) {
       oldvertex->deleted= True;
-      qh_setappend (&qh del_vertices, oldvertex);
+      qh_setappend(&qh del_vertices, oldvertex);
     }
-  }else if (qh_setsize (oldvertex->neighbors) == 2) {
+  }else if (qh_setsize(oldvertex->neighbors) == 2) {
     zinc_(Zrenameshare);
     if (istrace)
-      fprintf (qh ferr, "qh_renamevertex: renamed v%d to v%d in oldfacet f%d\n", 
+      qh_fprintf(qh ferr, 8083, "qh_renamevertex: renamed v%d to v%d in oldfacet f%d\n",
                oldvertex->id, newvertex->id, oldfacet->id);
     FOREACHneighbor_(oldvertex)
-      qh_setdelsorted (neighbor->vertices, oldvertex);
+      qh_setdelsorted(neighbor->vertices, oldvertex);
     oldvertex->deleted= True;
-    qh_setappend (&qh del_vertices, oldvertex);
+    qh_setappend(&qh del_vertices, oldvertex);
   }else {
     zinc_(Zrenamepinch);
     if (istrace || qh IStracing)
-      fprintf (qh ferr, "qh_renamevertex: renamed pinched v%d to v%d between f%d and f%d\n", 
+      qh_fprintf(qh ferr, 8084, "qh_renamevertex: renamed pinched v%d to v%d between f%d and f%d\n",
                oldvertex->id, newvertex->id, oldfacet->id, neighborA->id);
-    qh_setdelsorted (oldfacet->vertices, oldvertex);
-    qh_setdel (oldvertex->neighbors, oldfacet);
-    qh_remove_extravertices (neighborA);
+    qh_setdelsorted(oldfacet->vertices, oldvertex);
+    qh_setdel(oldvertex->neighbors, oldfacet);
+    qh_remove_extravertices(neighborA);
   }
 } /* renamevertex */
 
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="test_appendmerge">-</a>
-  
+
   qh_test_appendmerge( facet, neighbor )
     tests facet/neighbor for convexity
     appends to mergeset if non-convex
-    if pre-merging, 
+    if pre-merging,
       nop if qh.SKIPconvex, or qh.MERGEexact and coplanar
 
   returns:
@@ -3281,7 +3285,7 @@
      get angle if needed
      append concave or coplanar merge to qh.mergeset
 */
-boolT qh_test_appendmerge (facetT *facet, facetT *neighbor) {
+boolT qh_test_appendmerge(facetT *facet, facetT *neighbor) {
   realT dist, dist2= -REALmax, angle= -REALmax;
   boolT isconcave= False, iscoplanar= False, okangle= False;
 
@@ -3293,14 +3297,14 @@
     if (angle > qh cos_max) {
       zinc_(Zcoplanarangle);
       qh_appendmergeset(facet, neighbor, MRGanglecoplanar, &angle);
-      trace2((qh ferr, "qh_test_appendmerge: coplanar angle %4.4g between f%d and f%d\n",
+      trace2((qh ferr, 2039, "qh_test_appendmerge: coplanar angle %4.4g between f%d and f%d\n",
          angle, facet->id, neighbor->id));
       return True;
     }else
       okangle= True;
   }
   if (!facet->center)
-    facet->center= qh_getcentrum (facet);
+    facet->center= qh_getcentrum(facet);
   zzinc_(Zcentrumtests);
   qh_distplane(facet->center, neighbor, &dist);
   if (dist > qh centrum_radius)
@@ -3309,7 +3313,7 @@
     if (dist > -qh centrum_radius)
       iscoplanar= True;
     if (!neighbor->center)
-      neighbor->center= qh_getcentrum (neighbor);
+      neighbor->center= qh_getcentrum(neighbor);
     zzinc_(Zcentrumtests);
     qh_distplane(neighbor->center, facet, &dist2);
     if (dist2 > qh centrum_radius)
@@ -3328,20 +3332,20 @@
     if (qh ANGLEmerge)
       angle += qh_ANGLEconcave + 0.5;
     qh_appendmergeset(facet, neighbor, MRGconcave, &angle);
-    trace0((qh ferr, "qh_test_appendmerge: concave f%d to f%d dist %4.4g and reverse dist %4.4g angle %4.4g during p%d\n",
-	   facet->id, neighbor->id, dist, dist2, angle, qh furthest_id));
+    trace0((qh ferr, 18, "qh_test_appendmerge: concave f%d to f%d dist %4.4g and reverse dist %4.4g angle %4.4g during p%d\n",
+           facet->id, neighbor->id, dist, dist2, angle, qh furthest_id));
   }else /* iscoplanar */ {
     zinc_(Zcoplanarcentrum);
     qh_appendmergeset(facet, neighbor, MRGcoplanar, &angle);
-    trace2((qh ferr, "qh_test_appendmerge: coplanar f%d to f%d dist %4.4g, reverse dist %4.4g angle %4.4g\n",
-	      facet->id, neighbor->id, dist, dist2, angle));
+    trace2((qh ferr, 2040, "qh_test_appendmerge: coplanar f%d to f%d dist %4.4g, reverse dist %4.4g angle %4.4g\n",
+              facet->id, neighbor->id, dist, dist2, angle));
   }
   return True;
 } /* test_appendmerge */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="test_vneighbors">-</a>
-  
+
   qh_test_vneighbors()
     test vertex neighbors for convexity
     tests all facets on qh.newfacet_list
@@ -3364,15 +3368,15 @@
         for each unvisited facet neighbor of the vertex
           test new facet and neighbor for convexity
 */
-boolT qh_test_vneighbors (void /* qh newfacet_list */) {
+boolT qh_test_vneighbors(void /* qh newfacet_list */) {
   facetT *newfacet, *neighbor, **neighborp;
   vertexT *vertex, **vertexp;
   int nummerges= 0;
 
-  trace1((qh ferr, "qh_test_vneighbors: testing vertex neighbors for convexity\n"));
+  trace1((qh ferr, 1015, "qh_test_vneighbors: testing vertex neighbors for convexity\n"));
   if (!qh VERTEXneighbors)
     qh_vertexneighbors();
-  FORALLnew_facets 
+  FORALLnew_facets
     newfacet->seen= False;
   FORALLnew_facets {
     newfacet->seen= True;
@@ -3381,54 +3385,54 @@
       newfacet->visitid= qh visit_id;
     FOREACHvertex_(newfacet->vertices) {
       FOREACHneighbor_(vertex) {
-      	if (neighbor->seen || neighbor->visitid == qh visit_id)
-      	  continue;
-      	if (qh_test_appendmerge (newfacet, neighbor))
+        if (neighbor->seen || neighbor->visitid == qh visit_id)
+          continue;
+        if (qh_test_appendmerge(newfacet, neighbor))
           nummerges++;
       }
     }
   }
   zadd_(Ztestvneighbor, nummerges);
-  trace1((qh ferr, "qh_test_vneighbors: found %d non-convex, vertex neighbors\n",
+  trace1((qh ferr, 1016, "qh_test_vneighbors: found %d non-convex, vertex neighbors\n",
            nummerges));
-  return (nummerges > 0);    
+  return (nummerges > 0);
 } /* test_vneighbors */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="tracemerge">-</a>
-  
+
   qh_tracemerge( facet1, facet2 )
     print trace message after merge
 */
-void qh_tracemerge (facetT *facet1, facetT *facet2) {
+void qh_tracemerge(facetT *facet1, facetT *facet2) {
   boolT waserror= False;
 
 #ifndef qh_NOtrace
-  if (qh IStracing >= 4) 
-    qh_errprint ("MERGED", facet2, NULL, NULL, NULL);
+  if (qh IStracing >= 4)
+    qh_errprint("MERGED", facet2, NULL, NULL, NULL);
   if (facet2 == qh tracefacet || (qh tracevertex && qh tracevertex->newlist)) {
-    fprintf (qh ferr, "qh_tracemerge: trace facet and vertex after merge of f%d and f%d, furthest p%d\n", facet1->id, facet2->id, qh furthest_id);
+    qh_fprintf(qh ferr, 8085, "qh_tracemerge: trace facet and vertex after merge of f%d and f%d, furthest p%d\n", facet1->id, facet2->id, qh furthest_id);
     if (facet2 != qh tracefacet)
-      qh_errprint ("TRACE", qh tracefacet, 
-        (qh tracevertex && qh tracevertex->neighbors) ? 
+      qh_errprint("TRACE", qh tracefacet,
+        (qh tracevertex && qh tracevertex->neighbors) ?
            SETfirstt_(qh tracevertex->neighbors, facetT) : NULL,
-        NULL, qh tracevertex);      
+        NULL, qh tracevertex);
   }
   if (qh tracevertex) {
     if (qh tracevertex->deleted)
-      fprintf (qh ferr, "qh_tracemerge: trace vertex deleted at furthest p%d\n",
-	    qh furthest_id);
+      qh_fprintf(qh ferr, 8086, "qh_tracemerge: trace vertex deleted at furthest p%d\n",
+            qh furthest_id);
     else
-      qh_checkvertex (qh tracevertex);
+      qh_checkvertex(qh tracevertex);
   }
   if (qh tracefacet) {
-    qh_checkfacet (qh tracefacet, True, &waserror);
+    qh_checkfacet(qh tracefacet, True, &waserror);
     if (waserror)
-      qh_errexit (qh_ERRqhull, qh tracefacet, NULL);
+      qh_errexit(qh_ERRqhull, qh tracefacet, NULL);
   }
 #endif /* !qh_NOtrace */
   if (qh CHECKfrequently || qh IStracing >= 4) { /* can't check polygon here */
-    qh_checkfacet (facet2, True, &waserror);
+    qh_checkfacet(facet2, True, &waserror);
     if (waserror)
       qh_errexit(qh_ERRqhull, NULL, NULL);
   }
@@ -3436,42 +3440,42 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="tracemerging">-</a>
-  
+
   qh_tracemerging()
     print trace message during POSTmerging
 
   returns:
     updates qh.mergereport
-  
+
   notes:
     called from qh_mergecycle() and qh_mergefacet()
-  
+
   see:
     qh_buildtracing()
 */
-void qh_tracemerging (void) {
+void qh_tracemerging(void) {
   realT cpu;
   int total;
   time_t timedata;
   struct tm *tp;
 
   qh mergereport= zzval_(Ztotmerge);
-  time (&timedata);
-  tp= localtime (&timedata);
+  time(&timedata);
+  tp= localtime(&timedata);
   cpu= qh_CPUclock;
   cpu /= qh_SECticks;
   total= zzval_(Ztotmerge) - zzval_(Zcyclehorizon) + zzval_(Zcyclefacettot);
-  fprintf (qh ferr, "\n\
+  qh_fprintf(qh ferr, 8087, "\n\
 At %d:%d:%d & %2.5g CPU secs, qhull has merged %d facets.  The hull\n\
   contains %d facets and %d vertices.\n",
       tp->tm_hour, tp->tm_min, tp->tm_sec, cpu,
       total, qh num_facets - qh num_visible,
-      qh num_vertices-qh_setsize (qh del_vertices));
+      qh num_vertices-qh_setsize(qh del_vertices));
 } /* tracemerging */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="updatetested">-</a>
-  
+
   qh_updatetested( facet1, facet2 )
     clear facet2->tested and facet1->ridge->tested for merge
 
@@ -3484,23 +3488,23 @@
     clear ridge->tested for facet1's ridges
     if facet2 has a centrum
       if facet2 is large
-        set facet2->keepcentrum 
+        set facet2->keepcentrum
       else if facet2 has 3 vertices due to many merges, or not large and post merging
         clear facet2->keepcentrum
       unless facet2->keepcentrum
         clear facet2->center to recompute centrum later
         clear ridge->tested for facet2's ridges
 */
-void qh_updatetested (facetT *facet1, facetT *facet2) {
+void qh_updatetested(facetT *facet1, facetT *facet2) {
   ridgeT *ridge, **ridgep;
   int size;
-  
+
   facet2->tested= False;
   FOREACHridge_(facet1->ridges)
     ridge->tested= False;
   if (!facet2->center)
     return;
-  size= qh_setsize (facet2->vertices);
+  size= qh_setsize(facet2->vertices);
   if (!facet2->keepcentrum) {
     if (size > qh hull_dim + qh_MAXnewcentrum) {
       facet2->keepcentrum= True;
@@ -3512,7 +3516,7 @@
       facet2->keepcentrum= False; /* if many merges need to recompute centrum */
   }
   if (!facet2->keepcentrum) {
-    qh_memfree (facet2->center, qh normal_size);
+    qh_memfree(facet2->center, qh normal_size);
     facet2->center= NULL;
     FOREACHridge_(facet2->ridges)
       ridge->tested= False;
@@ -3521,7 +3525,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="vertexridges">-</a>
-  
+
   qh_vertexridges( vertex )
     return temporary set of ridges adjacent to a vertex
     vertex->neighbors defined
@@ -3532,11 +3536,11 @@
 
   design:
     for each neighbor of vertex
-      add ridges that include the vertex to ridges  
+      add ridges that include the vertex to ridges
 */
-setT *qh_vertexridges (vertexT *vertex) {
+setT *qh_vertexridges(vertexT *vertex) {
   facetT *neighbor, **neighborp;
-  setT *ridges= qh_settemp (qh TEMPsize);
+  setT *ridges= qh_settemp(qh TEMPsize);
   int size;
 
   qh visit_id++;
@@ -3544,14 +3548,14 @@
     neighbor->visitid= qh visit_id;
   FOREACHneighbor_(vertex) {
     if (*neighborp)   /* no new ridges in last neighbor */
-      qh_vertexridges_facet (vertex, neighbor, &ridges);
+      qh_vertexridges_facet(vertex, neighbor, &ridges);
   }
   if (qh PRINTstatistics || qh IStracing) {
-    size= qh_setsize (ridges);
+    size= qh_setsize(ridges);
     zinc_(Zvertexridge);
     zadd_(Zvertexridgetot, size);
     zmax_(Zvertexridgemax, size);
-    trace3((qh ferr, "qh_vertexridges: found %d ridges for v%d\n",
+    trace3((qh ferr, 3011, "qh_vertexridges: found %d ridges for v%d\n",
              size, vertex->id));
   }
   return ridges;
@@ -3559,7 +3563,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="vertexridges_facet">-</a>
-  
+
   qh_vertexridges_facet( vertex, facet, ridges )
     add adjacent ridges for vertex in facet
     neighbor->visitid==qh.visit_id if it hasn't been visited
@@ -3575,22 +3579,22 @@
           append ridge to vertex
     mark facet processed
 */
-void qh_vertexridges_facet (vertexT *vertex, facetT *facet, setT **ridges) {
+void qh_vertexridges_facet(vertexT *vertex, facetT *facet, setT **ridges) {
   ridgeT *ridge, **ridgep;
   facetT *neighbor;
 
   FOREACHridge_(facet->ridges) {
     neighbor= otherfacet_(ridge, facet);
-    if (neighbor->visitid == qh visit_id 
-    && qh_setin (ridge->vertices, vertex))
-      qh_setappend (ridges, ridge);
+    if (neighbor->visitid == qh visit_id
+    && qh_setin(ridge->vertices, vertex))
+      qh_setappend(ridges, ridge);
   }
   facet->visitid= qh visit_id-1;
 } /* vertexridges_facet */
 
 /*-<a                             href="qh-merge.htm#TOC"
   >-------------------------------</a><a name="willdelete">-</a>
-  
+
   qh_willdelete( facet, replace )
     moves facet to visible list
     sets facet->f.replace to replace (may be NULL)
@@ -3598,22 +3602,22 @@
   returns:
     bumps qh.num_visible
 */
-void qh_willdelete (facetT *facet, facetT *replace) {
+void qh_willdelete(facetT *facet, facetT *replace) {
 
   qh_removefacet(facet);
-  qh_prependfacet (facet, &qh visible_list);
+  qh_prependfacet(facet, &qh visible_list);
   qh num_visible++;
   facet->visible= True;
   facet->f.replace= replace;
 } /* willdelete */
 
 #else /* qh_NOmerge */
-void qh_premerge (vertexT *apex, realT maxcentrum, realT maxangle) {
+void qh_premerge(vertexT *apex, realT maxcentrum, realT maxangle) {
 }
-void qh_postmerge (char *reason, realT maxcentrum, realT maxangle, 
+void qh_postmerge(const char *reason, realT maxcentrum, realT maxangle,
                       boolT vneighbors) {
 }
-boolT qh_checkzero (boolT testall) {
+boolT qh_checkzero(boolT testall) {
    }
 #endif /* qh_NOmerge */
 

Modified: trunk/scipy/spatial/qhull/src/merge.h
===================================================================
--- trunk/scipy/spatial/qhull/src/merge.h	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/merge.h	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,18 +1,22 @@
 /*<html><pre>  -<a                             href="qh-merge.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-   merge.h 
+   merge.h
    header file for merge.c
 
    see qh-merge.htm and merge.c
 
-   copyright (c) 1993-2003, The Geometry Center
+   copyright (c) 1993-2010 C.B. Barber.
+   $Id: //product/qhull/main/rel/src/merge.h#21 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 */
 
 #ifndef qhDEFmerge
 #define qhDEFmerge 1
 
+#include "libqhull.h"
 
+
 /*============ -constants- ==============*/
 
 /*-<a                             href="qh-merge.htm#TOC"
@@ -25,7 +29,7 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >--------------------------------</a><a name="qh_ANGLEdegen">-</a>
-  
+
   qh_ANGLEdegen
     indicates degenerate facet in mergeT->angle
 */
@@ -33,10 +37,10 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >--------------------------------</a><a name="qh_ANGLEconcave">-</a>
-  
+
   qh_ANGLEconcave
     offset to indicate concave facets in mergeT->angle
-  
+
   notes:
     concave facets are assigned the range of [2,4] in mergeT->angle
     roundoff error may make the angle less than 2
@@ -45,31 +49,31 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >--------------------------------</a><a name="MRG">-</a>
-  
+
   MRG... (mergeType)
     indicates the type of a merge (mergeT->type)
 */
-typedef enum {	/* in sort order for facet_mergeset */
+typedef enum {  /* in sort order for facet_mergeset */
   MRGnone= 0,
-  MRGcoplanar,		/* centrum coplanar */
-  MRGanglecoplanar,	/* angle coplanar */
-  			/* could detect half concave ridges */
-  MRGconcave,		/* concave ridge */
-  MRGflip,		/* flipped facet. facet1 == facet2 */
-  MRGridge,		/* duplicate ridge (qh_MERGEridge) */
+  MRGcoplanar,          /* centrum coplanar */
+  MRGanglecoplanar,     /* angle coplanar */
+                        /* could detect half concave ridges */
+  MRGconcave,           /* concave ridge */
+  MRGflip,              /* flipped facet. facet1 == facet2 */
+  MRGridge,             /* duplicate ridge (qh_MERGEridge) */
                         /* degen and redundant go onto degen_mergeset */
-  MRGdegen,		/* degenerate facet (not enough neighbors) facet1 == facet2 */
-  MRGredundant,		/* redundant facet (vertex subset) */
-  			/* merge_degenredundant assumes degen < redundant */
-  MRGmirror,	        /* mirror facet from qh_triangulate */
+  MRGdegen,             /* degenerate facet (!enough neighbors) facet1 == facet2 */
+  MRGredundant,         /* redundant facet (vertex subset) */
+                        /* merge_degenredundant assumes degen < redundant */
+  MRGmirror,            /* mirror facet from qh_triangulate */
   ENDmrg
 } mergeType;
 
 /*-<a                             href="qh-merge.htm#TOC"
   >--------------------------------</a><a name="qh_MERGEapex">-</a>
-  
+
   qh_MERGEapex
-    flag for qh_mergefacet() to indicate an apex merge  
+    flag for qh_mergefacet() to indicate an apex merge
 */
 #define qh_MERGEapex     True
 
@@ -77,15 +81,15 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >--------------------------------</a><a name="mergeT">-</a>
-     
+
   mergeT
     structure used to merge facets
 */
 
 typedef struct mergeT mergeT;
-struct mergeT {		/* initialize in qh_appendmergeset */
+struct mergeT {         /* initialize in qh_appendmergeset */
   realT   angle;        /* angle between normals of facet1 and facet2 */
-  facetT *facet1; 	/* will merge facet1 into facet2 */
+  facetT *facet1;       /* will merge facet1 into facet2 */
   facetT *facet2;
   mergeType type;
 };
@@ -95,10 +99,10 @@
 
 /*-<a                             href="qh-merge.htm#TOC"
   >--------------------------------</a><a name="FOREACHmerge_">-</a>
-     
+
   FOREACHmerge_( merges ) {...}
     assign 'merge' to each merge in merges
-       
+
   notes:
     uses 'mergeT *merge, **mergep;'
     if qh_mergefacet(),
@@ -109,66 +113,66 @@
 
 /*============ prototypes in alphabetical order after pre/postmerge =======*/
 
-void    qh_premerge (vertexT *apex, realT maxcentrum, realT maxangle);
-void    qh_postmerge (char *reason, realT maxcentrum, realT maxangle, 
+void    qh_premerge(vertexT *apex, realT maxcentrum, realT maxangle);
+void    qh_postmerge(const char *reason, realT maxcentrum, realT maxangle,
              boolT vneighbors);
-void    qh_all_merges (boolT othermerge, boolT vneighbors);
+void    qh_all_merges(boolT othermerge, boolT vneighbors);
 void    qh_appendmergeset(facetT *facet, facetT *neighbor, mergeType mergetype, realT *angle);
 setT   *qh_basevertices( facetT *samecycle);
-void    qh_checkconnect (void /* qh new_facets */);
-boolT   qh_checkzero (boolT testall);
+void    qh_checkconnect(void /* qh new_facets */);
+boolT   qh_checkzero(boolT testall);
 int     qh_compareangle(const void *p1, const void *p2);
 int     qh_comparemerge(const void *p1, const void *p2);
-int     qh_comparevisit (const void *p1, const void *p2);
-void    qh_copynonconvex (ridgeT *atridge);
-void    qh_degen_redundant_facet (facetT *facet);
-void   	qh_degen_redundant_neighbors (facetT *facet, facetT *delfacet);
-vertexT *qh_find_newvertex (vertexT *oldvertex, setT *vertices, setT *ridges);
-void    qh_findbest_test (boolT testcentrum, facetT *facet, facetT *neighbor,
+int     qh_comparevisit(const void *p1, const void *p2);
+void    qh_copynonconvex(ridgeT *atridge);
+void    qh_degen_redundant_facet(facetT *facet);
+void    qh_degen_redundant_neighbors(facetT *facet, facetT *delfacet);
+vertexT *qh_find_newvertex(vertexT *oldvertex, setT *vertices, setT *ridges);
+void    qh_findbest_test(boolT testcentrum, facetT *facet, facetT *neighbor,
            facetT **bestfacet, realT *distp, realT *mindistp, realT *maxdistp);
 facetT *qh_findbestneighbor(facetT *facet, realT *distp, realT *mindistp, realT *maxdistp);
-void 	qh_flippedmerges(facetT *facetlist, boolT *wasmerge);
-void 	qh_forcedmerges( boolT *wasmerge);
-void	qh_getmergeset(facetT *facetlist);
-void 	qh_getmergeset_initial (facetT *facetlist);
-void    qh_hashridge (setT *hashtable, int hashsize, ridgeT *ridge, vertexT *oldvertex);
-ridgeT *qh_hashridge_find (setT *hashtable, int hashsize, ridgeT *ridge, 
+void    qh_flippedmerges(facetT *facetlist, boolT *wasmerge);
+void    qh_forcedmerges( boolT *wasmerge);
+void    qh_getmergeset(facetT *facetlist);
+void    qh_getmergeset_initial(facetT *facetlist);
+void    qh_hashridge(setT *hashtable, int hashsize, ridgeT *ridge, vertexT *oldvertex);
+ridgeT *qh_hashridge_find(setT *hashtable, int hashsize, ridgeT *ridge,
               vertexT *vertex, vertexT *oldvertex, int *hashslot);
-void 	qh_makeridges(facetT *facet);
+void    qh_makeridges(facetT *facet);
 void    qh_mark_dupridges(facetT *facetlist);
-void    qh_maydropneighbor (facetT *facet);
-int     qh_merge_degenredundant (void);
+void    qh_maydropneighbor(facetT *facet);
+int     qh_merge_degenredundant(void);
 void    qh_merge_nonconvex( facetT *facet1, facetT *facet2, mergeType mergetype);
-void    qh_mergecycle (facetT *samecycle, facetT *newfacet);
-void    qh_mergecycle_all (facetT *facetlist, boolT *wasmerge);
+void    qh_mergecycle(facetT *samecycle, facetT *newfacet);
+void    qh_mergecycle_all(facetT *facetlist, boolT *wasmerge);
 void    qh_mergecycle_facets( facetT *samecycle, facetT *newfacet);
 void    qh_mergecycle_neighbors(facetT *samecycle, facetT *newfacet);
 void    qh_mergecycle_ridges(facetT *samecycle, facetT *newfacet);
 void    qh_mergecycle_vneighbors( facetT *samecycle, facetT *newfacet);
-void 	qh_mergefacet(facetT *facet1, facetT *facet2, realT *mindist, realT *maxdist, boolT mergeapex);
-void    qh_mergefacet2d (facetT *facet1, facetT *facet2);
-void 	qh_mergeneighbors(facetT *facet1, facetT *facet2);
-void 	qh_mergeridges(facetT *facet1, facetT *facet2);
+void    qh_mergefacet(facetT *facet1, facetT *facet2, realT *mindist, realT *maxdist, boolT mergeapex);
+void    qh_mergefacet2d(facetT *facet1, facetT *facet2);
+void    qh_mergeneighbors(facetT *facet1, facetT *facet2);
+void    qh_mergeridges(facetT *facet1, facetT *facet2);
 void    qh_mergesimplex(facetT *facet1, facetT *facet2, boolT mergeapex);
-void    qh_mergevertex_del (vertexT *vertex, facetT *facet1, facetT *facet2);
+void    qh_mergevertex_del(vertexT *vertex, facetT *facet1, facetT *facet2);
 void    qh_mergevertex_neighbors(facetT *facet1, facetT *facet2);
-void	qh_mergevertices(setT *vertices1, setT **vertices);
-setT   *qh_neighbor_intersections (vertexT *vertex);
-void    qh_newvertices (setT *vertices);
-boolT   qh_reducevertices (void);
-vertexT *qh_redundant_vertex (vertexT *vertex);
-boolT   qh_remove_extravertices (facetT *facet);
-vertexT *qh_rename_sharedvertex (vertexT *vertex, facetT *facet);
-void	qh_renameridgevertex(ridgeT *ridge, vertexT *oldvertex, vertexT *newvertex);
+void    qh_mergevertices(setT *vertices1, setT **vertices);
+setT   *qh_neighbor_intersections(vertexT *vertex);
+void    qh_newvertices(setT *vertices);
+boolT   qh_reducevertices(void);
+vertexT *qh_redundant_vertex(vertexT *vertex);
+boolT   qh_remove_extravertices(facetT *facet);
+vertexT *qh_rename_sharedvertex(vertexT *vertex, facetT *facet);
+void    qh_renameridgevertex(ridgeT *ridge, vertexT *oldvertex, vertexT *newvertex);
 void    qh_renamevertex(vertexT *oldvertex, vertexT *newvertex, setT *ridges,
-			facetT *oldfacet, facetT *neighborA);
-boolT 	qh_test_appendmerge (facetT *facet, facetT *neighbor);
-boolT   qh_test_vneighbors (void /* qh newfacet_list */);
-void    qh_tracemerge (facetT *facet1, facetT *facet2);
-void    qh_tracemerging (void);
+                        facetT *oldfacet, facetT *neighborA);
+boolT   qh_test_appendmerge(facetT *facet, facetT *neighbor);
+boolT   qh_test_vneighbors(void /* qh newfacet_list */);
+void    qh_tracemerge(facetT *facet1, facetT *facet2);
+void    qh_tracemerging(void);
 void    qh_updatetested( facetT *facet1, facetT *facet2);
-setT   *qh_vertexridges (vertexT *vertex);
-void    qh_vertexridges_facet (vertexT *vertex, facetT *facet, setT **ridges);
-void    qh_willdelete (facetT *facet, facetT *replace);
+setT   *qh_vertexridges(vertexT *vertex);
+void    qh_vertexridges_facet(vertexT *vertex, facetT *facet, setT **ridges);
+void    qh_willdelete(facetT *facet, facetT *replace);
 
 #endif /* qhDEFmerge */

Modified: trunk/scipy/spatial/qhull/src/poly.c
===================================================================
--- trunk/scipy/spatial/qhull/src/poly.c	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/poly.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,15 +1,17 @@
 /*<html><pre>  -<a                             href="qh-poly.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-   poly.c 
+   poly.c
    implements polygons and simplices
 
-   see qh-poly.htm, poly.h and qhull.h
+   see qh-poly.htm, poly.h and libqhull.h
 
-   infrequent code is in poly2.c 
+   infrequent code is in poly2.c
    (all but top 50 and their callers 12/3/95)
 
-   copyright (c) 1993-2003, The Geometry Center
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/poly.c#26 $$Change: 1171 $
+   $DateTime: 2010/01/09 10:11:25 $$Author: bbarber $
 */
 
 #include "qhull_a.h"
@@ -18,14 +20,14 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="appendfacet">-</a>
-  
+
   qh_appendfacet( facet )
     appends facet to end of qh.facet_list,
 
   returns:
     updates qh.newfacet_list, facet_next, facet_list
     increments qh.numfacets
-  
+
   notes:
     assumes qh.facet_list/facet_tail is defined (createsimplex)
 
@@ -48,13 +50,13 @@
     qh facet_list= facet;
   tail->previous= facet;
   qh num_facets++;
-  trace4((qh ferr, "qh_appendfacet: append f%d to facet_list\n", facet->id));
+  trace4((qh ferr, 4044, "qh_appendfacet: append f%d to facet_list\n", facet->id));
 } /* appendfacet */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="appendvertex">-</a>
-  
+
   qh_appendvertex( vertex )
     appends vertex to end of qh.vertex_list,
 
@@ -67,7 +69,7 @@
     assumes qh.vertex_list/vertex_tail is defined (createsimplex)
 
 */
-void qh_appendvertex (vertexT *vertex) {
+void qh_appendvertex(vertexT *vertex) {
   vertexT *tail= qh vertex_tail;
 
   if (tail == qh newvertex_list)
@@ -81,13 +83,13 @@
     qh vertex_list= vertex;
   tail->previous= vertex;
   qh num_vertices++;
-  trace4((qh ferr, "qh_appendvertex: append v%d to vertex_list\n", vertex->id));
+  trace4((qh ferr, 4045, "qh_appendvertex: append v%d to vertex_list\n", vertex->id));
 } /* appendvertex */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="attachnewfacets">-</a>
-  
+
   qh_attachnewfacets( )
     attach horizon facets to new facets in qh.newfacet_list
     newfacets have neighbor and ridge links to horizon but not vice versa
@@ -95,7 +97,7 @@
 
   returns:
     set qh.NEWfacets
-    horizon facets linked to new facets 
+    horizon facets linked to new facets
       ridges changed from visible facets to new facets
       simplicial ridges deleted
     qh.visible_list, no ridges valid
@@ -124,83 +126,83 @@
           the first ridge of the new facet is the horizon ridge
           link the new facet into the horizon ridge
 */
-void qh_attachnewfacets (void ) {
+void qh_attachnewfacets(void ) {
   facetT *newfacet= NULL, *neighbor, **neighborp, *horizon, *visible;
   ridgeT *ridge, **ridgep;
 
   qh NEWfacets= True;
-  trace3((qh ferr, "qh_attachnewfacets: delete interior ridges\n"));
+  trace3((qh ferr, 3012, "qh_attachnewfacets: delete interior ridges\n"));
   qh visit_id++;
   FORALLvisible_facets {
     visible->visitid= qh visit_id;
     if (visible->ridges) {
       FOREACHridge_(visible->ridges) {
-	neighbor= otherfacet_(ridge, visible);
-	if (neighbor->visitid == qh visit_id
-	    || (!neighbor->visible && neighbor->simplicial)) {
-	  if (!neighbor->visible)  /* delete ridge for simplicial horizon */
-	    qh_setdel (neighbor->ridges, ridge);
-	  qh_setfree (&(ridge->vertices)); /* delete on 2nd visit */
-	  qh_memfree (ridge, sizeof(ridgeT));
-	}
+        neighbor= otherfacet_(ridge, visible);
+        if (neighbor->visitid == qh visit_id
+            || (!neighbor->visible && neighbor->simplicial)) {
+          if (!neighbor->visible)  /* delete ridge for simplicial horizon */
+            qh_setdel(neighbor->ridges, ridge);
+          qh_setfree(&(ridge->vertices)); /* delete on 2nd visit */
+          qh_memfree(ridge, (int)sizeof(ridgeT));
+        }
       }
       SETfirst_(visible->ridges)= NULL;
     }
     SETfirst_(visible->neighbors)= NULL;
   }
-  trace1((qh ferr, "qh_attachnewfacets: attach horizon facets to new facets\n"));
+  trace1((qh ferr, 1017, "qh_attachnewfacets: attach horizon facets to new facets\n"));
   FORALLnew_facets {
     horizon= SETfirstt_(newfacet->neighbors, facetT);
     if (horizon->simplicial) {
       visible= NULL;
       FOREACHneighbor_(horizon) {   /* may have more than one horizon ridge */
-	if (neighbor->visible) {
-	  if (visible) {
-	    if (qh_setequal_skip (newfacet->vertices, 0, horizon->vertices,
-				  SETindex_(horizon->neighbors, neighbor))) {
-	      visible= neighbor;
-	      break;
-	    }
-	  }else
-	    visible= neighbor;
-	}
+        if (neighbor->visible) {
+          if (visible) {
+            if (qh_setequal_skip(newfacet->vertices, 0, horizon->vertices,
+                                  SETindex_(horizon->neighbors, neighbor))) {
+              visible= neighbor;
+              break;
+            }
+          }else
+            visible= neighbor;
+        }
       }
       if (visible) {
-	visible->f.replace= newfacet;
-	qh_setreplace (horizon->neighbors, visible, newfacet);
+        visible->f.replace= newfacet;
+        qh_setreplace(horizon->neighbors, visible, newfacet);
       }else {
-	fprintf (qh ferr, "qhull internal error (qh_attachnewfacets): couldn't find visible facet for horizon f%d of newfacet f%d\n",
-		 horizon->id, newfacet->id);
-	qh_errexit2 (qh_ERRqhull, horizon, newfacet);
+        qh_fprintf(qh ferr, 6102, "qhull internal error (qh_attachnewfacets): couldn't find visible facet for horizon f%d of newfacet f%d\n",
+                 horizon->id, newfacet->id);
+        qh_errexit2 (qh_ERRqhull, horizon, newfacet);
       }
     }else { /* non-simplicial, with a ridge for newfacet */
       FOREACHneighbor_(horizon) {    /* may hold for many new facets */
-	if (neighbor->visible) {
-	  neighbor->f.replace= newfacet;
-	  qh_setdelnth (horizon->neighbors,
-			SETindex_(horizon->neighbors, neighbor));
-	  neighborp--; /* repeat */
-	}
+        if (neighbor->visible) {
+          neighbor->f.replace= newfacet;
+          qh_setdelnth(horizon->neighbors,
+                        SETindex_(horizon->neighbors, neighbor));
+          neighborp--; /* repeat */
+        }
       }
-      qh_setappend (&horizon->neighbors, newfacet);
+      qh_setappend(&horizon->neighbors, newfacet);
       ridge= SETfirstt_(newfacet->ridges, ridgeT);
       if (ridge->top == horizon)
-	ridge->bottom= newfacet;
+        ridge->bottom= newfacet;
       else
-	ridge->top= newfacet;
+        ridge->top= newfacet;
       }
   } /* newfacets */
   if (qh PRINTstatistics) {
     FORALLvisible_facets {
-      if (!visible->f.replace) 
-	zinc_(Zinsidevisible);
+      if (!visible->f.replace)
+        zinc_(Zinsidevisible);
     }
   }
 } /* attachnewfacets */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="checkflipped">-</a>
-  
+
   qh_checkflipped( facet, dist, allerror )
     checks facet orientation to interior point
 
@@ -213,7 +215,7 @@
     False if it flipped orientation (sets facet->flipped)
     distance if non-NULL
 */
-boolT qh_checkflipped (facetT *facet, realT *distp, boolT allerror) {
+boolT qh_checkflipped(facetT *facet, realT *distp, boolT allerror) {
   realT dist;
 
   if (facet->flipped && !distp)
@@ -225,9 +227,9 @@
   if ((allerror && dist > -qh DISTround)|| (!allerror && dist >= 0.0)) {
     facet->flipped= True;
     zzinc_(Zflippedfacets);
-    trace0((qh ferr, "qh_checkflipped: facet f%d is flipped, distance= %6.12g during p%d\n",
+    trace0((qh ferr, 19, "qh_checkflipped: facet f%d is flipped, distance= %6.12g during p%d\n",
               facet->id, dist, qh furthest_id));
-    qh_precision ("flipped facet");
+    qh_precision("flipped facet");
     return False;
   }
   return True;
@@ -235,7 +237,7 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="delfacet">-</a>
-  
+
   qh_delfacet( facet )
     removes facet from facet_list and frees up its memory
 
@@ -245,7 +247,7 @@
 void qh_delfacet(facetT *facet) {
   void **freelistp; /* used !qh_NOmem */
 
-  trace4((qh ferr, "qh_delfacet: delete f%d\n", facet->id));
+  trace4((qh ferr, 4046, "qh_delfacet: delete f%d\n", facet->id));
   if (facet == qh tracefacet)
     qh tracefacet= NULL;
   if (facet == qh GOODclosest)
@@ -267,13 +269,13 @@
     qh_setfree(&(facet->outsideset));
   if (facet->coplanarset)
     qh_setfree(&(facet->coplanarset));
-  qh_memfree_(facet, sizeof(facetT), freelistp);
+  qh_memfree_(facet, (int)sizeof(facetT), freelistp);
 } /* delfacet */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="deletevisible">-</a>
-  
+
   qh_deletevisible()
     delete visible facets and vertices
 
@@ -287,48 +289,48 @@
     new facets in qh.newfacet_list
     uses   qh.visit_id;
 */
-void qh_deletevisible (void /*qh visible_list*/) {
+void qh_deletevisible(void /*qh visible_list*/) {
   facetT *visible, *nextfacet;
   vertexT *vertex, **vertexp;
   int numvisible= 0, numdel= qh_setsize(qh del_vertices);
 
-  trace1((qh ferr, "qh_deletevisible: delete %d visible facets and %d vertices\n",
+  trace1((qh ferr, 1018, "qh_deletevisible: delete %d visible facets and %d vertices\n",
          qh num_visible, numdel));
-  for (visible= qh visible_list; visible && visible->visible; 
+  for (visible= qh visible_list; visible && visible->visible;
                 visible= nextfacet) { /* deleting current */
-    nextfacet= visible->next;        
+    nextfacet= visible->next;
     numvisible++;
     qh_delfacet(visible);
   }
   if (numvisible != qh num_visible) {
-    fprintf (qh ferr, "qhull internal error (qh_deletevisible): qh num_visible %d is not number of visible facets %d\n",
+    qh_fprintf(qh ferr, 6103, "qhull internal error (qh_deletevisible): qh num_visible %d is not number of visible facets %d\n",
              qh num_visible, numvisible);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
   qh num_visible= 0;
   zadd_(Zvisfacettot, numvisible);
   zmax_(Zvisfacetmax, numvisible);
   zzadd_(Zdelvertextot, numdel);
   zmax_(Zdelvertexmax, numdel);
-  FOREACHvertex_(qh del_vertices) 
-    qh_delvertex (vertex);
-  qh_settruncate (qh del_vertices, 0);
+  FOREACHvertex_(qh del_vertices)
+    qh_delvertex(vertex);
+  qh_settruncate(qh del_vertices, 0);
 } /* deletevisible */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="facetintersect">-</a>
-  
+
   qh_facetintersect( facetA, facetB, skipa, skipB, prepend )
     return vertices for intersection of two simplicial facets
     may include 1 prepended entry (if more, need to settemppush)
-    
+
   returns:
     returns set of qh.hull_dim-1 + prepend vertices
     returns skipped index for each test and checks for exactly one
 
   notes:
     does not need settemp since set in quick memory
-  
+
   see also:
     qh_vertexintersect and qh_vertexintersect_new
     use qh_setnew_delnthsorted to get nth ridge (no skip information)
@@ -338,8 +340,8 @@
     locate skipped vertex by scanning facet B's neighbors
     intersect the vertex sets
 */
-setT *qh_facetintersect (facetT *facetA, facetT *facetB,
-			 int *skipA,int *skipB, int prepend) {
+setT *qh_facetintersect(facetT *facetA, facetT *facetB,
+                         int *skipA,int *skipB, int prepend) {
   setT *intersect;
   int dim= qh hull_dim, i, j;
   facetT **neighborsA, **neighborsB;
@@ -354,7 +356,7 @@
   else if (facetB == *neighborsA++)
     *skipA= 2;
   else {
-    for (i= 3; i < dim; i++) {
+    for (i=3; i < dim; i++) {
       if (facetB == *neighborsA++) {
         *skipA= i;
         break;
@@ -368,7 +370,7 @@
   else if (facetA == *neighborsB++)
     *skipB= 2;
   else {
-    for (j= 3; j < dim; j++) {
+    for (j=3; j < dim; j++) {
       if (facetA == *neighborsB++) {
         *skipB= j;
         break;
@@ -376,34 +378,39 @@
     }
   }
   if (i >= dim || j >= dim) {
-    fprintf (qh ferr, "qhull internal error (qh_facetintersect): f%d or f%d not in others neighbors\n",
+    qh_fprintf(qh ferr, 6104, "qhull internal error (qh_facetintersect): f%d or f%d not in others neighbors\n",
             facetA->id, facetB->id);
     qh_errexit2 (qh_ERRqhull, facetA, facetB);
   }
-  intersect= qh_setnew_delnthsorted (facetA->vertices, qh hull_dim, *skipA, prepend);
-  trace4((qh ferr, "qh_facetintersect: f%d skip %d matches f%d skip %d\n",
-	  facetA->id, *skipA, facetB->id, *skipB));
+  intersect= qh_setnew_delnthsorted(facetA->vertices, qh hull_dim, *skipA, prepend);
+  trace4((qh ferr, 4047, "qh_facetintersect: f%d skip %d matches f%d skip %d\n",
+          facetA->id, *skipA, facetB->id, *skipB));
   return(intersect);
 } /* facetintersect */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="gethash">-</a>
-  
+
   qh_gethash( hashsize, set, size, firstindex, skipelem )
     return hashvalue for a set with firstindex and skipelem
 
   notes:
+    returned hash is in [0,hashsize)
     assumes at least firstindex+1 elements
     assumes skipelem is NULL, in set, or part of hash
-    
+
     hashes memory addresses which may change over different runs of the same data
     using sum for hash does badly in high d
 */
-unsigned qh_gethash (int hashsize, setT *set, int size, int firstindex, void *skipelem) {
+int qh_gethash(int hashsize, setT *set, int size, int firstindex, void *skipelem) {
   void **elemp= SETelemaddr_(set, firstindex, void);
   ptr_intT hash = 0, elem;
+  unsigned result;
   int i;
-  unsigned result;
+#ifdef _MSC_VER                   /* Microsoft Visual C++ -- warn about 64-bit issues */
+#pragma warning( push)            /* WARN64 -- ptr_intT holds a 64-bit pointer */
+#pragma warning( disable : 4311)  /* 'type cast': pointer truncation from 'void*' to 'ptr_intT' */
+#endif
 
   switch (size-firstindex) {
   case 1:
@@ -435,22 +442,29 @@
     do {     /* this is about 10% in 10-d */
       if ((elem= (ptr_intT)*elemp++) != (ptr_intT)skipelem) {
         hash ^= (elem << i) + (elem >> (32-i));
-	i += 3;
-	if (i >= 32)
-	  i -= 32;
+        i += 3;
+        if (i >= 32)
+          i -= 32;
       }
-    }while(*elemp);
+    }while (*elemp);
     break;
   }
+  if (hashsize<0) {
+    qh_fprintf(qh ferr, 6232, "qhull internal error: negative hashsize %d passed to qh_gethash [poly.c]\n", hashsize);
+    qh_errexit2 (qh_ERRqhull, NULL, NULL);
+  }
   result= (unsigned)hash;
   result %= (unsigned)hashsize;
-  /* result= 0; for debugging purposes */
+  /* result= 0; for debugging */
   return result;
+#ifdef _MSC_VER
+#pragma warning( pop)
+#endif
 } /* gethash */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="makenewfacet">-</a>
-  
+
   qh_makenewfacet( vertices, toporient, horizon )
     creates a toporient? facet from vertices
 
@@ -468,13 +482,13 @@
 
   FOREACHvertex_(vertices) {
     if (!vertex->newlist) {
-      qh_removevertex (vertex);
-      qh_appendvertex (vertex);
+      qh_removevertex(vertex);
+      qh_appendvertex(vertex);
     }
   }
   newfacet= qh_newfacet();
   newfacet->vertices= vertices;
-  newfacet->toporient= toporient;
+  newfacet->toporient= (unsigned char)toporient;
   if (horizon)
     qh_setappend(&(newfacet->neighbors), horizon);
   qh_appendfacet(newfacet);
@@ -484,7 +498,7 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="makenewplanes">-</a>
-  
+
   qh_makenewplanes()
     make new hyperplanes for facets on qh.newfacet_list
 
@@ -496,23 +510,23 @@
   notes:
     facet->f.samecycle is defined for facet->mergehorizon facets
 */
-void qh_makenewplanes (void /* newfacet_list */) {
+void qh_makenewplanes(void /* newfacet_list */) {
   facetT *newfacet;
 
   FORALLnew_facets {
     if (!newfacet->mergehorizon)
-      qh_setfacetplane (newfacet);  
+      qh_setfacetplane(newfacet);
   }
-  if (qh JOGGLEmax < REALmax/2)  
+  if (qh JOGGLEmax < REALmax/2)
     minimize_(qh min_vertex, -wwval_(Wnewvertexmax));
 } /* makenewplanes */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="makenew_nonsimplicial">-</a>
-  
+
   qh_makenew_nonsimplicial( visible, apex, numnew )
     make new facets for ridges of a visible facet
-    
+
   returns:
     first newfacet, bumps numnew as needed
     attaches new facets if !qh.ONLYgood
@@ -521,13 +535,13 @@
       ridges on newfacet, horizon, and visible
     else
       ridge and neighbors between newfacet and   horizon
-      visible facet's ridges are deleted    
+      visible facet's ridges are deleted
 
   notes:
     qh.visit_id if visible has already been processed
     sets neighbor->seen for building f.samecycle
       assumes all 'seen' flags initially false
-    
+
   design:
     for each ridge of visible facet
       get neighbor of visible facet
@@ -537,16 +551,16 @@
         create a new facet
         if neighbor coplanar
           adds newfacet to f.samecycle for later merging
-        else 
+        else
           updates neighbor's neighbor set
           (checks for non-simplicial facet with multiple ridges to visible facet)
         updates neighbor's ridge set
         (checks for simplicial neighbor to non-simplicial visible facet)
-	(deletes ridge if neighbor is simplicial)
-          
+        (deletes ridge if neighbor is simplicial)
+
 */
 #ifndef qh_NOmerge
-facetT *qh_makenew_nonsimplicial (facetT *visible, vertexT *apex, int *numnew) {
+facetT *qh_makenew_nonsimplicial(facetT *visible, vertexT *apex, int *numnew) {
   void **freelistp; /* used !qh_NOmem */
   ridgeT *ridge, **ridgep;
   facetT *neighbor, *newfacet= NULL, *samecycle;
@@ -560,19 +574,19 @@
     if (neighbor->visible) {
       if (!qh ONLYgood) {
         if (neighbor->visitid == qh visit_id) {
-          qh_setfree (&(ridge->vertices));  /* delete on 2nd visit */
-	  qh_memfree_(ridge, sizeof(ridgeT), freelistp);
-	}
+          qh_setfree(&(ridge->vertices));  /* delete on 2nd visit */
+          qh_memfree_(ridge, (int)sizeof(ridgeT), freelistp);
+        }
       }
     }else {  /* neighbor is an horizon facet */
       toporient= (ridge->top == visible);
-      vertices= qh_setnew (qh hull_dim); /* makes sure this is quick */
-      qh_setappend (&vertices, apex);
-      qh_setappend_set (&vertices, ridge->vertices);
+      vertices= qh_setnew(qh hull_dim); /* makes sure this is quick */
+      qh_setappend(&vertices, apex);
+      qh_setappend_set(&vertices, ridge->vertices);
       newfacet= qh_makenewfacet(vertices, toporient, neighbor);
       (*numnew)++;
       if (neighbor->coplanar) {
-	newfacet->mergehorizon= True;
+        newfacet->mergehorizon= True;
         if (!neighbor->seen) {
           newfacet->f.samecycle= newfacet;
           neighbor->f.newcycle= newfacet;
@@ -580,51 +594,51 @@
           samecycle= neighbor->f.newcycle;
           newfacet->f.samecycle= samecycle->f.samecycle;
           samecycle->f.samecycle= newfacet;
-	}
+        }
       }
       if (qh ONLYgood) {
         if (!neighbor->simplicial)
- 	  qh_setappend(&(newfacet->ridges), ridge);
+          qh_setappend(&(newfacet->ridges), ridge);
       }else {  /* qh_attachnewfacets */
         if (neighbor->seen) {
-	  if (neighbor->simplicial) {
-	    fprintf (qh ferr, "qhull internal error (qh_makenew_nonsimplicial): simplicial f%d sharing two ridges with f%d\n", 
-	           neighbor->id, visible->id);
-	    qh_errexit2 (qh_ERRqhull, neighbor, visible);
-	  }
-	  qh_setappend (&(neighbor->neighbors), newfacet);
-	}else
-          qh_setreplace (neighbor->neighbors, visible, newfacet);
+          if (neighbor->simplicial) {
+            qh_fprintf(qh ferr, 6105, "qhull internal error (qh_makenew_nonsimplicial): simplicial f%d sharing two ridges with f%d\n",
+                   neighbor->id, visible->id);
+            qh_errexit2 (qh_ERRqhull, neighbor, visible);
+          }
+          qh_setappend(&(neighbor->neighbors), newfacet);
+        }else
+          qh_setreplace(neighbor->neighbors, visible, newfacet);
         if (neighbor->simplicial) {
-          qh_setdel (neighbor->ridges, ridge);
-          qh_setfree (&(ridge->vertices)); 
-	  qh_memfree (ridge, sizeof(ridgeT));
-	}else {
- 	  qh_setappend(&(newfacet->ridges), ridge);
- 	  if (toporient)
- 	    ridge->top= newfacet;
- 	  else
- 	    ridge->bottom= newfacet;
- 	}
-      trace4((qh ferr, "qh_makenew_nonsimplicial: created facet f%d from v%d and r%d of horizon f%d\n",
-	    newfacet->id, apex->id, ridgeid, neighbor->id));
+          qh_setdel(neighbor->ridges, ridge);
+          qh_setfree(&(ridge->vertices));
+          qh_memfree(ridge, (int)sizeof(ridgeT));
+        }else {
+          qh_setappend(&(newfacet->ridges), ridge);
+          if (toporient)
+            ridge->top= newfacet;
+          else
+            ridge->bottom= newfacet;
+        }
+      trace4((qh ferr, 4048, "qh_makenew_nonsimplicial: created facet f%d from v%d and r%d of horizon f%d\n",
+            newfacet->id, apex->id, ridgeid, neighbor->id));
       }
     }
-    neighbor->seen= True;        
+    neighbor->seen= True;
   } /* for each ridge */
   if (!qh ONLYgood)
     SETfirst_(visible->ridges)= NULL;
   return newfacet;
 } /* makenew_nonsimplicial */
 #else /* qh_NOmerge */
-facetT *qh_makenew_nonsimplicial (facetT *visible, vertexT *apex, int *numnew) {
+facetT *qh_makenew_nonsimplicial(facetT *visible, vertexT *apex, int *numnew) {
   return NULL;
 }
 #endif /* qh_NOmerge */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="makenew_simplicial">-</a>
-  
+
   qh_makenew_simplicial( visible, apex, numnew )
     make new facets for simplicial visible facet and apex
 
@@ -633,7 +647,7 @@
       neighbors between newfacet and horizon
 
   notes:
-    nop if neighbor->seen or neighbor->visible (see qh_makenew_nonsimplicial)
+    nop if neighbor->seen or neighbor->visible(see qh_makenew_nonsimplicial)
 
   design:
     locate neighboring horizon facet for visible facet
@@ -641,9 +655,9 @@
     create new facet
     if coplanar,
       add new facet to f.samecycle
-    update horizon facet's neighbor list        
+    update horizon facet's neighbor list
 */
-facetT *qh_makenew_simplicial (facetT *visible, vertexT *apex, int *numnew) {
+facetT *qh_makenew_simplicial(facetT *visible, vertexT *apex, int *numnew) {
   facetT *neighbor, **neighborp, *newfacet= NULL;
   setT *vertices;
   boolT flip, toporient;
@@ -654,23 +668,23 @@
       vertices= qh_facetintersect(neighbor,visible, &horizonskip, &visibleskip, 1);
       SETfirst_(vertices)= apex;
       flip= ((horizonskip & 0x1) ^ (visibleskip & 0x1));
-      if (neighbor->toporient)         
-	toporient= horizonskip & 0x1;
+      if (neighbor->toporient)
+        toporient= horizonskip & 0x1;
       else
-	toporient= (horizonskip & 0x1) ^ 0x1;
+        toporient= (horizonskip & 0x1) ^ 0x1;
       newfacet= qh_makenewfacet(vertices, toporient, neighbor);
       (*numnew)++;
       if (neighbor->coplanar && (qh PREmerge || qh MERGEexact)) {
 #ifndef qh_NOmerge
-	newfacet->f.samecycle= newfacet;
-	newfacet->mergehorizon= True;
+        newfacet->f.samecycle= newfacet;
+        newfacet->mergehorizon= True;
 #endif
       }
       if (!qh ONLYgood)
         SETelem_(neighbor->neighbors, horizonskip)= newfacet;
-      trace4((qh ferr, "qh_makenew_simplicial: create facet f%d top %d from v%d and horizon f%d skip %d top %d and visible f%d skip %d, flip? %d\n",
-	    newfacet->id, toporient, apex->id, neighbor->id, horizonskip,
-	      neighbor->toporient, visible->id, visibleskip, flip));
+      trace4((qh ferr, 4049, "qh_makenew_simplicial: create facet f%d top %d from v%d and horizon f%d skip %d top %d and visible f%d skip %d, flip? %d\n",
+            newfacet->id, toporient, apex->id, neighbor->id, horizonskip,
+              neighbor->toporient, visible->id, visibleskip, flip));
     }
   }
   return newfacet;
@@ -678,7 +692,7 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="matchneighbor">-</a>
-  
+
   qh_matchneighbor( newfacet, newskip, hashsize, hashcount )
     either match subridge of newfacet with neighbor or add to hash_table
 
@@ -689,7 +703,7 @@
     ridge is newfacet->vertices w/o newskip vertex
     do not allocate memory (need to free hash_table cleanly)
     uses linear hash chains
-  
+
   see also:
     qh_matchduplicates
 
@@ -707,97 +721,97 @@
             mark both facets with a duplicate ridge
             add other facet (if defined) to hash table
 */
-void qh_matchneighbor (facetT *newfacet, int newskip, int hashsize, int *hashcount) {
+void qh_matchneighbor(facetT *newfacet, int newskip, int hashsize, int *hashcount) {
   boolT newfound= False;   /* True, if new facet is already in hash chain */
   boolT same, ismatch;
   int hash, scan;
   facetT *facet, *matchfacet;
   int skip, matchskip;
 
-  hash= (int)qh_gethash (hashsize, newfacet->vertices, qh hull_dim, 1, 
+  hash= qh_gethash(hashsize, newfacet->vertices, qh hull_dim, 1,
                      SETelem_(newfacet->vertices, newskip));
-  trace4((qh ferr, "qh_matchneighbor: newfacet f%d skip %d hash %d hashcount %d\n",
-	  newfacet->id, newskip, hash, *hashcount));
+  trace4((qh ferr, 4050, "qh_matchneighbor: newfacet f%d skip %d hash %d hashcount %d\n",
+          newfacet->id, newskip, hash, *hashcount));
   zinc_(Zhashlookup);
-  for (scan= hash; (facet= SETelemt_(qh hash_table, scan, facetT)); 
+  for (scan= hash; (facet= SETelemt_(qh hash_table, scan, facetT));
        scan= (++scan >= hashsize ? 0 : scan)) {
     if (facet == newfacet) {
       newfound= True;
       continue;
     }
     zinc_(Zhashtests);
-    if (qh_matchvertices (1, newfacet->vertices, newskip, facet->vertices, &skip, &same)) {
-      if (SETelem_(newfacet->vertices, newskip) == 
+    if (qh_matchvertices(1, newfacet->vertices, newskip, facet->vertices, &skip, &same)) {
+      if (SETelem_(newfacet->vertices, newskip) ==
           SETelem_(facet->vertices, skip)) {
-        qh_precision ("two facets with the same vertices");
-        fprintf (qh ferr, "qhull precision error: Vertex sets are the same for f%d and f%d.  Can not force output.\n",
+        qh_precision("two facets with the same vertices");
+        qh_fprintf(qh ferr, 6106, "qhull precision error: Vertex sets are the same for f%d and f%d.  Can not force output.\n",
           facet->id, newfacet->id);
         qh_errexit2 (qh_ERRprec, facet, newfacet);
       }
-      ismatch= (same == (newfacet->toporient ^ facet->toporient));
+      ismatch= (same == (boolT)((newfacet->toporient ^ facet->toporient)));
       matchfacet= SETelemt_(facet->neighbors, skip, facetT);
       if (ismatch && !matchfacet) {
         SETelem_(facet->neighbors, skip)= newfacet;
         SETelem_(newfacet->neighbors, newskip)= facet;
         (*hashcount)--;
-        trace4((qh ferr, "qh_matchneighbor: f%d skip %d matched with new f%d skip %d\n",
+        trace4((qh ferr, 4051, "qh_matchneighbor: f%d skip %d matched with new f%d skip %d\n",
            facet->id, skip, newfacet->id, newskip));
         return;
       }
       if (!qh PREmerge && !qh MERGEexact) {
-        qh_precision ("a ridge with more than two neighbors");
-	fprintf (qh ferr, "qhull precision error: facets f%d, f%d and f%d meet at a ridge with more than 2 neighbors.  Can not continue.\n",
-		 facet->id, newfacet->id, getid_(matchfacet));
-	qh_errexit2 (qh_ERRprec, facet, newfacet);
+        qh_precision("a ridge with more than two neighbors");
+        qh_fprintf(qh ferr, 6107, "qhull precision error: facets f%d, f%d and f%d meet at a ridge with more than 2 neighbors.  Can not continue.\n",
+                 facet->id, newfacet->id, getid_(matchfacet));
+        qh_errexit2 (qh_ERRprec, facet, newfacet);
       }
       SETelem_(newfacet->neighbors, newskip)= qh_DUPLICATEridge;
       newfacet->dupridge= True;
       if (!newfacet->normal)
-	qh_setfacetplane (newfacet);
-      qh_addhash (newfacet, qh hash_table, hashsize, hash);
+        qh_setfacetplane(newfacet);
+      qh_addhash(newfacet, qh hash_table, hashsize, hash);
       (*hashcount)++;
       if (!facet->normal)
-	qh_setfacetplane (facet);
+        qh_setfacetplane(facet);
       if (matchfacet != qh_DUPLICATEridge) {
-	SETelem_(facet->neighbors, skip)= qh_DUPLICATEridge;
-	facet->dupridge= True;
-	if (!facet->normal)
-	  qh_setfacetplane (facet);
-	if (matchfacet) {
-	  matchskip= qh_setindex (matchfacet->neighbors, facet);
-	  SETelem_(matchfacet->neighbors, matchskip)= qh_DUPLICATEridge;
-	  matchfacet->dupridge= True;
-	  if (!matchfacet->normal)
-	    qh_setfacetplane (matchfacet);
-	  qh_addhash (matchfacet, qh hash_table, hashsize, hash);
-	  *hashcount += 2;
-	}
+        SETelem_(facet->neighbors, skip)= qh_DUPLICATEridge;
+        facet->dupridge= True;
+        if (!facet->normal)
+          qh_setfacetplane(facet);
+        if (matchfacet) {
+          matchskip= qh_setindex(matchfacet->neighbors, facet);
+          SETelem_(matchfacet->neighbors, matchskip)= qh_DUPLICATEridge;
+          matchfacet->dupridge= True;
+          if (!matchfacet->normal)
+            qh_setfacetplane(matchfacet);
+          qh_addhash(matchfacet, qh hash_table, hashsize, hash);
+          *hashcount += 2;
+        }
       }
-      trace4((qh ferr, "qh_matchneighbor: new f%d skip %d duplicates ridge for f%d skip %d matching f%d ismatch %d at hash %d\n",
-	   newfacet->id, newskip, facet->id, skip, 
-	   (matchfacet == qh_DUPLICATEridge ? -2 : getid_(matchfacet)), 
-	   ismatch, hash));
+      trace4((qh ferr, 4052, "qh_matchneighbor: new f%d skip %d duplicates ridge for f%d skip %d matching f%d ismatch %d at hash %d\n",
+           newfacet->id, newskip, facet->id, skip,
+           (matchfacet == qh_DUPLICATEridge ? -2 : getid_(matchfacet)),
+           ismatch, hash));
       return; /* end of duplicate ridge */
     }
   }
-  if (!newfound) 
+  if (!newfound)
     SETelem_(qh hash_table, scan)= newfacet;  /* same as qh_addhash */
   (*hashcount)++;
-  trace4((qh ferr, "qh_matchneighbor: no match for f%d skip %d at hash %d\n",
+  trace4((qh ferr, 4053, "qh_matchneighbor: no match for f%d skip %d at hash %d\n",
            newfacet->id, newskip, hash));
 } /* matchneighbor */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="matchnewfacets">-</a>
-  
+
   qh_matchnewfacets()
     match newfacets in qh.newfacet_list to their newfacet neighbors
 
   returns:
     qh.newfacet_list with full neighbor sets
       get vertices with nth neighbor by deleting nth vertex
-    if qh.PREmerge/MERGEexact or qh.FORCEoutput 
+    if qh.PREmerge/MERGEexact or qh.FORCEoutput
       sets facet->flippped if flipped normal (also prevents point partitioning)
     if duplicate ridges and qh.PREmerge/MERGEexact
       sets facet->dupridge
@@ -819,7 +833,7 @@
         match it with a facet
     check for flipped facets
 */
-void qh_matchnewfacets (void /* qh newfacet_list */) {
+void qh_matchnewfacets(void /* qh newfacet_list */) {
   int numnew=0, hashcount=0, newskip;
   facetT *newfacet, *neighbor;
   int dim= qh hull_dim, hashsize, neighbor_i, neighbor_n;
@@ -828,22 +842,22 @@
   int facet_i, facet_n, numfree= 0;
   facetT *facet;
 #endif
-  
-  trace1((qh ferr, "qh_matchnewfacets: match neighbors for new facets.\n"));
+
+  trace1((qh ferr, 1019, "qh_matchnewfacets: match neighbors for new facets.\n"));
   FORALLnew_facets {
     numnew++;
-    {  /* inline qh_setzero (newfacet->neighbors, 1, qh hull_dim); */
+    {  /* inline qh_setzero(newfacet->neighbors, 1, qh hull_dim); */
       neighbors= newfacet->neighbors;
       neighbors->e[neighbors->maxsize].i= dim+1; /*may be overwritten*/
-      memset ((char *)SETelemaddr_(neighbors, 1, void), 0, dim * SETelemsize);
-    }    
+      memset((char *)SETelemaddr_(neighbors, 1, void), 0, dim * SETelemsize);
+    }
   }
-  qh_newhashtable (numnew*(qh hull_dim-1)); /* twice what is normally needed,
+  qh_newhashtable(numnew*(qh hull_dim-1)); /* twice what is normally needed,
                                      but every ridge could be DUPLICATEridge */
-  hashsize= qh_setsize (qh hash_table);
+  hashsize= qh_setsize(qh hash_table);
   FORALLnew_facets {
     for (newskip=1; newskip<qh hull_dim; newskip++) /* furthest/horizon already matched */
-      qh_matchneighbor (newfacet, newskip, hashsize, &hashcount);
+      qh_matchneighbor(newfacet, newskip, hashsize, &hashcount);
 #if 0   /* use the following to trap hashcount errors */
     {
       int count= 0, k;
@@ -851,18 +865,18 @@
 
       count= 0;
       FORALLfacet_(qh newfacet_list) {  /* newfacet already in use */
-	for (k=1; k < qh hull_dim; k++) {
-	  neighbor= SETelemt_(facet->neighbors, k, facetT);
-	  if (!neighbor || neighbor == qh_DUPLICATEridge)
-	    count++;
-	}
-	if (facet == newfacet)
-	  break;
+        for (k=1; k < qh hull_dim; k++) {
+          neighbor= SETelemt_(facet->neighbors, k, facetT);
+          if (!neighbor || neighbor == qh_DUPLICATEridge)
+            count++;
+        }
+        if (facet == newfacet)
+          break;
       }
       if (count != hashcount) {
-	fprintf (qh ferr, "qh_matchnewfacets: after adding facet %d, hashcount %d != count %d\n",
-		 newfacet->id, hashcount, count);
-	qh_errexit (qh_ERRqhull, newfacet, NULL);
+        qh_fprintf(qh ferr, 8088, "qh_matchnewfacets: after adding facet %d, hashcount %d != count %d\n",
+                 newfacet->id, hashcount, count);
+        qh_errexit(qh_ERRqhull, newfacet, NULL);
       }
     }
 #endif  /* end of trap code */
@@ -872,18 +886,18 @@
       if (newfacet->dupridge) {
         FOREACHneighbor_i_(newfacet) {
           if (neighbor == qh_DUPLICATEridge) {
-            qh_matchduplicates (newfacet, neighbor_i, hashsize, &hashcount);
-         	    /* this may report MERGEfacet */
-	  }
+            qh_matchduplicates(newfacet, neighbor_i, hashsize, &hashcount);
+                    /* this may report MERGEfacet */
+          }
         }
       }
     }
   }
   if (hashcount) {
-    fprintf (qh ferr, "qhull internal error (qh_matchnewfacets): %d neighbors did not match up\n",
+    qh_fprintf(qh ferr, 6108, "qhull internal error (qh_matchnewfacets): %d neighbors did not match up\n",
         hashcount);
-    qh_printhashtable (qh ferr);
-    qh_errexit (qh_ERRqhull, NULL, NULL);
+    qh_printhashtable(qh ferr);
+    qh_errexit(qh_ERRqhull, NULL, NULL);
   }
 #ifndef qh_NOtrace
   if (qh IStracing >= 2) {
@@ -891,26 +905,26 @@
       if (!facet)
         numfree++;
     }
-    fprintf (qh ferr, "qh_matchnewfacets: %d new facets, %d unused hash entries .  hashsize %d\n",
-	     numnew, numfree, qh_setsize (qh hash_table));
+    qh_fprintf(qh ferr, 8089, "qh_matchnewfacets: %d new facets, %d unused hash entries .  hashsize %d\n",
+             numnew, numfree, qh_setsize(qh hash_table));
   }
 #endif /* !qh_NOtrace */
-  qh_setfree (&qh hash_table);
+  qh_setfree(&qh hash_table);
   if (qh PREmerge || qh MERGEexact) {
     if (qh IStracing >= 4)
-      qh_printfacetlist (qh newfacet_list, NULL, qh_ALL);
+      qh_printfacetlist(qh newfacet_list, NULL, qh_ALL);
     FORALLnew_facets {
       if (newfacet->normal)
-	qh_checkflipped (newfacet, NULL, qh_ALL);
+        qh_checkflipped(newfacet, NULL, qh_ALL);
     }
   }else if (qh FORCEoutput)
-    qh_checkflipped_all (qh newfacet_list);  /* prints warnings for flipped */
+    qh_checkflipped_all(qh newfacet_list);  /* prints warnings for flipped */
 } /* matchnewfacets */
 
-    
+
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="matchvertices">-</a>
-  
+
   qh_matchvertices( firstindex, verticesA, skipA, verticesB, skipB, same )
     tests whether vertices match with a single skip
     starts match at firstindex since all new facets have a common vertex
@@ -928,7 +942,7 @@
     scan both sets checking for a match
     test orientation
 */
-boolT qh_matchvertices (int firstindex, setT *verticesA, int skipA, 
+boolT qh_matchvertices(int firstindex, setT *verticesA, int skipA,
        setT *verticesB, int *skipB, boolT *same) {
   vertexT **elemAp, **elemBp, **skipBp=NULL, **skipAp;
 
@@ -941,21 +955,21 @@
         return False;
       skipBp= elemBp;  /* one extra like FOREACH */
     }
-  }while(*(++elemAp));
+  }while (*(++elemAp));
   if (!skipBp)
     skipBp= ++elemBp;
-  *skipB= SETindex_(verticesB, skipB);
-  *same= !(((ptr_intT)skipA & 0x1) ^ ((ptr_intT)*skipB & 0x1));
-  trace4((qh ferr, "qh_matchvertices: matched by skip %d (v%d) and skip %d (v%d) same? %d\n",
-	  skipA, (*skipAp)->id, *skipB, (*(skipBp-1))->id, *same));
-  return (True);
+  *skipB= SETindex_(verticesB, skipB); /* i.e., skipBp - verticesB */
+  *same= !((skipA & 0x1) ^ (*skipB & 0x1)); /* result is 0 or 1 */
+  trace4((qh ferr, 4054, "qh_matchvertices: matched by skip %d(v%d) and skip %d(v%d) same? %d\n",
+          skipA, (*skipAp)->id, *skipB, (*(skipBp-1))->id, *same));
+  return(True);
 } /* matchvertices */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="newfacet">-</a>
-  
+
   qh_newfacet()
-    return a new facet 
+    return a new facet
 
   returns:
     all fields initialized or cleared   (NULL)
@@ -964,9 +978,9 @@
 facetT *qh_newfacet(void) {
   facetT *facet;
   void **freelistp; /* used !qh_NOmem */
-  
-  qh_memalloc_(sizeof(facetT), freelistp, facet, facetT);
-  memset ((char *)facet, 0, sizeof(facetT));
+
+  qh_memalloc_((int)sizeof(facetT), freelistp, facet, facetT);
+  memset((char *)facet, (size_t)0, sizeof(facetT));
   if (qh facet_id == qh tracefacet_id)
     qh tracefacet= facet;
   facet->id= qh facet_id++;
@@ -983,14 +997,14 @@
   facet->simplicial= True;
   facet->good= True;
   facet->newfacet= True;
-  trace4((qh ferr, "qh_newfacet: created facet f%d\n", facet->id));
-  return (facet);
+  trace4((qh ferr, 4055, "qh_newfacet: created facet f%d\n", facet->id));
+  return(facet);
 } /* newfacet */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="newridge">-</a>
-  
+
   qh_newridge()
     return a new ridge
 */
@@ -998,25 +1012,25 @@
   ridgeT *ridge;
   void **freelistp;   /* used !qh_NOmem */
 
-  qh_memalloc_(sizeof(ridgeT), freelistp, ridge, ridgeT);
-  memset ((char *)ridge, 0, sizeof(ridgeT));
+  qh_memalloc_((int)sizeof(ridgeT), freelistp, ridge, ridgeT);
+  memset((char *)ridge, (size_t)0, sizeof(ridgeT));
   zinc_(Ztotridges);
   if (qh ridge_id == 0xFFFFFF) {
-    fprintf(qh ferr, "\
+    qh_fprintf(qh ferr, 7074, "\
 qhull warning: more than %d ridges.  ID field overflows and two ridges\n\
 may have the same identifier.  Otherwise output ok.\n", 0xFFFFFF);
   }
-  ridge->id= qh ridge_id++;     
-  trace4((qh ferr, "qh_newridge: created ridge r%d\n", ridge->id));
-  return (ridge);
+  ridge->id= qh ridge_id++;
+  trace4((qh ferr, 4056, "qh_newridge: created ridge r%d\n", ridge->id));
+  return(ridge);
 } /* newridge */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="pointid">-</a>
-  
+
   qh_pointid(  )
-    return id for a point, 
+    return id for a point,
     returns -3 if null, -2 if interior, or -1 if not known
 
   alternative code:
@@ -1024,30 +1038,32 @@
     id= ((unsigned long)point - (unsigned long)qh.first_point)/qh.normal_size;
 
   notes:
+    WARN64 -- id truncated to 32-bits, at most 2G points
+    NOerrors returned (QhullPoint::id)
     if point not in point array
       the code does a comparison of unrelated pointers.
 */
-int qh_pointid (pointT *point) {
-  long offset, id;
+int qh_pointid(pointT *point) {
+  ptr_intT offset, id;
 
   if (!point)
-    id= -3;
+    return -3;
   else if (point == qh interior_point)
-    id= -2;
+    return -2;
   else if (point >= qh first_point
   && point < qh first_point + qh num_points * qh hull_dim) {
-    offset= point - qh first_point;
+    offset= (ptr_intT)(point - qh first_point);
     id= offset / qh hull_dim;
-  }else if ((id= qh_setindex (qh other_points, point)) != -1)
+  }else if ((id= qh_setindex(qh other_points, point)) != -1)
     id += qh num_points;
   else
-    id= -1;
-  return (int) id;
+    return -1;
+  return (int)id;
 } /* pointid */
-  
+
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="removefacet">-</a>
-  
+
   qh_removefacet( facet )
     unlinks facet from qh.facet_list,
 
@@ -1060,13 +1076,13 @@
 */
 void qh_removefacet(facetT *facet) {
   facetT *next= facet->next, *previous= facet->previous;
-  
+
   if (facet == qh newfacet_list)
     qh newfacet_list= next;
   if (facet == qh facet_next)
     qh facet_next= next;
   if (facet == qh visible_list)
-    qh visible_list= next; 
+    qh visible_list= next;
   if (previous) {
     previous->next= next;
     next->previous= previous;
@@ -1075,23 +1091,23 @@
     qh facet_list->previous= NULL;
   }
   qh num_facets--;
-  trace4((qh ferr, "qh_removefacet: remove f%d from facet_list\n", facet->id));
+  trace4((qh ferr, 4057, "qh_removefacet: remove f%d from facet_list\n", facet->id));
 } /* removefacet */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="removevertex">-</a>
-  
+
   qh_removevertex( vertex )
     unlinks vertex from qh.vertex_list,
 
   returns:
-    updates qh.vertex_list .newvertex_list 
+    updates qh.vertex_list .newvertex_list
     decrements qh.num_vertices
 */
 void qh_removevertex(vertexT *vertex) {
   vertexT *next= vertex->next, *previous= vertex->previous;
-  
+
   if (vertex == qh newvertex_list)
     qh newvertex_list= next;
   if (previous) {
@@ -1102,19 +1118,19 @@
     qh vertex_list->previous= NULL;
   }
   qh num_vertices--;
-  trace4((qh ferr, "qh_removevertex: remove v%d from vertex_list\n", vertex->id));
+  trace4((qh ferr, 4058, "qh_removevertex: remove v%d from vertex_list\n", vertex->id));
 } /* removevertex */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="updatevertices">-</a>
-  
+
   qh_updatevertices()
     update vertex neighbors and delete interior vertices
 
   returns:
     if qh.VERTEXneighbors, updates neighbors for each vertex
-      if qh.newvertex_list, 
+      if qh.newvertex_list,
          removes visible neighbors  from vertex neighbors
       if qh.newfacet_list
          adds new facets to vertex neighbors
@@ -1129,38 +1145,38 @@
         removes visible facets from neighbor lists
         marks unused vertices for deletion
 */
-void qh_updatevertices (void /*qh newvertex_list, newfacet_list, visible_list*/) {
+void qh_updatevertices(void /*qh newvertex_list, newfacet_list, visible_list*/) {
   facetT *newfacet= NULL, *neighbor, **neighborp, *visible;
   vertexT *vertex, **vertexp;
 
-  trace3((qh ferr, "qh_updatevertices: delete interior vertices and update vertex->neighbors\n"));
+  trace3((qh ferr, 3013, "qh_updatevertices: delete interior vertices and update vertex->neighbors\n"));
   if (qh VERTEXneighbors) {
     FORALLvertex_(qh newvertex_list) {
       FOREACHneighbor_(vertex) {
-	if (neighbor->visible) 
-	  SETref_(neighbor)= NULL;
+        if (neighbor->visible)
+          SETref_(neighbor)= NULL;
       }
-      qh_setcompact (vertex->neighbors);
+      qh_setcompact(vertex->neighbors);
     }
     FORALLnew_facets {
       FOREACHvertex_(newfacet->vertices)
-        qh_setappend (&vertex->neighbors, newfacet);
+        qh_setappend(&vertex->neighbors, newfacet);
     }
     FORALLvisible_facets {
       FOREACHvertex_(visible->vertices) {
         if (!vertex->newlist && !vertex->deleted) {
-  	  FOREACHneighbor_(vertex) { /* this can happen under merging */
-	    if (!neighbor->visible)
-	      break;
-	  }
-	  if (neighbor)
-	    qh_setdel (vertex->neighbors, visible);
-	  else {
-	    vertex->deleted= True;
-	    qh_setappend (&qh del_vertices, vertex);
-	    trace2((qh ferr, "qh_updatevertices: delete vertex p%d (v%d) in f%d\n",
-		  qh_pointid(vertex->point), vertex->id, visible->id));
-  	  }
+          FOREACHneighbor_(vertex) { /* this can happen under merging */
+            if (!neighbor->visible)
+              break;
+          }
+          if (neighbor)
+            qh_setdel(vertex->neighbors, visible);
+          else {
+            vertex->deleted= True;
+            qh_setappend(&qh del_vertices, vertex);
+            trace2((qh ferr, 2041, "qh_updatevertices: delete vertex p%d(v%d) in f%d\n",
+                  qh_pointid(vertex->point), vertex->id, visible->id));
+          }
         }
       }
     }
@@ -1169,10 +1185,10 @@
       FOREACHvertex_(visible->vertices) {
         if (!vertex->newlist && !vertex->deleted) {
           vertex->deleted= True;
-	  qh_setappend (&qh del_vertices, vertex);
-	  trace2((qh ferr, "qh_updatevertices: delete vertex p%d (v%d) in f%d\n",
-		  qh_pointid(vertex->point), vertex->id, visible->id));
-  	}
+          qh_setappend(&qh del_vertices, vertex);
+          trace2((qh ferr, 2042, "qh_updatevertices: delete vertex p%d(v%d) in f%d\n",
+                  qh_pointid(vertex->point), vertex->id, visible->id));
+        }
       }
     }
   }

Modified: trunk/scipy/spatial/qhull/src/poly.h
===================================================================
--- trunk/scipy/spatial/qhull/src/poly.h	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/poly.h	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,56 +1,60 @@
 /*<html><pre>  -<a                             href="qh-poly.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-   poly.h 
+   poly.h
    header file for poly.c and poly2.c
 
-   see qh-poly.htm, qhull.h and poly.c
+   see qh-poly.htm, libqhull.h and poly.c
 
-   copyright (c) 1993-2003, The Geometry Center
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/poly.h#22 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 */
 
 #ifndef qhDEFpoly
 #define qhDEFpoly 1
 
+#include "libqhull.h"
+
 /*===============   constants ========================== */
 
 /*-<a                             href="qh-geom.htm#TOC"
   >--------------------------------</a><a name="ALGORITHMfault">-</a>
-  
-  ALGORITHMfault   
+
+  ALGORITHMfault
     use as argument to checkconvex() to report errors during buildhull
 */
 #define qh_ALGORITHMfault 0
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="DATAfault">-</a>
-  
-  DATAfault        
+
+  DATAfault
     use as argument to checkconvex() to report errors during initialhull
 */
 #define qh_DATAfault 1
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="DUPLICATEridge">-</a>
-  
+
   DUPLICATEridge
     special value for facet->neighbor to indicate a duplicate ridge
-  
+
   notes:
     set by matchneighbor, used by matchmatch and mark_dupridge
 */
-#define qh_DUPLICATEridge ( facetT * ) 1L
+#define qh_DUPLICATEridge (facetT *)1L
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="MERGEridge">-</a>
-  
+
   MERGEridge       flag in facet
     special value for facet->neighbor to indicate a merged ridge
-  
+
   notes:
     set by matchneighbor, used by matchmatch and mark_dupridge
 */
-#define qh_MERGEridge ( facetT * ) 2L
+#define qh_MERGEridge (facetT *)2L
 
 
 /*============ -structures- ====================*/
@@ -59,49 +63,49 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FORALLfacet_">-</a>
-  
+
   FORALLfacet_( facetlist ) { ... }
     assign 'facet' to each facet in facetlist
-    
+
   notes:
     uses 'facetT *facet;'
     assumes last facet is a sentinel
-    
+
   see:
     FORALLfacets
 */
-#define FORALLfacet_( facetlist ) if ( facetlist ) for( facet=( facetlist );facet && facet->next;facet=facet->next )
+#define FORALLfacet_( facetlist ) if (facetlist ) for ( facet=( facetlist ); facet && facet->next; facet= facet->next )
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FORALLnew_facets">-</a>
-  
-  FORALLnew_facets { ... } 
+
+  FORALLnew_facets { ... }
     assign 'newfacet' to each facet in qh.newfacet_list
-    
+
   notes:
     uses 'facetT *newfacet;'
     at exit, newfacet==NULL
 */
-#define FORALLnew_facets for( newfacet=qh newfacet_list;newfacet && newfacet->next;newfacet=newfacet->next )
+#define FORALLnew_facets for ( newfacet=qh newfacet_list;newfacet && newfacet->next;newfacet=newfacet->next )
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FORALLvertex_">-</a>
-  
+
   FORALLvertex_( vertexlist ) { ... }
     assign 'vertex' to each vertex in vertexlist
-    
+
   notes:
     uses 'vertexT *vertex;'
     at exit, vertex==NULL
 */
-#define FORALLvertex_( vertexlist ) for ( vertex=( vertexlist );vertex && vertex->next;vertex= vertex->next )
+#define FORALLvertex_( vertexlist ) for (vertex=( vertexlist );vertex && vertex->next;vertex= vertex->next )
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FORALLvisible_facets">-</a>
-  
+
   FORALLvisible_facets { ... }
     assign 'visible' to each visible facet in qh.visible_list
-    
+
   notes:
     uses 'vacetT *visible;'
     at exit, visible==NULL
@@ -110,10 +114,10 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FORALLsame_">-</a>
-  
-  FORALLsame_( newfacet ) { ... } 
+
+  FORALLsame_( newfacet ) { ... }
     assign 'same' to each facet in newfacet->f.samecycle
-    
+
   notes:
     uses 'facetT *same;'
     stops when it returns to newfacet
@@ -122,10 +126,10 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FORALLsame_cycle_">-</a>
-  
-  FORALLsame_cycle_( newfacet ) { ... } 
+
+  FORALLsame_cycle_( newfacet ) { ... }
     assign 'same' to each facet in newfacet->f.samecycle
-    
+
   notes:
     uses 'facetT *same;'
     at exit, same == NULL
@@ -136,13 +140,13 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FOREACHneighborA_">-</a>
-  
+
   FOREACHneighborA_( facet ) { ... }
     assign 'neighborA' to each neighbor in facet->neighbors
-  
+
   FOREACHneighborA_( vertex ) { ... }
     assign 'neighborA' to each neighbor in vertex->neighbors
-  
+
   declare:
     facetT *neighborA, **neighborAp;
 
@@ -153,10 +157,10 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FOREACHvisible_">-</a>
-  
-  FOREACHvisible_( facets ) { ... } 
+
+  FOREACHvisible_( facets ) { ... }
     assign 'visible' to each facet in facets
-    
+
   notes:
     uses 'facetT *facet, *facetp;'
     see <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
@@ -165,10 +169,10 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FOREACHnewfacet_">-</a>
-  
-  FOREACHnewfacet_( facets ) { ... } 
+
+  FOREACHnewfacet_( facets ) { ... }
     assign 'newfacet' to each facet in facets
-    
+
   notes:
     uses 'facetT *newfacet, *newfacetp;'
     see <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
@@ -177,10 +181,10 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FOREACHvertexA_">-</a>
-  
-  FOREACHvertexA_( vertices ) { ... } 
+
+  FOREACHvertexA_( vertices ) { ... }
     assign 'vertexA' to each vertex in vertices
-    
+
   notes:
     uses 'vertexT *vertexA, *vertexAp;'
     see <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
@@ -189,11 +193,11 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >--------------------------------</a><a name="FOREACHvertexreverse12_">-</a>
-  
-  FOREACHvertexreverse12_( vertices ) { ... } 
+
+  FOREACHvertexreverse12_( vertices ) { ... }
     assign 'vertex' to each vertex in vertices
     reverse order of first two vertices
-    
+
   notes:
     uses 'vertexT *vertex, *vertexp;'
     see <a href="qset.h#FOREACHsetelement_">FOREACHsetelement_</a>
@@ -205,87 +209,87 @@
 
 void    qh_appendfacet(facetT *facet);
 void    qh_appendvertex(vertexT *vertex);
-void 	qh_attachnewfacets (void);
-boolT   qh_checkflipped (facetT *facet, realT *dist, boolT allerror);
-void	qh_delfacet(facetT *facet);
-void 	qh_deletevisible(void /*qh visible_list, qh horizon_list*/);
-setT   *qh_facetintersect (facetT *facetA, facetT *facetB, int *skipAp,int *skipBp, int extra);
-unsigned qh_gethash (int hashsize, setT *set, int size, int firstindex, void *skipelem);
+void    qh_attachnewfacets(void);
+boolT   qh_checkflipped(facetT *facet, realT *dist, boolT allerror);
+void    qh_delfacet(facetT *facet);
+void    qh_deletevisible(void /*qh visible_list, qh horizon_list*/);
+setT   *qh_facetintersect(facetT *facetA, facetT *facetB, int *skipAp,int *skipBp, int extra);
+int     qh_gethash(int hashsize, setT *set, int size, int firstindex, void *skipelem);
 facetT *qh_makenewfacet(setT *vertices, boolT toporient, facetT *facet);
-void    qh_makenewplanes ( void /* newfacet_list */);
-facetT *qh_makenew_nonsimplicial (facetT *visible, vertexT *apex, int *numnew);
-facetT *qh_makenew_simplicial (facetT *visible, vertexT *apex, int *numnew);
-void    qh_matchneighbor (facetT *newfacet, int newskip, int hashsize,
-			  int *hashcount);
-void	qh_matchnewfacets (void);
-boolT   qh_matchvertices (int firstindex, setT *verticesA, int skipA, 
-			  setT *verticesB, int *skipB, boolT *same);
+void    qh_makenewplanes(void /* newfacet_list */);
+facetT *qh_makenew_nonsimplicial(facetT *visible, vertexT *apex, int *numnew);
+facetT *qh_makenew_simplicial(facetT *visible, vertexT *apex, int *numnew);
+void    qh_matchneighbor(facetT *newfacet, int newskip, int hashsize,
+                          int *hashcount);
+void    qh_matchnewfacets(void);
+boolT   qh_matchvertices(int firstindex, setT *verticesA, int skipA,
+                          setT *verticesB, int *skipB, boolT *same);
 facetT *qh_newfacet(void);
 ridgeT *qh_newridge(void);
-int     qh_pointid (pointT *point);
-void 	qh_removefacet(facetT *facet);
-void 	qh_removevertex(vertexT *vertex);
-void    qh_updatevertices (void);
+int     qh_pointid(pointT *point);
+void    qh_removefacet(facetT *facet);
+void    qh_removevertex(vertexT *vertex);
+void    qh_updatevertices(void);
 
 
 /*========== -prototypes poly2.c in alphabetical order ===========*/
 
-void    qh_addhash (void* newelem, setT *hashtable, int hashsize, unsigned hash);
-void 	qh_check_bestdist (void);
-void    qh_check_maxout (void);
-void    qh_check_output (void);
-void    qh_check_point (pointT *point, facetT *facet, realT *maxoutside, realT *maxdist, facetT **errfacet1, facetT **errfacet2);
-void   	qh_check_points(void);
-void 	qh_checkconvex(facetT *facetlist, int fault);
+void    qh_addhash(void* newelem, setT *hashtable, int hashsize, int hash);
+void    qh_check_bestdist(void);
+void    qh_check_maxout(void);
+void    qh_check_output(void);
+void    qh_check_point(pointT *point, facetT *facet, realT *maxoutside, realT *maxdist, facetT **errfacet1, facetT **errfacet2);
+void    qh_check_points(void);
+void    qh_checkconvex(facetT *facetlist, int fault);
 void    qh_checkfacet(facetT *facet, boolT newmerge, boolT *waserrorp);
-void 	qh_checkflipped_all (facetT *facetlist);
-void 	qh_checkpolygon(facetT *facetlist);
-void    qh_checkvertex (vertexT *vertex);
-void 	qh_clearcenters (qh_CENTER type);
-void 	qh_createsimplex(setT *vertices);
-void 	qh_delridge(ridgeT *ridge);
-void    qh_delvertex (vertexT *vertex);
-setT   *qh_facet3vertex (facetT *facet);
-facetT *qh_findbestfacet (pointT *point, boolT bestoutside,
+void    qh_checkflipped_all(facetT *facetlist);
+void    qh_checkpolygon(facetT *facetlist);
+void    qh_checkvertex(vertexT *vertex);
+void    qh_clearcenters(qh_CENTER type);
+void    qh_createsimplex(setT *vertices);
+void    qh_delridge(ridgeT *ridge);
+void    qh_delvertex(vertexT *vertex);
+setT   *qh_facet3vertex(facetT *facet);
+facetT *qh_findbestfacet(pointT *point, boolT bestoutside,
            realT *bestdist, boolT *isoutside);
-facetT *qh_findbestlower (facetT *upperfacet, pointT *point, realT *bestdistp, int *numpart);
-facetT *qh_findfacet_all (pointT *point, realT *bestdist, boolT *isoutside,
-			  int *numpart);
-int 	qh_findgood (facetT *facetlist, int goodhorizon);
-void 	qh_findgood_all (facetT *facetlist);
-void    qh_furthestnext (void /* qh facet_list */);
-void    qh_furthestout (facetT *facet);
-void    qh_infiniteloop (facetT *facet);
-void 	qh_initbuild(void);
-void 	qh_initialhull(setT *vertices);
+facetT *qh_findbestlower(facetT *upperfacet, pointT *point, realT *bestdistp, int *numpart);
+facetT *qh_findfacet_all(pointT *point, realT *bestdist, boolT *isoutside,
+                          int *numpart);
+int     qh_findgood(facetT *facetlist, int goodhorizon);
+void    qh_findgood_all(facetT *facetlist);
+void    qh_furthestnext(void /* qh facet_list */);
+void    qh_furthestout(facetT *facet);
+void    qh_infiniteloop(facetT *facet);
+void    qh_initbuild(void);
+void    qh_initialhull(setT *vertices);
 setT   *qh_initialvertices(int dim, setT *maxpoints, pointT *points, int numpoints);
-vertexT *qh_isvertex (pointT *point, setT *vertices);
-vertexT *qh_makenewfacets (pointT *point /*horizon_list, visible_list*/);
-void    qh_matchduplicates (facetT *atfacet, int atskip, int hashsize, int *hashcount);
-void    qh_nearcoplanar ( void /* qh.facet_list */);
-vertexT *qh_nearvertex (facetT *facet, pointT *point, realT *bestdistp);
-int 	qh_newhashtable(int newsize);
+vertexT *qh_isvertex(pointT *point, setT *vertices);
+vertexT *qh_makenewfacets(pointT *point /*horizon_list, visible_list*/);
+void    qh_matchduplicates(facetT *atfacet, int atskip, int hashsize, int *hashcount);
+void    qh_nearcoplanar(void /* qh.facet_list */);
+vertexT *qh_nearvertex(facetT *facet, pointT *point, realT *bestdistp);
+int     qh_newhashtable(int newsize);
 vertexT *qh_newvertex(pointT *point);
-ridgeT *qh_nextridge3d (ridgeT *atridge, facetT *facet, vertexT **vertexp);
-void    qh_outcoplanar (void /* facet_list */);
-pointT *qh_point (int id);
-void 	qh_point_add (setT *set, pointT *point, void *elem);
-setT   *qh_pointfacet (void /*qh facet_list*/);
-setT   *qh_pointvertex (void /*qh facet_list*/);
-void 	qh_prependfacet(facetT *facet, facetT **facetlist);
-void	qh_printhashtable(FILE *fp);
-void    qh_printlists (void);
-void    qh_resetlists (boolT stats, boolT resetVisible /*qh newvertex_list newfacet_list visible_list*/);
-void    qh_setvoronoi_all (void);
-void	qh_triangulate (void /*qh facet_list*/);
-void    qh_triangulate_facet (facetT *facetA, vertexT **first_vertex);
-void    qh_triangulate_link (facetT *oldfacetA, facetT *facetA, facetT *oldfacetB, facetT *facetB);
-void	qh_triangulate_mirror (facetT *facetA, facetT *facetB);
-void    qh_triangulate_null (facetT *facetA);
+ridgeT *qh_nextridge3d(ridgeT *atridge, facetT *facet, vertexT **vertexp);
+void    qh_outcoplanar(void /* facet_list */);
+pointT *qh_point(int id);
+void    qh_point_add(setT *set, pointT *point, void *elem);
+setT   *qh_pointfacet(void /*qh facet_list*/);
+setT   *qh_pointvertex(void /*qh facet_list*/);
+void    qh_prependfacet(facetT *facet, facetT **facetlist);
+void    qh_printhashtable(FILE *fp);
+void    qh_printlists(void);
+void    qh_resetlists(boolT stats, boolT resetVisible /*qh newvertex_list newfacet_list visible_list*/);
+void    qh_setvoronoi_all(void);
+void    qh_triangulate(void /*qh facet_list*/);
+void    qh_triangulate_facet(facetT *facetA, vertexT **first_vertex);
+void    qh_triangulate_link(facetT *oldfacetA, facetT *facetA, facetT *oldfacetB, facetT *facetB);
+void    qh_triangulate_mirror(facetT *facetA, facetT *facetB);
+void    qh_triangulate_null(facetT *facetA);
 void    qh_vertexintersect(setT **vertexsetA,setT *vertexsetB);
 setT   *qh_vertexintersect_new(setT *vertexsetA,setT *vertexsetB);
-void    qh_vertexneighbors (void /*qh facet_list*/);
-boolT 	qh_vertexsubset(setT *vertexsetA, setT *vertexsetB);
+void    qh_vertexneighbors(void /*qh facet_list*/);
+boolT   qh_vertexsubset(setT *vertexsetA, setT *vertexsetB);
 
 
 #endif /* qhDEFpoly */

Modified: trunk/scipy/spatial/qhull/src/poly2.c
===================================================================
--- trunk/scipy/spatial/qhull/src/poly2.c	2010-11-14 21:38:04 UTC (rev 6901)
+++ trunk/scipy/spatial/qhull/src/poly2.c	2010-11-16 21:18:37 UTC (rev 6902)
@@ -1,14 +1,16 @@
 /*<html><pre>  -<a                             href="qh-poly.htm"
   >-------------------------------</a><a name="TOP">-</a>
 
-   poly2.c 
+   poly2.c
    implements polygons and simplices
 
-   see qh-poly.htm, poly.h and qhull.h
+   see qh-poly.htm, poly.h and libqhull.h
 
    frequently used code is in poly.c
 
-   copyright (c) 1993-2003, The Geometry Center
+   copyright (c) 1993-2010 The Geometry Center.
+   $Id: //product/qhull/main/rel/src/poly2.c#40 $$Change: 1164 $
+   $DateTime: 2010/01/07 21:52:00 $$Author: bbarber $
 */
 
 #include "qhull_a.h"
@@ -17,15 +19,15 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="addhash">-</a>
-  
+
   qh_addhash( newelem, hashtable, hashsize, hash )
     add newelem to linear hash table at hash if not already there
 */
-void qh_addhash (void* newelem, setT *hashtable, int hashsize, unsigned hash) {
+void qh_addhash(void* newelem, setT *hashtable, int hashsize, int hash) {
   int scan;
   void *elem;
 
-  for (scan= (int)hash; (elem= SETelem_(hashtable, scan)); 
+  for (scan= (int)hash; (elem= SETelem_(hashtable, scan));
        scan= (++scan >= hashsize ? 0 : scan)) {
     if (elem == newelem)
       break;
@@ -37,13 +39,13 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="check_bestdist">-</a>
-  
+
   qh_check_bestdist()
     check that all points are within max_outside of the nearest facet
     if qh.ONLYgood,
       ignores !good facets
 
-  see: 
+  see:
     qh_check_maxout(), qh_outerinner()
 
   notes:
@@ -61,27 +63,27 @@
       find the best facet for the point and check all coplanar facets
       error if point is outside of facet
 */
-void qh_check_bestdist (void) {
+void qh_check_bestdist(void) {
   boolT waserror= False, unassigned;
   facetT *facet, *bestfacet, *errfacet1= NULL, *errfacet2= NULL;
-  facetT *facetlist; 
+  facetT *facetlist;
   realT dist, maxoutside, maxdist= -REALmax;
   pointT *point;
   int numpart= 0, facet_i, facet_n, notgood= 0, notverified= 0;
   setT *facets;
 
-  trace1((qh ferr, "qh_check_bestdist: check points below nearest facet.  Facet_list f%d\n",
+  trace1((qh ferr, 1020, "qh_check_bestdist: check points below nearest facet.  Facet_list f%d\n",
       qh facet_list->id));
   maxoutside= qh_maxouter();
   maxoutside += qh DISTround;
   /* one more qh.DISTround for check computation */
-  trace1((qh ferr, "qh_check_bestdist: check that all points are within %2.2g of best facet\n", maxoutside));
-  facets= qh_pointfacet (/*qh facet_list*/);
+  trace1((qh ferr, 1021, "qh_check_bestdist: check that all points are within %2.2g of best facet\n", maxoutside));
+  facets= qh_pointfacet(/*qh facet_list*/);
   if (!qh_QUICKhelp && qh PRINTprecision)
-    fprintf (qh ferr, "\n\
+    qh_fprintf(qh ferr, 8091, "\n\
 qhull output completed.  Verifying that %d points are\n\
 below %2.2g of the nearest %sfacet.\n",
-	     qh_setsize(facets), maxoutside, (qh ONLYgood ?  "good " : ""));
+             qh_setsize(facets), maxoutside, (qh ONLYgood ?  "good " : ""));
   FOREACHfacet_i_(facets) {  /* for each point with facet assignment */
     if (facet)
       unassigned= False;
@@ -94,45 +96,44 @@
       continue;
     qh_distplane(point, facet, &dist);
     numpart++;
-    bestfacet= qh_findbesthorizon (!qh_IScheckmax, point, facet, qh_NOupper, &dist, &numpart);
+    bestfacet= qh_findbesthorizon(!qh_IScheckmax, point, facet, qh_NOupper, &dist, &numpart);
     /* occurs after statistics reported */
     maximize_(maxdist, dist);
     if (dist > maxoutside) {
-      if (qh ONLYgood && !bestfacet->good 
-	  && !((bestfacet= qh_findgooddist (point, bestfacet, &dist, &facetlist))
-	       && dist > maxoutside))
-	notgood++;
+      if (qh ONLYgood && !bestfacet->good
+          && !((bestfacet= qh_findgooddist(point, bestfacet, &dist, &facetlist))
+               && dist > maxoutside))
+        notgood++;
       else {
-	waserror= True;
-	fprintf(qh ferr, "qhull precision error: point p%d is outside facet f%d, distance= %6.8g maxoutside= %6.8g\n", 
-		facet_i, bestfacet->id, dist, maxoutside);
-	if (errfacet1 != bestfacet) {
-	  errfacet2= errfacet1;
-	  errfacet1= bestfacet;
-	}
+        waserror= True;
+        qh_fprintf(qh ferr, 6109, "qhull precision error: point p%d is outside facet f%d, distance= %6.8g maxoutside= %6.8g\n",
+                facet_i, bestfacet->id, dist, maxoutside);
+        if (errfacet1 != bestfacet) {
+          errfacet2= errfacet1;
+          errfacet1= bestfacet;
+        }
       }
     }else if (unassigned && dist < -qh MAXcoplanar)
       notverified++;
   }
-  qh_settempfree (&facets);
-  if (notverified && !qh DELAUNAY && !qh_QUICKhelp && qh PRINTprecision) 
-    fprintf(qh ferr, "\n%d points were well inside the hull.  If the hull contains\n\
+  qh_settempfree(&facets);
+  if (notverified && !qh DELAUNAY && !qh_QUICKhelp && qh PRINTprecision)
+    qh_fprintf(qh ferr, 8092, "\n%d points were well inside the hull.  If the hull contains\n\
 a lens-shaped component, these points were not verified.  Use\n\
-options 'Qci Tv' to verify all points.\n", notverified); 
+options 'Qci Tv' to verify all points.\n", notverified);
   if (maxdist > qh outside_err) {
-    fprintf( qh ferr, "qhull precision error (qh_check_bestdist): a coplanar point is %6.2g from convex hull.  The maximum value (qh.outside_err) is %6.2g\n",
+    qh_fprintf(qh ferr, 6110, "qhull precision error (qh_check_bestdist): a coplanar point is %6.2g from convex hull.  The maximum value(qh.outside_err) is %6.2g\n",
               maxdist, qh outside_err);
     qh_errexit2 (qh_ERRprec, errfacet1, errfacet2);
   }else if (waserror && qh outside_err > REALmax/2)
     qh_errexit2 (qh_ERRprec, errfacet1, errfacet2);
-  else if (waserror)
-    ;                       /* the error was logged to qh.ferr but does not effect the output */
-  trace0((qh ferr, "qh_check_bestdist: max distance outside %2.2g\n", maxdist));
+  /* else if waserror, the error was logged to qh.ferr but does not effect the output */
+  trace0((qh ferr, 20, "qh_check_bestdist: max distance outside %2.2g\n", maxdist));
 } /* check_bestdist */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="check_maxout">-</a>
-  
+
   qh_check_maxout()
     updates qh.max_outside by checking all points against bestfacet
     if qh.ONLYgood, ignores !good facets
@@ -140,13 +141,13 @@
   returns:
     updates facet->maxoutside via qh_findbesthorizon()
     sets qh.maxoutdone
-    if printing qh.min_vertex (qh_outerinner), 
+    if printing qh.min_vertex (qh_outerinner),
       it is updated to the current vertices
     removes inside/coplanar points from coplanarset as needed
 
   notes:
-    defines coplanar as min_vertex instead of MAXcoplanar 
-    may not need to check near-inside points because of qh.MAXcoplanar 
+    defines coplanar as min_vertex instead of MAXcoplanar
+    may not need to check near-inside points because of qh.MAXcoplanar
       and qh.KEEPnearinside (before it was -DISTround)
 
   see also:
@@ -163,7 +164,7 @@
     remove near-inside points from coplanar sets
 */
 #ifndef qh_NOmerge
-void qh_check_maxout (void) {
+void qh_check_maxout(void) {
   facetT *facet, *bestfacet, *neighbor, **neighborp, *facetlist;
   realT dist, maxoutside, minvertex, old_maxoutside;
   pointT *point;
@@ -171,94 +172,94 @@
   setT *facets, *vertices;
   vertexT *vertex;
 
-  trace1((qh ferr, "qh_check_maxout: check and update maxoutside for each facet.\n"));
+  trace1((qh ferr, 1022, "qh_check_maxout: check and update maxoutside for each facet.\n"));
   maxoutside= minvertex= 0;
-  if (qh VERTEXneighbors 
-  && (qh PRINTsummary || qh KEEPinside || qh KEEPcoplanar 
-	|| qh TRACElevel || qh PRINTstatistics
-	|| qh PRINTout[0] == qh_PRINTsummary || qh PRINTout[0] == qh_PRINTnone)) { 
-    trace1((qh ferr, "qh_check_maxout: determine actual maxoutside and minvertex\n"));
-    vertices= qh_pointvertex (/*qh facet_list*/);
+  if (qh VERTEXneighbors
+  && (qh PRINTsummary || qh KEEPinside || qh KEEPcoplanar
+        || qh TRACElevel || qh PRINTstatistics
+        || qh PRINTout[0] == qh_PRINTsummary || qh PRINTout[0] == qh_PRINTnone)) {
+    trace1((qh ferr, 1023, "qh_check_maxout: determine actual maxoutside and minvertex\n"));
+    vertices= qh_pointvertex(/*qh facet_list*/);
     FORALLvertices {
       FOREACHneighbor_(vertex) {
         zinc_(Zdistvertex);  /* distance also computed by main loop below */
-	qh_distplane (vertex->point, neighbor, &dist);
-	minimize_(minvertex, dist);
-	if (-dist > qh TRACEdist || dist > qh TRACEdist 
-	|| neighbor == qh tracefacet || vertex == qh tracevertex)
-	  fprintf (qh ferr, "qh_check_maxout: p%d (v%d) is %.2g from f%d\n",
-		    qh_pointid (vertex->point), vertex->id, dist, neighbor->id);
+        qh_distplane(vertex->point, neighbor, &dist);
+        minimize_(minvertex, dist);
+        if (-dist > qh TRACEdist || dist > qh TRACEdist
+        || neighbor == qh tracefacet || vertex == qh tracevertex)
+          qh_fprintf(qh ferr, 8093, "qh_check_maxout: p%d(v%d) is %.2g from f%d\n",
+                    qh_pointid(vertex->point), vertex->id, dist, neighbor->id);
       }
     }
     if (qh MERGING) {
       wmin_(Wminvertex, qh min_vertex);
     }
     qh min_vertex= minvertex;
-    qh_settempfree (&vertices);  
+    qh_settempfree(&vertices);
   }
-  facets= qh_pointfacet (/*qh facet_list*/);
+  facets= qh_pointfacet(/*qh facet_list*/);
   do {
     old_maxoutside= fmax_(qh max_outside, maxoutside);
     FOREACHfacet_i_(facets) {     /* for each point with facet assignment */
-      if (facet) { 
-	point= qh_point(facet_i);
-	if (point == qh GOODpointp)
-	  continue;
-	zinc_(Ztotcheck);
-	qh_distplane(point, facet, &dist);
-	numpart++;
-	bestfacet= qh_findbesthorizon (qh_IScheckmax, point, facet, !qh_NOupper, &dist, &numpart);
-	if (bestfacet && dist > maxoutside) {
-	  if (qh ONLYgood && !bestfacet->good 
-	  && !((bestfacet= qh_findgooddist (point, bestfacet, &dist, &facetlist))
-	       && dist > maxoutside))
-	    notgood++;
-	  else
-	    maxoutside= dist;
-	}
-	if (dist > qh TRACEdist || (bestfacet && bestfacet == qh tracefacet))
-	  fprintf (qh ferr, "qh_check_maxout: p%d is %.2g above f%d\n",
-		     qh_pointid (point), dist, bestfacet->id);
+      if (facet) {
+        point= qh_point(facet_i);
+        if (point == qh GOODpointp)
+          continue;
+        zzinc_(Ztotcheck);
+        qh_distplane(point, facet, &dist);
+        numpart++;
+        bestfacet= qh_findbesthorizon(qh_IScheckmax, point, facet, !qh_NOupper, &dist, &numpart);
+        if (bestfacet && dist > maxoutside) {
+          if (qh ONLYgood && !bestfacet->good
+          && !((bestfacet= qh_findgooddist(point, bestfacet, &dist, &facetlist))
+               && dist > maxoutside))
+            notgood++;
+          else
+            maxoutside= dist;
+        }
+        if (dist > qh TRACEdist || (bestfacet && bestfacet == qh tracefacet))
+          qh_fprintf(qh ferr, 8094, "qh_check_maxout: p%d is %.2g above f%d\n",
+                     qh_pointid(point), dist, bestfacet->id);
       }
     }
-  }while 
+  }while
     (maxoutside > 2*old_maxoutside);
-    /* if qh.maxoutside increases substantially, qh_SEARCHdist is not valid 
+    /* if qh.maxoutside increases substantially, qh_SEARCHdist is not valid
           e.g., RBOX 5000 s Z1 G1e-13 t1001200614 | qhull */
   zzadd_(Zcheckpart, numpart);
-  qh_settempfree (&facets);
+  qh_settempfree(&facets);
   wval_(Wmaxout)= maxoutside - qh max_outside;
   wmax_(Wmaxoutside, qh max_outside);
   qh max_outside= maxoutside;
-  qh_nearcoplanar (/*qh.facet_list*/);
+  qh_nearcoplanar(/*qh.facet_list*/);
   qh maxoutdone= True;
-  trace1((qh ferr, "qh_check_maxout: maxoutside %2.2g, min_vertex %2.2g, outside of not good %d\n",
+  trace1((qh ferr, 1024, "qh_check_maxout: maxoutside %2.2g, min_vertex %2.2g, outside of not good %d\n",
        maxoutside, qh min_vertex, notgood));
 } /* check_maxout */
 #else /* qh_NOmerge */
-void qh_check_maxout (void) {
+void qh_check_maxout(void) {
 }
 #endif
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="check_output">-</a>
-  
+
   qh_check_output()
     performs the checks at the end of qhull algorithm
     Maybe called after voronoi output.  Will recompute otherwise centrums are Voronoi centers instead
 */
-void qh_check_output (void) {
+void qh_check_output(void) {
   int i;
 
   if (qh STOPcone)
     return;
   if (qh VERIFYoutput | qh IStracing | qh CHECKfrequently) {
-    qh_checkpolygon (qh facet_list);
-    qh_checkflipped_all (qh facet_list);
-    qh_checkconvex (qh facet_list, qh_ALGORITHMfault);
-  }else if (!qh MERGING && qh_newstats (qhstat precision, &i)) {
-    qh_checkflipped_all (qh facet_list);
-    qh_checkconvex (qh facet_list, qh_ALGORITHMfault);
+    qh_checkpolygon(qh facet_list);
+    qh_checkflipped_all(qh facet_list);
+    qh_checkconvex(qh facet_list, qh_ALGORITHMfault);
+  }else if (!qh MERGING && qh_newstats(qhstat precision, &i)) {
+    qh_checkflipped_all(qh facet_list);
+    qh_checkconvex(qh facet_list, qh_ALGORITHMfault);
   }
 } /* check_output */
 
@@ -266,11 +267,11 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="check_point">-</a>
-  
+
   qh_check_point( point, facet, maxoutside, maxdist, errfacet1, errfacet2 )
     check that point is less than maxoutside from facet
 */
-void qh_check_point (pointT *point, facetT *facet, realT *maxoutside, realT *maxdist, facetT **errfacet1, facetT **errfacet2) {
+void qh_check_point(pointT *point, facetT *facet, realT *maxoutside, realT *maxdist, facetT **errfacet1, facetT **errfacet2) {
   realT dist;
 
   /* occurs after statistics reported */
@@ -280,8 +281,8 @@
       *errfacet2= *errfacet1;
       *errfacet1= facet;
     }
-    fprintf(qh ferr, "qhull precision error: point p%d is outside facet f%d, distance= %6.8g maxoutside= %6.8g\n", 
-	      qh_pointid(point), facet->id, dist, *maxoutside);
+    qh_fprintf(qh ferr, 6111, "qhull precision error: point p%d is outside facet f%d, distance= %6.8g maxoutside= %6.8g\n",
+              qh_pointid(point), facet->id, dist, *maxoutside);
   }
   maximize_(*maxdist, dist);
 } /* qh_check_point */
@@ -289,12 +290,12 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="check_points">-</a>
-  
+
   qh_check_points()
     checks that all points are inside all facets
 
   notes:
-    if many points and qh_check_maxout not called (i.e., !qh.MERGING), 
+    if many points and qh_check_maxout not called (i.e., !qh.MERGING),
        calls qh_findbesthorizon (seldom done).
     ignores flipped facets
     maxoutside includes 2 qh.DISTrounds
@@ -310,7 +311,7 @@
         for all points
           check that point is inside facet
 */
-void qh_check_points (void) {
+void qh_check_points(void) {
   facetT *facet, *errfacet1= NULL, *errfacet2= NULL;
   realT total, maxoutside, maxdist= -REALmax;
   pointT *point, **pointp, *pointtemp;
@@ -319,16 +320,15 @@
   maxoutside= qh_maxouter();
   maxoutside += qh DISTround;
   /* one more qh.DISTround for check computation */
-  trace1((qh ferr, "qh_check_points: check all points below %2.2g of all facet planes\n",
-	  maxoutside));
+  trace1((qh ferr, 1025, "qh_check_points: check all points below %2.2g of all facet planes\n",
+          maxoutside));
   if (qh num_good)   /* miss counts other_points and !good facets */
-     total= (float) qh num_good * qh num_points;
+     total= (float)qh num_good * (float)qh num_points;
   else
-     total= (float) qh num_facets * qh num_points;
+     total= (float)qh num_facets * (float)qh num_points;
   if (total >= qh_VERIFYdirect && !qh maxoutdone) {
     if (!qh_QUICKhelp && qh SKIPcheckmax && qh MERGING)
-      fprintf (qh ferr, "\n\
-qhull input warning: merging without checking outer planes ('Q5' or 'Po').\n\
+      qh_fprintf(qh ferr, 7075, "qhull input warning: merging without checking outer planes('Q5' or 'Po').\n\
 Verify may report that a point is outside of a facet.\n");
     qh_check_bestdist();
   }else {
@@ -338,26 +338,24 @@
       testouter= False;
     if (!qh_QUICKhelp) {
       if (qh MERGEexact)
-	fprintf (qh ferr, "\n\
-qhull input warning: exact merge ('Qx').  Verify may report that a point\n\
+        qh_fprintf(qh ferr, 7076, "qhull input warning: exact merge ('Qx').  Verify may report that a point\n\
 is outside of a facet.  See qh-optq.htm#Qx\n");
       else if (qh SKIPcheckmax || qh NOnearinside)
-	fprintf (qh ferr, "\n\
-qhull input warning: no outer plane check ('Q5') or no processing of\n\
+        qh_fprintf(qh ferr, 7077, "qhull input warning: no outer plane check ('Q5') or no processing of\n\
 near-inside points ('Q8').  Verify may report that a point is outside\n\
 of a facet.\n");
     }
     if (qh PRINTprecision) {
       if (testouter)
-	fprintf (qh ferr, "\n\
+        qh_fprintf(qh ferr, 8098, "\n\
 Output completed.  Verifying that all points are below outer planes of\n\
-all %sfacets.  Will make %2.0f distance computations.\n", 
-	      (qh ONLYgood ?  "good " : ""), total);
+all %sfacets.  Will make %2.0f distance computations.\n",
+              (qh ONLYgood ?  "good " : ""), total);
       else
-	fprintf (qh ferr, "\n\
+        qh_fprintf(qh ferr, 8099, "\n\
 Output completed.  Verifying that all points are below %2.2g of\n\
-all %sfacets.  Will make %2.0f distance computations.\n", 
-	      maxoutside, (qh ONLYgood ?  "good " : ""), total);
+all %sfacets.  Will make %2.0f distance computations.\n",
+              maxoutside, (qh ONLYgood ?  "good " : ""), total);
     }
     FORALLfacets {
       if (!facet->good && qh ONLYgood)
@@ -365,40 +363,39 @@
       if (facet->flipped)
         continue;
       if (!facet->normal) {
-	fprintf( qh ferr, "qhull warning (qh_check_points): missing normal for facet f%d\n", facet->id);
+        qh_fprintf(qh ferr, 7061, "qhull warning (qh_check_points): missing normal for facet f%d\n", facet->id);
         continue;
       }
       if (testouter) {
 #if qh_MAXoutside
-	maxoutside= facet->maxoutside + 2* qh DISTround;
-	/* one DISTround to actual point and another to computed point */
+        maxoutside= facet->maxoutside + 2* qh DISTround;
+        /* one DISTround to actual point and another to computed point */
 #endif
       }
       FORALLpoints {
-	if (point != qh GOODpointp)
-	  qh_check_point (point, facet, &maxoutside, &maxdist, &errfacet1, &errfacet2);
+        if (point != qh GOODpointp)
+          qh_check_point(point, facet, &maxoutside, &maxdist, &errfacet1, &errfacet2);
       }
       FOREACHpoint_(qh other_points) {
-	if (point != qh GOODpointp)
-	  qh_check_point (point, facet, &maxoutside, &maxdist, &errfacet1, &errfacet2);
+        if (point != qh GOODpointp)
+          qh_check_point(point, facet, &maxoutside, &maxdist, &errfacet1, &errfacet2);
       }
     }
     if (maxdist > qh outside_err) {
-      fprintf( qh ferr, "qhull precision error (qh_check_points): a coplanar point is %6.2g from convex hull.  The maximum value (qh.outside_err) is %6.2g\n",
+      qh_fprintf(qh ferr, 6112, "qhull precision error (qh_check_points): a coplanar point is %6.2g from convex hull.  The maximum value(qh.outside_err) is %6.2g\n",
                 maxdist, qh outside_err );
       qh_errexit2( qh_ERRprec, errfacet1, errfacet2 );
     }else if (errfacet1 && qh outside_err > REALmax/2)
         qh_errexit2( qh_ERRprec, errfacet1, errfacet2 );
-    else if (errfacet1)
-        ;  /* the error was logged to qh.ferr but does not effect the output */
-    trace0((qh ferr, "qh_check_points: max distance outside %2.2g\n", maxdist));
+    /* else if errfacet1, the error was logged to qh.ferr but does not effect the output */
+    trace0((qh ferr, 21, "qh_check_points: max distance outside %2.2g\n", maxdist));
   }
 } /* check_points */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="checkconvex">-</a>
-  
+
   qh_checkconvex( facetlist, fault )
     check that each ridge in facetlist is convex
     fault = qh_DATAfault if reporting errors
@@ -409,11 +406,11 @@
     errors if concaveridge or if merging an coplanar ridge
 
   note:
-    if not merging, 
+    if not merging,
       tests vertices for neighboring simplicial facets
-    else if ZEROcentrum, 
+    else if ZEROcentrum,
       tests vertices for neighboring simplicial   facets
-    else 
+    else
       tests centrums of neighboring facets
 
   design:
@@ -422,7 +419,7 @@
       if ZEROcentrum and simplicial neighbors
         test vertices for neighboring simplicial facets
       else
-        test centrum against all neighbors 
+        test centrum against all neighbors
 */
 void qh_checkconvex(facetT *facetlist, int fault) {
   facetT *facet, *neighbor, **neighborp, *errfacet1=NULL, *errfacet2=NULL;
@@ -432,16 +429,16 @@
   boolT waserror= False, centrum_warning= False, tempcentrum= False, allsimplicial;
   int neighbor_i;
 
-  trace1((qh ferr, "qh_checkconvex: check all ridges are convex\n"));
+  trace1((qh ferr, 1026, "qh_checkconvex: check all ridges are convex\n"));
   if (!qh RERUN) {
     zzval_(Zconcaveridges)= 0;
     zzval_(Zcoplanarridges)= 0;
   }
   FORALLfacet_(facetlist) {
     if (facet->flipped) {
-      qh_precision ("flipped facet");
-      fprintf (qh ferr, "qhull precision error: f%d is flipped (interior point is outside)\n",
-	       facet->id);
+      qh_precision("flipped facet");
+      qh_fprintf(qh ferr, 6113, "qhull precision error: f%d is flipped(interior point is outside)\n",
+               facet->id);
       errfacet1= facet;
       waserror= True;
       continue;
@@ -453,39 +450,39 @@
       neighbor_i= 0;
       FOREACHneighbor_(facet) {
         vertex= SETelemt_(facet->vertices, neighbor_i++, vertexT);
-	if (!neighbor->simplicial || neighbor->tricoplanar) {
-	  allsimplicial= False;
-	  continue;
-	}
-        qh_distplane (vertex->point, neighbor, &dist);
+        if (!neighbor->simplicial || neighbor->tricoplanar) {
+          allsimplicial= False;
+          continue;
+        }
+        qh_distplane(vertex->point, neighbor, &dist);
         if (dist > -qh DISTround) {
-	  if (fault == qh_DATAfault) {
-            qh_precision ("coplanar or concave ridge");
-	    fprintf (qh ferr, "qhull precision error: initial simplex is not convex. Distance=%.2g\n", dist);
-	    qh_errexit(qh_ERRsingular, NULL, NULL);
-	  }
+          if (fault == qh_DATAfault) {
+            qh_precision("coplanar or concave ridge");
+            qh_fprintf(qh ferr, 6114, "qhull precision error: initial simplex is not convex. Distance=%.2g\n", dist);
+            qh_errexit(qh_ERRsingular, NULL, NULL);
+          }
           if (dist > qh DISTround) {
             zzinc_(Zconcaveridges);
-            qh_precision ("concave ridge");
-            fprintf (qh ferr, "qhull precision error: f%d is concave to f%d, since p%d (v%d) is %6.4g above\n",
+            qh_precision("concave ridge");
+            qh_fprintf(qh ferr, 6115, "qhull precision error: f%d is concave to f%d, since p%d(v%d) is %6.4g above\n",
               facet->id, neighbor->id, qh_pointid(vertex->point), vertex->id, dist);
             errfacet1= facet;
             errfacet2= neighbor;
             waserror= True;
           }else if (qh ZEROcentrum) {
             if (dist > 0) {     /* qh_checkzero checks that dist < - qh DISTround */
-              zzinc_(Zcoplanarridges); 
-              qh_precision ("coplanar ridge");
-              fprintf (qh ferr, "qhull precision error: f%d is clearly not convex to f%d, since p%d (v%d) is %6.4g above\n",
+              zzinc_(Zcoplanarridges);
+              qh_precision("coplanar ridge");
+              qh_fprintf(qh ferr, 6116, "qhull precision error: f%d is clearly not convex to f%d, since p%d(v%d) is %6.4g above\n",
                 facet->id, neighbor->id, qh_pointid(vertex->point), vertex->id, dist);
               errfacet1= facet;
               errfacet2= neighbor;
               waserror= True;
-	    }
-	  }else {              
+            }
+          }else {
             zzinc_(Zcoplanarridges);
-            qh_precision ("coplanar ridge");
-            trace0((qh ferr, "qhull precision error: f%d may be coplanar to f%d, since p%d (v%d) is within %6.4g during p%d\n",
+            qh_precision("coplanar ridge");
+            trace0((qh ferr, 22, "qhull precision error: f%d may be coplanar to f%d, since p%d(v%d) is within %6.4g during p%d\n",
               facet->id, neighbor->id, qh_pointid(vertex->point), vertex->id, dist, qh furthest_id));
           }
         }
@@ -494,40 +491,40 @@
     if (!allsimplicial) {
       if (qh CENTERtype == qh_AScentrum) {
         if (!facet->center)
-          facet->center= qh_getcentrum (facet);
+          facet->center= qh_getcentrum(facet);
         centrum= facet->center;
       }else {
-	if (!centrum_warning && (!facet->simplicial || facet->tricoplanar)) {
-	   centrum_warning= True;
-	   fprintf (qh ferr, "qhull note: recomputing centrums for convexity test.  This may lead to false, precision errors.\n");
-	}
+        if (!centrum_warning && (!facet->simplicial || facet->tricoplanar)) {
+           centrum_warning= True;
+           qh_fprintf(qh ferr, 7062, "qhull warning: recomputing centrums for convexity test.  This may lead to false, precision errors.\n");
+        }
         centrum= qh_getcentrum(facet);
         tempcentrum= True;
       }
       FOREACHneighbor_(facet) {
-	if (qh ZEROcentrum && facet->simplicial && neighbor->simplicial)
-	  continue;
-	if (facet->tricoplanar || neighbor->tricoplanar)
-	  continue;
+        if (qh ZEROcentrum && facet->simplicial && neighbor->simplicial)
+          continue;
+        if (facet->tricoplanar || neighbor->tricoplanar)
+          continue;
         zzinc_(Zdistconvex);
-        qh_distplane (centrum, neighbor, &dist);
+        qh_distplane(centrum, neighbor, &dist);
         if (dist > qh DISTround) {
           zzinc_(Zconcaveridges);
-          qh_precision ("concave ridge");
-          fprintf (qh ferr, "qhull precision error: f%d is concave to f%d.  Centrum of f%d is %6.4g above f%d\n",
+          qh_precision("concave ridge");
+          qh_fprintf(qh ferr, 6117, "qhull precision error: f%d is concave to f%d.  Centrum of f%d is %6.4g above f%d\n",
             facet->id, neighbor->id, facet->id, dist, neighbor->id);
           errfacet1= facet;
           errfacet2= neighbor;
           waserror= True;
-	}else if (dist >= 0.0) {   /* if arithmetic always rounds the same,
-				     can test against centrum radius instead */
+        }else if (dist >= 0.0) {   /* if arithmetic always rounds the same,
+                                     can test against centrum radius instead */
           zzinc_(Zcoplanarridges);
-          qh_precision ("coplanar ridge");
-          fprintf (qh ferr, "qhull precision error: f%d is coplanar or concave to f%d.  Centrum of f%d is %6.4g above f%d\n",
+          qh_precision("coplanar ridge");
+          qh_fprintf(qh ferr, 6118, "qhull precision error: f%d is coplanar or concave to f%d.  Centrum of f%d is %6.4g above f%d\n",
             facet->id, neighbor->id, facet->id, dist, neighbor->id);
-	  errfacet1= facet;
-	  errfacet2= neighbor;
-	  waserror= True;
+          errfacet1= facet;
+          errfacet2= neighbor;
+          waserror= True;
         }
       }
       if (tempcentrum)
@@ -541,7 +538,7 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="checkfacet">-</a>
-  
+
   qh_checkfacet( facet, newmerge, waserror )
     checks for consistency errors in facet
     newmerge set if from merge.c
@@ -560,11 +557,11 @@
     neighbors are reciprocated
     ridge neighbors are facet neighbors and a ridge for every neighbor
     simplicial neighbors match facetintersect
-    vertex intersection matches vertices of common ridges 
+    vertex intersection matches vertices of common ridges
     vertex neighbors and facet vertices agree
     all ridges have distinct vertex sets
 
-  notes:  
+  notes:
     uses neighbor->seen
 
   design:
@@ -587,28 +584,28 @@
   setT *intersection;
 
   if (facet->visible) {
-    fprintf (qh ferr, "qhull internal error (qh_checkfacet): facet f%d is on the visible_list\n",
+    qh_fprintf(qh ferr, 6119, "qhull internal error (qh_checkfacet): facet f%d is on the visible_list\n",
       facet->id);
-    qh_errexit (qh_ERRqhull, facet, NULL);
+    qh_errexit(qh_ERRqhull, facet, NULL);
   }
   if (!facet->normal) {
-    fprintf (qh ferr, "qhull internal error (qh_checkfacet): facet f%d does not have  a normal\n",
+    qh_fprintf(qh ferr, 6120, "qhull internal error (qh_checkfacet): facet f%d does not have  a normal\n",
       facet->id);
     waserror= True;
   }
-  qh_setcheck (facet->vertices, "vertices for f", facet->id);
-  qh_setcheck (facet->ridges, "ridges for f", facet->id);
-  qh_setcheck (facet->outsideset, "outsideset for f", facet->id);
-  qh_setcheck (facet->coplanarset, "coplanarset for f", facet->id);
-  qh_setcheck (facet->neighbors, "neighbors for f", facet->id);
+  qh_setcheck(facet->vertices, "vertices for f", facet->id);
+  qh_setcheck(facet->ridges, "ridges for f", facet->id);
+  qh_setcheck(facet->outsideset, "outsideset for f", facet->id);
+  qh_setcheck(facet->coplanarset, "coplanarset for f", facet->id);
+  qh_setcheck(facet->neighbors, "neighbors for f", facet->id);
   FOREACHvertex_(facet->vertices) {
     if (vertex->deleted) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): deleted vertex v%d in f%d\n", vertex->id, facet->id);
-      qh_errprint ("ERRONEOUS", NULL, NULL, NULL, vertex);
+      qh_fprintf(qh ferr, 6121, "qhull internal error (qh_checkfacet): deleted vertex v%d in f%d\n", vertex->id, facet->id);
+      qh_errprint("ERRONEOUS", NULL, NULL, NULL, vertex);
       waserror= True;
     }
     if (vertex->id >= previousid) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): vertices of f%d are not in descending id order at v%d\n", facet->id, vertex->id);
+      qh_fprintf(qh ferr, 6122, "qhull internal error (qh_checkfacet): vertices of f%d are not in descending id order at v%d\n", facet->id, vertex->id);
       waserror= True;
       break;
     }
@@ -618,18 +615,18 @@
   numvertices= qh_setsize(facet->vertices);
   numridges= qh_setsize(facet->ridges);
   if (facet->simplicial) {
-    if (numvertices+numneighbors != 2*qh hull_dim 
+    if (numvertices+numneighbors != 2*qh hull_dim
     && !facet->degenerate && !facet->redundant) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): for simplicial facet f%d, #vertices %d + #neighbors %d != 2*qh hull_dim\n", 
+      qh_fprintf(qh ferr, 6123, "qhull internal error (qh_checkfacet): for simplicial facet f%d, #vertices %d + #neighbors %d != 2*qh hull_dim\n",
                 facet->id, numvertices, numneighbors);
-      qh_setprint (qh ferr, "", facet->neighbors);
+      qh_setprint(qh ferr, "", facet->neighbors);
       waserror= True;
     }
   }else { /* non-simplicial */
-    if (!newmerge 
+    if (!newmerge
     &&(numvertices < qh hull_dim || numneighbors < qh hull_dim)
     && !facet->degenerate && !facet->redundant) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): for facet f%d, #vertices %d or #neighbors %d < qh hull_dim\n",
+      qh_fprintf(qh ferr, 6124, "qhull internal error (qh_checkfacet): for facet f%d, #vertices %d or #neighbors %d < qh hull_dim\n",
          facet->id, numvertices, numneighbors);
        waserror= True;
     }
@@ -638,49 +635,49 @@
     ||(qh hull_dim == 3 && numvertices > numridges && !qh NEWfacets)
     ||(qh hull_dim == 2 && numridges + numvertices + numneighbors != 6)) {
       if (!facet->degenerate && !facet->redundant) {
-	fprintf(qh ferr, "qhull internal error (qh_checkfacet): for facet f%d, #ridges %d < #neighbors %d or (3-d) > #vertices %d or (2-d) not all 2\n",
-	    facet->id, numridges, numneighbors, numvertices);
-	waserror= True;
+        qh_fprintf(qh ferr, 6125, "qhull internal error (qh_checkfacet): for facet f%d, #ridges %d < #neighbors %d or(3-d) > #vertices %d or(2-d) not all 2\n",
+            facet->id, numridges, numneighbors, numvertices);
+        waserror= True;
       }
     }
   }
   FOREACHneighbor_(facet) {
     if (neighbor == qh_MERGEridge || neighbor == qh_DUPLICATEridge) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d still has a MERGE or DUP neighbor\n", facet->id);
-      qh_errexit (qh_ERRqhull, facet, NULL);
+      qh_fprintf(qh ferr, 6126, "qhull internal error (qh_checkfacet): facet f%d still has a MERGE or DUP neighbor\n", facet->id);
+      qh_errexit(qh_ERRqhull, facet, NULL);
     }
     neighbor->seen= True;
   }
   FOREACHneighbor_(facet) {
     if (!qh_setin(neighbor->neighbors, facet)) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d has neighbor f%d, but f%d does not have neighbor f%d\n",
-	      facet->id, neighbor->id, neighbor->id, facet->id);
+      qh_fprintf(qh ferr, 6127, "qhull internal error (qh_checkfacet): facet f%d has neighbor f%d, but f%d does not have neighbor f%d\n",
+              facet->id, neighbor->id, neighbor->id, facet->id);
       errother= neighbor;
       waserror= True;
     }
     if (!neighbor->seen) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d has a duplicate neighbor f%d\n",
-	      facet->id, neighbor->id);
+      qh_fprintf(qh ferr, 6128, "qhull internal error (qh_checkfacet): facet f%d has a duplicate neighbor f%d\n",
+              facet->id, neighbor->id);
       errother= neighbor;
       waserror= True;
-    }    
+    }
     neighbor->seen= False;
   }
   FOREACHridge_(facet->ridges) {
-    qh_setcheck (ridge->vertices, "vertices for r", ridge->id);
+    qh_setcheck(ridge->vertices, "vertices for r", ridge->id);
     ridge->seen= False;
   }
   FOREACHridge_(facet->ridges) {
     if (ridge->seen) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d has a duplicate ridge r%d\n",
-	      facet->id, ridge->id);
+      qh_fprintf(qh ferr, 6129, "qhull internal error (qh_checkfacet): facet f%d has a duplicate ridge r%d\n",
+              facet->id, ridge->id);
       errridge= ridge;
       waserror= True;
-    }    
+    }
     ridge->seen= True;
     numRvertices= qh_setsize(ridge->vertices);
     if (numRvertices != qh hull_dim - 1) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): ridge between f%d and f%d has %d vertices\n", 
+      qh_fprintf(qh ferr, 6130, "qhull internal error (qh_checkfacet): ridge between f%d and f%d has %d vertices\n",
                 ridge->top->id, ridge->bottom->id, numRvertices);
       errridge= ridge;
       waserror= True;
@@ -688,7 +685,7 @@
     neighbor= otherfacet_(ridge, facet);
     neighbor->seen= True;
     if (!qh_setin(facet->neighbors, neighbor)) {
-      fprintf(qh ferr, "qhull internal error (qh_checkfacet): for facet f%d, neighbor f%d of ridge r%d not in facet\n",
+      qh_fprintf(qh ferr, 6131, "qhull internal error (qh_checkfacet): for facet f%d, neighbor f%d of ridge r%d not in facet\n",
            facet->id, neighbor->id, ridge->id);
       errridge= ridge;
       waserror= True;
@@ -697,73 +694,73 @@
   if (!facet->simplicial) {
     FOREACHneighbor_(facet) {
       if (!neighbor->seen) {
-        fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d does not have a ridge for neighbor f%d\n",
-	      facet->id, neighbor->id);
-	errother= neighbor;
+        qh_fprintf(qh ferr, 6132, "qhull internal error (qh_checkfacet): facet f%d does not have a ridge for neighbor f%d\n",
+              facet->id, neighbor->id);
+        errother= neighbor;
         waserror= True;
       }
       intersection= qh_vertexintersect_new(facet->vertices, neighbor->vertices);
-      qh_settemppush (intersection);
+      qh_settemppush(intersection);
       FOREACHvertex_(facet->vertices) {
-	vertex->seen= False;
-	vertex->seen2= False;
+        vertex->seen= False;
+        vertex->seen2= False;
       }
       FOREACHvertex_(intersection)
-	vertex->seen= True;
+        vertex->seen= True;
       FOREACHridge_(facet->ridges) {
-	if (neighbor != otherfacet_(ridge, facet))
-	    continue;
-	FOREACHvertex_(ridge->vertices) {
-	  if (!vertex->seen) {
-	    fprintf (qh ferr, "qhull internal error (qh_checkfacet): vertex v%d in r%d not in f%d intersect f%d\n",
-  	          vertex->id, ridge->id, facet->id, neighbor->id);
-	    qh_errexit (qh_ERRqhull, facet, ridge);
-	  }
-	  vertex->seen2= True;
-	}
+        if (neighbor != otherfacet_(ridge, facet))
+            continue;
+        FOREACHvertex_(ridge->vertices) {
+          if (!vertex->seen) {
+            qh_fprintf(qh ferr, 6133, "qhull internal error (qh_checkfacet): vertex v%d in r%d not in f%d intersect f%d\n",
+                  vertex->id, ridge->id, facet->id, neighbor->id);
+            qh_errexit(qh_ERRqhull, facet, ridge);
+          }
+          vertex->seen2= True;
+        }
       }
       if (!newmerge) {
-	FOREACHvertex_(intersection) {
-	  if (!vertex->seen2) {
-	    if (qh IStracing >=3 || !qh MERGING) {
-	      fprintf (qh ferr, "qhull precision error (qh_checkfacet): vertex v%d in f%d intersect f%d but\n\
+        FOREACHvertex_(intersection) {
+          if (!vertex->seen2) {
+            if (qh IStracing >=3 || !qh MERGING) {
+              qh_fprintf(qh ferr, 6134, "qhull precision error (qh_checkfacet): vertex v%d in f%d intersect f%d but\n\
  not in a ridge.  This is ok under merging.  Last point was p%d\n",
-		     vertex->id, facet->id, neighbor->id, qh furthest_id);
-	      if (!qh FORCEoutput && !qh MERGING) {
-		qh_errprint ("ERRONEOUS", facet, neighbor, NULL, vertex);
-		if (!qh MERGING)
-		  qh_errexit (qh_ERRqhull, NULL, NULL);
-	      }
-	    }
-	  }
-	}
-      }      
-      qh_settempfree (&intersection);
+                     vertex->id, facet->id, neighbor->id, qh furthest_id);
+              if (!qh FORCEoutput && !qh MERGING) {
+                qh_errprint("ERRONEOUS", facet, neighbor, NULL, vertex);
+                if (!qh MERGING)
+                  qh_errexit(qh_ERRqhull, NULL, NULL);
+              }
+            }
+          }
+        }
+      }
+      qh_settempfree(&intersection);
     }
   }else { /* simplicial */
     FOREACHneighbor_(facet) {
-      if (neighbor->simplicial) {    
-	skipA= SETindex_(facet->neighbors, neighbor);
-	skipB= qh_setindex (neighbor->neighbors, facet);
-	if (!qh_setequal_skip (facet->vertices, skipA, neighbor->vertices, skipB)) {
-	  fprintf (qh ferr, "qhull internal error (qh_checkfacet): facet f%d skip %d and neighbor f%d skip %d do not match \n",
-		   facet->id, skipA, neighbor->id, skipB);
-	  errother= neighbor;
-	  waserror= True;
-	}
+      if (neighbor->simplicial) {
+        skipA= SETindex_(facet->neighbors, neighbor);
+        skipB= qh_setindex(neighbor->neighbors, facet);
+        if (!qh_setequal_skip(facet->vertices, skipA, neighbor->vertices, skipB)) {
+          qh_fprintf(qh ferr, 6135, "qhull internal error (qh_checkfacet): facet f%d skip %d and neighbor f%d skip %d do not match \n",
+                   facet->id, skipA, neighbor->id, skipB);
+          errother= neighbor;
+          waserror= True;
+        }
       }
     }
   }
   if (qh hull_dim < 5 && (qh IStracing > 2 || qh CHECKfrequently)) {
     FOREACHridge_i_(facet->ridges) {           /* expensive */
-      for (i= ridge_i+1; i < ridge_n; i++) {
-	ridge2= SETelemt_(facet->ridges, i, ridgeT);
-	if (qh_setequal (ridge->vertices, ridge2->vertices)) {
-	  fprintf (qh ferr, "qh_checkfacet: ridges r%d and r%d have the same vertices\n",
-		  ridge->id, ridge2->id);
-	  errridge= ridge;
-	  waserror= True;
-	}
+      for (i=ridge_i+1; i < ridge_n; i++) {
+        ridge2= SETelemt_(facet->ridges, i, ridgeT);
+        if (qh_setequal(ridge->vertices, ridge2->vertices)) {
+          qh_fprintf(qh ferr, 6227, "Qhull internal error (qh_checkfacet): ridges r%d and r%d have the same vertices\n",
+                  ridge->id, ridge2->id);
+          errridge= ridge;
+          waserror= True;
+        }
       }
     }
   }
@@ -776,11 +773,11 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="checkflipped_all">-</a>
-  
+
   qh_checkflipped_all( facetlist )
     checks orientation of facets in list against interior point
 */
-void qh_checkflipped_all (facetT *facetlist) {
+void qh_checkflipped_all(facetT *facetlist) {
   facetT *facet;
   boolT waserror= False;
   realT dist;
@@ -788,17 +785,17 @@
   if (facetlist == qh facet_list)
     zzval_(Zflippedfacets)= 0;
   FORALLfacet_(facetlist) {
-    if (facet->normal && !qh_checkflipped (facet, &dist, !qh_ALL)) {
-      fprintf(qh ferr, "qhull precision error: facet f%d is flipped, distance= %6.12g\n",
-	      facet->id, dist);
+    if (facet->normal && !qh_checkflipped(facet, &dist, !qh_ALL)) {
+      qh_fprintf(qh ferr, 6136, "qhull precision error: facet f%d is flipped, distance= %6.12g\n",
+              facet->id, dist);
       if (!qh FORCEoutput) {
-	qh_errprint("ERRONEOUS", facet, NULL, NULL, NULL);
-	waserror= True;
+        qh_errprint("ERRONEOUS", facet, NULL, NULL, NULL);
+        waserror= True;
       }
     }
   }
   if (waserror) {
-    fprintf (qh ferr, "\n\
+    qh_fprintf(qh ferr, 8101, "\n\
 A flipped facet occurs when its distance to the interior point is\n\
 greater than %2.2g, the maximum roundoff error.\n", -qh DISTround);
     qh_errexit(qh_ERRprec, NULL, NULL);
@@ -807,7 +804,7 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="checkpolygon">-</a>
-  
+
   qh_checkpolygon( facetlist )
     checks the correctness of the structure
 
@@ -821,7 +818,7 @@
     initializes vertexlist
     for each facet
       checks vertex set
-    if checking all facets (qh.facetlist)
+    if checking all facets(qh.facetlist)
       check facet count
       if qh.VERTEXneighbors
         check vertex neighbors and count
@@ -833,8 +830,8 @@
   int numfacets= 0, numvertices= 0, numridges= 0;
   int totvneighbors= 0, totvertices= 0;
   boolT waserror= False, nextseen= False, visibleseen= False;
-  
-  trace1((qh ferr, "qh_checkpolygon: check all facets from f%d\n", facetlist->id));
+
+  trace1((qh ferr, 1027, "qh_checkpolygon: check all facets from f%d\n", facetlist->id));
   if (facetlist != qh facet_list || qh ONLYgood)
     nextseen= True;
   FORALLfacet_(facetlist) {
@@ -842,28 +839,28 @@
       visibleseen= True;
     if (!facet->visible) {
       if (!nextseen) {
-	if (facet == qh facet_next)
-	  nextseen= True;
-	else if (qh_setsize (facet->outsideset)) {
-	  if (!qh NARROWhull
+        if (facet == qh facet_next)
+          nextseen= True;
+        else if (qh_setsize(facet->outsideset)) {
+          if (!qh NARROWhull
 #if !qh_COMPUTEfurthest
-	       || facet->furthestdist >= qh MINoutside
+               || facet->furthestdist >= qh MINoutside
 #endif
-			) {
-	    fprintf (qh ferr, "qhull internal error (qh_checkpolygon): f%d has outside points before qh facet_next\n",
-		     facet->id);
-	    qh_errexit (qh_ERRqhull, facet, NULL);
-	  }
-	}
+                        ) {
+            qh_fprintf(qh ferr, 6137, "qhull internal error (qh_checkpolygon): f%d has outside points before qh facet_next\n",
+                     facet->id);
+            qh_errexit(qh_ERRqhull, facet, NULL);
+          }
+        }
       }
       numfacets++;
       qh_checkfacet(facet, False, &waserror);
     }
   }
   if (qh visible_list && !visibleseen && facetlist == qh facet_list) {
-    fprintf (qh ferr, "qhull internal error (qh_checkpolygon): visible list f%d no longer on facet list\n", qh visible_list->id);
+    qh_fprintf(qh ferr, 6138, "qhull internal error (qh_checkpolygon): visible list f%d no longer on facet list\n", qh visible_list->id);
     qh_printlists();
-    qh_errexit (qh_ERRqhull, qh visible_list, NULL);
+    qh_errexit(qh_ERRqhull, qh visible_list, NULL);
   }
   if (facetlist == qh facet_list)
     vertexlist= qh vertex_list;
@@ -874,75 +871,75 @@
   FORALLvertex_(vertexlist) {
     vertex->seen= False;
     vertex->visitid= 0;
-  }  
+  }
   FORALLfacet_(facetlist) {
     if (facet->visible)
       continue;
     if (facet->simplicial)
       numridges += qh hull_dim;
     else
-      numridges += qh_setsize (facet->ridges);
+      numridges += qh_setsize(facet->ridges);
     FOREACHvertex_(facet->vertices) {
       vertex->visitid++;
       if (!vertex->seen) {
-	vertex->seen= True;
-	numvertices++;
-	if (qh_pointid (vertex->point) == -1) {
-	  fprintf (qh ferr, "qhull internal error (qh_checkpolygon): unknown point %p for vertex v%d first_point %p\n",
-		   vertex->point, vertex->id, qh first_point);
-	  waserror= True;
-	}
+        vertex->seen= True;
+        numvertices++;
+        if (qh_pointid(vertex->point) == -1) {
+          qh_fprintf(qh ferr, 6139, "qhull internal error (qh_checkpolygon): unknown point %p for vertex v%d first_point %p\n",
+                   vertex->point, vertex->id, qh first_point);
+          waserror= True;
+        }
       }
     }
   }
-  qh vertex_visit += numfacets;
+  qh vertex_visit += (unsigned int)numfacets;
   if (facetlist == qh facet_list) {
     if (numfacets != qh num_facets - qh num_visible) {
-      fprintf(qh ferr, "qhull internal error (qh_checkpolygon): actual number of facets is %d, cumulative facet count is %d - %d visible facets\n",
-	      numfacets, qh num_facets, qh num_visible);
+      qh_fprintf(qh ferr, 6140, "qhull internal error (qh_checkpolygon): actual number of facets is %d, cumulative facet count is %d - %d visible facets\n",
+              numfacets, qh num_facets, qh num_visible);
       waserror= True;
     }
     qh vertex_visit++;
     if (qh VERTEXneighbors) {
       FORALLvertices {
-	qh_setcheck (vertex->neighbors, "neighbors for v", vertex->id);
-	if (vertex->deleted)
-	  continue;
-	totvneighbors += qh_setsize (vertex->neighbors);
+        qh_setcheck(vertex->neighbors, "neighbors for v", vertex->id);
+        if (vertex->deleted)
+          continue;
+        totvneighbors += qh_setsize(vertex->neighbors);
       }
       FORALLfacet_(facetlist)
-	totvertices += qh_setsize (facet->vertices);
+        totvertices += qh_setsize(facet->vertices);
       if (totvneighbors != totvertices) {
-	fprintf(qh ferr, "qhull internal error (qh_checkpolygon): vertex neighbors inconsistent.  Totvneighbors %d, totvertices %d\n",
-		totvneighbors, totvertices);
-	waserror= True;
+        qh_fprintf(qh ferr, 6141, "qhull internal error (qh_checkpolygon): vertex neighbors inconsistent.  Totvneighbors %d, totvertices %d\n",
+                totvneighbors, totvertices);
+        waserror= True;
       }
     }
     if (numvertices != qh num_vertices - qh_setsize(qh del_vertices)) {
-      fprintf(qh ferr, "qhull internal error (qh_checkpolygon): actual number of vertices is %d, cumulative vertex count is %d\n",
-	      numvertices, qh num_vertices - qh_setsize(qh del_vertices));
+      qh_fprintf(qh ferr, 6142, "qhull internal error (qh_checkpolygon): actual number of vertices is %d, cumulative vertex count is %d\n",
+              numvertices, qh num_vertices - qh_setsize(qh del_vertices));
       waserror= True;
     }
     if (qh hull_dim == 2 && numvertices != numfacets) {
-      fprintf (qh ferr, "qhull internal error (qh_checkpolygon): #vertices %d != #facets %d\n",
+      qh_fprintf(qh ferr, 6143, "qhull internal error (qh_checkpolygon): #vertices %d != #facets %d\n",
         numvertices, numfacets);
       waserror= True;
     }
     if (qh hull_dim == 3 && numvertices + numfacets - numridges/2 != 2) {
-      fprintf (qh ferr, "qhull warning: #vertices %d + #facets %d - #edges %d != 2\n\
-	A vertex appears twice in a edge list.  May occur during merging.",
+      qh_fprintf(qh ferr, 7063, "qhull warning: #vertices %d + #facets %d - #edges %d != 2\n\
+        A vertex appears twice in a edge list.  May occur during merging.",
         numvertices, numfacets, numridges/2);
       /* occurs if lots of merging and a vertex ends up twice in an edge list.  e.g., RBOX 1000 s W1e-13 t995849315 D2 | QHULL d Tc Tv */
     }
   }
-  if (waserror) 
+  if (waserror)
     qh_errexit(qh_ERRqhull, NULL, NULL);
 } /* checkpolygon */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="checkvertex">-</a>
-  
+
   qh_checkvertex( vertex )
     check vertex for consistency
     checks vertex->neighbors
@@ -950,38 +947,38 @@
   notes:
     neighbors checked efficiently in checkpolygon
 */
-void qh_checkvertex (vertexT *vertex) {
+void qh_checkvertex(vertexT *vertex) {
   boolT waserror= False;
   facetT *neighbor, **neighborp, *errfacet=NULL;
 
-  if (qh_pointid (vertex->point) == -1) {
-    fprintf (qh ferr, "qhull internal error (qh_checkvertex): unknown point id %p\n", vertex->point);
+  if (qh_pointid(vertex->point) == -1) {
+    qh_fprintf(qh ferr, 6144, "qhull internal error (qh_checkvertex): unknown point id %p\n", vertex->point);
     waserror= True;
   }
   if (vertex->id >= qh vertex_id) {
-    fprintf (qh ferr, "qhull internal error (qh_checkvertex): unknown vertex id %d\n", vertex->id);
+    qh_fprintf(qh ferr, 6145, "qhull internal error (qh_checkvertex): unknown vertex id %d\n", vertex->id);
     waserror= True;
   }
   if (!waserror && !vertex->deleted) {
-    if (qh_setsize (vertex->neighbors)) {
+    if (qh_setsize(vertex->neighbors)) {
       FOREACHneighbor_(vertex) {
-        if (!qh_setin (neighbor->vertices, vertex)) {
-          fprintf (qh ferr, "qhull internal error (qh_checkvertex): neighbor f%d does not contain v%d\n", neighbor->id, vertex->id);
-	  errfacet= neighbor;
-	  waserror= True;
-	}
+        if (!qh_setin(neighbor->vertices, vertex)) {
+          qh_fprintf(qh ferr, 6146, "qhull internal error (qh_checkvertex): neighbor f%d does not contain v%d\n", neighbor->id, vertex->id);
+          errfacet= neighbor;
+          waserror= True;
+        }
       }
     }
   }
   if (waserror) {
-    qh_errprint ("ERRONEOUS", NULL, NULL, NULL, vertex);
-    qh_errexit (qh_ERRqhull, errfacet, NULL);
+    qh_errprint("ERRONEOUS", NULL, NULL, NULL, vertex);
+    qh_errexit(qh_ERRqhull, errfacet, NULL);
   }
 } /* checkvertex */
-  
+
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="clearcenters">-</a>
-  
+
   qh_clearcenters( type )
     clear old data from facet->center
 
@@ -989,31 +986,33 @@
     sets new centertype
     nop if CENTERtype is the same
 */
-void qh_clearcenters (qh_CENTER type) {
+void qh_clearcenters(qh_CENTER type) {
   facetT *facet;
-  
+
   if (qh CENTERtype != type) {
     FORALLfacets {
-      if (qh CENTERtype == qh_ASvoronoi){
+      if (facet->tricoplanar && !facet->keepcentrum)
+          facet->center= NULL;
+      else if (qh CENTERtype == qh_ASvoronoi){
         if (facet->center) {
-          qh_memfree (facet->center, qh center_size);
+          qh_memfree(facet->center, qh center_size);
           facet->center= NULL;
         }
       }else /* qh CENTERtype == qh_AScentrum */ {
         if (facet->center) {
-          qh_memfree (facet->center, qh normal_size);
-	  facet->center= NULL;
+          qh_memfree(facet->center, qh normal_size);
+          facet->center= NULL;
         }
       }
     }
     qh CENTERtype= type;
   }
-  trace2((qh ferr, "qh_clearcenters: switched to center type %d\n", type));
+  trace2((qh ferr, 2043, "qh_clearcenters: switched to center type %d\n", type));
 } /* clearcenters */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="createsimplex">-</a>
-  
+
   qh_createsimplex( vertices )
     creates a simplex from a set of vertices
 
@@ -1033,38 +1032,38 @@
   facetT *facet= NULL, *newfacet;
   boolT toporient= True;
   int vertex_i, vertex_n, nth;
-  setT *newfacets= qh_settemp (qh hull_dim+1);
+  setT *newfacets= qh_settemp(qh hull_dim+1);
   vertexT *vertex;
-  
+
   qh facet_list= qh newfacet_list= qh facet_tail= qh_newfacet();
   qh num_facets= qh num_vertices= qh num_visible= 0;
   qh vertex_list= qh newvertex_list= qh vertex_tail= qh_newvertex(NULL);
   FOREACHvertex_i_(vertices) {
     newfacet= qh_newfacet();
-    newfacet->vertices= qh_setnew_delnthsorted (vertices, vertex_n,
-						vertex_i, 0);
-    newfacet->toporient= toporient;
+    newfacet->vertices= qh_setnew_delnthsorted(vertices, vertex_n,
+                                                vertex_i, 0);
+    newfacet->toporient= (unsigned char)toporient;
     qh_appendfacet(newfacet);
     newfacet->newfacet= True;
-    qh_appendvertex (vertex);
-    qh_setappend (&newfacets, newfacet);
+    qh_appendvertex(vertex);
+    qh_setappend(&newfacets, newfacet);
     toporient ^= True;
   }
   FORALLnew_facets {
     nth= 0;
     FORALLfacet_(qh newfacet_list) {
-      if (facet != newfacet) 
+      if (facet != newfacet)
         SETelem_(newfacet->neighbors, nth++)= facet;
     }
-    qh_settruncate (newfacet->neighbors, qh hull_dim);
+    qh_settruncate(newfacet->neighbors, qh hull_dim);
   }
-  qh_settempfree (&newfacets);
-  trace1((qh ferr, "qh_createsimplex: created simplex\n"));
+  qh_settempfree(&newfacets);
+  trace1((qh ferr, 1028, "qh_createsimplex: created simplex\n"));
 } /* createsimplex */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="delridge">-</a>
-  
+
   qh_delridge( ridge )
     deletes ridge from data structures it belongs to
     frees up its memory
@@ -1075,17 +1074,17 @@
 */
 void qh_delridge(ridgeT *ridge) {
   void **freelistp; /* used !qh_NOmem */
-  
+
   qh_setdel(ridge->top->ridges, ridge);
   qh_setdel(ridge->bottom->ridges, ridge);
   qh_setfree(&(ridge->vertices));
-  qh_memfree_(ridge, sizeof(ridgeT), freelistp);
+  qh_memfree_(ridge, (int)sizeof(ridgeT), freelistp);
 } /* delridge */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="delvertex">-</a>
-  
+
   qh_delvertex( vertex )
     deletes a vertex and frees its memory
 
@@ -1093,19 +1092,19 @@
     assumes vertex->adjacencies have been updated if needed
     unlinks from vertex_list
 */
-void qh_delvertex (vertexT *vertex) {
+void qh_delvertex(vertexT *vertex) {
 
   if (vertex == qh tracevertex)
     qh tracevertex= NULL;
-  qh_removevertex (vertex);
-  qh_setfree (&vertex->neighbors);
-  qh_memfree(vertex, sizeof(vertexT));
+  qh_removevertex(vertex);
+  qh_setfree(&vertex->neighbors);
+  qh_memfree(vertex, (int)sizeof(vertexT));
 } /* delvertex */
 
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="facet3vertex">-</a>
-  
+
   qh_facet3vertex(  )
     return temporary set of 3-d vertices in qh_ORIENTclock order
 
@@ -1116,35 +1115,35 @@
       for each ridge in order
         build set from ridge's vertices
 */
-setT *qh_facet3vertex (facetT *facet) {
+setT *qh_facet3vertex(facetT *facet) {
   ridgeT *ridge, *firstridge;
   vertexT *vertex;
   int cntvertices, cntprojected=0;
   setT *vertices;
 
   cntvertices= qh_setsize(facet->vertices);
-  vertices= qh_settemp (cntvertices);
+  vertices= qh_settemp(cntvertices);
   if (facet->simplicial) {
     if (cntvertices != 3) {
-      fprintf (qh ferr, "qhull internal error (qh_facet3vertex): only %d vertices for simplicial facet f%d\n", 
+      qh_fprintf(qh ferr, 6147, "qhull internal error (qh_facet3vertex): only %d vertices for simplicial facet f%d\n",
                   cntvertices, facet->id);
       qh_errexit(qh_ERRqhull, facet, NULL);
     }
-    qh_setappend (&vertices, SETfirst_(facet->vertices));
+    qh_setappend(&vertices, SETfirst_(facet->vertices));
     if (facet->toporient ^ qh_ORIENTclock)
-      qh_setappend (&vertices, SETsecond_(facet->vertices));
+      qh_setappend(&vertices, SETsecond_(facet->vertices));
     else
-      qh_setaddnth (&vertices, 0, SETsecond_(facet->vertices));
-    qh_setappend (&vertices, SETelem_(facet->vertices, 2));
+      qh_setaddnth(&vertices, 0, SETsecond_(facet->vertices));
+    qh_setappend(&vertices, SETelem_(facet->vertices, 2));
   }else {
     ridge= firstridge= SETfirstt_(facet->ridges, ridgeT);   /* no infinite */
-    while ((ridge= qh_nextridge3d (ridge, facet, &vertex))) {
-      qh_setappend (&vertices, vertex);
+    while ((ridge= qh_nextridge3d(ridge, facet, &vertex))) {
+      qh_setappend(&vertices, vertex);
       if (++cntprojected > cntvertices || ridge == firstridge)
         break;
     }
     if (!ridge || cntprojected != cntvertices) {
-      fprintf (qh ferr, "qhull internal error (qh_facet3vertex): ridges for facet %d don't match up.  got at least %d\n", 
+      qh_fprintf(qh ferr, 6148, "qhull internal error (qh_facet3vertex): ridges for facet %d don't match up.  got at least %d\n",
                   facet->id, cntprojected);
       qh_errexit(qh_ERRqhull, facet, ridge);
     }
@@ -1154,13 +1153,13 @@
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="findbestfacet">-</a>
-  
+
   qh_findbestfacet( point, bestoutside, bestdist, isoutside )
-    find facet that is furthest below a point 
+    find facet that is furthest below a point
 
-    for Delaunay triangulations, 
+    for Delaunay triangulations,
       Use qh_setdelaunay() to lift point to paraboloid and scale by 'Qbb' if needed
-      Do not use options 'Qbk', 'QBk', or 'QbB' since they scale the coordinates. 
+      Do not use options 'Qbk', 'QBk', or 'QbB' since they scale the coordinates.
 
   returns:
     if bestoutside is set (e.g., qh_ALL)
@@ -1171,51 +1170,51 @@
       if point is inside, returns nearest, !upperdelaunay facet
     distance to facet
     isoutside set if outside of facet
-    
+
   notes:
-    For tricoplanar facets, this finds one of the tricoplanar facets closest 
-    to the point.  For Delaunay triangulations, the point may be inside a 
-    different tricoplanar facet. See <a href="../html/qh-in.htm#findfacet">locate a facet with qh_findbestfacet()</a>
-    
+    For tricoplanar facets, this finds one of the tricoplanar facets closest
+    to the point.  For Delaunay triangulations, the point may be inside a
+    different tricoplanar facet. See <a href="../html/qh-code.htm#findfacet">locate a facet with qh_findbestfacet()</a>
+
     If inside, qh_findbestfacet performs an exhaustive search
        this may be too conservative.  Sometimes it is clearly required.
 
     qh_findbestfacet is not used by qhull.
     uses qh.visit_id and qh.coplanarset
-    
+
   see:
     <a href="geom.c#findbest">qh_findbest</a>
 */
-facetT *qh_findbestfacet (pointT *point, boolT bestoutside,
+facetT *qh_findbestfacet(pointT *point, boolT bestoutside,
            realT *bestdist, boolT *isoutside) {
   facetT *bestfacet= NULL;
   int numpart, totpart= 0;
-  
-  bestfacet= qh_findbest (point, qh facet_list, 
-			    bestoutside, !qh_ISnewfacets, bestoutside /* qh_NOupper */,
-			    bestdist, isoutside, &totpart);
+
+  bestfacet= qh_findbest(point, qh facet_list,
+                            bestoutside, !qh_ISnewfacets, bestoutside /* qh_NOupper */,
+                            bestdist, isoutside, &totpart);
   if (*bestdist < -qh DISTround) {
-    bestfacet= qh_findfacet_all (point, bestdist, isoutside, &numpart);
+    bestfacet= qh_findfacet_all(point, bestdist, isoutside, &numpart);
     totpart += numpart;
     if ((isoutside && bestoutside)
     || (!isoutside && bestfacet->upperdelaunay)) {
-      bestfacet= qh_findbest (point, bestfacet, 
-			    bestoutside, False, bestoutside,
-			    bestdist, isoutside, &totpart);
+      bestfacet= qh_findbest(point, bestfacet,
+                            bestoutside, False, bestoutside,
+                            bestdist, isoutside, &totpart);
       totpart += numpart;
     }
   }
-  trace3((qh ferr, "qh_findbestfacet: f%d dist %2.2g isoutside %d totpart %d\n",
-	  bestfacet->id, *bestdist, *isoutside, totpart));
+  trace3((qh ferr, 3014, "qh_findbestfacet: f%d dist %2.2g isoutside %d totpart %d\n",
+          bestfacet->id, *bestdist, *isoutside, totpart));
   return bestfacet;
-} /* findbestfacet */ 
+} /* findbestfacet */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="findbestlower">-</a>
-  
+
   qh_findbestlower( facet, point, bestdist, numpart )
     returns best non-upper, non-flipped neighbor of facet for point
-    if needed, searches vertex neighbors 
+    if needed, searches vertex neighbors
 
   returns:
     returns bestdist and updates numpart
@@ -1225,7 +1224,7 @@
     called by qh_findbest() for points above an upperdelaunay facet
 
 */
-facetT *qh_findbestlower (facetT *upperfacet, pointT *point, realT *bestdistp, int *numpart) {
+facetT *qh_findbestlower(facetT *upperfacet, pointT *point, realT *bestdistp, int *numpart) {
   facetT *neighbor, **neighborp, *bestfacet= NULL;
   realT bestdist= -REALmax/2 /* avoid underflow */;
   realT dist;
@@ -1236,7 +1235,7 @@
     if (neighbor->upperdelaunay || neighbor->flipped)
       continue;
     (*numpart)++;
-    qh_distplane (point, neighbor, &dist);
+    qh_distplane(point, neighbor, &dist);
     if (dist > bestdist) {
       bestfacet= neighbor;
       bestdist= dist;
@@ -1245,63 +1244,66 @@
   if (!bestfacet) {
     zinc_(Zbestlowerv);
     /* rarely called, numpart does not count nearvertex computations */
-    vertex= qh_nearvertex (upperfacet, point, &dist);
+    vertex= qh_nearvertex(upperfacet, point, &dist);
     qh_vertexneighbors();
     FOREACHneighbor_(vertex) {
       if (neighbor->upperdelaunay || neighbor->flipped)
-	continue;
+        continue;
       (*numpart)++;
-      qh_distplane (point, neighbor, &dist);
+      qh_distplane(point, neighbor, &dist);
       if (dist > bestdist) {
-	bestfacet= neighbor;
-	bestdist= dist;
+        bestfacet= neighbor;
+        bestdist= dist;
       }
     }
   }
   if (!bestfacet) {
-    fprintf(qh ferr, "\n\
-qh_findbestlower: all neighbors of facet %d are flipped or upper Delaunay.\n\
+    qh_fprintf(qh ferr, 6228, "\n\
+Qhull internal error (qh_findbestlower): all neighbors of facet %d are flipped or upper Delaunay.\n\
 Please report this error to qhull_bug@qhull.org with the input and all of the output.\n",
        upperfacet->id);
-    qh_errexit (qh_ERRqhull, upperfacet, NULL);
+    qh_errexit(qh_ERRqhull, upperfacet, NULL);
   }
   *bestdistp= bestdist;
-  trace3((qh ferr, "qh_findbestlower: f%d dist %2.2g for f%d p%d\n",
-	  bestfacet->id, bestdist, upperfacet->id, qh_pointid(point)));
+  trace3((qh ferr, 3015, "qh_findbestlower: f%d dist %2.2g for f%d p%d\n",
+          bestfacet->id, bestdist, upperfacet->id, qh_pointid(point)));
   return bestfacet;
 } /* findbestlower */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="findfacet_all">-</a>
-  
+
   qh_findfacet_all( point, bestdist, isoutside, numpart )
-    exhaustive search for facet below a point 
+    exhaustive search for facet below a point
 
-    for Delaunay triangulations, 
+    for Delaunay triangulations,
       Use qh_setdelaunay() to lift point to paraboloid and scale by 'Qbb' if needed
-      Do not use options 'Qbk', 'QBk', or 'QbB' since they scale the coordinates. 
+      Do not use options 'Qbk', 'QBk', or 'QbB' since they scale the coordinates.
 
   returns:
     returns first facet below point
-    if point is inside, 
+    if point is inside,
       returns nearest facet
     distance to facet
     isoutside if point is outside of the hull
     number of distance tests
+
+  notes:
+    for library users, not used by Qhull
 */
-facetT *qh_findfacet_all (pointT *point, realT *bestdist, boolT *isoutside,
-			  int *numpart) {
+facetT *qh_findfacet_all(pointT *point, realT *bestdist, boolT *isoutside,
+                          int *numpart) {
   facetT *bestfacet= NULL, *facet;
   realT dist;
   int totpart= 0;
-  
-  *bestdist= REALmin;
+
+  *bestdist= -REALmax;
   *isoutside= False;
   FORALLfacets {
     if (facet->flipped || !facet->normal)
       continue;
     totpart++;
-    qh_distplane (point, facet, &dist);
+    qh_distplane(point, facet, &dist);
     if (dist > *bestdist) {
       *bestdist= dist;
       bestfacet= facet;
@@ -1312,14 +1314,14 @@
     }
   }
   *numpart= totpart;
-  trace3((qh ferr, "qh_findfacet_all: f%d dist %2.2g isoutside %d totpart %d\n",
-	  getid_(bestfacet), *bestdist, *isoutside, totpart));
+  trace3((qh ferr, 3016, "qh_findfacet_all: f%d dist %2.2g isoutside %d totpart %d\n",
+          getid_(bestfacet), *bestdist, *isoutside, totpart));
   return bestfacet;
-} /* findfacet_all */ 
- 
+} /* findfacet_all */
+
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="findgood">-</a>
-  
+
   qh_findgood( facetlist, goodhorizon )
     identify good facets for qh.PRINTgood
     if qh.GOODvertex>0
@@ -1327,29 +1329,29 @@
       if !match, returns goodhorizon
       inactive if qh.MERGING
     if qh.GOODpoint
-      facet is visible or coplanar (>0) or not visible (<0) 
+      facet is visible or coplanar (>0) or not visible (<0)
     if qh.GOODthreshold
       facet->normal matches threshold
-    if !goodhorizon and !match, 
+    if !goodhorizon and !match,
       selects facet with closest angle
       sets GOODclosest
-      
+
   returns:
     number of new, good facets found
     determines facet->good
     may update qh.GOODclosest
-    
+
   notes:
     qh_findgood_all further reduces the good region
 
   design:
     count good facets
-    mark good facets for qh.GOODpoint  
+    mark good facets for qh.GOODpoint
     mark good facets for qh.GOODthreshold
     if necessary
-      update qh.GOODclosest  
+      update qh.GOODclosest
 */
-int qh_findgood (facetT *facetlist, int goodhorizon) {
+int qh_findgood(facetT *facetlist, int goodhorizon) {
   facetT *facet, *bestfacet= NULL;
   realT angle, bestangle= REALmax, dist;
   int  numgood=0;
@@ -1360,7 +1362,7 @@
   }
   if (qh GOODvertex>0 && !qh MERGING) {
     FORALLfacet_(facetlist) {
-      if (!qh_isvertex (qh GOODvertexp, facet->vertices)) {
+      if (!qh_isvertex(qh GOODvertexp, facet->vertices)) {
         facet->good= False;
         numgood--;
       }
@@ -1370,7 +1372,7 @@
     FORALLfacet_(facetlist) {
       if (facet->good && facet->normal) {
         zinc_(Zdistgood);
-        qh_distplane (qh GOODpointp, facet, &dist);
+        qh_distplane(qh GOODpointp, facet, &dist);
         if ((qh GOODpoint > 0) ^ (dist > 0.0)) {
           facet->good= False;
           numgood--;
@@ -1381,7 +1383,7 @@
   if (qh GOODthreshold && (numgood || goodhorizon || qh GOODclosest)) {
     FORALLfacet_(facetlist) {
       if (facet->good && facet->normal) {
-        if (!qh_inthresholds (facet->normal, &angle)) {
+        if (!qh_inthresholds(facet->normal, &angle)) {
           facet->good= False;
           numgood--;
           if (angle < bestangle) {
@@ -1393,23 +1395,23 @@
     }
     if (!numgood && (!goodhorizon || qh GOODclosest)) {
       if (qh GOODclosest) {
-	if (qh GOODclosest->visible)
-	  qh GOODclosest= NULL;
-	else {
-	  qh_inthresholds (qh GOODclosest->normal, &angle);
-	  if (angle < bestangle)
-	    bestfacet= qh GOODclosest;
-	}
+        if (qh GOODclosest->visible)
+          qh GOODclosest= NULL;
+        else {
+          qh_inthresholds(qh GOODclosest->normal, &angle);
+          if (angle < bestangle)
+            bestfacet= qh GOODclosest;
+        }
       }
       if (bestfacet && bestfacet != qh GOODclosest) {
-	if (qh GOODclosest)
-	  qh GOODclosest->good= False;
-	qh GOODclosest= bestfacet;
-	bestfacet->good= True;
-	numgood++;
-	trace2((qh ferr, "qh_findgood: f%d is closest (%2.2g) to thresholds\n", 
+        if (qh GOODclosest)
+          qh GOODclosest->good= False;
+        qh GOODclosest= bestfacet;
+        bestfacet->good= True;
+        numgood++;
+        trace2((qh ferr, 2044, "qh_findgood: f%d is closest(%2.2g) to thresholds\n",
            bestfacet->id, bestangle));
-	return numgood;
+        return numgood;
       }
     }else if (qh GOODclosest) { /* numgood > 0 */
       qh GOODclosest->good= False;
@@ -1417,19 +1419,19 @@
     }
   }
   zadd_(Zgoodfacet, numgood);
-  trace2((qh ferr, "qh_findgood: found %d good facets with %d good horizon\n",
+  trace2((qh ferr, 2045, "qh_findgood: found %d good facets with %d good horizon\n",
                numgood, goodhorizon));
-  if (!numgood && qh GOODvertex>0 && !qh MERGING) 
+  if (!numgood && qh GOODvertex>0 && !qh MERGING)
     return goodhorizon;
   return numgood;
 } /* findgood */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="findgood_all">-</a>
-  
+
   qh_findgood_all( facetlist )
     apply other constraints for good facets (used by qh.PRINTgood)
-    if qh.GOODvertex 
+    if qh.GOODvertex
       facet includes (>0) or doesn't include (<0) point as vertex
       if last good facet and ONLYgood, prints warning and continues
     if qh.SPLITthresholds
@@ -1447,36 +1449,36 @@
   design:
     uses qh_findgood to mark good facets
     marks facets for qh.GOODvertex
-    marks facets for qh.SPLITthreholds  
+    marks facets for qh.SPLITthreholds
 */
-void qh_findgood_all (facetT *facetlist) {
+void qh_findgood_all(facetT *facetlist) {
   facetT *facet, *bestfacet=NULL;
   realT angle, bestangle= REALmax;
   int  numgood=0, startgood;
 
-  if (!qh GOODvertex && !qh GOODthreshold && !qh GOODpoint 
+  if (!qh GOODvertex && !qh GOODthreshold && !qh GOODpoint
   && !qh SPLITthresholds)
     return;
   if (!qh ONLYgood)
-    qh_findgood (qh facet_list, 0);
+    qh_findgood(qh facet_list, 0);
   FORALLfacet_(facetlist) {
     if (facet->good)
       numgood++;
   }
   if (qh GOODvertex <0 || (qh GOODvertex > 0 && qh MERGING)) {
     FORALLfacet_(facetlist) {
-      if (facet->good && ((qh GOODvertex > 0) ^ !!qh_isvertex (qh GOODvertexp, facet->vertices))) {
+      if (facet->good && ((qh GOODvertex > 0) ^ !!qh_isvertex(qh GOODvertexp, facet->vertices))) {
         if (!--numgood) {
-	  if (qh ONLYgood) {
-            fprintf (qh ferr, "qhull warning: good vertex p%d does not match last good facet f%d.  Ignored.\n",
+          if (qh ONLYgood) {
+            qh_fprintf(qh ferr, 7064, "qhull warning: good vertex p%d does not match last good facet f%d.  Ignored.\n",
                qh_pointid(qh GOODvertexp), facet->id);
-	    return;
-	  }else if (qh GOODvertex > 0)
-            fprintf (qh ferr, "qhull warning: point p%d is not a vertex ('QV%d').\n",
-		qh GOODvertex-1, qh GOODvertex-1);
-	  else
-            fprintf (qh ferr, "qhull warning: point p%d is a vertex for every facet ('QV-%d').\n",
-	        -qh GOODvertex - 1, -qh GOODvertex - 1);
+            return;
+          }else if (qh GOODvertex > 0)
+            qh_fprintf(qh ferr, 7065, "qhull warning: point p%d is not a vertex('QV%d').\n",
+                qh GOODvertex-1, qh GOODvertex-1);
+          else
+            qh_fprintf(qh ferr, 7066, "qhull warning: point p%d is a vertex for every facet('QV-%d').\n",
+                -qh GOODvertex - 1, -qh GOODvertex - 1);
         }
         facet->good= False;
       }
@@ -1486,7 +1488,7 @@
   if (qh SPLITthresholds) {
     FORALLfacet_(facetlist) {
       if (facet->good) {
-        if (!qh_inthresholds (facet->normal, &angle)) {
+        if (!qh_inthresholds(facet->normal, &angle)) {
           facet->good= False;
           numgood--;
           if (angle < bestangle) {
@@ -1499,19 +1501,19 @@
     if (!numgood && bestfacet) {
       bestfacet->good= True;
       numgood++;
-      trace0((qh ferr, "qh_findgood_all: f%d is closest (%2.2g) to thresholds\n", 
+      trace0((qh ferr, 23, "qh_findgood_all: f%d is closest(%2.2g) to thresholds\n",
            bestfacet->id, bestangle));
       return;
     }
   }
   qh num_good= numgood;
-  trace0((qh ferr, "qh_findgood_all: %d good facets remain out of %d facets\n",
+  trace0((qh ferr, 24, "qh_findgood_all: %d good facets remain out of %d facets\n",
         numgood, startgood));
 } /* findgood_all */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="furthestnext">-</a>
-  
+
   qh_furthestnext()
     set qh.facet_next to facet with furthest of all furthest points
     searches all facets on qh.facet_list
@@ -1519,7 +1521,7 @@
   notes:
     this may help avoid precision problems
 */
-void qh_furthestnext (void /* qh facet_list */) {
+void qh_furthestnext(void /* qh facet_list */) {
   facetT *facet, *bestfacet= NULL;
   realT dist, bestdist= -REALmax;
 
@@ -1527,29 +1529,29 @@
     if (facet->outsideset) {
 #if qh_COMPUTEfurthest
       pointT *furthest;
-      furthest= (pointT*)qh_setlast (facet->outsideset);
+      furthest= (pointT*)qh_setlast(facet->outsideset);
       zinc_(Zcomputefurthest);
-      qh_distplane (furthest, facet, &dist);
+      qh_distplane(furthest, facet, &dist);
 #else
       dist= facet->furthestdist;
 #endif
       if (dist > bestdist) {
-	bestfacet= facet;
-	bestdist= dist;
+        bestfacet= facet;
+        bestdist= dist;
       }
     }
   }
   if (bestfacet) {
-    qh_removefacet (bestfacet);
-    qh_prependfacet (bestfacet, &qh facet_next);
-    trace1((qh ferr, "qh_furthestnext: made f%d next facet (dist %.2g)\n",
-	    bestfacet->id, bestdist));
+    qh_removefacet(bestfacet);
+    qh_prependfacet(bestfacet, &qh facet_next);
+    trace1((qh ferr, 1029, "qh_furthestnext: made f%d next facet(dist %.2g)\n",
+            bestfacet->id, bestdist));
   }
 } /* furthestnext */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="furthestout">-</a>
-  
+
   qh_furthestout( facet )
     make furthest outside point the last point of outsideset
 
@@ -1562,12 +1564,12 @@
     determine best point of outsideset
     make it the last point of outsideset
 */
-void qh_furthestout (facetT *facet) {
+void qh_furthestout(facetT *facet) {
   pointT *point, **pointp, *bestpoint= NULL;
   realT dist, bestdist= -REALmax;
 
   FOREACHpoint_(facet->outsideset) {
-    qh_distplane (point, facet, &dist);
+    qh_distplane(point, facet, &dist);
     zinc_(Zcomputefurthest);
     if (dist > bestdist) {
       bestpoint= point;
@@ -1575,33 +1577,33 @@
     }
   }
   if (bestpoint) {
-    qh_setdel (facet->outsideset, point);
-    qh_setappend (&facet->outsideset, point);
+    qh_setdel(facet->outsideset, point);
+    qh_setappend(&facet->outsideset, point);
 #if !qh_COMPUTEfurthest
     facet->furthestdist= bestdist;
 #endif
   }
   facet->notfurthest= False;
-  trace3((qh ferr, "qh_furthestout: p%d is furthest outside point of f%d\n",
-	  qh_pointid (point), facet->id));
+  trace3((qh ferr, 3017, "qh_furthestout: p%d is furthest outside point of f%d\n",
+          qh_pointid(point), facet->id));
 } /* furthestout */
 
 
 /*-<a                             href="qh-qhull.htm#TOC"
   >-------------------------------</a><a name="infiniteloop">-</a>
-  
+
   qh_infiniteloop( facet )
     report infinite loop error due to facet
 */
-void qh_infiniteloop (facetT *facet) {
+void qh_infiniteloop(facetT *facet) {
 
-  fprintf (qh ferr, "qhull internal error (qh_infiniteloop): potential infinite loop detected\n");
-  qh_errexit (qh_ERRqhull, facet, NULL);
+  qh_fprintf(qh ferr, 6149, "qhull internal error (qh_infiniteloop): potential infinite loop detected\n");
+  qh_errexit(qh_ERRqhull, facet, NULL);
 } /* qh_infiniteloop */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="initbuild">-</a>
-  
+
   qh_initbuild()
     initialize hull and outside sets with point array
     qh.FIRSTpoint/qh.NUMpoints is point array
@@ -1616,12 +1618,12 @@
   design:
     initialize global variables used during qh_buildhull
     determine precision constants and points with max/min coordinate values
-      if qh.SCALElast, scale last coordinate (for 'd')
+      if qh.SCALElast, scale last coordinate(for 'd')
     build initial simplex
     partition input points into facets of initial simplex
     set up lists
     if qh.ONLYgood
-      check consistency  
+      check consistency
       add qh.GOODvertex if defined
 */
 void qh_initbuild( void) {
@@ -1637,101 +1639,101 @@
   qh visit_id= qh vertex_visit= 0;
   qh maxoutdone= False;
 
-  if (qh GOODpoint > 0) 
-    qh GOODpointp= qh_point (qh GOODpoint-1);
-  else if (qh GOODpoint < 0) 
-    qh GOODpointp= qh_point (-qh GOODpoint-1);
+  if (qh GOODpoint > 0)
+    qh GOODpointp= qh_point(qh GOODpoint-1);
+  else if (qh GOODpoint < 0)
+    qh GOODpointp= qh_point(-qh GOODpoint-1);
   if (qh GOODvertex > 0)
-    qh GOODvertexp= qh_point (qh GOODvertex-1);
-  else if (qh GOODvertex < 0) 
-    qh GOODvertexp= qh_point (-qh GOODvertex-1);
-  if ((qh GOODpoint  
+    qh GOODvertexp= qh_point(qh GOODvertex-1);
+  else if (qh GOODvertex < 0)
+    qh GOODvertexp= qh_point(-qh GOODvertex-1);
+  if ((qh GOODpoint
        && (qh GOODpointp < qh first_point  /* also catches !GOODpointp */
-	   || qh GOODpointp > qh_point (qh num_points-1)))
+           || qh GOODpointp > qh_point(qh num_points-1)))
     || (qh GOODvertex
-	&& (qh GOODvertexp < qh first_point  /* also catches !GOODvertexp */
-	    || qh GOODvertexp > qh_point (qh num_points-1)))) {
-    fprintf (qh ferr, "qhull input error: either QGn or QVn point is > p%d\n",
-	     qh num_points-1);
-    qh_errexit (qh_ERRinput, NULL, NULL);
+        && (qh GOODvertexp < qh first_point  /* also catches !GOODvertexp */
+            || qh GOODvertexp > qh_point(qh num_points-1)))) {
+    qh_fprintf(qh ferr, 6150, "qhull input error: either QGn or QVn point is > p%d\n",
+             qh num_points-1);
+    qh_errexit(qh_ERRinput, NULL, NULL);
   }
   maxpoints= qh_maxmin(qh first_point, qh num_points, qh hull_dim);
   if (qh SCALElast)
-    qh_scalelast (qh first_point, qh num_points, qh hull_dim,
+    qh_scalelast(qh first_point, qh num_points, qh hull_dim,
                qh MINlastcoord, qh MAXlastcoord, qh MAXwidth);
   qh_detroundoff();
   if (qh DELAUNAY && qh upper_threshold[qh hull_dim-1] > REALmax/2
                   && qh lower_threshold[qh hull_dim-1] < -REALmax/2) {
-    for (i= qh_PRINTEND; i--; ) {
-      if (qh PRINTout[i] == qh_PRINTgeom && qh DROPdim < 0 
- 	  && !qh GOODthreshold && !qh SPLITthresholds)
-	break;  /* in this case, don't set upper_threshold */
+    for (i=qh_PRINTEND; i--; ) {
+      if (qh PRINTout[i] == qh_PRINTgeom && qh DROPdim < 0
+          && !qh GOODthreshold && !qh SPLITthresholds)
+        break;  /* in this case, don't set upper_threshold */
     }
     if (i < 0) {
       if (qh UPPERdelaunay) { /* matches qh.upperdelaunay in qh_setfacetplane */
-	qh lower_threshold[qh hull_dim-1]= qh ANGLEround * qh_ZEROdelaunay;
-	qh GOODthreshold= True;
-      }else { 
-	qh upper_threshold[qh hull_dim-1]= -qh ANGLEround * qh_ZEROdelaunay;
-        if (!qh GOODthreshold) 
-	  qh SPLITthresholds= True; /* build upper-convex hull even if Qg */
+        qh lower_threshold[qh hull_dim-1]= qh ANGLEround * qh_ZEROdelaunay;
+        qh GOODthreshold= True;
+      }else {
+        qh upper_threshold[qh hull_dim-1]= -qh ANGLEround * qh_ZEROdelaunay;
+        if (!qh GOODthreshold)
+          qh SPLITthresholds= True; /* build upper-convex hull even if Qg */
           /* qh_initqhull_globals errors if Qg without Pdk/etc. */
       }
     }
   }
-  vertices= qh_initialvertices(qh hull_dim, maxpoints, qh first_point, qh num_points); 
-  qh_initialhull (vertices);  /* initial qh facet_list */
-  qh_partitionall (vertices, qh first_point, qh num_points);
+  vertices= qh_initialvertices(qh hull_dim, maxpoints, qh first_point, qh num_points);
+  qh_initialhull(vertices);  /* initial qh facet_list */
+  qh_partitionall(vertices, qh first_point, qh num_points);
   if (qh PRINToptions1st || qh TRACElevel || qh IStracing) {
     if (qh TRACElevel || qh IStracing)
-      fprintf (qh ferr, "\nTrace level %d for %s | %s\n", 
+      qh_fprintf(qh ferr, 8103, "\nTrace level %d for %s | %s\n",
          qh IStracing ? qh IStracing : qh TRACElevel, qh rbox_command, qh qhull_command);
-    fprintf (qh ferr, "Options selected for Qhull %s:\n%s\n", qh_version, qh qhull_options);
+    qh_fprintf(qh ferr, 8104, "Options selected for Qhull %s:\n%s\n", qh_version, qh qhull_options);
   }
-  qh_resetlists (False, qh_RESETvisible /*qh visible_list newvertex_list newfacet_list */);
+  qh_resetlists(False, qh_RESETvisible /*qh visible_list newvertex_list newfacet_list */);
   qh facet_next= qh facet_list;
-  qh_furthestnext (/* qh facet_list */);
+  qh_furthestnext(/* qh facet_list */);
   if (qh PREmerge) {
     qh cos_max= qh premerge_cos;
     qh centrum_radius= qh premerge_centrum;
   }
   if (qh ONLYgood) {
     if (qh GOODvertex > 0 && qh MERGING) {
-      fprintf (qh ferr, "qhull input error: 'Qg QVn' (only good vertex) does not work with merging.\nUse 'QJ' to joggle the input or 'Q0' to turn off merging.\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6151, "qhull input error: 'Qg QVn' (only good vertex) does not work with merging.\nUse 'QJ' to joggle the input or 'Q0' to turn off merging.\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
     if (!(qh GOODthreshold || qh GOODpoint
          || (!qh MERGEexact && !qh PREmerge && qh GOODvertexp))) {
-      fprintf (qh ferr, "qhull input error: 'Qg' (ONLYgood) needs a good threshold ('Pd0D0'), a\n\
-good point (QGn or QG-n), or a good vertex with 'QJ' or 'Q0' (QVn).\n");
-      qh_errexit (qh_ERRinput, NULL, NULL);
+      qh_fprintf(qh ferr, 6152, "qhull input error: 'Qg' (ONLYgood) needs a good threshold('Pd0D0'), a\n\
+good point(QGn or QG-n), or a good vertex with 'QJ' or 'Q0' (QVn).\n");
+      qh_errexit(qh_ERRinput, NULL, NULL);
     }
     if (qh GOODvertex > 0  && !qh MERGING  /* matches qh_partitionall */
-	&& !qh_isvertex (qh GOODvertexp, vertices)) {
-      facet= qh_findbestnew (qh GOODvertexp, qh facet_list, 
-			  &dist, !qh_ALL, &isoutside, &numpart);
+        && !qh_isvertex(qh GOODvertexp, vertices)) {
+      facet= qh_findbestnew(qh GOODvertexp, qh facet_list,
+                          &dist, !qh_ALL, &isoutside, &numpart);
       zadd_(Zdistgood, numpart);
       if (!isoutside) {
-        fprintf (qh ferr, "qhull input error: point for QV%d is inside initial simplex.  It can not be made a vertex.\n",
-	       qh_pointid(qh GOODvertexp));
-        qh_errexit (qh_ERRinput, NULL, NULL);
+        qh_fprintf(qh ferr, 6153, "qhull input error: point for QV%d is inside initial simplex.  It can not be made a vertex.\n",
+               qh_pointid(qh GOODvertexp));
+        qh_errexit(qh_ERRinput, NULL, NULL);
       }
-      if (!qh_addpoint (qh GOODvertexp, facet, False)) {
-	qh_settempfree(&vertices);
-	qh_settempfree(&maxpoints);
-	return;
+      if (!qh_addpoint(qh GOODvertexp, facet, False)) {
+        qh_settempfree(&vertices);
+        qh_settempfree(&maxpoints);
+        return;
       }
     }
-    qh_findgood (qh facet_list, 0);
+    qh_findgood(qh facet_list, 0);
   }
   qh_settempfree(&vertices);
   qh_settempfree(&maxpoints);
-  trace1((qh ferr, "qh_initbuild: initial hull created and points partitioned\n"));
+  trace1((qh ferr, 1030, "qh_initbuild: initial hull created and points partitioned\n"));
 } /* initbuild */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="initialhull">-</a>
-  
+
   qh_initialhull( vertices )
     constructs the initial hull as a DIM3 simplex of vertices
 
@@ -1741,7 +1743,7 @@
     sets hyperplanes for facets
     doubles checks orientation (in case of axis-parallel facets with Gaussian elimination)
     checks for flipped facets and qh.NARROWhull
-    checks the result   
+    checks the result
 */
 void qh_initialhull(setT *vertices) {
   facetT *facet, *firstfacet, *neighbor, **neighborp;
@@ -1751,71 +1753,66 @@
 #endif
 
   qh_createsimplex(vertices);  /* qh facet_list */
-  qh_resetlists (False, qh_RESETvisible);
+  qh_resetlists(False, qh_RESETvisible);
   qh facet_next= qh facet_list;      /* advance facet when processed */
   qh interior_point= qh_getcenter(vertices);
   firstfacet= qh facet_list;
   qh_setfacetplane(firstfacet);
   zinc_(Znumvisibility); /* needs to be in printsummary */
   qh_distplane(qh interior_point, firstfacet, &dist);
-  if (dist > 0) {  
+  if (dist > 0) {
     FORALLfacets
-      facet->toporient ^= True;
+      facet->toporient ^= (unsigned char)True;
   }
   FORALLfacets
     qh_setfacetplane(facet);
   FORALLfacets {
-    if (!qh_checkflipped (facet, NULL, qh_ALL)) {/* due to axis-parallel facet */
-      trace1((qh ferr, "qh_initialhull: initial orientation incorrect.  Correct all facets\n"));
+    if (!qh_checkflipped(facet, NULL, qh_ALL)) {/* due to axis-parallel facet */
+      trace1((qh ferr, 1031, "qh_initialhull: initial orientation incorrect.  Correct all facets\n"));
       facet->flipped= False;
       FORALLfacets {
-	facet->toporient ^= True;
-	qh_orientoutside (facet);
+        facet->toporient ^= (unsigned char)True;
+        qh_orientoutside(facet);
       }
       break;
     }
   }
   FORALLfacets {
-    if (!qh_checkflipped (facet, NULL, !qh_ALL)) {  /* can happen with 'R0.1' */
-      qh_precision ("initial facet is coplanar with interior point");
-      fprintf (qh ferr, "qhull precision error: initial facet %d is coplanar with the interior point\n",
+    if (!qh_checkflipped(facet, NULL, !qh_ALL)) {  /* can happen with 'R0.1' */
+      qh_precision("initial facet is coplanar with interior point");
+      qh_fprintf(qh ferr, 6154, "qhull precision error: initial facet %d is coplanar with the interior point\n",
                    facet->id);
-      qh_errexit (qh_ERRsingular, facet, NULL);
+      qh_errexit(qh_ERRsingular, facet, NULL);
     }
     FOREACHneighbor_(facet) {
-      angle= qh_getangle (facet->normal, neighbor->normal);
+      angle= qh_getangle(facet->normal, neighbor->normal);
       minimize_( minangle, angle);
     }
   }
-  if (minangle < qh_MAXnarrow && !qh NOnarrow) { 
+  if (minangle < qh_MAXnarrow && !qh NOnarrow) {
     realT diff= 1.0 + minangle;
 
     qh NARROWhull= True;
-    qh_option ("_narrow-hull", NULL, &diff);
+    qh_option("_narrow-hull", NULL, &diff);
     if (minangle < qh_WARNnarrow && !qh RERUN && qh PRINTprecision)
-      fprintf (qh ferr, "qhull precision warning: \n\
-The initial hull is narrow (cosine of min. angle is %.16f).\n\
-A coplanar point may lead to a wide facet.  Options 'QbB' (scale to unit box)\n\
-or 'Qbb' (scale last coordinate) may remove this warning.  Use 'Pp' to skip\n\
-this warning.  See 'Limitations' in qh-impre.htm.\n",
-          -minangle);   /* convert from angle between normals to angle between facets */
+      qh_printhelp_narrowhull(qh ferr, minangle);
   }
   zzval_(Zprocessed)= qh hull_dim+1;
-  qh_checkpolygon (qh facet_list);
+  qh_checkpolygon(qh facet_list);
   qh_checkconvex(qh facet_list,   qh_DATAfault);
 #ifndef qh_NOtrace
   if (qh IStracing >= 1) {
-    fprintf(qh ferr, "qh_initialhull: simplex constructed, interior point:");
-    for (k=0; k < qh hull_dim; k++) 
-      fprintf (qh ferr, " %6.4g", qh interior_point[k]);
-    fprintf (qh ferr, "\n");
+    qh_fprintf(qh ferr, 8105, "qh_initialhull: simplex constructed, interior point:");
+    for (k=0; k < qh hull_dim; k++)
+      qh_fprintf(qh ferr, 8106, " %6.4g", qh interior_point[k]);
+    qh_fprintf(qh ferr, 8107, "\n");
   }
 #endif
 } /* initialhull */
 
 /*-<a                             href="qh-poly.htm#TOC"
   >-------------------------------</a><a name="initialvertices">-</a>
-  
+
   qh_initialvertices( dim, maxpoints, points, numpoints )
     determines a non-singular set of initial vertices
     maxpoints may include duplicate points
@@ -1824,97 +1821,97 @@
     temporary set of dim+1 vertices in descending order by vertex id
     if qh.RANDOMoutside && !qh.ALLpoints
       picks random points
-    if dim >= qh_INITIALmax, 
+    if dim >= qh_INITIALmax,
       uses min/max x and max points with non-zero determinants
 
   notes:
-    unless qh.ALLpoints, 
+    unless qh.ALLpoints,
       uses maxpoints as long as determinate is non-zero
 */
 setT *qh_initialvertices(int dim, setT *maxpoints, pointT *points, int numpoints) {
   pointT *point, **pointp;
   setT *vertices, *simplex, *tested;
   realT randr;
-  int index, point_i, point_n, k;
+  int idx, point_i, point_n, k;
   boolT nearzero= False;
-  
-  vertices= qh_settemp (dim + 1);
-  simplex= qh_settemp (dim+1);
-  if (qh ALLpoints) 
-    qh_maxsimplex (dim, NULL, points, numpoints, &simplex);
+
+  vertices= qh_settemp(dim + 1);
+  simplex= qh_settemp(dim+1);
+  if (qh ALLpoints)
+    qh_maxsimplex(dim, NULL, points, numpoints, &simplex);
   else if (qh RANDOMoutside) {
-    while (qh_setsize (simplex) != dim+1) {
+    while (qh_setsize(simplex) != dim+1) {
       randr= qh_RANDOMint;
       randr= randr/(qh_RANDOMmax+1);
-      index= (int)floor(qh num_points * randr);
-      while (qh_setin (simplex, qh_point (index))) {
-	index++; /* in case qh_RANDOMint always returns the same value */
-        index= index < qh num_points ? index : 0;
+      idx= (int)floor(qh num_points * randr);
+      while (qh_setin(simplex, qh_point(idx))) {
+            idx++; /* in case qh_RANDOMint always returns the same value */
+        idx= idx < qh num_points ? idx : 0;
       }
-      qh_setappend (&simplex, qh_point (index));
+      qh_setappend(&simplex, qh_point(idx));
     }
   }else if (qh hull_dim >= qh_INITIALmax) {
-    tested= qh_settemp (dim+1);
-    qh_setappend (&simplex, SETfirst_(maxpoints));   /* max and min X coord */
-    qh_setappend (&simplex, SETsecond_(maxpoints));
-    qh_maxsimplex (fmin_(qh_INITIALsearch, dim), maxpoints, points, numpoints, &simplex);
-    k= q