Changeset 3813
- Timestamp:
- Oct 17, 2006, 3:04:13 PM (18 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/examples/sww_file_visualiser_example.py
r3678 r3813 31 31 o.render_axes() 32 32 33 # Draw a polygon (here, a triangle) at height 10 34 o.overlay_polygon([(20, 50), (40, 40), (50, 10), (30, 20), (10, 30)], 10, colour=(1.0, 1.0, 0.0)) 35 33 36 # Precaching the height-based quantities reduces the time taken to draw each 34 37 # frame, but increases the time taken when the visualiser starts. -
anuga_core/source/anuga/visualiser/visualiser.py
r3670 r3813 2 2 from Tkinter import Tk, Button, Frame, N, E, S, W 3 3 from types import FunctionType, TupleType 4 from vtk import vtkActor, vtkCubeAxesActor2D, vtk FloatArray, vtkPolyDataMapper, vtkRenderer4 from vtk import vtkActor, vtkCubeAxesActor2D, vtkDelaunay2D, vtkFloatArray, vtkPoints, vtkPolyData, vtkPolyDataMapper, vtkRenderer 5 5 from vtk.tk.vtkTkRenderWidget import vtkTkRenderWidget 6 6 … … 162 162 """ 163 163 self.colours_height[quantityName] = colour 164 164 165 # --- Overlaid Polygons --- # 166 167 def overlay_polygon(self, coords, height=0.0, colour=(1.0, 0.0, 0.0)): 168 """Add a polygon to the output of the visualiser. 169 170 coords is a list of 2-tuples representing x and y coordinates. 171 These are triangulated by vtkDelaunay2D. 172 173 height is the z-value given to all points. 174 175 colour is the colour of the polygon, as a 3-tuple representing 176 r, g, b values between 0 and 1.""" 177 points = vtkPoints() 178 for coord in coords: 179 points.InsertNextPoint(coord[0], coord[1], height) 180 profile = vtkPolyData() 181 profile.SetPoints(points) 182 delny = vtkDelaunay2D() 183 delny.SetInput(profile) 184 mesh = vtkPolyDataMapper() 185 mesh.SetInput(delny.GetOutput()) 186 actor = vtkActor() 187 actor.SetMapper(mesh) 188 actor.GetProperty().SetColor(colour) 189 self.vtk_renderer.AddActor(actor) 190 165 191 # --- Vector Fields --- # 166 192
Note: See TracChangeset
for help on using the changeset viewer.