Scientific Visualization in SCIRun
description
Transcript of Scientific Visualization in SCIRun
Scientific Computing and Imaging InstituteScientific Computing and Imaging InstituteSchool of ComputingSchool of Computing
University of UtahUniversity of Utah
Scientific Computing and Imaging InstituteScientific Computing and Imaging InstituteSchool of ComputingSchool of Computing
University of UtahUniversity of Utah
David Weinstein
SIAM CSE
02.09.2003
David Weinstein
SIAM CSE
02.09.2003
Scientific Visualization inSCIRun
Scientific Visualization inSCIRun
SCIRun
SIAM CSESIAM CSE
OverviewOverview
Examples
Tour of SCIRun
- How To Get / Install It
- Dataflow
- Building A Module
Live Demos
SCIRun
SIAM CSESIAM CSE
Natalie: Surgical PlanningNatalie: Surgical Planning
SCIRun
SIAM CSESIAM CSE
Aneurysm: Volume RenderingAneurysm: Volume Rendering
SCIRun
SIAM CSESIAM CSE
Forward and Inverse EEGForward and Inverse EEG
SCIRun
SIAM CSESIAM CSE
ElectrocardiographyElectrocardiography
SCIRun
SIAM CSESIAM CSE
ElectroencephalographyElectroencephalography
SCIRun
SIAM CSESIAM CSE
MEG / Diffusion TensorsMEG / Diffusion Tensors
SCIRun
SIAM CSESIAM CSE
Photorealism for Sci Vis: RTRTPhotorealism for Sci Vis: RTRT
SCIRun
SIAM CSESIAM CSE
CSAFE: Fire-spreadCSAFE: Fire-spread
SCIRun
SIAM CSESIAM CSE
Nuclear Fusion: TokamakNuclear Fusion: Tokamak
SCIRun
SIAM CSESIAM CSE
SCIRun
SIAM CSESIAM CSE
Integration and InteractionIntegration and Interaction
Modeling
Simulation
Visualization
userguides
What If?
SCIRun
SIAM CSESIAM CSE
Elements of SCIRunElements of SCIRun
Visual programming Environment
SCIRun
SIAM CSESIAM CSE
PSE RelationshipsPSE Relationships
SCIRun
SIAM CSESIAM CSE
ExtensibilityExtensibility
• Leverage existing utilities• Extensibility through bridges
SCIRun
Matlab
mpeg
libimage
Teem
GENESIS
liblib
liblibsocketsocket
liblib
SQLSQL
SCIRun
SIAM CSESIAM CSE
Documentation: The Central SourceDocumentation: The Central Source
http://internal.sci.utah.edu/developer/doc/
SCIRun
SIAM CSESIAM CSE
Documentation: User SupportDocumentation: User Support
On-line Documentation• Tutorial• User’s Manual• FAQ Lists
Printed Documentation• User’s Manuals
Mailing List• [email protected]
Direct Contact• Email and Bugzilla• Phone
SCIRun
SIAM CSESIAM CSE
System Specs and RequirementsSystem Specs and Requirements
Required OS and Build ToolsRequired OS and Build Tools• SGISGI• IRIX 6.5IRIX 6.5• MIPSPro Compilers (CC) 7.3.1.1mMIPSPro Compilers (CC) 7.3.1.1m
• LinuxLinux• Kernel 2.2.17Kernel 2.2.17• GCC 2.95.3GCC 2.95.3
• BothBoth• GNU Make 3.79.1GNU Make 3.79.1
http://software.sci.utah.edu/doc/TechnicalGuide/p1c1.htmlhttp://software.sci.utah.edu/doc/TechnicalGuide/p1c1.html
SCIRun
SIAM CSESIAM CSE
Minimum System RequirementsMinimum System Requirements
Tested Systems: Gateway, Micron, Dell.Tested Systems: Gateway, Micron, Dell.http://software.sci.utah.edu/tested_systems/tested_systems.htmlhttp://software.sci.utah.edu/tested_systems/tested_systems.html
Processor(s)Processor(s) Main MemoryMain Memory Other HW/SWOther HW/SW
SGISGI250 MHz250 MHz
R10KR10K256 MB256 MB Texture Mapping Texture Mapping
Hardware/MemoryHardware/Memory
LinuxLinux700 MHz700 MHz
Pentium IIIPentium III256 MB256 MB
NVIDIA GeForce3 Graphics NVIDIA GeForce3 Graphics Card, XFree86 drivers Card, XFree86 drivers
version 1.0-1541version 1.0-1541
http://software.sci.utah.edu/doc/TechnicalGuide/p1c2.htmlhttp://software.sci.utah.edu/doc/TechnicalGuide/p1c2.html
SCIRun
SIAM CSESIAM CSE
Documentation: TutorialDocumentation: Tutorial
SCIRun
SIAM CSESIAM CSE
Network DesignNetwork Design• Dataflow Vocabulary• Module• Dataport• Datapipe• UI
• Send and Get• GuiVars• Scheduler• Dependencies• loops: send_intermediate
SCIRun
SIAM CSESIAM CSE
PackagesPackages
• Encapsulated project• External code resides in Thirdparty• Packages enabled via “configure”
options% configure ‘--enable-package=BioPSE mypackage’
SCIRun
SIAM CSESIAM CSE
Module CategoriesModule Categories
• …/Dataflow/Modules/{Fields,Math,…}
SCIRun
SIAM CSESIAM CSE
FieldsFields
Data
int, float, double, …
Vector, Tensor, …
Data
int, float, double, …
Vector, Tensor, …
Geometry
Regular
Irregular
Geometry
Regular
Irregular
Properties
Data_at (center)
Properties
Data_at (center)
PointCloudField
ScanlineField CurveField
ImageField QuadSurfField TriSurfField
LatVolField HexVolField TetVolField
SCIRun
SIAM CSESIAM CSE
On-the-fly CompilationOn-the-fly Compilation
•Combinatorial Explosion!•Geometry•Data type•Data_at
•Build source, compile, link – all at run time
SCIRun
SIAM CSESIAM CSE
Error MessagesError Messages
•Run-time messages are sent to the module’s “log”
Startup messagesStartup messages
Log message indicatorGray: no messagesRed: errorBlue: warning/remark
Log message indicatorGray: no messagesRed: errorBlue: warning/remark
SCIRun
SIAM CSESIAM CSE
Tikhonov RegularizationTikhonov Regularization
SCIRun
SIAM CSESIAM CSE
Tikhonov RegularizationTikhonov Regularization
SCIRun
SIAM CSESIAM CSE
How To Build A ModuleHow To Build A Module
•Before You Start
• Structure of a Module
• Ports and Datatypes
•Component Wizard
•GUI’s
•Dynamic Compilation Algorithm
SCIRun
SIAM CSESIAM CSE
Before You StartBefore You Start
Design Your Function• A Module is a Function• Inputs and Outputs• User Input (GUI Variables)• Dataflow
Coding Standard• Standards• Advice• SCIRun/doc/Developer/Guide/coding_standard.html
SCIRun
SIAM CSESIAM CSE
Module StructureModule Structure
Support Files• .cc file• sub.mk• .xml file• .tcl file• sub.mk• .h file (optional)
SCIRun
SIAM CSESIAM CSE
Ports and DatatypesPorts and Datatypes
Ports• LockingHandles• Generation number• Memory Management• Sending Data• Cache Results
Datatypes• Fields, Matrix, SceneGraph• Detach (Dataflow)• Properties
SCIRun
SIAM CSESIAM CSE
Component WizardComponent Wizard
Adding a Module
SCIRun
SIAM CSESIAM CSE
Component WizardComponent Wizard
SCIRun
SIAM CSESIAM CSE
Component WizardComponent Wizard
Edit a Port• Name• Namespace
SCIRun
SIAM CSESIAM CSE
Component WizardComponent Wizard• Package• Category• Path
SCIRun
SIAM CSESIAM CSE
Component WizardComponent Wizard• New Package?• New Category?• Reconfiguring.
SCIRun
SIAM CSESIAM CSE
Component WizardComponent Wizard
After Compiling
SCIRun
SIAM CSESIAM CSE
Component WizardComponent Wizard
Your Skeleton GUI
SCIRun
SIAM CSESIAM CSE
GUI’sGUI’s
TCL• itcl
• blt
•Use Simple GUI as a Pattern
•GuiVars
SCIRun
SIAM CSESIAM CSE
GUI’sGUI’s itcl_class SCIRun_Fields_SelectField {
inherit Module constructor {config} { set name SelectField
global $this-stampvalue global $this-runmode
set_defaults }
method set_defaults {} {set $this-stampvalue 100set $this-runmode 0# 0 nothing 1 accumulate 2 replace
}
method replace {} {set $this-runmode 2$this-c needexecute
}
method accumulate {} {set $this-runmode 1$this-c needexecute
}
SCIRun
SIAM CSESIAM CSE
GUI’sGUI’s method ui {} {
set w .ui[modname] if {[winfo exists $w]} { raise $w return } toplevel $w
frame $w.row1frame $w.row3frame $w.row4
pack $w.row1 $w.row3 $w.row4 -side top -e y -f both -padx 5 -pady 5
label $w.row1.value_label -text "Selection Value"entry $w.row1.value -textvariable $this-stampvaluepack $w.row1.value_label $w.row1.value -side left
button $w.row3.execute -text "Replace" -command "$this replace"pack $w.row3.execute -side top -e n -f both
button $w.row4.execute -text "Accumulate" -command "$this accumulate"
pack $w.row4.execute -side top -e n -f both }
SCIRun
SIAM CSESIAM CSE
GUI’sGUI’s
GuiVars• Values to from C side– Initialize
C++ side constructor synchs with tcl name tcl side sets the initial value
–my_var.reset()
–my_var.get()
• tcl_command(...)– $this-c “needexecute”
SCIRun
SIAM CSESIAM CSE
Algorithm StructureAlgorithm StructureAlgorithm Base Class
• Inherits from common base class• Defines the pure virtual interface needed by a module• Provides a static CompileInfo
Templated Algorithm• Implements the pure virtual interface in the base class• Potentially specialized for specific field type
Algorithm Base Class• Inherits from common base class• Defines the pure virtual interface needed by a module• Provides a static CompileInfo
Templated Algorithm• Implements the pure virtual interface in the base class• Potentially specialized for specific field type
RenderFieldBase
RenderField<TetVol<double> >
RenderField<TetVol<Vector> >
RenderField<LatticeVol<double> >
RenderField<LatticeVol<Vector> >
etc...
virtual void render(FieldBase&)=0;virtual void render(FieldBase&)=0;
template<class Field> RenderField : public RenderFieldBasetemplate<class Field> RenderField : public RenderFieldBase
SCIRun
SIAM CSESIAM CSE
TypeDescriptionTypeDescription
TypeDescription object augments RTTIHolds:
• Strings that describe object’s exact type• Namespace string• Path to the .h file that declares the object
Has a recursive structure
Example: foo<bar, foobar<int> >;
TypeDescription object augments RTTIHolds:
• Strings that describe object’s exact type• Namespace string• Path to the .h file that declares the object
Has a recursive structure
Example: foo<bar, foobar<int> >;
foo
int
foobarbar
SCIRun
SIAM CSESIAM CSE
CompileInfoCompileInfo
Similar info as a TypeDescriptionAlgorithm is not instantiated, so cannot yet be
queriedStart with a CompileInfo from Algorithm base classAugmented with information from all pertinent
TypeDescription objects for the specific types involved
Passed to DynamicLoader, which creates the proper type
Similar info as a TypeDescriptionAlgorithm is not instantiated, so cannot yet be
queriedStart with a CompileInfo from Algorithm base classAugmented with information from all pertinent
TypeDescription objects for the specific types involved
Passed to DynamicLoader, which creates the proper type
SCIRun
SIAM CSESIAM CSE
DynamicLoaderDynamicLoader
Returns Requested Algorithm• Writes C++ instantiation code• Compile shared library, using SCIRun makefiles• Load shared library (dlopen)• Return Instance of Algorithm (Cached for next use)
Synchronization code such that• Only 1 thread can compile at a time per algorithm• Multiple algorithms can compile and load at the same time
Returns Requested Algorithm• Writes C++ instantiation code• Compile shared library, using SCIRun makefiles• Load shared library (dlopen)• Return Instance of Algorithm (Cached for next use)
Synchronization code such that• Only 1 thread can compile at a time per algorithm• Multiple algorithms can compile and load at the same time
SCIRun
SIAM CSESIAM CSE
Calling ModuleCalling Module void ShowField::execute()
{ // Get a Field from input field port. field = (FieldIPort *)get_iport("Field"); field->get(field_handle); // Get the input field's type info. const TypeDescription *td = field_handle->get_type_description();
// Get the Algorithm. CompileInfo *ci = RenderFieldBase::get_compile_info(td); if (! DynamicLoader::scirun_loader().get(*ci, rend_algo)) { error("Could not compile algorithm for ShowField -");
return; } RenderFieldBase *rf = dynamic_cast<RenderFieldBase*>(rend_algo); // Let the templated algorithm render this field. rf->render(field_handle, /* any other parameters from gui */);
// Send results downstream...}
No template instantiations for the exact algorithm typeNo template instantiations for the exact algorithm type
SCIRun
SIAM CSESIAM CSE
ExampleExample
//! ConvertTetBase supports the dynamically loadable algorithm concept.//! when dynamically loaded the user will dynamically cast to a //! ConvertTetBase from the DynamicAlgoBase they will have a pointer to.class ConvertTetBase : public DynamicAlgoBase{public: virtual FieldHandle convert_quadratic(FieldHandle in) = 0; virtual ~ConvertTetBase();
static const string& get_h_file_path(); static string dyn_file_name(const TypeDescription *td) { // add no extension. return template_class_name() + "." + td->get_filename() + "."; }
static const string base_class_name() { static string name("ConvertTetBase"); return name; }
static const string template_class_name() { static string name("ConvertTet"); return name; }
//! support the dynamically compiled algorithm concept static CompileInfo *get_compile_info(const TypeDescription *td);};
SCIRun
SIAM CSESIAM CSE
ExampleExample
template <class Fld>class ConvertTet : public ConvertTetBase{public: //! virtual interface. virtual FieldHandle convert_quadratic(FieldHandle in);};
template <class Fld>FieldHandleConvertTet<Fld>::convert_quadratic(FieldHandle ifh){ Fld *fld = dynamic_cast<Fld*>(ifh.get_rep()); ASSERT(fld != 0); typedef typename Fld::value_type val_t; FieldHandle fh(QuadraticTetVolField<val_t>::create_from(*fld)); return fh;}
SCIRun
SIAM CSESIAM CSE
SummarySummary
Concepts• Ports and Datatypes
•Modules (Component Wizard)
• Templated Algorithms
•Dynamic Loading
SCIRun
SIAM CSESIAM CSE
On the Horizon (BioPSE 2.0)On the Horizon (BioPSE 2.0)
GUI Separation: Event/State Managers•Detachable interface•Reproducibility•Collaboration•Remote vis•Custom UI• Scripting•Regression testing
BioPSEGUI
StateManager
GUI
GUI