octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: qh_new_qhull calling conventions


From: Brad Barber
Subject: Re: qh_new_qhull calling conventions
Date: Wed, 01 Feb 2012 19:20:57 -0500

At 12:20 AM 2/1/2012, Rik wrote:
>1/31/12
>
>Brad,
>
>I built a small C++ test case to verify the problem with Qhull returning
>either 6 or 12 facets when given a 3D cube input.  I was correct that the
>behavior changed from 2009 to 2012.  But, you were correct that something
>was wrong with the Octave code.
>
>The prototype for the function qh_new_qhull is:
>
>int qh_new_qhull(int dim, int numpoints, coordT *points, boolT ismalloc,
>                 char *qhull_cmd, FILE *outfile, FILE *errfile);
>
>In Octave, the FILE pointers are initialized as
>
>// Replace the 0 pointer with stdout for debugging information.
>FILE *outfile = 0;
>FILE *errfile = stderr;
>
>In Qhull2012 this causes no problems.  In Qhull2009, however, I get a hull
>with only 6 facets.  However, if I initialize outfile to a valid FILE
>pointer such as stdout or a pointer returned from fopen() then Qhull2009
>returns 12 facets.  If I had to guess, I'd say that Qhull2009 is not
>checking the argument for a NULL pointer and there is some sort of memory
>corruption happening.
>
>In my test case, I solved the problem by using
>
>FILE *outfile = fopen ("/dev/null", "w");
>
>Octave Maintainer's:
>
>This should be solved before the 3.6.1 release.  Does anybody have a good
>way to create a throw-away FILE pointer?
>
>The "/dev/null" solution would be fine except I'm not certain it would work
>on MinGW and Cygwin platforms.  My little bit of a web search seemed to
>indicate that they DO implement this special file.
>
>Otherwise, we could always use fopen with a temporary file name created
>through tmpnam and then delete it afterwards but this seems like a lot of
>work for every convhull, voronoi, or delaunay call.  
>
>I've attached my test case and Makefile.  On my machine I had Qhull2009
>installed by the package manager in /usr and Qhull2012 installed by hand in
>/usr/local and used -L options to flip between the two.
>
>--Rik

Hi Rik,

Yes that is a known problem that was fixed in Qhull 2011.2.  See the extract 
from Changes.txt below.   It was introduced with the C++ interface where a 
routine was split into two pieces.

For Qhull 2010.1 and 2011.1, if outfile was 0, qh_prepare_output was not 
called.  Since this routine performs the triangulation, it did not occur if 
outfile was 0.  qh_prepare_output performs other tasks such as volume 
computation.  You should either define outfile, or upgrade to 2011.2.

I think part of the problem is that you are trying to support too many versions 
of Qhull from one source tree.  

Also note that all versions of Qhull prior to 2012.1, gcc requires 
-fno-strict-aliasing when compiling qset.c.

It may be easiest to work in person or by phone to resolve these issues.  I 
live in the Boston area.

                        --Brad

------------
Qhull 2011.2  2011/11/29 6.2.1.1446

Bug fixes
 - qh_new_qhull: Call qh_prepare_output if !outfile [A. Aldoma]
   No effect on qhull users since qh_prepare_output is always called. 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]