#include <isosurface.h>
Display an isosurface of a 3D image. It uses the marching cube algorithm to display the isosurface mesh.
To compute the normal of the mesh two options are available. The first method uses the triangle normals. The resulting mesh is blocky as the normal is identical on the whole triangle. The second method uses the data gradient. The resulting mesh is smoother as the normal is different on the triangle. The default is to use the gradient method as it gives a nicer mesh.
It the isosurface to be displayed is showing a darker region, the surface normals must be changed as they normally points from bright to dark regions.
For better results use the following OpenGL initialization:
glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
The Marching Cube code is adapted from Paul Bourke code which can be found at: http://local.wasp.uwa.edu.au/~pbourke/modelling/polygonise/
Public Member Functions | |
IsoSurface () | |
~IsoSurface () | |
void | display () const |
template<typename DataType> | |
void | update (const DataType *data, unsigned int width, unsigned int height, unsigned depth, float isovalue, bool from_bright_to_dark=true, bool use_gradient=true) |
Classes | |
struct | GRIDCELL |
struct | TRIANGLE |
struct | XYZ |
Display::IsoSurface::IsoSurface | ( | ) |
Display::IsoSurface::~IsoSurface | ( | ) |
void Display::IsoSurface::display | ( | ) | const |
display the isosurface mesh
void Display::IsoSurface::update | ( | const DataType * | data, | |
unsigned int | width, | |||
unsigned int | height, | |||
unsigned | depth, | |||
float | isovalue, | |||
bool | from_bright_to_dark = true , |
|||
bool | use_gradient = true | |||
) | [inline] |
create a new mesh
data | 3D image to extract the isovalue | |
width | width of the data | |
height | height of the data | |
depth | depth of the data | |
isovalue | isovalue to extract | |
from_bright_to_dark | is the surface enclosing a bright (true) or dark (false) surface | |
use_gradient | compute the surface normals from the image gradient (smoother) rather than using triangle normals (produces facets) |