Generating Meshes


I’m working on a program that models scientific data (geophysical resistivity) in 3d. I have a function calculates a value for any point (x,y,z) underground. I need to create an OpenGL object that is a ‘shell’ (think 3d topographic map) where the calculated value is within a certain user-defined range. If that description doesn’t make sense, an analogy could be a program that generates an OpenGL model of a skeleton given CAT scan data. There are two main problems that I’m having a hard time figuring out:

  1. The function that computes a resistivity value given a position is necessarily computationally expensive, so I’d like to call it as little as possible.
  2. There may be multiple ‘shells’ and I can’t figure out how to tell when this is the case.

I’d appreciate any pointers, source code, algorithm names, or whatever. Thanks!!


You want to plot an isosurface of a 3D function where the value == X (which in a discrete solution means where value >= X && value < X).

If you have a good derivative of the function, then you can find a jumping-on point by walking your sample cube (hill climbing towards the iso level) and then doing flood-fill out from that point, based on derivative at each point.

If you have disjoint areas (which it sounds like you have) and no special knowledge about the function, you HAVE to calculate it once for each sample point to find all places that are of interest. After you’ve done that, you can do the hill climbing/flood fill much more simply, though, assuming you can fit your data area in memory. Else, divide and conquer :slight_smile:

That’s just the kind of info I needed (new to the 3d graphics world.) I’ve been reading up on the marching cubes algorithm and some variations on it, what’s the deal with the patent? Is it something I’d need to worry about on an open source application? Are there any other algorithms that are comparable and not hindered by patents? Thanks!!


Most scientific data is collected in a grid of some sort. In the hydro world (as with our colleagues in the atmospheric world), we have a grid of IM x JM x KB cells in a curvilinear grid, each cell having:

concentration (of some chemical, possibly many)
u,v,w vectors

We also have x,y of each grid corner which don’t change,

eta (the elevation of the water) which changes every time step, and in sigma coordinates, z=H + eta, so the definition of the cells changes in the vertical every timestep.

For an isosurface, you don’t need derivatives, you simply linearly interpolate in your grid of values to get the value you want, then connect the points to make a surface. See vis5d on sourceforge, it’s not very flexible for my needs, but it’s very cool looking. The difficulty for isosurfaces is that there can be multiple disconnected surfaces, but the algorithm isn’t bad.

We don’t yet do surfaces, we’re more interested in color mapping a slice through our data. We wrote a tool in Java (Stevens Data Visualizer, not yet ready for release) that displays a 4d image where you can map any variable in your dataset to:

x, y, z, color

In the next iteration, I’m also making the vectors generic, so you can display any vector quantity centered within the box.
Feel free to contact me for collaboration and code sharing. The original code is in Java, but I am currently doing bits in C++.