Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
VolumeMarchingCubes Class Reference

VSG extension (Preview feature) [Medical] Class for computing an isosurface from a VolumeViz data set. More...

#include <Medical/helpers/VolumeMarchingCubes.h>

Public Member Functions

 VolumeMarchingCubes ()
 Constructor.
 
 ~VolumeMarchingCubes ()
 Destructor.
 
SoTriangleSetgetIsosurface (const SoVolumeData &volume, float isovalue)
 Returns the geometry for an isosurface with the specified value.
 
size_t getNumTriangles () const
 Returns number of triangles in most recently generated isosurface.
 
float getIsovalue () const
 Returns isovalue of most recently generated isosurface.
 

Detailed Description

VSG extension (Preview feature) [Medical] Class for computing an isosurface from a VolumeViz data set.

This class contains a simple implementation of the classic Marching Cubes algorithm that computes the geometry (triangles) of an isosurface from a VolumeViz data set. It returns a shape node (e.g. SoTriangleSet) with an attached SoVertexProperty node containing the vertices.

The computed geometry can be exported using the usual Open Inventor tools, for example SoSTLWriteAction will write an STL format file.

This class is not intended to be used for rendering an isosurface and therefore is not implemented as an Open Inventor node. The computed geometry may be rendered, if desired, by adding the returned node to the scene graph. However, the SoVolumeIsosurface node is a much better tool for rendering isosurfaces. Using the GPU, SoVolumeIsosurface can render multiple isosurfaces simultaneously with interactive performance. We recommend using SoVolumeIsosurface for rendering and using this class only when the actual geometry is needed for export.

There are faster and better implementations of isosurface extraction, including the one in Open Inventor's MeshVizXLM extension. You can use that implementation by following the "VolumeMesh" example provided with the Open Inventor SDK. The intent here is for the code to be easy to understand so that applications can extend and modify.

Notes:

  • Performance.
    VolumeViz automatically manages volume data internally as "tiles". Accessing the data in a single tile for computation is very efficient, but accessing across tile boundaries takes more time. This class has optimized code for volumes that fit in a single tile. For best performance, set the volume's tile size equal to the power-of-2 that is greater than or equal to the largest volume dimension, but do not set the tile size larger than 512.
  • Geometry extent.
    We consider the center of each voxel to be a vertex of a regular mesh so we can apply the MarchingCubes algorithm to the mesh. As a result the 3D extent of the mesh starts at volumeMin + 1/2 the voxel size and ends at volumeMax - 1/2 the voxel size.
  • Normal vectors.
    The algorithm does not currently compute normal vectors for the triangle vertices. For rendering, Open Inventor will automatically compute normal vectors, but by default the rendered shape will not be "smooth". We recommend that applications add an SoShapeHints node to the scene graph above the marching cubes geometry node and set the 'creaseAngle' field to PI (3.14159).

Limitations:

  • Separate triangles.
    The geometry is returned as a collection of separate triangles. It would be possible to create an indexed geometry where multiple triangles share vertices, but the implementation would be much more complex. Note that if the geometry will be exported as STL then it will be exported as separate triangles anyway.
  • Triangle quality.
    The classic Marching Cubes algorithm produces a very large number of triangles from a typical volume data set and some triangles may have poor aspect ratio.
  • Region of Interest.
    Currently the algorithm does not consider the region of interest (SoROI). The isosurface is extracted from the whole volume.

SEE ALSO

PlaneGeometryIntersection

Definition at line 109 of file VolumeMarchingCubes.h.

Constructor & Destructor Documentation

◆ VolumeMarchingCubes()

VolumeMarchingCubes::VolumeMarchingCubes ( )

Constructor.

◆ ~VolumeMarchingCubes()

VolumeMarchingCubes::~VolumeMarchingCubes ( )

Destructor.

Member Function Documentation

◆ getIsosurface()

SoTriangleSet * VolumeMarchingCubes::getIsosurface ( const SoVolumeData volume,
float  isovalue 
)

Returns the geometry for an isosurface with the specified value.

The vertices are stored in an SoVertexProperty node which can be accessed in the vertexProperty field of the returned shape node.

Returns null if any error occurs (for example accessing volume data). Returns null if volume contains RGBA data.

◆ getIsovalue()

float VolumeMarchingCubes::getIsovalue ( ) const

Returns isovalue of most recently generated isosurface.

Returns zero if no isosurface has been extracted.

◆ getNumTriangles()

size_t VolumeMarchingCubes::getNumTriangles ( ) const

Returns number of triangles in most recently generated isosurface.

Returns zero if no isosurface has been extracted.


The documentation for this class was generated from the following file: