[cig-commits] r8399 - short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs

brad at geodynamics.org brad at geodynamics.org
Thu Dec 6 18:22:52 PST 2007


Author: brad
Date: 2007-12-06 18:22:51 -0800 (Thu, 06 Dec 2007)
New Revision: 8399

Added:
   short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/plot_geometry.py
   short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/vtk_geometry.py
Log:
Added mayavi2 scripts to plot geometry.

Added: short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/plot_geometry.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/plot_geometry.py	2007-12-06 23:54:43 UTC (rev 8398)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/plot_geometry.py	2007-12-07 02:22:51 UTC (rev 8399)
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+from enthought.mayavi.app import Mayavi
+import vtk_geometry
+from enthought.mayavi.sources.vtk_data_source import VTKDataSource
+
+class PlotGeometry(Mayavi):
+
+  def run(self):
+    from enthought.mayavi.modules.outline import Outline
+    from enthought.mayavi.modules.axes import Axes
+    from enthought.mayavi.modules.surface import Surface
+    
+    script = self.script
+    
+    # Create rendering scene
+    script.new_scene()
+    script.engine.current_scene.scene.background = (1,1,1)
+    script.engine.current_scene.scene.foreground = (0,0,0)
+    vtk_geometry.setCamera(script.engine.current_scene.scene.camera)
+
+    # Domain (axes and outline)
+    script.add_source(VTKDataSource(data=vtk_geometry.domain()))
+    script.engine.current_object.name = "Domain"
+    outline = Outline()
+    script.add_module(outline)
+    outline.actor.property.opacity = 0.2
+    axes = Axes()
+    axes.axes.x_label = "X (km)"
+    axes.axes.y_label = "Y (km)"
+    axes.axes.z_label = "Z (km)"
+    axes.axes.label_format = "%-0.1f"
+    script.add_module(axes)
+
+    # Fault surface
+    srcs = vtk_geometry.fault(showTaper=True)
+    for src in srcs:
+      script.add_source(VTKDataSource(data=src['object']))
+      script.engine.current_object.name = "Fault %s" % src['name']
+      surf = Surface()
+      script.add_module(surf)
+      surf.actor.property.color = (1,0,0)
+      if src['name'] == "taper":
+        surf.actor.property.opacity = 0.1
+      else:
+        surf.actor.property.opacity = 0.3
+
+    # Materials
+    srcs = vtk_geometry.materials()
+    for src in srcs:
+      script.add_source(VTKDataSource(data=src['object']))
+      script.engine.current_object.name = "Material %s" % src['name']
+      surf = Surface()
+      script.add_module(surf)
+      surf.actor.property.opacity = 0.1
+      if src['name'] == "elastic":
+        surf.actor.property.color = (1,1,0)
+      elif src['name'] == "viscoelastic":
+        surf.actor.property.color = (0,1,1)
+
+    return
+
+
+# ----------------------------------------------------------------------
+if __name__ == "__main__":
+  app = PlotGeometry()
+  app.main()
+
+
+# End of file
+


Property changes on: short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/plot_geometry.py
___________________________________________________________________
Name: svn:executable
   + *

Added: short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/vtk_geometry.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/vtk_geometry.py	2007-12-06 23:54:43 UTC (rev 8398)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/strikeslipnog/figs/vtk_geometry.py	2007-12-07 02:22:51 UTC (rev 8399)
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+from enthought.tvtk.api import tvtk
+import numpy
+
+# ----------------------------------------------------------------------
+def domain():
+    l = 24.0
+    domain = tvtk.CubeSource()
+    domain.set_bounds(0, l, 0, l, -l, 0.0)
+    return domain.get_output()
+
+# ----------------------------------------------------------------------
+def fault(showTaper=False):
+    vertices = numpy.array(
+        [ [12.0,  0.0,   0.0], # 0
+          [12.0, 12.0,   0.0], # 1
+          [12.0, 16.0,   0.0], # 2
+          [12.0,  0.0, -12.0], # 3
+          [12.0, 12.0, -12.0], # 4
+          [12.0,  0.0, -16.0], # 5
+          [12.0, 12.0, -16.0], # 6
+          [12.0, 16.0, -16.0] ], # 7
+        dtype=numpy.float32)
+    
+    # Setup VTK vertices
+    if not showTaper:
+        polys = numpy.array(
+            [ [0, 3, 1],
+              [1, 3, 4],
+              [3, 5, 4],
+              [4, 5, 6],
+              [1, 6, 2],
+              [2, 6, 7] ],
+            dtype=numpy.int32)
+        
+        # Setup VTK simplices
+        data = [{'name': "fault",
+                 'object': tvtk.PolyData(points=vertices, polys=polys)}]
+    else:
+        polys = numpy.array(
+            [ [0, 3, 1],
+              [1, 3, 4] ],
+            dtype=numpy.int32)
+        polysTaper = numpy.array(
+            [ [3, 5, 4],
+              [4, 5, 6],
+              [1, 6, 2],
+              [2, 6, 7] ],
+            dtype=numpy.int32)
+        
+        data= [{'name': "fault",
+                'object': tvtk.PolyData(points=vertices, polys=polys)},
+               {'name': "taper",
+                'object': tvtk.PolyData(points=vertices, polys=polysTaper)}]
+    return data
+
+
+# ----------------------------------------------------------------------
+def materials():
+    l = 24.0
+    elastic = tvtk.CubeSource()
+    elastic.set_bounds(0, l, 0, l, -l/2.0, 0.0)
+    viscoelastic = tvtk.CubeSource()
+    viscoelastic.set_bounds(0, l, 0, l, -l, -l/2.0)
+    return [{'name': "elastic",
+             'object': elastic.get_output()},
+            {'name': "viscoelastic",
+            'object': viscoelastic.get_output()}]
+
+# ----------------------------------------------------------------------
+def setCamera(camera):
+    dist = 70.0
+    angle = 40.0
+    elev = 30.0
+    azimuth = 35.0
+    clipRange = numpy.array( [5, 100] )
+    ptTo = numpy.array( [8.0, 12.0, -18.0] )
+    ptFrom = ptTo + numpy.array( [0.0, -dist, 0.0])
+    
+    camera.view_angle = angle
+    camera.view_up = (0,0,1)
+    camera.focal_point = ptTo
+    camera.position = ptFrom
+    camera.elevation(elev)
+    camera.azimuth(azimuth)
+    camera.clipping_range = clipRange
+    return
+
+    
+# ----------------------------------------------------------------------
+def setWindow(maya):
+    return



More information about the cig-commits mailing list