\documentclass{article} \usepackage{graphicx} \usepackage{rotating} \title{VTK Visualiser Reference} \author{Jack Kelly} % Override the date command, so we can get the date later. \let\olddate\date \newcommand{\thedate}{\today} \renewcommand{\date}[1]{ \olddate{#1} \renewcommand{\thedate}{#1} } \date{10 Nov 2006} % To prevent it being updated each time the % document is generated; only update this if the % material is being updated. \begin{document} \maketitle \tableofcontents \newpage \section{Introduction} This document provides a simple reference for the new VTK-based realtime visualiser for the ANUGA project. It covers usage examples, descriptions of the public interface and explanation of the design. The contents of this document are accurate as of \thedate. \section{Examples} \subsection{A Simple Offline Example} This is almost the simplest example possible. It reads in a SWW file and renders the stage in blue and elevation in the default grey. \begin{verbatim} #!/usr/bin/env python # Import the offline visualiser from anuga.visualiser import OfflineVisualiser # The argument to OfflineVisualiser is the path to a sww file o = OfflineVisualiser("path/to/sww/file") # Specify the height-based-quantities to render. # Remember to set dynamic=True for time-varying quantities o.render_quantity_height("elevation", dynamic=False) o.render_quantity_height("stage", dynamic=True) # Colour the stage with an RGB 3-tuple of values in [0,1]: o.colour_height_quantity('stage', (0.0, 0.0, 0.8)) # Start the visualiser (in its own thread). o.start() # Wait for the visualiser to terminate before shutting down. o.join() \end{verbatim} The basic pattern for using a visualiser consists of 4 steps: create the visualiser, configure it to display the required quantities, start the visualiser in its own thread using start() and finally wait on all the visualiser threads using join(). \subsection{A More Complicated Realtime Example} This example demonstrates the realtime visualiser and shows off additional capabilities of both visualisers. \begin{verbatim} #!/usr/bin/env python # Import the realtime visualiser from anuga.visualiser import RealtimeVisualiser from vtk import vtkCubeAxesActor2D import time from Numeric import array from anuga.shallow_water import Domain from anuga.shallow_water import Reflective_boundary from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular class Set_Stage: def __init__(self, x0=0.25, x1=0.75, y0=0.0, y1=1.0, h=5.0, h0=0.0): self.x0 = x0 self.x1 = x1 self.y0 = y0 self.y1 = y1 self.h = h self.h0 = h0 def __call__(self, x, y): return self.h0 + self.h*((x>self.x0)&(xself.y0)&(y