Example 4: Subtract 3D Objects
Introduction
In this example, we load an image and render it as WEMIsoSurface. Then, we create a three-dimensional SoSphere and subtract the sphere from the initial WEM.
Steps to Do
Develop Your Network
Add a LocalImage module to your workspace and select load $(DemoDataPath)/BrainMultiModal/ProbandT1.dcm. Add a WEMIsoSurface, a SoWEMRenderer, a SoBackground, and a SoExaminerViewer module and connect them as seen below. Make sure to configure the WEMIsoSurface to use a Iso Min. Value of 420 and a Voxel Sampling 1.
The SoExaminerViewer now shows the head as a three-dimensional rendering.
Add a 3D Sphere to your Scene
We now want to add a three-dimensional sphere to our scene. Add a SoMaterial and a SoSphere to your network, connect them to a SoSeparator and then to the SoExaminerViewer. Set your material to use a Diffuse Color red and adapt the size of the sphere to Radius 50.
The SoExaminerViewer now shows the head and the red sphere inside.
Set Location of your Sphere
In order to define the best possible location of the sphere, we additionally add a SoTranslation module and connect it to the SoSeparator between the material and the sphere. Define a translation of x=0, y=20 and z=80.
Subtract the Sphere from the Head
We now want to subtract the sphere from the head to get a hole. Add another SoWEMRenderer, a WEMLevelSetBoolean, and a SoWEMConvertInventor to the network and connect them to a SoSwitch as seen below. The SoSwitch also needs to be connected to the SoWEMRenderer of the head. Set your WEMLevelSetBoolean to use the Mode Difference.
What happens in your network now?
- The
SoSphereis converted to a WEM. - The WEMs from the head and from the sphere are subtracted by using a
WEMLevelSetBoolean. - The result of the subtraction is used for a
SoWEMRenderer - Both
SoWEMRenderer(the head on the left side and the subtraction on the right side) are inputs for aSoSwitch. - The
SoSwitchtoggles through its inputs and you can show the original WEM of the head or the subtraction.
You can now toggle the hole to be shown or not, depending on your setting for the SoSwitch.
Summary
- The module
WEMLevelSetBooleanallows to subtract or add three-dimensional WEM objects. - The
SoSwitchcan toggle multiple Open Inventor scenes as input.











