Class SoUniformGridClipping
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.misc.SoBase
-
- com.openinventor.inventor.fields.SoFieldContainer
-
- com.openinventor.inventor.nodes.SoNode
-
- com.openinventor.inventor.nodes.SoTexture
-
- com.openinventor.inventor.nodes.SoTexture2
-
- com.openinventor.volumeviz.nodes.SoUniformGridClipping
-
- All Implemented Interfaces:
SafeDisposable
- Direct Known Subclasses:
SoUniformGridProjectionClipping
public class SoUniformGridClipping extends SoTexture2
Clips a volume using a 2D surface. TheSoUniformGridClipping
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 alsoSoUniformGridProjectionClipping
). 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 are 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.
NOTE: 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 theSoHeightFieldGeometry
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 fromSoTexture2
, 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. For example, a grayscale .png file will automatically be in this format. We suggest to use
LUMINANCE_FLOAT32
explicitely for floating point data in order to preserve floating point precision. 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
SoUniformGridProjectionClipping
node provides an alternate way to specify the clipping grid. This node may be more convenient when clipping using surface geometry that is already in the scene graph, for example anSoHeightFieldRender
node.The figure below shows the result (right) of applying the left texture to a volume.
Clipping surface Clipping applied to a volume SoTextureUnit texUnit = new SoTextureUnit(); texUnit.unit.setValue( 2 ); SoUniformGridClipping gridClip = new SoUniformGridClipping(); gridClip.filename.setValue( "horizon2D.png" ); SoSeparator volSep = new SoSeparator(); volSep.addChild( texUnit ); volSep.addChild( gridClip ); volSep.addChild( transferFunction ); volSep.addChild( volumeData ); volSep.addChild( volumeRender ); root.addChild( volSep ); clipAbove
andclipBelow
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.The thickness field expands the clipping surface in both directions perpendicular to the surface.The value of this field is specified in 0..1 normalized units spanning the specified extent of the surface. A completely flat clipping surface with thickness greater than zero can be used to implement "thick slice" (aka "thin slab") rendering. A transform node, for example
SoTransform
, can be used to position and orient the clipping surface. In this case the transform node and the clipping surface node should usually be placed under anSoTransformSeparator
node. This allows the surface to clip the volume primitives, but prevents the transform node from affecting the volume primitives. Remember that, as usual, the transform node will rotate the clipping surface around the origin (0,0,0) of the world coordinate system.Clipping surface thicknes - When using a custom
SoVolumeShader
with this node and redefining the main() function, you must call VVizClipVoxel() in the main() function if you are writing a fragment shader or VVizCalcDistToUniformGrid() if it's a vertex shader. If you don't do this, you will get a GLSL compilation error or clipping won't work.
Limitations:
- Only graphics cards supporting the GLSL language can use this node.
- The maximum number of
SoUniformGridClipping
nodes that can be applied to the same volume is limited togetMaxNumberOfUniformGrids()
. This limitation depends on the maximum number of sets of OpenGL texture coordinates supported on the graphics board (GL_MAX_TEXTURE_COORDS), which is typically 8, minus 3 sets used elsewhere in VolumeViz, leaving 5 for uniform grids.
File format/default:
UniformGridClipping {
axis Y extent -1,0,-1 1,1,1 filename "" image 0 0 0 wrapS CLAMP_TO_EDGE wrapT CLAMP_TO_EDGE model MODULATE enableCompressedTexture false blendColor 0 0 0 enableBorder false borderColor 0 0 0 0 maxAnisotropy 1.0 minFilter AUTO magFilter AUTO loadingMode AUTO useAutoMipmap false internalFormat AUTO_INTERNAL_FORMAT thickness 0 clipBelow false clipAbove true
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SoUniformGridClipping.AxisType
Slice Axis.-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoTexture2
SoTexture2.Loadings
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoTexture
SoTexture.FileTypes, SoTexture.Filters, SoTexture.HW_Features, SoTexture.InternalFormats, SoTexture.Models, SoTexture.WrapType
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
Fields Modifier and Type Field Description SoSFEnum<SoUniformGridClipping.AxisType>
axis
Height axis: X, Y, or Z.SoSFBool
clipAbove
Clip voxels above the surface.SoSFBool
clipBelow
Clip voxels below the surface.SoSFBox3f
extent
Bounding box of the surface in 3D geometric coordinates.SoSFFloat
thickness
Defines a clipping thickness in the axis direction.SoSFFloat
undefinedValue
Texels in the clipping texture with this value will clip all voxels above and below the surface.-
Fields inherited from class com.openinventor.inventor.nodes.SoTexture2
filename, image, loadingMode, renderToTextureProperty, wrapT
-
Fields inherited from class com.openinventor.inventor.nodes.SoTexture
blendColor, borderColor, enableBorder, enableCompressedTexture, internalFormat, magFilter, maxAnisotropy, minFilter, model, wrapS
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoUniformGridClipping()
Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getMaxNumberOfUniformGrids()
Calls getMaxNumberOfUniformGrids((com.openinventor.inventor.misc.SoState)null).static int
getMaxNumberOfUniformGrids(SoState state)
Returns the maximum number of clipping surfaces supported by the hardware.static boolean
isSupported()
Calls isSupported((com.openinventor.inventor.misc.SoState)null).static boolean
isSupported(SoState state)
Returns true if uniform grid clipping is supported by the graphics board.-
Methods inherited from class com.openinventor.inventor.nodes.SoTexture2
loadTexture
-
Methods inherited from class com.openinventor.inventor.nodes.SoTexture
getBitmapFileType, isSupported, readTexture, readTexture, setBitmapFileType
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Field Detail
-
extent
public final SoSFBox3f extent
Bounding box of the surface in 3D geometric coordinates.
Default is a box of size (2, 1, 2) with its back left corner at (-1, 0, -1).
- Since:
- Open Inventor 8.0
-
axis
public final SoSFEnum<SoUniformGridClipping.AxisType> axis
Height axis: X, Y, or Z. . Default is Y.- Since:
- Open Inventor 8.0
-
thickness
public final SoSFFloat thickness
Defines a clipping thickness in the axis direction. Ignored if set to 0. Default is 0;Value is in the normalized
extent
space (can be seen as a percentage of the extent).Notes:
- If thickness is 0 and clipBelow and clipAbove are both true then the whole volume is clipped.
- A value greater than 1.0 makes sense only if the extent of the
SoUniformGridClipping
is smaller than the extent of the volume data it applies to.
- Since:
- Open Inventor 8.6
-
-
clipBelow
public final SoSFBool clipBelow
Clip voxels below the surface. Default is false;- Since:
- Open Inventor 8.6
-
clipAbove
public final SoSFBool clipAbove
Clip voxels above the surface. Default is true;- Since:
- Open Inventor 8.6
-
undefinedValue
public final SoSFFloat undefinedValue
Texels in the clipping texture with this value will clip all voxels above and below the surface.
Default is NaN (not a number).- Since:
- Open Inventor 9.0
-
-
Method Detail
-
isSupported
public static boolean isSupported()
Calls isSupported((com.openinventor.inventor.misc.SoState)null).
-
getMaxNumberOfUniformGrids
public static int getMaxNumberOfUniformGrids()
Calls getMaxNumberOfUniformGrids((com.openinventor.inventor.misc.SoState)null).
-
isSupported
public static boolean isSupported(SoState state)
Returns true if uniform grid clipping is supported by the graphics board. The GPU must support GLSL. Check the maximum number of clipping surfaces using getMaxNumberofUniformGrids.When using a debug build of Open Inventor, some "no context available" warning messages may be generated. You can ignore them or see
SoGLExtension
for an example of usingSoGLContext
to avoid them.
-
getMaxNumberOfUniformGrids
public static int getMaxNumberOfUniformGrids(SoState state)
Returns the maximum number of clipping surfaces supported by the hardware.
-