CIBC:Documentation:SCIRun:Tutorial:BioPSE:Chapter 1
From SCIRun Documentation Wiki
Chapter 1: SCIRun Introduction (Geometry Visualization)
Chapter Sections
- Chapter Overview
- Before Running SCIRun
- ReadField Module
- Hooking Modules Together
- Dynamic Compilation
- ViewScene Module
- Navigating the ViewWindow
- Mouse Controls
- Visualization Parameters
- Saving and Reloading Networks
- Summary
Appendices
Chapter Overview
SCIRun is a modular dataflow programming Problem Solving Environment (PSE). SCIRun has a set of Modules that perform specific functions on a data stream. Each module reads data from its input ports, calculates the data, and sends new data from output ports. In SCIRun, a module is represented by a rectangular box on the Network Editor canvas. Data flowing between modules is represented by pipes connecting the modules. A group of connected modules is called a Dataflow Network, or Net (see Figure 1.3). An infinite number of nets can be created, each solving a separate problem. Chapter 1 of this tutorial demonstrates the use of SCIRun to visualize a tetrahedral mesh. This chapter demonstrates the construction of a network comprised of three standard modules: ReadField, ShowField, and ViewScene. This chapter also instructs the user on reading Field data from a file, setting rendering properties for the nodes, edges, and faces (the nodes are rendered as blue spheres), and rendering geometry to the screen in an interactive ViewWindow.
Before Running SCIRun
Before running the scirun executable, The SCIRUN_DATA environment variable (and optionally SCIRUN_DATASET) needs to be set up. See the SCIRun's Environment section of the User Guide for information on how to set up this and other environment variables.
Starting SCIRun
Once the environment has been set up, SCIRun is ready to run:
- Move into the SCIRun executable directory and enter the command scirun. (Note: SCIRun cannot run as a background application.)
- The SCIRun NetworkEditor window will appear on the screen (see Figure 1.2.) The NetworkEditor screen consists of three frames: the GlobalView frame in the upper left corner, the Message frame in the upper right corner, and the NetEdit frame. The NetEdit frame is the large area where networks of modules are constructed. Since the NetEdit frame is extensive, the GlobalView frame shows which part of the NetEdit frame is currently being viewed. The Message frame reports errors, warnings, and important information.

Figure 1.3: SCIRun NetworkEditor after building the Chapter 1 network.
Figure 1.4: SCIRun Module Icon.
Pipes: Data is transfered from one module to another using dataflow connections,commonly refered to as Pipes. Each dataflow pipe transfers a specific datatype in SCIRun, denoted by a unique color. Pipes run from the output Port of one module to the input Port(s) of one or more other modules. Ports of the same color correspond to the same datatype and can be connected. These colors are described in detail in the Anatomy of a Module Section of the User Guide.
Two or more connected modules form a SCIRun network, or net.
ReadField Module
Now it is time to begin creating a SCIRun dataflow net. First, create a ReadField module, which will be used to load a SCIRun Field dataset from disk.
- Select SCIRun->DataIO->ReadField from the menu bar, as shown in Figure 1.5.
- The file selection window disappears.
- The module reads in the dataset (a SCIRun Field) and the progress bar turns green.
- The module icon displays a number that indicates the amount of CPU time required to complete its execution (Figure 1.4).
Hooking Modules Together
Now add a second module to the network. This module is used to visualize various Field types. Then connect the two modules in the canvas so data can flow between them.
- Create a ShowField module using the SCIRun->Visualization menu (use the same menus used to create the ReadField module).
- Position the mouse pointer over the yellow output port on the ReadField. Press and hold the mouse middle button. The name of the port and lines indicating possible data pipe connections will appear.
- Continue to hold the middle mouse button and drag the mouse toward the first yellow ShowField input port.
- The line turns red, showing the desired connection has been selected. See Figure 1.7.

Figure 1.7: Pipe Selection Options.
- Release the mouse button. A yellow pipe showing a data flow connection between ReadField and ShowField will appear (Figure 1.8).
Dynamic Compilation
ShowField works with all SCIRun Field data types. However, these data types must first be compiled into a shared library (as needed) where they are saved for future use. This process is called "Dynamic Compilation."
Dynamic Compilation causes a delay when the module executes the first time. For more details, refer to "Dynamic Compilation."
In addition, the module turns light yellow while it compiles, and compilation output goes to the module's log as a remark. Note that SGI computers can take over 30 seconds to perform dynamic compilation. When compilation is done, the modules color returns to a light gray.
Setting the ShowField User Interface
The ShowField module has options for changing the visual representations of a Field's geometry. To illustrate the module's functionality, change ShowField parameters using its GUI. Specifically, change the color of the nodes to blue spheres.
- Select the UI button on the ShowField module.
- Select the Default Color button near the bottom of the GUI to change the default color and a separate Color Chooser GUI appears.
- In the Color Chooser GUI, use the sliders to adjust the color values. Set Red and Green to 0.00, and Blue to 1.00. The Alpha value remains at 0.50.
- Select the Apply button in the Color Chooser GUI. Notice that the Default Color swatch in the ShowField GUI has changed to blue. SCIRun and the ShowField GUI should now look like Figure 1.9.
- Close the Color Chooser GUI.
- Set the name of the Field to Voltage. This makes it easy to identify the Field in the ViewScene Window (discussed later).
- In the ShowField GUI, a slider widget represents the Node Scale. The Node Scale interval can be increased or decreased by a power of 10 by pressing the or - button. Set the Node Scale to 2. Make sure the Node Display Type is set to Spheres.
- Set the Sphere, Box and Disk Resolution to 5.
- Go to the Edges tab and turn off the display of edges by deselecting the Show Edges check box.
- Go the the Faces tab and repeat the same action.
- Close the ShowField GUI by pressing the Close button.
ViewScene module
The ViewScene is the last module that will be added to the network. (More information about the ViewScene can be found in the Visualization Section of the User Guide])
- Create a ViewScene module by using the SCIRun->Render menu.
- Connect the output port from ShowField into the ViewScene input port. Notice the ViewScene module automatically creates a new input port; this is an example of a SCIRun module that has dynamic input ports. This allows the ViewScene module to support an infinite number of geometry producing modules.
- Open the ViewWindow by pressing the ViewScene's UI button.
- In the ViewWindow, there is a set of axes, representing X, Y, and Z directions. To make all of geometry piped to the viewer visible, press the Autoview button. (Note: any time the view is changed (scaled, rotated, or translated), and you want the viewer to re-display everything in the center of the screen, use the Autoview button.) At this point, the utah-torso voltage Field should appear in the ViewScene window. It should appear similar to Figure 1.11, but will be somewhat different as the figure has been scaled and rotated.

