1.4.5. Fence Slice

The SoFenceSlice( C++ | Java | .NET ) node renders a strip (connected series) of oblique slices. The strip is defined by a set of planar 2D vertices that form a polyline in one of the axis planes, for example the XY plane. Each segment of the polyline is extruded along the axis specified in the axis field to form (in effect) an oblique slice. A similar effect could be obtained using volume geometry (e.g. SoVolumeFaceSet( C++ | Java | .NET )), but SoFenceSlice( C++ | Java | .NET ) is more convenient and is optimized for this specific case.

The 2D coordinates are interpreted according to the following table:

Fence axis Coordinate axes
X Y , Z
Y Z , X
Z X , Y

For example, when a fence slice is extruded along the Z axis (the default), the 2D points are interpreted as X,Y values. The points may be outside the 3D extent of the volume, but only the portion of the slice inside the volume will be drawn (subject to region of interest and other clipping nodes).

[Warning]

This node needs a graphic card with support for GLSL shader, vertex buffer objects (VBO) and framebuffer object (FBO). Use the isSupported() method to check if the current graphics board can render SoFenceSlice( C++ | Java | .NET ).

The following code fragment creates a simple fence slice extruded along the Y axis:


C++
SoFenceSlice* pFenceSlice = new SoFenceSlice;
pFenceSlice->axis = SoFenceSlice::Y;
pFenceSlice->points.set1Value( 0, SbVec2f(-0.2f, -0.66f) );
pFenceSlice->points.set1Value( 1, SbVec2f( 0.2f, -0.4f ) );
pFenceSlice->points.set1Value( 2, SbVec2f(-0.2f,  0.4f ) );
pFenceSlice->points.set1Value( 3, SbVec2f( 0.2f,  0.66f) );

.NET
SbVec2f[] pts = new SbVec2f[4];
pts[0].SetValue(-0.2f, -0.66f); 
pts[1].SetValue( 0.2f, -0.4f); 
pts[2].SetValue(-0.2f,  0.4f); 
pts[3].SetValue( 0.2f,  0.66f);
SoFenceSlice fenceSlice = new SoFenceSlice();
fenceSlice.axis.Value = SoFenceSlice.AxisType.Y;
fenceSlice.points.SetValues(0, pts);

Java
SoFenceSlice fenceSlice = new SoFenceSlice();
fenceSlice.axis.setValue( SoFenceSlice.AxisType.Y );
fenceSlice.points.set1Value( 0, new SbVec2f(-0.2f, -0.66f) );
fenceSlice.points.set1Value( 1, new SbVec2f( 0.2f, -0.4f ) );
fenceSlice.points.set1Value( 2, new SbVec2f(-0.2f,  0.4f ) );
fenceSlice.points.set1Value( 3, new SbVec2f( 0.2f,  0.66f) );
Fence slice – Y axis

Figure 1.35. Fence slice – Y axis


Fence slices extruded along the X axis and the Z axis

Figure 1.36. Fence slices extruded along the X axis and the Z axis


All the usual slice properties for appearance and clipping apply to fence slices. The positions of the points may be changed dynamically, for example using an SoTranslate2Dragger( C++ | Java | .NET ), but the dragger cannot be connected directly to the fence slice because the points are SbVec2f( C++ | Java ) values. The application can attach a valueChanged callback to the dragger and update the slice in the callback function, transferring the appropriate X, Y or Z values from the 3D position to the 2D position.

See the example program in:

$OIVHOME/src/VolumeViz/examples/fenceSlice

See the example program in:

$OIVHOME/demos/VolumeViz/sample/fenceSlice