Jump to content
  • Advertisement
Sign in to follow this  
coollofty

who knows how to use qhull!!

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by cow_in_the_well
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).


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 this post


Link to post
Share on other sites
Quote:
Original post by Dave Eberly
Try 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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!