Figure 1.11: ViewWindow showing the utahtorso-lowres-voltage data.
Navigating the ViewWindow
Since the ViewScene is one of the most important SCIRun modules, we suggest reading Anatomy of the ViewScene Window Section of the User Guide for a full description of the ViewScene.
- Please note, this tutorial was tested on a 1.8 Ghz Linux/Nvidia GForce 3 at approximately 7 fps (frames per second). On slower systems with a frame rate less than .3 fps, the GUI may appear to freeze.
Mouse Controls
In the Viewer, the mouse can be used to rotate, scale, and translate the image. The Mouse Control in the ViewScene Window Section of the User Guide provides more complete information.
Translating the image (Left Button)
- Move the mouse to the center of the image.
- Click and hold the left mouse button.
- Move the mouse to translate the image.
- Release the button, and the image stays in its new location.
Rotating the image (Middle Button)
- Click and hold the middle mouse button.
- Move the mouse to rotate the image.
- Release the mouse button.
- If the mouse button is released while dragging, the image will continue to rotate.
- Click the middle mouse button to stop rotation.
Scaling the scene (Right Button)
- Click the right mouse button and drag the mouse.
- Move the mouse up or to the left to zoom the image out.
- Move the mouse down or to the right to zoom the image in.
Setting Visualization Parameters
Now review the controls at the bottom of the ViewWindow (see Figure 1.13). Buttons located at the bottom of the ViewWindow are used for the following functions:
- Autoview: attempts to render all objects on the screen.
- Set Home View: captures the setting of the current view (position, scale, angle, etc.) so it can be returned to by clicking the "Go home" button.
- Go home: restores the current home view (set by the last press of the Set Home View button.)
- Views: allows the user to select from a list of standard viewing angles and orientations.
- The Extended Control Window contains additional ViewScene settings.To access the Extended Control Window, press the " " button in the lower right corner of the ViewWindow (see Figure 1.14). For a more complete description, read the Extended Control Window Section of the User Guide Notice that in the Objects list, the geometry is named "Voltage Nodes" based on the name given to the field using the ShowField GUI earlier.
The Extended Control Window can be used to manipulate various settings for individual objects.
Saving and reloading networks
Now that a three-module network has been created, save the net to disk. The net can easily be reloaded in a future SCIRun session.
Saving a SCIRun network:
- Click on the File menu (at the top of the Network Editor window) and select "Save As."
- When the file browser appears, follow the prompt to choose a location and filename for the net. By convention, most nets are stored in the SCIRun/src/nets/ directory, but can be stored in another location.
- For this example, store the net as SCIRun/src/nets/show-torso-mesh.srn, as in Figure 1.15. The .srn suffix is used for SCIRun network files.
Please note, to avoid losing work, it is strongly recommended that nets be saved frequently.
- Click the Save button. The network is saved, and the dialog disappears.
- Exit SCIRun by selecting File->Quit from the NetworkEditor menu or pressing Ctrl-Q.
- Start SCIRun.
- From the File drop-down menu, select the the Load... option.
- Select SCIRun/src/nets/show-torso-mesh.srn.
- Overwrite existing show-torso-mesh.srn file by using File->Save from the drop-down menu.
- Save the net to a new file by using File->Save As...
Summary
Chapter 1 demonstrated the construction of a three module network to visualize the geometry of a mesh, and how to render that mesh to the viewing window. This chapter also instructed the user on saving and reloading networks.
Chapter 2 features additional tools to examine data values, and instructions for varying colors over the geometry.
Appendix 1: Overview of Field types
SCIRun has nine geometric meshes available for Fields:
PointCloudMesh: unconnected points
ScanlineMesh: regularly segmented straight line (a regular 1D grid)
ImageMesh: regular 2D grid (see note below)
Structured Quad Surface mesh: surface made of connected quadrilaterals on a structured grid
Structured Hex Volume mesh: subdivision of space into structured hexagonal elements
TriSurfMesh: surface made of connected triangles
QuadSurfMesh: surface made of connected quadrilaterals
TetVolMesh: subdivision of space into tetrahedral elements
HexVolMesh: subdivision of space into hexagonal elements
PrismVolMesh: five faces, two triangular faces connected together by three quadrilateral faces.
The following data types can be stored in a Field:
- tensor
- vector
- double precision
- floating point
- integer
- short integer
- char
- unsigned integer
- unsigned short integer
- unsigned char











