Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Height field clipping

VolumeViz supports clipping the volume against one or more surfaces defined by a height field.The SoUniformGridClipping node specifies a clipping surface defined by a clipping axis (axis field),a bounding box (extent field) in world coordinates and a uniform scalar clipping grid (a 2D array of height values). This tool provides an efficient way for seismic applications to clip volume rendering against horizon surfaces (see also the discussion of SoUniformGridProjectionClipping below). A flat clipping surface with non-zero thickness can also be used in medical applications to implement "thick slice" rendering. The clipping grid does not need to have the same dimensions as the volume to be clipped (it will be sampled and interpolated). The clipping grid may be rotated and translated by standard Open Inventor transform nodes.

The height values specified using a 2D texture. Each texel is a normalized value that, together with the extent, specifies a height. For integer valued textures, the range of the integer type (e.g. 0..255 for byte values) is normalized to the floating point range 0..1. For float valued textures the values should already be in the range 0..1. Each normalized value specifies a height based on the range of values in the extent box along the specified clipping axis. The default clipping axis is the Y axis.

For integer valued textures this is similar to the way values are interpreted for the SoHeightFieldGeometry node. However for float valued textures it is quite different because the SoHeightFieldGeometry node interprets float values as actual height values and ignores the extent values.

It is also possible to specify an "undefined" value using the undefinedValue field. Texels with this value will clip all voxels above and below the surface. The default undefined value is Nan (Not a Number).

The X, Y and Z coordinates of the extent are in the same coordinate system as the volume extent. They specify the bounding box of the clipping surface and also the range of height values that can be specified with the normalized values in the height field texture. They are typically, but not necessariliy, set to the same values as the volume extent. The extent of the clipping surface may be larger than the volume extent. In this case the volume is only clipped where its extent overlaps with the surface. The extent of the clipping surface may also be smaller than the volume extent. In this case the volume is clipped to the "horizontal" extent of the clipping surface (the dimensions perpendicular to the clipping axis). However along the clipping axis the volume is only limited by the surface itself, not by its extent.

SoUniformGridClipping is derived from SoTexture2, so the clipping grid texture can be specified by setting the filename field or by directly setting the image field. Directly setting the image field is convenient if the height field data is floating point. All the usual texturing parameters apply. Wrapping and filtering modes are particularly important. Setting wrap mode to something other than CLAMP_TO_EDGE may cause unwanted interpolation on edges. Setting filter mode to NEAREST will give a blocky result which may or may not be desired. The format of the texture used for the grid should be the LUMINANCE* type for best performance. If no red component is available in the format used (for example ALPHA texture...), the grid will be totally flat.

Each clipping surface texture must be stored in a different OpenGL texture unit. One that is not currently used by VolumeViz for multi-data composition (i.e., a texture unit number greater than the highest dataSetId plus 1). Setting the texture unit for a clipping surface is done using the SoTextureUnit node, just like with any texture node.

The figure below shows the result (right) of applying the left texture to the volume in the middle.

The following code shows one way to achieve this result:

C++ :

SoTextureUnit* texUnit = new SoTextureUnit;
texUnit->unit = 2;
SoUniformGridClipping* gridClip = new SoUniformGridClipping;
griClip->filename = "horizon2D.png";
root->addChild( texUnit );
root->addChild( gridClip );
root->addChild( transferFunction );
root->addChild( volumeData );
root->addChild( volumeRender );

C# :

SoTextureUnit texUnit = new SoTextureUnit();
texUnit.unit.Value = 2;
SoUniformGridClipping gridClip = new SoUniformGridClipping();
gridClip.filename.Value = "horizon2D.png";
Root.AddChild( texUnit );
Root.AddChild( gridClip );
Root.AddChild( transferFunction );
Root.AddChild( volumeData );
Root.AddChild( volumeRender );

Java :

SoTextureUnit texUnit = new SoTextureUnit();
texUnit.unit.setValue( 2 );
SoUniformGridClipping gridClip = new SoUniformGridClipping();
gridClip.filename.setValue( "horizon2D.png" );
root.addChild( texUnit );
root.addChild( gridClip );
root.addChild( transferFunction );
root.addChild( volumeData );
root.addChild( volumeRender );

The uniform grid clipping node provides both clipAbove and clipBelow boolean fields. By default only clipAbove is true. Using a pair of grid clipping nodes, one with clipAbove and one with clipBelow, allows clipping between two surfaces. This is useful in seismic applications to clip between two "horizon" surfaces. Note that if both of these fields are true and the thickness field is zero then the entire volume will be clipped.

Clipping between two horizon surfaces
Figure: Clipping surface thickness

The maximum number of simultaneous SoUniformGridClipping nodes that can be applied to the same volume is limited by the hardware. To query the maximum, use the following query: SoUniformGridClipping::getMaxNumberOfUniformGrids(). Typically the maximum is four or five clipping surfaces.

Automatically generating a clipping surface

SoUniformGridProjectionClipping is a helper class derived from SoUniformGridClipping. Its clipping behavior is the same as SoUniformGridClipping, but it creates the clipping surface by rendering a specified scene graph and storing the resulting depth values as the height values in the clipping texture. This is an easy way to convert a surface such as a height field (SoHeightFieldGeometry) to a clipping surface. It also saves memory, because typically the clipping surface can be lower resolution than the actual geometry, such as a seismic horizon surface. For added convenience the clipping surface is automatically updated if the specified scene graph changes.

The SoUniformGridProjectionClipping node has one additional field, sceneGraph of type SoSFNode. Normally an SoSeparator (or other grouping node) will be assigned to this field. The specified scene graph should not contain a camera node. The projection clipping node will automatically create an orthographic (parallel projection) camera. The created camera will be oriented according to the axis specified for the clipping surface in the axis field:

  • X axis: camera is looking in -X direction
  • Y axis: camera is looking in -Y direction
  • Z axis: camera is looking in -Z direction The created camera is automatically positioned to look at the center of the bounding box of the specified scene graph.

The clipping surface texture is generated using an SoRenderToTextureProperty node, which is automatically created and assigned to the clipping surface node's renderToTextureProperty field (inherited from its parent class SoTexture2). By default the clipping surface texture will be 2048 texels on its longest axis. The other dimension is computed using the aspect ratio of the specified scene graph's bounding box as viewed by the created camera. In other words, the texture will be 2048 by 2048 if the aspect ratio is 1, and 2048 by something less than 2048 if the aspect ratio is greater than 1.

  • Rendering the sceneGraph on top of the clipped volume might result in z-fighting artifacts due to depth precision. In order to avoid this issue it is necessary to use a SoPolygonOffset node before the geometry to render.
  • The sceneGraph should not contain any draggers or manipulators because they will become part of the clipping texture and might lead to unwanted results. As a workaround, you can put draggers outside of sceneGraph, put an SoTransform inside your sceneGraph and connect it to your dragger.
  • If the sceneGraph contains holes, you should set the minFilter and magFilter fields to NEAREST to avoid interpolation issues between holes and the true surface.