# who knows how to use qhull!!

This topic is 4853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Who knows how to use the qhull library? I read but don't understand its documents, who can provides some clear tutorials or demo?? THX!

##### Share on other sites
I have used it in the past and then switched it for CGAL, so I have no source anymore. But if you are more specific about your problem I might be able to help.

Greetz,

Illco

##### Share on other sites
Oh, CGAL??
http://www.cgal.org/
Is this? Seems a good library:) maybe I will switched to it too:)

##### Share on other sites
heh, amazing. Just a few days ago I was bashing my head against my keyboard trying to work out how to get qhull to give me what i wanted. It is quite obviously written by mathematicians :P.

What I wanted to do (which I assume you want to do) is to feed it a bunch of points, and be returned a bunch of triangles that represent the hull. After much anguish I figured out the following method (it's a bit of a hack, but it works).

I opted for using qhull as an external process as trying to use the lib in my mesh packer directly probably would have given me even more grey hairs. So, in my packer program, I wrote all my vertex data to a temporary text file. I then launched qhull using system(), feeding in the data from the file via stdin, and told it to output to another temporary file:

system("qhull.exe s p < smpack_qhull_input TO smpack_qhull_output_i")

the s parameter prints a summary, and the 'p' parameter tells it to give me the resulting points.

Now, interestingly enough I could _NOT_ work out how to tell qhull to give me the points as well as giving me triangulated face indices at the same time. I ended up doing it in two passes by calling qhull again on the data from the previous execution:

system("qhull.exe QJ o < smpack_qhull_output_i TO smpack_qhull_output")

QJ "joggles" the data. Apparently that means it triangulates it *shrug*.
o outputs the points as well as the the face indices. You'd think you could do this on the original data set and do it in one pass. But NO it refused to give me triangulated data as well as a hull.

Oh well. It works :)

(After all this I, of course, parsed the results from smpack_qhull_output).

This CGAL looks interesting. I should have looked arounnd for alternatives :|. I might look at it some time in the future.

##### Share on other sites
Quote:
 Original post by cow_in_the_wellheh, amazing. Just a few days ago I was bashing my head against my keyboard trying to work out how to get qhull to give me what i wanted. It is quite obviously written by mathematicians :P.What I wanted to do (which I assume you want to do) is to feed it a bunch of points, and be returned a bunch of triangles that represent the hull. After much anguish I figured out the following method (it's a bit of a hack, but it works).

Try this.
QhullProperties props;props.mNumInputVerts = <number of vertices, int>;props.mInputVertices = <vertices, array of float*>;if (ql.CreateConvexHull(props)){    <number of hull vertices> = props.mNumOutputVertices;    <array of hull vertices>  = props.mOutputVertices;    <number of hull faces>    = props.mNumFaces;    <number of hull indices>  = props.mNumIndices;    <array of hull indices>   = props.mIndices;}

Quote:
 QJ "joggles" the data. Apparently that means it triangulates it *shrug*.

I usually refer to this as "jittering". The points are perturbed slightly to avoid collinear and coplanar points. Most convex hull finders have a difficult time with collinearity and coplanarity. My experience has been that jittering does not always help.

##### Share on other sites
Quote:
 Original post by Dave EberlyTry this.

Heh, heh :) So much for posting late. This was actually a fragment from a wrapper John Ratcliff wrote for qhull for his "Open Dynamics Framework", which included some rewriting of interfaces. For a real sample of how to use qhull, I saw a test project in the qhull distribution for computing the convex hull of some 2D points. Take a look at that for information on how to use it.

##### Share on other sites
mmm....that qhull wrapper looks mighty tasty :). I'll look for that sample you mentioned sometime. I'd definately rather not launch qhull as an external process :).

Thanks.

1. 1
2. 2
3. 3
frob
15
4. 4
5. 5

• 20
• 12
• 13
• 14
• 82
• ### Forum Statistics

• Total Topics
632144
• Total Posts
3004413

×