Purpose

The module DrawVoxels3D voxelizes simple geometric forms into an ML image, controlled by a voxel position.

In conjunction with a 2D viewer and a SoView2DDrawVoxels3D, it allows for an interactive manipulation of a voxel (mask) image.

The module works with an UndoManager; without this module, undo/redo is not active or accessible.

It also supports copying in subimages from an extra image input to replace parts of the image. This also supports undo/redo. See Copy External Image for details.

Usage

Have a look at the module’s example network.

Details

The data type of the resulting image is set to the data type of the input image. However, the module can only process scalar data types.

The Voxel Write Value is clamped by the input image’s data type range; the actual used voxel write value after clamping is displayed in the field Clamped Voxel Write Value.

The resulting mask image has always a background value of 0.

The min/max values of the resulting image are determined by the background value (which is always 0) and the voxel write value (Voxel Write Value).

Windows

Default Panel

../../../Modules/ML/MLDrawVoxels3D/mhelp/Images/Screenshots/DrawVoxels3D._default.png

Input Fields

input0

name: input0, type: Image

inUndoContext

name: inUndoContext, type: UndoContext(MLBase)
For accessing this object via scripting see the Scripting Reference: MLUndoContextWrapper.

input1

name: input1, type: Image

External image for copy image feature

Output Fields

output0

name: output0, type: Image

outSelf

name: outSelf, type: MLBase

This output can be used as input for a SoView2DDrawVoxels3D module to provide interactive drawing.

Parameter Fields

Field Index

C: Integer Draw Thickness: Double Use External Image World Offset: Bool
Clamped Voxel Write Value: Double External Image Offset: IntVector6 Voxel Position: Vector3
Clear: Trigger Memory Mode: Enum Voxel Write Mode: Enum
Clear All Drawings Undoable: Trigger Size Coordinate System: Enum Voxel Write Value: Double
Copy External Image: Trigger T: Integer  
Copy Input Image: Trigger U: Integer  
Draw Mode: Enum undoRedoPerformed: Trigger  
Draw Size: Double Update Mode: Enum  

Visible Fields

Memory Mode

name: memoryMode, type: Enum, default: WholeVolume

Select how the internal volume is allocated.

Values:

Title Name Description
Whole Volume WholeVolume The whole volume is allocated as a MemoryImage. This allows very fast updates with SoOrthoView2D or SoView2DOverlayMPR without requiring a memory copy.
Virtual Volume VirtualVolume This uses a virtual volume, which is quite slow but allows to draw sparsely in large volumes without allocating the whole volume.

Voxel Position

name: voxelPosition, type: Vector3, default: 0 0 0

Sets the voxel position where the voxel from should be rastered to. Any change of this field causes a rasterization if the voxel position is inside the connected image.

C

name: cDimensionPosition, type: Integer, default: 0, minimum: 0

Sets the position in the c-dimension.

T

name: tDimensionPosition, type: Integer, default: 0, minimum: 0

Sets the position in the t-dimension.

U

name: uDimensionPosition, type: Integer, default: 0, minimum: 0

Sets the position in the u-dimension.

Voxel Write Value

name: voxelWriteValue, type: Double, default: 1024

Sets the voxel write value. The actually used voxel write value may be clamped by the data type’s range.

Clamped Voxel Write Value

name: clampedVoxelWriteValue, type: Double, persistent: no

Shows the actually used voxel write value after clamping by the data type’s range.

Voxel Write Mode

name: voxelWriteMode, type: Enum, default: WriteAlways

Defines how voxels are written.

Values:

Title Name Description
Always WriteAlways Always writes
If Not Zero WriteIfNotZero Only writes if the voxel value below the drawn voxel is not 0.

Draw Mode

name: drawMode, type: Enum, default: DiskZ

Defines the function of the rasterizer.

Values:

Title Name Description
Cube Cube A cube is rastered.
Sphere Sphere A sphere is rastered.
Square X SquareX A square in the X plane is rastered.
Square Y SquareY A square in the Y-plane is rastered.
Square Z SquareZ A square in the Z-plane is rastered. The Z-plane is what a typical 2D viewer shows.
Disk X DiskX A circular disk in the X-plane is rastered.
Disk Y DiskY A circular disk in the Y-plane is rastered.
Disk Z DiskZ A circular disk in the Z-plane is rastered. The Z-plane is what a typical 2D viewer shows.

Draw Size

name: drawSize, type: Double, default: 5, minimum: 0.5

Sets the size of the rastered form in voxel or millimeters, depending on the selected Size Coordinate System. It always ensures that the minimum size of one voxel is used.

Draw Thickness

name: drawThickness, type: Double, default: 1, minimum: 0.1

Sets the thickness of the drawn shape if the shape is not cube or sphere. The thickness is given in voxel or millimeters, depending on the selected Size Coordinate System. It always ensures that the minimum thickness of one voxel is used.

Size Coordinate System

name: sizeCoordinateSystem, type: Enum, default: Voxel

Defines the coordinates system for the size.

Values:

Title Name Description
Voxel Voxel Sets size to voxels.
World World Sets size to mm in world space.

Update Mode

name: updateMode, type: Enum, default: Clear

Defines how the module behaves on input image changes.

Values:

Title Name Description
Clear Clear The output image is cleared.
Copy Input CopyInput The output image is copied from the input image.
Off Off Nothing happens.

Clear

name: clear, type: Trigger, deprecated name: reset

Clears the output image.

Copy Input Image

name: copyInputImage, type: Trigger

Copies the input image to the output image.

Copy External Image

name: copyExternalImage, type: Trigger

If triggered, the image at input1 is copied into the volume (it is cast to the datatype of the drawvoxels volume). This currently only works when using the ‘WholeVolume’ memory mode. It only supports images with matching direction vectors, so the external image to copy from has to be located on the same voxel grid as the input image. If the difference in the direction vectors is too big, the image is not copied. The image is copied voxel-wise and is not resampled. The external image is copied directly, the Voxel Write Mode is not used/supported.

External Image Offset

name: externalImageOffset, type: IntVector6, default: 0 0 0 0 0 0

The extra voxel offset that is added when copying the input1 via Copy External Image. This offset is always added, even when Use External Image World Offset is enabled.

Use External Image World Offset

name: useExternalImageWorldOffset, type: Bool, default: TRUE

If enabled, the world location of the first voxel of input1 is used to calculate the start offset of the image copied via Copy External Image. If disabled, the start offset it at voxel position (0,0,0,0,0,0).

Clear All Drawings Undoable

name: clearAllDrawingsUndoable, type: Trigger

If pressed, all drawings are cleared; this clearing is undoable.

Hidden Fields

undoRedoPerformed

name: undoRedoPerformed, type: Trigger