Class SoVolumeMask
- java.lang.Object
-
- All Implemented Interfaces:
SafeDisposable
public class SoVolumeMask extends SoVolumeData
Volume mask. This node specifies an arbitrary voxel-based region of a volume data set (SoVolumeData
). A volume mask is itself a data volume consisting of binary values. Zero values are "false" and non-zero values are "true". A large number of masks may be defined simultaneously, using anSoVolumeMask
node for each one, and mask regions may overlap if desired.SoVolumeMask
is derived fromSoVolumeData
. LikeSoVolumeData
it accesses its data through anSoVolumeReader
class. I.e. the data may be in a file or in memory (or any data source using a custom volume reader). The mask volume can be any data type, but unsigned byte is currently the most memory efficient representation.SoVolumeMask
nodes must follow these rules:- Each mask volume must have exactly the same voxel dimensions and tile size value as the data volume it is applied to.
- All
SoVolumeMask
nodes must be children of anSoVolumeMaskGroup
node. - The
SoVolumeData
node and theSoVolumeMaskGroup
nodes must be children of anSoMultiDataSeparator
node. - The
SoVolumeData
and associatedSoVolumeMask
nodes must each have a different value assigned to their dataSetId field (seeSoDataSet
). Note thatSoVolumeData
andSoVolumeMask
both have a default value of 1 for the dataSetId field, so some ids must be explicitly set. - Currently
SoVolumeMask
nodes only affect volume rendering (SoVolumeRender
). They do not affect slice rendering or other VolumeViz primitives.
SoVolumeMask
can be used to clip the data volume on a per-voxel basis. But the mask mechanism is much more powerful than that. Each region can have its own transfer function (color map) usingSoTransferFunction
nodes. Each region can also have its own draw style (volume rendering, isosurface or boundary) usingSoVolumeDataDrawStyle
nodes. Each region, including the original unmasked volume, is only visible if there exists a transfer function (SoTransferFunction
) with the same id value.Mask regions:
A single
SoVolumeMask
node effectively defines two regions:- False voxels (where the mask voxel = 0), and
- True voxels (where is mask voxel != 0).
Because intersecting regions are allowed, two
SoVolumeMask
nodes define (up to) four regions:- False (where all masks are 0),
- True only in mask 1,
- True only in mask 2, and
- True in more than one mask (intersection region).
Each additional mask defines one additional region (voxels that are true only in that mask).
In addition, if there exists a transfer function with the same id as the original volume (
SoVolumeData
node), the color value from that transfer function is combined with the color value from the mask region's transfer function.Transfer functions:
A separate transfer function can be specified for each of these regions using
SoTransferFunction
nodes. The transfer function nodes may be placed under theSoVolumeMaskGroup
node, but this is not required.NOTE: It is not currently possible to specify a different data range for each mask.
- A transfer function is associated with a specific mask (i.e. with the voxels that are true only in that mask), by setting the
SoTransferFunction
node's transferFunctionId equal to the mask's dataSetId . If there is no transfer function with the same id as the mask, then that mask is ignored. - A transfer function is associated with all "false" voxels (voxels that do not belong to any mask) by setting its transferFunctionId equal to zero. If there is no transfer function with id = 0, then "false" voxels are not rendered.
- A transfer function is associated with all "intersection" voxels (voxels that belong to more than one mask) by setting its transferFunctionId equal to SoVolumeMaskGroup.TRANSFERFUNCTION_INTERSECTION_ID. If there is no transfer function with this id value, then intersection voxels (if any) are rendered using the default GRAY color map.
Draw Styles:
A separate draw style can be specified for each mask region and for the intersection voxels (but not for false voxels) using
SoVolumeDataDrawStyle
nodes:- Unlike transfer functions, a draw style is associated with a mask (voxels that are true only in that mask) by traversal order. In other words, each mask uses the draw style that is current when the mask is traversed. So you need to put
SoVolumeDataDrawStyle
nodes under the VolumeMaskGroup, alternating draw style, mask, draw style, mask. - A draw style is associated with all "intersection" voxels (voxels that belong to more than one mask) by placing it before the
SoVolumeMaskGroup
node in the scene graph.
Data Range:
SoVolumeMask
currently does not support separate data ranges for each mask region. The sameSoDataRange
will be applied on all regions.Note that the inherited undefinedValue field is ignored. Setting it has no effect.
File format/default:
VolumeMask {
allocateResourceOnRender false data NODATA 0 0 0 UBYTE 8 dataRGBA false dataSetId 1 dataTransform NULL extent -1 -1 -1 1 1 1 fileName "" texturePrecision 0 undefinedValue NaN useCompressedTexture true useExtendedData false usePalettedTexture true useSharedPalettedTexture true
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.volumeviz.nodes.SoVolumeData
SoVolumeData.Axis, SoVolumeData.CoordinateTypes, SoVolumeData.OverMethods, SoVolumeData.StorageHints, SoVolumeData.SubMethods
-
Nested classes/interfaces inherited from class com.openinventor.ldm.nodes.SoDataSet
SoDataSet.DataTypes, SoDataSet.LDMDataModifier
-
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 inherited from class com.openinventor.volumeviz.nodes.SoVolumeData
data, dataRGBA, useExtendedData, usePalettedTexture, useSharedPalettedTexture
-
Fields inherited from class com.openinventor.ldm.nodes.SoDataSet
allocateResourceOnRender, dataSetId, dataTransform, extent, fileName, ldmResourceParameters, texturePrecision, undefinedValue, useCompressedTexture
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoVolumeMask()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
editSolidShape(SoNode solidShape, double value)
Replace all voxels inside the given shape with the specified value.int
editSubVolume(SbBox3i32 subVolume, double value)
Replace the contents of a subvolume with the specified value.int
editSubVolume(SbBox3i32 subVolume, SoBufferObject userData)
Replace the contents of a subvolume with the given data.int
editSurfaceShape(SoNode surfaceShape, float thickness, double newValue)
Replace all voxels intersecting the polygons or lines defined by the surfaceShape and given thickness with the specified value.boolean
getDefaultValue()
Returns default value of the volume mask.SoVolumeData
getVolumeData()
void
GLRender(SoGLRenderAction action)
void
setDefaultValue(boolean defValue)
Set default value of the volume mask.void
setIsReadChar(boolean flag)
void
setProperties(SbVec3i32 dimension, SbVec3i32 tileSize, int border)
-
Methods inherited from class com.openinventor.volumeviz.nodes.SoVolumeData
doAction, editTile, editTile, finishEditing, getCoordinateType, getDoubleMinMax, getHistogram, getMinMax, getRectilinearCoordinates, getRenderUnitID, getTexMemorySize, redoEditing, reSampling, reSampling, setRGBAData, setTexMemorySize, startEditing, subSetting, undoEditing, updateRegions, useFakeData
-
Methods inherited from class com.openinventor.ldm.nodes.SoDataSet
callback, dataSize, editBoxes, getBoundingBox, getDataSize, getDataType, getDatumSize, getDimension, getLdmDataAccess, getLDMReader, getLDMTopoOctree, getMaxNumDataSets, getOverlapping, getReader, getTileDimension, handleEvent, hasEditedTile, isDataFloat, isDataInMemory, isDataSigned, isInMemory, numSigBits, pick, readTile, resetReader, setLDMDataModifier, setLDMReader, setReader, setReader, voxelToXYZ, voxelToXYZ, write, writeTile, XYZToVoxel, XYZToVoxel
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, copy, copy, distribute, getAlternateRep, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, isBoundingBoxIgnoring, isOverride, rayPick, search, setOverride, touch
-
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
-
-
-
-
Method Detail
-
getDefaultValue
public boolean getDefaultValue()
Returns default value of the volume mask.
-
GLRender
public void GLRender(SoGLRenderAction action)
- Overrides:
GLRender
in classSoVolumeData
-
editSurfaceShape
public int editSurfaceShape(SoNode surfaceShape, float thickness, double newValue)
Replace all voxels intersecting the polygons or lines defined by the surfaceShape and given thickness with the specified value. Returns 0 if successful.- surfaceShape is defined in the same 3D space as the dataSet.
- thickness is defined in voxels. The surfaceShape can be deleted after calling this function.
- Only an
SoVolumeMask
with data size of 1 (ie. byte or unsigned byte) can be edited. - All zero values are set to zero and all non-zero values are set to 1.
Call
startEditing()
before calling this method.- Overrides:
editSurfaceShape
in classSoVolumeData
-
editSolidShape
public int editSolidShape(SoNode solidShape, double value)
Replace all voxels inside the given shape with the specified value. Returns 0 if successful.The geometry defined under solidShape must represent a list of closed surfaces otherwise the result is unpredictable. solidShape must not contain any lines or open polyhedrons (polyhedron with shapes). The result is based on the odd-winding rule, so the result is not necessarily the union or the intersection of the closed surfaces. If you want to voxelize lines or single polygons, see also the
editSurfaceShape
method.If the goal is to define a shape which is the results of the intersection/union of multiple closed surfaces, see the
SoCSGShape
node.- solidShape is defined in the same 3D space as the dataSet. The solidShape can be deleted after calling this function.
- Only VolumeMask with data size of 1 (ie. byte or unsigned byte) can be edited.
- All zero values are set to zero and all non-zero values are set to 1.
Call
startEditing()
before calling this method.- Overrides:
editSolidShape
in classSoVolumeData
-
setDefaultValue
public void setDefaultValue(boolean defValue)
Set default value of the volume mask. Default is 0.
-
editSubVolume
public int editSubVolume(SbBox3i32 subVolume, SoBufferObject userData)
Replace the contents of a subvolume with the given data. Returns 0 if successful.- The subvolume is specified in voxel/cell coordinates.
- The buffer size (in bytes) must match the subvolume size (in bytes) exactly.
- Only an
SoVolumeMask
with data size of 1 (ie. byte or unsigned byte) can be edited. This implies that dataType of userData must be byte or unsigned byte. - warning : userData must be an
SoCpuBufferBitSet
.
Call
startEditing()
before calling this method.- Overrides:
editSubVolume
in classSoVolumeData
-
getVolumeData
public SoVolumeData getVolumeData()
-
setIsReadChar
public void setIsReadChar(boolean flag)
-
editSubVolume
public int editSubVolume(SbBox3i32 subVolume, double value)
Replace the contents of a subvolume with the specified value. Returns 0 if successful.- The subvolume is specified in voxel/cell coordinates.
- Only an
SoVolumeMask
with data size of 1 (ie. byte or unsigned byte) can be edited. - All zero values are set to zero and all non-zero values are set to 1.
Call
startEditing()
before calling this method.- Overrides:
editSubVolume
in classSoVolumeData
-
-