octave-maintainers
[Top][All Lists]
Advanced

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

qh_new_qhull calling conventions


From: Rik
Subject: qh_new_qhull calling conventions
Date: Tue, 31 Jan 2012 21:20:10 -0800

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

Attachment: qhulltst.cc
Description: Text Data

Attachment: Makefile
Description: Text document


reply via email to

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