PDA

View Full Version : Surface triangles

umugl
04-17-2008, 07:11 AM
I would like to understand the process of extracting 3D surface triangle patches from an object in 3D space for STL file generation.

So, given a 3D volume which contains some object, how would I go about finding the patches?

I hope this the proper forum to ask this type of a question...

Thank you!

Budric
04-21-2008, 11:19 AM
That's a fairly hard problem. What kind of data do you have? If you have voxels, look up "marching cubes" algorithm.

If you have your 3d object as a point cloud then there are algorithms that attempt to reconstruct the surface. You can look at Delaunay triangulation as a starting point - although personally I haven't been able to find an actual algorithm to use in 3 dimensions. Are the points noisy or not? That complicates things.

umugl
04-21-2008, 11:49 AM
Thanks Budric,

I know how to do this with marching cubes, but then I could do it all without using OpenGL. Yes the system is voxel-based. And the surface is quite clean, barely any noise and I see the object in a 3D cube in front of me. So with that the challenge is to tesselate that object surface in 3D space and I was curious what a good OpenGL-based approach would be for this job.

If the object were all convex it'd be pretty easy, but it has concave sections, so something like a convex hull won't do :-(

Thanks!

Zengar
04-21-2008, 03:43 PM
umugl, OpenGL is an API for rendering polygonal objects, nothing else. If you know how to solve your problem "without GL", do it. GL is just there to draw it.

ZbuffeR
04-21-2008, 05:15 PM
As said Zengar.
There are some domains of computing that can be interesting to do with a GPU (see the GPGPU stuff, image filtering, feature tracking, matrix computations, CFD, etc) but tesselating a point cloud does not really fit to a stream processor.

-NiCo-
04-22-2008, 03:43 AM
Well, there are GPU implementations of the marching cubes (CUDA) and marching tetrahedra (OpenGL) algorithms available...

ZbuffeR
04-22-2008, 05:15 AM

-NiCo-
04-22-2008, 05:22 AM
There's code for marching cubes in the CUDA SDK (http://www.nvidia.com/object/cuda_get.html) and code for marching tetrahedra in NVidia SDK 10 (http://developer.download.nvidia.com/SDK/10/opengl/samples.html#cg_isosurf) (look for Cg Isosurf).
Some background information on Cg Isosurf can be found in this (http://developer.download.nvidia.com/SDK/10/opengl/OpenGL_SDK_Guide.pdf) whitepaper.

Zengar
04-22-2008, 08:44 AM
I decided to answer the question in the way I did based on umugls position in this and other threads. While I don't doubt that it is possible to solve this problems on GPU, it appeared to me that he doesn't want to use shaders and indeed has a misconception about GL: it seems he wants it to solve his problems "automatically", with a minimal effort from his side. This won't be possible.

-NiCo-
04-22-2008, 09:13 AM
You're right. Being afraid to use shaders is so 20th century ;)

Seth Hoffert
04-22-2008, 12:44 PM
I created a 2D version using the geometry shader to plot implicit 2D plots ( :D ):

http://cse.unl.edu/~shoffert/yinyang2.png

With my 8800 GTS, and with 500x500 divisions with this particular implicit plot (I found the inequality on a website, I didn't come up with it!), it renders at 331 fps.

The inequality is something like this:

(cos(p.y - p.x) - sin(p.y)) * (p.x * p.x * p.x * p.x - 2.0 * p.x * p.x * cos(2.0 * p.y + 2.4 + time) + 0.9) + pow(0.62 * p.x, 1000.0) < 0.0;

with appropriate scaling on p.

Zengar
04-22-2008, 12:55 PM
Wow! You have found THE FORMULA!

Seth Hoffert
04-22-2008, 01:05 PM
Nah, I got the formula from here (http://surreality.info/up/graph%20calc.JPG).

;)

umugl
04-24-2008, 04:20 PM
Now that you are done bickering about the limitations I have to pose, I know it is possible to do this using a GPU's pipeline, and I will find a way. There ain't no mountain high enough.

The reason for my posting here was simply to see if anyone had any prior experience or pointers on this topic, not to fire off a round of sentiments.

Thanks!

Zengar
04-24-2008, 04:53 PM
If you don't want using shaders, do it on the CPU. Doing stuff like that with plain GL is like trying to build a house using a screwdriver only. I mean, you could, but why should you? It won't be fast or nice anyway. Just face it: OpenGL is not designed with such things in mind: it is an API to draw triangles.