WEMSaveAsU3D

MLModule

genre

WEMPersistence

author

MeVis Medical Solutions AG

package

MeVisLab/Standard

dll

MLWEMModules

definition

MLWEMModules.def

see also

WEMSave, ComposeWEMDescriptionForU3D

keywords

CAD

Purpose

The module WEMSaveAsU3D saves a WEM in the U3D file format.

Details

The module saves WEMs in U3D files as defined in Standard ECMA-363 (Universal 3D File Format), 4th edition (June 2007).

If a WEM contains more than one patch, each patch is converted to a U3D object. Each patch should have a unique name, specified by its “Label” property. If the names of the patches in a WEM are not unique (or not specified at all), the module creates new (unique) names for the U3D objects (the patches themselves are not altered). The names must fit within the “NameString” key type scheme (see below).

More U3D object properties can be specified using the “Description” property of a WEM patch. All U3D properties need to be composed into a single string and then written to the “Description” property of a WEM patch to be parsed by the module (if the module’s parameter “Parse WEM Description” is activated). Multiple properties can be concatenated with a “;” Each property is specified by a Key=Value string.

The following keys are parsed:

Key

Key Type

Description

U3DGroupName

NameString

Objects may be grouped to establish a simple tree-like hierarchy. This key specifies the group to which an object is assigned.

Important: Although the U3D standard supports an almost arbitrary hierarchy depth, currently only one group level is supported. All groups will have the same hierarchy level (groups cannot be assigned to other groups but can be assigned to models; see below).

NB: Objects may be grouped but must still have a unique name. It is not allowed to have an object named “ObjectX” in group “A” and another “ObjectX” in group “B.” In this case, a new name will automatically be created for the second “ObjectX.”

U3DModelName

NameString

Objects and groups may be assigned to models (a kind of top-level group). This key specifies the model to which an object (and, if specified, its group) is assigned.

Important: Currently, only one model is supported. Different model names may be specified, but only the last one found will be considered and used for all objects!

U3DColor

ColorStringWithTransparency

This key specifies the color and transparency of an object.

U3DGroupColor

ColorStringWithTransparency

This key specifies the color and transparency of an object group. If specified, each object is written twice to the U3D file: once with its original color and once with its group color. Two groups are also created: one with the group name plus the suffix ” (color coded)” and another with the group name plus the suffix “ (grouped).” If this key is not specified, only one group without a suffix is created. The file size increases only minimally when this key is specified, since the geometry data of the affected objects is not written twice.

NB: This color must have the same value for all objects grouped into a group with the same name!

U3DSpecularColor

ColorString

This key specifies the specular color of an object.

The Key Types are specified as follows:

Key Type

Description

NameString

A string that consists of the letters a–z, A–Z, spaces (” “), brackets (“(” and “)”), and the digits 0–9 only. Other characters are not allowed.

Example: “Object 01 (left)”.

ColorStringWithTransparency

Four groups of floats, separated by spaces, defining the red, green, blue, and transparency values in the range of [0, 1].

Example: “1.0 0.0 0.0 0.4” for red with 40% transparency.

ColorString

Three groups of floats, separated by spaces, defining the red, green, and blue values in the range of [0, 1].

Example: “0.0 1.0 0.0” for green.

Example:

../../../Modules/ML/MLWEMModules/mhelp/Images/U3DObjectsHierarchy.png

The object hierarchy in the image above has been assembled using the following properties:

Object name

Keys/Values

(in WEM Label property)

(in WEM Description property)

BD territory B5

U3DModelName=Demo_LDLT (XYZ123);

U3DGroupName=BD Territories;

U3DColor=1.0 0.0 0.0 0.0

BD territory B6

U3DModelName=Demo_LDLT (XYZ123);

U3DGroupName=BD Territories;

U3DColor=0.0 1.0 0.0 0.0

BD territory B8

U3DModelName=Demo_LDLT (XYZ123);

U3DGroupName=BD Territories;

U3DColor=0.0 0.0 1.0 0.0

BD branch B8

U3DModelName=Demo_LDLT (XYZ123);

U3DGroupName=BD Vessels;

U3DColor=1.0 0.0 0.0 0.0;

U3DGroupColor=0.75 0.75 0.75 0.0

BD branch B6

U3DModelName=Demo_LDLT (XYZ123);

U3DGroupName=BD Vessels;

U3DColor=0.0 1.0 0.0 0.0;

U3DGroupColor=0.75 0.75 0.75 0.0

BD branch B4

U3DModelName=Demo_LDLT (XYZ123);

U3DGroupName=BD Vessels;

U3DColor=0.0 0.0 1.0 0.0;

U3DGroupColor=0.75 0.75 0.75 0.0

Liver

U3DModelName=Demo_LDLT (XYZ123);

U3DColor=1.0 0.0 0.0 0.5

Notes:

  • For the “BD territory” objects, no U3DGroupColor is specified; therefore, only one group without a suffix is created.

  • The “BD branch” objects have a U3DGroupColor (the same for all). This results in two groups being created: one with the suffix “ (color coded)” and one with the suffix “ (grouped).” Since object names must be unique, they also receive these suffixes.

  • The “Liver” object has no U3DObjectGroup specified and is therefore directly assigned to the U3DModelName model. The U3DModelName must be the same for all objects, as more than one model name is not allowed in the current version.

  • All these settings are not made in the WEMSaveAsU3D module itself but in the WEM generating module chain that is connected to its input!

