Chapter 3: Derived Fields
- 3-1: GetFieldBoundary
- 3-2: DirectMapping
- 3-3: StreamLines
- 3-4: Controlling Widgets
- 3-5: Network Execution And Data Dependence
- 3-6: Summary
Chapters 1 and 2 demonstrated the construction of SCIRun networks to visualize the geometry and data values in a field. This chapter explores additional visualization techniques, and examines filter modules that receive a field as input, then output a newly derived field.
Rather than building one net to introduce these modules, several nets are constructed. Each net describes a single visualization technique. This chapter is divided into three sections, one for each method.
First, create a net to show how to extract the boundary of a field. The GetFieldBoundary module extracts a boundary surface from a volume. For example, given a TetVolMesh (volume), the module extracts the boundary faces, and outputs a TriSurfMesh (surface).
Follow these steps to create a net using the GetFieldBoundary (SCIRun->NewField->GetFieldBoundary) module:
- Add a ReadField module to the canvas, and load the utahtorso-lowres-voltage.tvd.fld file.
- Now add a GetFieldBoundary module from SCIRun->NewField->GetFieldBoundary.
- Attach the output from a ReadField into the GetFieldBoundary input port.
- Add a ShowField module and connect the GetFieldBoundary's first output to the ShowField's first input.
- Set the ShowField module to display edges only (turn off the nodes and the faces) and set the Field Name to Boundary.
- Also in the ShowField UI:
- Render the edges as Lines, with a scale of 2.0.
- Enable Transparency.
- Set the default color to dark gray (give red, green, and blue a value of 0.3 and an alpha of 0.8).
- Create a ViewScene module, and connect the output from the ShowField module into the ViewScene module.
- Press the Autoview button and rotate the image downward, to look like Figure 3.2.
Figure 3.1, GetFieldBoundary Net (3A)
Next, interpolate data values from one field to another field. This section, demonstrates how to load two datasets. The first contains the utahtorso-lowres-voltage.tvd.fld examined in Chapter 1, which referred to as the volume field. The second contains the electrode positions in utahtorso-lowres-electrodes.pcd.fld, from Chapter 2.
Once the datasets are loaded, create a new field by interpolating the electrode positions and voltage values. Interpolation is the means used to calculate the value at a certain point, by using the known values at surrounding points. For each electrode, the corresponding voltage value must be found from the volume field.
The MapFieldDataFromSourceToDestination module implements this algorithm. Follow these steps to create the MapFieldDataFromSourceToDestination net:
- Create a ReadField module and load the utahtorso-lowres-voltage.tvd.fld file.
- Create a second ReadField module and load the utahtorso-lowres-electrodes.pcd.fld file.
- Create a (SCIRun->ChangeFieldData) MapFieldDataFromSourceToDestination module.
- Create a (SCIRun->Visualization) ShowField module, select Spheres in the ShowField UI and set the SphereScale to at least 5.0.
- Create a (SCIRun->Visualization) CreateStandardColorMaps module.
- Create a (SCIRun->Visualization) RescaleColorMap module.
- Finally, create a (SCIRun->Render) ViewScene module.
- These modules should be hooked together as shown in Figure 3.3.
- NOTE: press the Autoview button in the ViewWindow and rotate the image in the ViewWindow downward to match the appearance found in Figure 3.4.
- NOTE: the ReadField module on the left should read in the utahtorso-lowres-voltage.tvd.fld input file. The ReadField on the right should read in the utahtorso-lowres-electrodes.pcd.fld input file. Notice that the pipes from each of the ReadField modules (Figure 3.3) have been labeled with the type of field data flowing through them. The ability to annotate pipes can be accessed by right clicking on the pipe and selecting Notes. This annotation has no effect on the application, but is useful to the user for making networks more clear.
Figure 3.3: MapFieldDataFromSourceToDestination net
Figure 3.4: DirectMapping Visualization
Streamline advection is the last visualization technique explored in this chapter. The GenerateStreamLines module visualizes vector fields by integrating curves through a gradient vector flow field.
The input vector field is generated by using the CalculateGradients module (SCIRun->ChangeFieldData) to compute the gradient of the utahtorso-lowres-voltage.tvd.fld.
Then, use the (SCIRun->NewField) GeneratePointSamplesFromFieldOrWidget module to generate a sample distribution of streamline seed points. GeneratePointSamplesFromFieldOrWidget generates samples from any type of input field, and outputs the samples as a PointCloud field. The following modules are needed to run the StreamLines net:
- One ReadField module.
- One (SCIRun->ChangeFieldData) CalculateGradients module.
- One (SCIRun->NewField) GeneratePointSamplesFromFieldOrWidget module.
- Two ShowField modules.
- One (SCIRun->ChangeFieldData) MapFieldDataFromSourceToDestination module.
- One CreateStandardColorMaps module.
- One RescaleColorMap module.
- One ViewScene module.
- One (SCIRun->Visualization) GenerateStreamLines module.
These modules should be hooked together as shown in Figure 3.5.
Figure 3.5: GenerateStreamLines net
Once the modules are connected, set the following GUI parameters:
- In the GeneratePointSamplesFromFieldOrWidget UI, select the rake option and set the number of samples to 50.
- Use the ReadField module to load the input file utahtorso-lowres-voltage.tvd.fld.
- In the first ShowField UI (the upper right ShowField module), display only Nodes as spheres or points, with SphereScale set to approximately 1.0 - 2.0.
- In the second ShowField module (in the bottom-left corner of Figure 3.5), set the UI to display Edges only as cylinders with a Cylinder Scale of 2.
- In the GenerateStreamLines UI, choose Cell Walk, set Error Tolerance to 0.8, Step Size to 0.8, and Maximum Steps to 250.
- In the RescaleColorMap UI, select Fixed Scale and set the Min value to -50 and the Max value to 50.
The GeneratePointSamplesFromFieldOrWidget module can generate samples randomly, or the user can select samples using a 3D widget. For streamline visualization, use a 3D Rake widget for distributing seed points. The user can interactively position the rake of seed points within the volume.
The GenerateStreamLines module works by advecting the seed points through the vector field. The vector field is piecewise constant, so the Cell Walk algorithm is used to trace out the streamlines.
Figure 3.6: GenerateStreamLines UI
The rake is one of many widgets used in SCIRun. Widgets are graphical elements in the ViewWindow that allow the user to interactively control features of the display. SCIRun widgets have similar visual characteristics, but manipulate different aspects of the display, as detailed in the Control Widgets Section of the User Guide.
Practice manipulating the widgets (and thus the ViewScene module's display) in the following manner:
- Hold down the Shift key, then left-click the mouse on the widget and move the widget around the region of view to change its location and action.
- While holding down the Shift key, left-click the mouse on a sphere in the widget and change the position of that widget.
- Hold the Shift key and left-click the mouse on the end knob (green resize cylinders) in the widget and change, for example, the density of streamlines.
- SCIRun will redraw the image in the ViewWindow when the mouse button is released.
Network Execution and Data Dependence
There are several ways to execute a SCIRun network that has not fired.
In the GenerateStreamLines network:
- On the Network Editor's File Menu, select Execute All
- On the module itself, right-click the mouse and select the Execute option from the dropdown menu (Figure 3.7).
- Each module's UI has its own Execute button.
When a module is instructed to execute, all modules in its net will also execute.
- NOTE: if a module has already computed a result, and its inputs have not changed, it will use the previously computed result.
Figure 3.7: Module Control Menu
After executing the GenerateStreamLines network, an image like Figure 3.8 will appear in the ViewWindow. The rake widget will appear as a gray bar with spheres at the ends. The user's image may be slightly different than Figure 3.8, but the user should see the rake and colored streamlines. If the streamlines do not appear, the user may need to check the object list and turn on the Edges.
Figure 3.8: Streamlines Visualization