Tips

The ComposeWEMDescriptionForU3D automatically generates valid WEM names and descriptions.

Windows

Panel

../../../Modules/ML/MLWEMModules/mhelp/Images/Screenshots/WEMSaveAsU3D.Panel.png

DefaultSettings

../../../Modules/ML/MLWEMModules/mhelp/Images/Screenshots/WEMSaveAsU3D.DefaultSettings.png

Input Fields

inWEM

name: inWEM, type: WEM(MLBase)

The WEM that should be saved in the U3D format.

For accessing this object via scripting, see the Scripting Reference: MLWEMWrapper.

Parameter Fields

Field Index

apply: Trigger

Default Material Name: String

listenToRepaintNotifications: Bool

Auto Apply: Bool

Default Material Specular Color: Color

listenToSelectionChangedNotifications: Bool

Auto Update: Bool

Default Material Transparency: Float

Normal Mode: Enum

autoClear: Bool

Default Shader Name: String

Parse WEM description: Bool

Custom Version: String

elapsedTime: Float

progress: Float

Default Group Name: String

Filename: String

Save: Trigger

Default Light Name: String

hasToCMarkerInData: Bool

Status: String

Default Material Ambient Color: Color

inWEMValid: Bool

Version Mode: Enum

Default Material Diffuse Color: Color

isProcessing: Bool

Default Material Emissive Color: Color

listenToFinishingNotifications: Bool

Visible Fields

Auto Apply

name: autoApply, type: Bool, default: FALSE

If checked, the module saves the input WEM if any parameter changes on the GUI.

Auto Update

name: autoUpdate, type: Bool, default: FALSE

If checked, the module saves the input WEM if the input changes.

Default Group Name

name: defaultGroupName, type: String, default: DefaultGroup

Sets a group name that is used if no U3DGroupName is specified.

Default Shader Name

name: defaultShaderName, type: String, default: DefaultShader

(Reserved for future use.)

Default Material Name

name: defaultMaterialName, type: String, default: DefaultMaterial

(Reserved for future use.)

Default Light Name

name: defaultLightName, type: String, default: DefaultAmbientLight

(Reserved for future use.)

Default Material Ambient Color

name: defaultMaterialAmbientColor, type: Color, default: 0 0 0

(Reserved for future use.)

Default Material Diffuse Color

name: defaultMaterialDiffuseColor, type: Color, default: 0.75 0.75 0.75

Sets an object surface color that is used if no U3DColor is specified.

Default Material Specular Color

name: defaultMaterialSpecularColor, type: Color, default: 0.75 0.75 0.75

Sets an object specular color that is used if no U3DSpecularColor is specified.

Default Material Emissive Color

name: defaultMaterialEmissiveColor, type: Color, default: 0 0 0

(Reserved for future use.)

Default Material Transparency

name: defaultMaterialTransparency, type: Float, default: 0

Sets an object transparency that is used if no U3DColor is specified.

Normal Mode

name: normalMode, type: Enum, default: PerFaceNormals

Specifies how normals are written to U3D.

Values:

Title

Name

Description

​Face Normals

​PerFaceNormals

​Saves per-face normals; the resulting 3D rendering will appear flat shaded.

​Node Normals

​PerNodeNormals

​Saves per-node normals; the resulting 3D rendering will appear smoothly shaded.

Version Mode

name: versionMode, type: Enum, default: MLVersion

Defines which version is written into the U3D file.

Values:

Title

Name

Description

​MLVersion

​MLVersion

​The current ML version is written.

​Custom Version

​CustomVersion

​A custom string defined in Custom Version is written.

Custom Version

name: customVersion, type: String

Sets a custom version string.

Filename

name: filename, type: String

Sets the filename and path for the generated U3D file.

Save

name: save, type: Trigger

When pressed, the module saves the input WEM with the parameters to a U3D file.

Parse WEM description

name: parseWEMDescription, type: Bool, default: TRUE

If checked, the WEM description property will be parsed.

Status

name: status, type: String

Shows the current status of the module.

Hidden Fields

isProcessing

name: isProcessing, type: Bool, persistent: no

elapsedTime

name: elapsedTime, type: Float, persistent: no

autoClear

name: autoClear, type: Bool, default: TRUE

apply

name: apply, type: Trigger

listenToFinishingNotifications

name: listenToFinishingNotifications, type: Bool, default: FALSE

listenToRepaintNotifications

name: listenToRepaintNotifications, type: Bool, default: FALSE

listenToSelectionChangedNotifications

name: listenToSelectionChangedNotifications, type: Bool, default: FALSE

hasToCMarkerInData

name: hasToCMarkerInData, type: Bool, persistent: no

inWEMValid

name: inWEMValid, type: Bool, default: FALSE

Shows whether a valid WEM is connected to the input.

progress

name: progress, type: Float, persistent: no