[cig-commits] r4444 - in mc/3D/CitcomS/trunk/visual: . Mayavi2
Mayavi2/core Mayavi2/filter Mayavi2/plugins
Mayavi2/plugins/filter Mayavi2/plugins/plugin_defs
maweier at geodynamics.org
maweier at geodynamics.org
Mon Aug 28 16:17:46 PDT 2006
Author: maweier
Date: 2006-08-28 16:17:45 -0700 (Mon, 28 Aug 2006)
New Revision: 4444
Added:
mc/3D/CitcomS/trunk/visual/Mayavi2/
mc/3D/CitcomS/trunk/visual/Mayavi2/HdfDisplay.py
mc/3D/CitcomS/trunk/visual/Mayavi2/VtkDisplay.py
mc/3D/CitcomS/trunk/visual/Mayavi2/__init__.py
mc/3D/CitcomS/trunk/visual/Mayavi2/citcoms_hdf2vtk.py
mc/3D/CitcomS/trunk/visual/Mayavi2/core/
mc/3D/CitcomS/trunk/visual/Mayavi2/core/CitcomSHDFUgrid.py
mc/3D/CitcomS/trunk/visual/Mayavi2/core/CitcomSHDFUgrid.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/core/__init__.py
mc/3D/CitcomS/trunk/visual/Mayavi2/core/__init__.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSFilterActions.py
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSFilterActions.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSSphere.py
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSSphere.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSreduce.py
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSreduce.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowCaps.py
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowCaps.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowSurface.py
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/__init__.py
mc/3D/CitcomS/trunk/visual/Mayavi2/filter/__init__.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomSHDFUgrid.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomSHDFUgrid.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_hdf_file_reader.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_hdf_file_reader.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_vtk_file_reader.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_vtk_file_reader.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/OpenCitcomSFILES.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/OpenCitcomSFILES.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/__init__.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/__init__.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSFilterActions.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSFilterActions.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSSphere.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSSphere.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSreduce.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSreduce.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowCaps.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowCaps.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowSurface.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/__init__.py
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/__init__.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/showcaps.pyc
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/plugin_defs/
mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/plugin_defs/mayavi_ui_plugin_definition.py
Log:
Files for Mayavi2 plugins
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/HdfDisplay.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/HdfDisplay.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/HdfDisplay.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,104 @@
+#! /usr/bin/env python
+
+from enthought.mayavi.app import Mayavi
+import sys
+from os.path import isfile
+
+class HdfDisplay(Mayavi):
+
+ filename = None
+ timestep = 0
+
+ def run(self):
+
+ from enthought.mayavi.sources.vtk_file_reader import VTKFileReader
+ #import modules here
+ from enthought.mayavi.modules import surface, glyph , axes, outline, orientation_axes, scalar_cut_plane
+ from enthought.mayavi.sources.vtk_data_source import VTKDataSource
+ from enthought.tvtk.api import tvtk
+ from core.CitcomSHDFUgrid import CitcomSHDFUgrid
+ from filter.CitcomSshowCaps import CitcomSshowCaps
+ from filter.CitcomSreduce import CitcomSreduce
+ #import filter.CitcomSSphere
+ import re
+
+ #DEFINES
+ orange = (1.0,0.5,0)
+ reduce_factor = 2
+ nx = 17
+ ny = 17
+ nz = 17
+
+ #Read Hdf file
+ src_hdf = CitcomSHDFUgrid()
+ hexgrid = src_hdf.initialize(self.filename,self.timestep,0,0,0,False,False)
+ radius_inner = src_hdf._radius_inner
+ data = VTKDataSource()
+ data.data = hexgrid
+
+
+ ###########Display Data############
+ #Create new scene
+ script.new_scene()
+ script.add_source(data)
+
+ scap = CitcomSshowCaps
+ #scap.setvalues(nx,ny,nz)
+ script.add_filter(scap)
+
+ #Orientation Axes
+ oa = orientation_axes.OrientationAxes()
+ script.add_module(oa)
+
+ #Show ScalarCutPlane
+ scp = scalar_cut_plane.ScalarCutPlane()
+ script.add_module(scp)
+
+ #Add filter for a reduce grid
+ redu = CitcomSreduce()
+ #redu.setvalues(nx,ny,nz)
+ script.add_filter(redu)
+
+ gly = glyph.Glyph()
+ gly.glyph.glyph_source.scale = 0.082
+ gly.glyph.scale_mode = 'data_scaling_off'
+ gly.glyph.color_mode = 'no_coloring'
+ script.add_module(gly)
+
+ ################### Create CORE ################################
+ #Load VTK Data Sets
+ sphere = tvtk.SphereSource()
+ sphere.radius = radius_inner
+ sphere.theta_resolution = 24
+ sphere.phi_resolution = 24
+
+ # Create a mesh from the data created above.
+ src = VTKDataSource()
+ src.data = sphere.output
+ script.add_source(src)
+
+ #Show Surface
+ surf_module = surface.Surface()
+ surf_module.actor.property.color = orange
+ script.add_module(surf_module)
+
+
+ # to create the rendering scene
+ ## your stuff here
+
+if __name__ == '__main__':
+ mc = HdfDisplay()
+ if len(sys.argv)==3:
+ mc.filename = sys.argv[1]
+ try:
+ mc.timestep = int(sys.argv[2])
+ except ValueError:
+ print "Timestep is not a number."
+ sys.exit(1)
+ if isfile(mc.filename):
+ mc.main()
+ else:
+ sys.exit(1)
+ print "File not found."
+ else:
+ print "[filename] [timestep]"
\ No newline at end of file
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/VtkDisplay.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/VtkDisplay.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/VtkDisplay.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,131 @@
+#! /usr/bin/env python
+try:
+ import wxversion
+ wxversion.ensureMinimal('2.6')
+except ImportError:
+ pass
+
+from enthought.mayavi.app import Mayavi
+import sys
+from os.path import isfile
+
+class VtkDisplay(Mayavi):
+
+ filename = None
+
+ def run(self):
+
+ from enthought.mayavi.sources.vtk_file_reader import VTKFileReader
+ #import modules here
+ from enthought.mayavi.modules import surface, glyph , axes, outline, orientation_axes, scalar_cut_plane
+ from enthought.mayavi.sources.vtk_data_source import VTKDataSource
+ from enthought.tvtk.api import tvtk
+ #CitcomS filter
+ from filter.CitcomSshowCaps import CitcomSshowCaps
+ from filter.CitcomSreduce import CitcomSreduce
+ import re
+
+
+ script = self.script
+
+ #DEFINES
+ orange = (1.0,0.5,0)
+
+ ################
+ #Read Meta information
+ meta = ""
+ try:
+ vtk = open(self.filename, "r")
+ vtk.readline()
+ meta = vtk.readline()
+ except IOError:
+ print 'cannot open file'
+ try:
+ print "Reading meta-information"
+ m = re.search('(?<=NX:)\d+', meta)
+ nx = int(m.group(0))
+ print "NX: ", nx
+ m = re.search('(?<=NY:)\d+', meta)
+ ny = int(m.group(0))
+ print "NY: ", ny
+ m = re.search('(?<=NZ:)\d+', meta)
+ nz = int(m.group(0))
+ print "NZ: ", nz
+ m = re.search('(?<=Radius_Inner:)(\d+|.)+', meta)
+ print m.group(0)
+ radius_inner = float(m.group(0))
+ print "Radius Inner: ", radius_inner
+
+ except ValueError:
+ print "Non-valid meta information in file..."
+
+ vtk.close()
+
+
+ ################
+
+ #Read Vtk file
+ src_vtkf = VTKFileReader()
+ src_vtkf.initialize(self.filename)
+
+ ###########Display Data############
+ #Create new scene
+ script.new_scene()
+
+
+ script.add_source(src_vtkf)
+
+
+ scap = CitcomSshowCaps()
+ script.add_filter(scap)
+
+ #Orientation Axes
+ oa = orientation_axes.OrientationAxes()
+ script.add_module(oa)
+
+ #Show ScalarCutPlane
+ scp = scalar_cut_plane.ScalarCutPlane()
+ script.add_module(scp)
+
+ #Add filter for a reduce grid
+ redu = CitcomSreduce()
+ script.add_filter(redu)
+
+ #Shows Glyph on reduce grid
+ gly = glyph.Glyph()
+ gly.glyph.glyph_source.scale = 0.082
+ gly.glyph.scale_mode = 'data_scaling_off'
+ gly.glyph.color_mode = 'no_coloring'
+ script.add_module(gly)
+
+ ################### Create CORE ################################
+ #Load VTK Data Sets
+ sphere = tvtk.SphereSource()
+ sphere.radius = radius_inner
+ sphere.theta_resolution = 24
+ sphere.phi_resolution = 24
+
+ # Create a mesh from the data created above.
+ src = VTKDataSource()
+ src.data = sphere.output
+ script.add_source(src)
+
+ #Show Surface
+ surf_module = surface.Surface()
+ surf_module.actor.property.color = orange
+ script.add_module(surf_module)
+
+
+
+ # to create the rendering scene
+ ## your stuff here
+
+if __name__ == '__main__':
+ mc = VtkDisplay()
+ #mc.filename = "/home/maweier/vtk_output_temp/general.0.vtk"
+ mc.filename = sys.argv[1]
+ if isfile(mc.filename):
+ mc.main()
+ else:
+ print "Type filename of Vtkfile to display"
+ sys.exit(1)
\ No newline at end of file
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/__init__.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/__init__.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/__init__.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,40 @@
+#------------------------------------------------------------------------------
+# Copyright 2003, Enthought, Inc.
+# All rights reserved.
+#
+# This software is provided without warranty under the terms of the BSD
+# license included in enthought/LICENSE.txt and may be redistributed only
+# under the conditions described in the aforementioned license. The license
+# is also available online at http://www.enthought.com/licenses/BSD.txt
+# Thanks for using Enthought open source!
+#
+# Author: Enthought, Inc.
+# Description: <Enthought library component>
+#------------------------------------------------------------------------------
+"""
+==========================
+Enthought Library
+==========================
+
+The Enthought Open Source Library
+
+Copyright 2003-2005, Enthought, Inc.
+
+
+"""
+
+try:
+ import __config__
+except ImportError:
+ __config__ = None
+
+if __config__ is not None:
+ if __config__.get_info('numpy'):
+ import os
+ if os.environ.get('NUMERIX','numpy').lower() not in ['','numpy']:
+ print 55*'*'
+ print "*** This enthought installation is built against numpy\n"\
+ "*** but the current environment is for %r.\n"\
+ "*** Resetting NUMERIX variable to 'numpy'."% (os.environ['NUMERIX'])
+ print 55*'*'
+ os.environ['NUMERIX'] = 'numpy'
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/__init__.py
___________________________________________________________________
Name: svn:executable
+ *
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/citcoms_hdf2vtk.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/citcoms_hdf2vtk.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/citcoms_hdf2vtk.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,623 @@
+#!/usr/bin/env python
+
+# <Script to generate VTK files from CitcomS hdf files>
+# Copyright (C) 2006 California Institue of Technology
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+# For more information contact maweier at geodynamics.org
+
+#import scipy
+import sys
+from datetime import datetime
+from getopt import getopt, GetoptError
+from pprint import *
+from math import *
+import tables #For HDF support
+import numpy
+import pyvtk
+import sys
+# defaults
+
+path = "./example0.h5"
+vtk_path = "./vtk_output"
+vtkfile = "%s.%d.vtk"
+
+initial = 0
+timesteps= None
+create_topo = False
+create_bottom = False
+create_surface = False
+create_ascii = False
+
+nx_redu=None
+ny_redu=None
+nz_redu=None
+
+
+def print_help():
+ print "Program to convert CitcomS HDF to Vtk files.\n"
+ print "-p, --path [path to hdf] \n\t Specify input file."
+ print "-o, --output [output filename] \n\t Specify the path to the folder for output files."
+ print ("-i, --initial [initial timestep] \n\t Specify initial timestep to export. If not \n \
+ \t specified script starts exporting from timestep 0.")
+ print "-t, --timestep [max timestep] \n\t Specify to which timestep you want to export. If not\n \
+ \t specified export all all timestep starting from intial timestep."
+ print "-x, --nx_reduce [nx] \n\t Set new nx to reduce output grid."
+ print "-y, --ny_reduce [ny] \n\t Set new ny to reduce output grid."
+ print "-z, --nz_reduce [nz] \n\t Set new nz to reduce output grid."
+ print "-b, --bottom \n\t Set to export Bottom information to Vtk file."
+ print "-s, --surface \n\t Set to export Surface information to Vtk file."
+ print "-c, --createtopo \n\t Set to create topography information in bottom and surface Vtk file."
+ print "-a, --ascii \n\t Create Vtk ASCII encoded files."
+ print "-h, --help, -? \n\t Print this help."
+
+# parse command line parameters
+try:
+ opts, args = getopt(sys.argv[1:], "p:o:i:t:x:y:z:bscah?", ['path=','output=','timestep=','x=','y=','z=','bottom','surface','createtopo','ascii', 'help','?'])
+except GetoptError, msg:
+ print "Error: %s" % msg
+ sys.exit(1)
+
+if len(opts)<=1:
+ print_help()
+ sys.exit(0)
+
+for opt,arg in opts:
+ if opt in ('-p','--path'):
+ path = arg
+
+ if opt in ('-o','--output'):
+ vtk_path = arg
+
+ if opt in ('-i','--initial'):
+ try:
+ initial = int(arg)
+ except ValueError:
+ print "Initial is not a number."
+ sys.exit(1)
+ if opt in ('-t','--timestep'):
+ try:
+ timesteps = int(arg)
+ except ValueError:
+ print "Timestep is not a number."
+ sys.exit(1)
+ if opt in ('-x','--nx_reduce'):
+ try:
+ nx_redu = int(arg)
+ except ValueError:
+ print "NX is not a number."
+
+ if opt in ('-y','--ny_reduce'):
+ try:
+ ny_redu = int(arg)
+ except ValueError:
+ print "NY is not a number."
+
+ if opt in ('-z','--nz_reduce'):
+ try:
+ nz_redu = int(arg)
+ except ValueError:
+ print "NZ is not a number."
+
+ if opt in ('-b','--bottom'):
+ create_bottom = True
+ if opt in ('-s','--surface'):
+ create_surface = True
+ if opt in ('-c','--createtopo'):
+ create_topo = True
+ if opt in ('-a','--ascii'):
+ create_ascii = True
+ if opt in ('-h','--help'):
+ print_help()
+ sys.exit(0)
+ if opt == '-?':
+ print_help()
+ sys.exit(0)
+
+#############################globals############################################
+
+f = tables.openFile(path,'r')
+
+
+nx = int(f.root.input._v_attrs.nodex)
+ny = int(f.root.input._v_attrs.nodey)
+nz = int(f.root.input._v_attrs.nodez)
+
+#If not defined as argument read from hdf
+hdf_timesteps = int(f.root.time.nrows)
+
+if timesteps==None or timesteps>hdf_timesteps:
+ timesteps = hdf_timesteps
+
+
+if nx_redu:
+ nx_redu = nx-1
+if ny_redu:
+ ny_redu = ny-1
+if nz_redu:
+ nz_redu = nz-1
+
+if nx_redu>=nx:
+ nx_redu=nx-1
+if ny_redu>=ny:
+ ny_redu=ny-1
+if nz_redu>=nz:
+ nz_redu=nz-1
+
+el_nx_redu = nx_redu+1
+el_ny_redu = ny_redu+1
+el_nz_redu = nz_redu+1
+
+radius_inner = float(f.root.input._v_attrs.radius_inner)
+radius_outer = float(f.root.input._v_attrs.radius_outer)
+#rayleigh = float(f.root.input._v_attrs.rayleigh) #Important for creating the right lookup table
+nproc_surf = int(f.root.input._v_attrs.nproc_surf)
+
+
+###############################################################################
+
+#Iterator for CitcomDataRepresentation(yxz) to VTK(xyz)
+def vtk_iter(nx,ny,nz):
+ for i in xrange(nx):
+ for j in xrange(ny):
+ for k in xrange(nz):
+ yield k + nz * i + nz * nx * j
+
+#Reduces the CitcomS grid
+def reduce_iter(n,nredu):
+ i=0
+ n_f=float(n)
+ nredu_f=float(nredu)
+ fl=(n_f-1)/nredu_f
+ redu = 0
+ for i in xrange(nredu+1):
+ yield int(round(redu))
+ redu = redu + fl
+
+#Transform Vectors in Spherical to Cartesian Coordinates 2d
+#def velocity2cart2d(vel_colat, vel_lon,x , y):
+# x1 = vel_colat*cos(x)*cos(y)-vel_lon*sin(y)
+# y1 = vel_colat*cos(x)*sin(y)+vel_lon*cos(y)
+# z1 = -vel_colat*sin(x)
+# return x1,y1,z1
+
+#Converts Spherical to Carthesian Coordinates 2d
+#def RTF2XYZ2d(vel_colat, vel_lon):
+# x1 = sin(vel_colat)*cos(vel_lon)
+# y1 = sin(vel_colat)*sin(vel_lon)
+# z1 = cos(vel_colat)
+# return x1,y1,z1
+
+#Transform Vectors in Spherical to Cartesian Coordinates
+def velocity2cart(vel_colat,vel_long,r, x, y, z):
+ x1 = r*sin(x)*cos(y)+vel_colat*cos(x)*cos(y)-vel_long*sin(y)
+ y1 = r*sin(x)*sin(y)+vel_colat*cos(x)*sin(y)+vel_long*cos(y)
+ z1 = r*cos(x)-vel_colat*sin(x)
+ return x1, y1, z1
+
+
+#Converts Spherical to Cartesian Coordinates
+def RTF2XYZ(thet, phi, r):
+ x = r * sin(thet) * cos(phi)
+ y = r * sin(thet) * sin(phi)
+ z = r * cos(thet)
+ return x, y, z
+
+
+polygons3d = [] # arrays containing connectivity information
+polygons2d = []
+counter=0 #Counts iterations of citcom2vtk
+
+
+#Reads Citcom Files and creates a VTK File
+def citcom2vtk(t):
+ print "Timestep:",t
+
+ benchmarkstr = ""
+ #Assign create_bottom and create_surface to bottom and surface
+ #to make them valid in methods namespace
+ bottom = create_bottom
+ surface = create_surface
+
+ ordered_points = [] #reset Sequences for points
+ ordered_temperature = []
+ ordered_velocity = []
+ ordered_visc = []
+
+ #Surface and Bottom Points
+ #Initialize empty sequences
+ surf_vec = []
+ botm_vec = []
+ surf_topo = []
+ surf_hflux = []
+ botm_topo = []
+ botm_hflux = []
+
+ surf_points = []
+ botm_points = []
+
+ for capnr in xrange(nproc_surf):
+ ###Benchmark Point 1 Start##
+ #start = datetime.now()
+ ############################
+ print "Processing cap",capnr+1,"of",nproc_surf
+ cap = f.root._f_getChild("cap%02d" % capnr)
+
+ temp_coords = [] # reset Coordinates, Velocity, Temperature Sequence
+ temp_vel = []
+ temp_temp = []
+ temp_visc = []
+
+ #Information from hdf
+ #This information needs to be read only once
+
+ hdf_coords = cap.coord[:]
+ hdf_velocity = cap.velocity[t]
+ hdf_temperature = cap.temperature[t]
+ hdf_viscosity = cap.viscosity[t]
+
+
+ ###Benchmark Point 1 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 2 Start##
+ #start = datetime.now()
+ ############################
+
+ #Create Iterator to change data representation
+ nx_redu_iter = reduce_iter(nx,nx_redu)
+ ny_redu_iter = reduce_iter(ny,ny_redu)
+ nz_redu_iter = reduce_iter(nz,nz_redu)
+ vtk_i = vtk_iter(el_nx_redu,el_ny_redu,el_nz_redu)
+
+ # read citcom data - zxy (z fastest)
+ for j in xrange(el_ny_redu):
+ j_redu = ny_redu_iter.next()
+ nx_redu_iter = reduce_iter(nx,nx_redu)
+ for i in xrange(el_nx_redu):
+ i_redu = nx_redu_iter.next()
+ nz_redu_iter = reduce_iter(nz,nz_redu)
+ for k in xrange(el_nz_redu):
+ k_redu = nz_redu_iter.next()
+
+ thet , phi, r = map(float,hdf_coords[i_redu][j_redu][k_redu])
+ temp_coords.append((thet,phi,r))
+
+ vel_colat, vel_lon , vel_r = map(float,hdf_velocity[i_redu][j_redu][k_redu])
+ temperature = float(hdf_temperature[i_redu][j_redu][k_redu])
+ visc = float(hdf_viscosity[i_redu][j_redu][k_redu])
+
+ temp_vel.append((vel_colat,vel_lon,vel_r))
+ temp_temp.append(temperature)
+ temp_visc.append(visc)
+
+ ##Delete Objects for GC
+ del hdf_coords
+ del hdf_velocity
+ del hdf_temperature
+ del hdf_viscosity
+
+ ###Benchmark Point 2 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 3 Start##
+ #start = datetime.now()
+ ############################
+
+ # rearange vtk data - xyz (x fastest).
+ for n0 in xrange(el_nz_redu*el_ny_redu*el_nx_redu):
+ iter = vtk_i.next()
+ #print iter
+ #Get Cartesian Coords from Coords
+ #zxy Citcom to xyz Vtk
+ colat, lon, r = temp_coords[iter]
+ x_coord, y_coord, z_coord = RTF2XYZ(colat,lon,r)
+ ordered_points.append((x_coord,y_coord,z_coord))
+
+ #Get Vectors in Cartesian Coords from Velocity
+ vel_colat,vel_lon,vel_r = temp_vel[iter]
+ x_velo, y_velo, z_velo = velocity2cart(vel_colat,vel_lon,vel_r, colat,lon , r)
+ ordered_velocity.append((x_velo,y_velo,z_velo))
+
+ ordered_temperature.append(temp_temp[iter])
+ ordered_visc.append(temp_visc[iter])
+
+ ###Benchmark Point 3 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ##Delete Unused Object for GC
+ del temp_coords
+ del temp_vel
+ del temp_temp
+ del temp_visc
+
+
+ ###Benchmark Point 4 Start##
+ #start = datetime.now()
+ ############################
+
+ #Bottom Information from hdf
+ if bottom == True:
+ try:
+ hdf_bottom_coord = cap.botm.coord[:]
+ hdf_bottom_heatflux = cap.botm.heatflux[t]
+ hdf_bottom_topography = cap.botm.topography[t]
+ hdf_bottom_velocity = cap.botm.velocity[t]
+ except:
+ print "\tCould not find bottom information in file.\n \
+ Set create bottom to false"
+ bottom = False
+ #Surface Information from hdf
+ if surface==True:
+ try:
+ hdf_surface_coord = cap.surf.coord[:]
+ hdf_surface_heatflux = cap.surf.heatflux[t]
+ hdf_surface_topography = cap.surf.topography[t]
+ hdf_surface_velocity = cap.surf.velocity[t]
+ except:
+ print "\tCould not find surface information in file.\n \
+ Set create surface to false"
+ surface = False
+
+ ###Benchmark Point 4 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+
+ ###Benchmark Point 5 Start##
+ #start = datetime.now()
+ ############################
+
+ #Compute surface/bottom topography mean
+ if create_topo:
+ surf_mean=0.0
+ botm_mean=0.0
+
+ if surface:
+ for i in xrange(ny):
+ surf_mean += numpy.mean(hdf_surface_topography[i])
+ surf_mean = surf_mean/ny
+
+ if bottom:
+ for i in xrange(ny):
+ botm_mean += numpy.mean(hdf_bottom_topography[i])
+ botm_mean = botm_mean/ny
+ #print "Mean Surface:",surf_mean
+
+ ###Benchmark Point 5 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 6 Start##
+ #start = datetime.now()
+ ############################
+
+ #Read Surface and Bottom Data
+ if bottom==True or surface == True:
+ for i in xrange(ny):
+ for j in xrange(nx):
+
+
+ if bottom==True:
+ #Bottom Coordinates
+ if create_topo==True:
+ colat, lon = hdf_bottom_coord[i,j]
+ x,y,z = RTF2XYZ(colat,lon,radius_inner+float( (hdf_bottom_topography[i,j]-botm_mean)*(10**21)/(6371000**2/10**(-6))/(3300*10)/1000 ))
+ botm_points.append((x,y,z))
+ else:
+ colat, lon = hdf_bottom_coord[i,j]
+ x,y,z = RTF2XYZ(colat, lon,radius_inner)
+ botm_points.append((x,y,z))
+
+ #Bottom Heatflux
+ botm_hflux.append(float(hdf_bottom_heatflux[i,j]))
+
+ #Bottom Velocity
+ vel_colat, vel_lon = map(float,hdf_bottom_velocity[i,j])
+ x,y,z = velocity2cart(vel_colat,vel_lon, radius_inner, colat, lon, radius_inner)
+ botm_vec.append((x,y,z))
+
+ if surface==True:
+ #Surface Information
+ if create_topo==True:
+ colat,lon = hdf_surface_coord[i][j]
+ #637100 = Earth radius, 33000 = ?
+ x,y,z = RTF2XYZ(colat,lon,radius_outer+float( (hdf_surface_topography[i][j]-surf_mean)*(10**21)/(6371000**2/10**(-6))/(3300*10)/1000 ))
+ surf_points.append((x,y,z))
+ else:
+ colat, lon = hdf_surface_coord[i][j]
+ x,y,z = RTF2XYZ(colat, lon,radius_outer)
+ surf_points.append((x,y,z))
+
+ #Surface Heatflux
+ surf_hflux.append(float(hdf_surface_heatflux[i][j]))
+
+ #Surface Velocity
+ vel_colat, vel_lon = map(float,hdf_surface_velocity[i][j])
+ x,y,z = velocity2cart(vel_colat,vel_lon, radius_outer, colat, lon, radius_outer)
+ surf_vec.append((x,y,z))
+
+ #del variables for GC
+ if bottom==True:
+ del hdf_bottom_coord
+ del hdf_bottom_heatflux
+ del hdf_bottom_velocity
+ if surface==True:
+ del hdf_surface_coord
+ del hdf_surface_heatflux
+ del hdf_surface_velocity
+
+ ###Benchmark Point 6 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 7 Start##
+ #start = datetime.now()
+ ############################
+
+
+##################################################################
+ #Create Connectivity info
+ if counter==0:
+ #For 3d Data
+ i=1 #Counts X Direction
+ j=1 #Counts Y Direction
+ k=1 #Counts Z Direction
+
+ for n in xrange(((el_nx_redu*el_ny_redu*el_nz_redu)-(el_nz_redu*el_ny_redu))):
+ if (i%el_nz_redu)==0: #X-Values!!!
+ j+=1 #Count Y-Values
+
+ if (j%el_ny_redu)==0:
+ k+=1 #Count Z-Values
+
+ if i%el_nz_redu!=0 and j%el_ny_redu!=0: #Check if Box can be created
+ #Get Vertnumbers
+ n0 = n+(capnr*(el_nx_redu*el_ny_redu*el_nz_redu))
+ n1 = n0+1
+ n2 = n1+el_nz_redu
+ n3 = n0+el_nz_redu
+ n4 = n0+(el_ny_redu*el_nz_redu)
+ n5 = n4+1
+ n6 = n4+el_nz_redu+1
+ n7 = n4+el_nz_redu
+
+ #Created Polygon Box
+ polygons3d.append([n0,n1,n2,n3,n4,n5,n6,n7]) #Hexahedron VTK Representation
+
+ i+=1
+
+
+ if bottom==True or surface==True:
+ #Connectivity for 2d-Data
+ i=1
+ for n in xrange((nx)*(ny) - nx):
+ if i%nx!=0 :
+ n0 = n+(capnr*((nx)*(ny)))
+ n1 = n0+1
+ n2 = n0+ny
+ n3 = n2+1
+ polygons2d.append([n0,n1,n2,n3])
+ i+=1
+
+ ###Benchmark Point 7 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf\n" % (delta.seconds + float(delta.microseconds)/1e6)
+ #print benchmarkstr
+
+#################################################################
+#Write Data to VTK
+
+ #benchmarkstr = "\n\nIO:\n"
+ ###Benchmark Point 8 Start##
+ #start = datetime.now()
+ ############################
+
+
+ #Surface Points
+ if surface==True:
+ struct_coords = pyvtk.UnstructuredGrid(surf_points, pixel=polygons2d)
+ #topo_scal = pyvtk.Scalars(surf_topo,'Surface Topography', lookup_table='default')
+ hflux_scal = pyvtk.Scalars(surf_hflux,'Surface Heatflux',lookup_table='default')
+ vel_vec = pyvtk.Vectors(surf_vec,'Surface Velocity Vectors')
+ ##
+ tempdata = pyvtk.PointData(hflux_scal,vel_vec)
+ data = pyvtk.VtkData(struct_coords, tempdata,'CitcomS Output %s Timestep %s' % ('surface info',t))
+ if create_ascii:
+ data.tofile(vtk_path + (vtkfile % ('surfaceinfo',t)),)
+ else:
+ data.tofile(vtk_path + (vtkfile % ('surfaceinfo',t)),'binary')
+ print "Written Surface information to file"
+
+ ###Benchmark Point 8 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 9 Start##
+ #start = datetime.now()
+ ############################
+
+ if bottom==True:
+ #Bottom Points
+ struct_coords = pyvtk.UnstructuredGrid(botm_points, pixel=polygons2d)
+ #topo_scal = pyvtk.Scalars(botm_topo,'Bottom Topography','default')
+ hflux_scal = pyvtk.Scalars(botm_hflux,'Bottom Heatflux','default')
+ vel_vec = pyvtk.Vectors(botm_vec,'Bottom Velocity Vectors')
+ ##
+ tempdata = pyvtk.PointData(hflux_scal,vel_vec)
+ data = pyvtk.VtkData(struct_coords, tempdata, 'CitcomS Output %s Timestep %s' % ('Bottom info',t))
+ if create_ascii:
+ data.tofile(vtk_path + (vtkfile % ('bottominfo',t)))
+ else:
+ data.tofile(vtk_path + (vtkfile % ('bottominfo',t)),'binary')
+ print "Written Bottom information to file"
+
+
+ ###Benchmark Point 9 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+
+
+ ###Benchmark Point 10 Start##
+ #start = datetime.now()
+
+ #General Data
+ struct_coords = pyvtk.UnstructuredGrid(ordered_points,hexahedron=polygons3d)
+ vel_vec = pyvtk.Vectors(ordered_velocity, 'Velocity Vectors')
+ temp_scal = pyvtk.Scalars(ordered_temperature,'Temperature Scalars','default')
+ visc_scal = pyvtk.Scalars(ordered_visc,'Viscosity Scalars','default')
+ ##
+ tempdata = pyvtk.PointData(temp_scal,visc_scal,vel_vec)
+ data = pyvtk.VtkData(struct_coords, tempdata, 'CitcomS Output %s Timestep:%d NX:%d NY:%d NZ:%d Radius_Inner:%f' % (path,t,el_nx_redu,el_ny_redu,el_nz_redu,radius_inner))
+ ############################
+ if create_ascii:
+ data.tofile(vtk_path + (vtkfile % ('general',t)))
+ else:
+ data.tofile(vtk_path + (vtkfile % ('general',t)),'binary')
+ print "Written general data to file"
+
+ ###Benchmark Point 10 Stop##
+ #delta = datetime.now() - start
+ #benchmarkstr += "%.5lf\n" % (delta.seconds + float(delta.microseconds)/1e6)
+
+
+ #print benchmarkstr
+ #print "\n"
+
+
+###############################################################################
+d1 = datetime.now()
+
+print "Converting Hdf to Vtk"
+print "Initial: ",initial, "Timesteps:",timesteps
+print "NX:",el_nx_redu, "NY:",el_ny_redu, "NZ:", el_nz_redu
+print "Create Bottom: ",create_bottom, " Create Surface: ", create_surface
+print "Create Topography: ", create_topo
+
+for t in xrange(initial,timesteps):
+ start = datetime.now()
+ citcom2vtk(t)
+ counter+=1
+ delta = datetime.now() - start
+ print "\t%.3lf sec" % (delta.seconds + float(delta.microseconds)/1e6)
+
+d2 = datetime.now()
+f.close()
+print "Total: %d seconds" % (d2 - d1).seconds
+###############################################################################
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/core/CitcomSHDFUgrid.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/core/CitcomSHDFUgrid.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/core/CitcomSHDFUgrid.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,419 @@
+from enthought.tvtk.api import tvtk
+import tables #For HDF support
+import numpy
+from math import *
+from datetime import datetime
+
+class CitcomSHDFUgrid:
+
+ data = None
+ _nx = None
+ _ny = None
+ _nz = None
+ _nx_redu = None
+ _ny_redu = None
+ _nz_redu = None
+ _radius_inner = None
+ _radius_outer = None
+ timesteps = None
+ frequency = None
+
+ #Iterator for CitcomDataRepresentation(yxz) to VTK(xyz)
+ def vtk_iter(self,nx,ny,nz):
+ for i in xrange(nx):
+ for j in xrange(ny):
+ for k in xrange(nz):
+ yield k + nz * i + nz * nx * j
+
+ #Reduces the CitcomS grid
+ def reduce_iter(self,n,nredu):
+ i=0
+ n_f=float(n)
+ nredu_f=float(nredu)
+ fl=(n_f-1)/nredu_f
+ redu = 0
+ for i in xrange(nredu+1):
+ yield int(round(redu))
+ redu = redu + fl
+
+
+ def velocity2cart(self,vel_colat,vel_long,r, x, y, z):
+ x1 = r*sin(x)*cos(y)+vel_colat*cos(x)*cos(y)-vel_long*sin(y)
+ y1 = r*sin(x)*sin(y)+vel_colat*cos(x)*sin(y)+vel_long*cos(y)
+ z1 = r*cos(x)-vel_colat*sin(x)
+ return x1, y1, z1
+
+
+ #Converts Spherical to Cartesian Coordinates
+ def RTF2XYZ(self,thet, phi, r):
+ x = r * sin(thet) * cos(phi)
+ y = r * sin(thet) * sin(phi)
+ z = r * cos(thet)
+ return x, y, z
+
+
+
+ def citcom2vtk(self,t,f,nproc_surf,nx_redu,ny_redu,nz_redu,bottom,surface):
+ #Assign create_bottom and create_surface to bottom and surface
+ #to make them valid in methods namespace
+
+ benchmarkstr = ""
+ fd = open('/home/maweier/benchmark.txt','w')
+
+ hexagrid = tvtk.UnstructuredGrid()
+ surfPixelGrid = tvtk.UnstructuredGrid()
+ botmPixelGrid = tvtk.UnstructuredGrid()
+
+ vtkordered_temp = tvtk.FloatArray()
+ vtkordered_velo = tvtk.FloatArray()
+ vtkordered_visc = tvtk.FloatArray()
+
+ hexagrid.allocate(1,1)
+ surfPixelGrid.allocate(1, 1)
+ botmPixelGrid.allocate(1,1)
+
+ nx = self._nx
+ ny = self._ny
+ nz = self._nz
+ counter = 0
+ el_nx_redu = nx_redu + 1
+ el_ny_redu = ny_redu + 1
+ el_nz_redu = nz_redu + 1
+
+ ordered_points = [] #reset Sequences for points
+ ordered_temperature = []
+ ordered_velocity = []
+ ordered_visc = []
+
+ #Surface and Bottom Points
+ #Initialize empty sequences
+ surf_vec = []
+ botm_vec = []
+ surf_topo = []
+ surf_hflux = []
+ botm_topo = []
+ botm_hflux = []
+
+ surf_points = []
+ botm_points = []
+
+ for capnr in xrange(nproc_surf):
+
+ ###Benchmark Point 1 Start##
+ d1 = datetime.now()
+ ############################
+
+ cap = f.root._f_getChild("cap%02d" % capnr)
+
+ temp_coords = [] # reset Coordinates, Velocity, Temperature Sequence
+ temp_vel = []
+ temp_temp = []
+ temp_visc = []
+
+ #Information from hdf
+ #This information needs to be read only once
+ hdf_coords = cap.coord[:]
+
+ hdf_velocity = cap.velocity[t]
+ hdf_temperature = cap.temperature[t]
+ hdf_viscosity = cap.viscosity[t]
+
+
+
+ #Create Iterator to change data representation
+ nx_redu_iter = self.reduce_iter(nx,nx_redu)
+ ny_redu_iter = self.reduce_iter(ny,ny_redu)
+ nz_redu_iter = self.reduce_iter(nz,nz_redu)
+
+ vtk_i = self.vtk_iter(el_nx_redu,el_ny_redu,el_nz_redu)
+
+ ##Benchmark Point 1 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 2 Start##
+ d1 = datetime.now()
+ ############################
+
+ # read citcom data - zxy (z fastest)
+ for j in xrange(el_ny_redu):
+ j_redu = ny_redu_iter.next()
+ nx_redu_iter = self.reduce_iter(nx,nx_redu)
+ for i in xrange(el_nx_redu):
+ i_redu = nx_redu_iter.next()
+ nz_redu_iter = self.reduce_iter(nz,nz_redu)
+ for k in xrange(el_nz_redu):
+ k_redu = nz_redu_iter.next()
+ thet , phi, r = map(float,hdf_coords[i_redu][j_redu][k_redu])
+ temp_coords.append((thet,phi,r))
+
+ vel_colat, vel_lon , vel_r = map(float,hdf_velocity[i][j][k])
+ temperature = float(hdf_temperature[i][j][k])
+ visc = float(hdf_viscosity[i][j][k])
+
+ temp_vel.append((vel_colat,vel_lon,vel_r))
+ temp_temp.append(temperature)
+ temp_visc.append(visc)
+
+ ##Delete Objects for GC
+ del hdf_coords
+ del hdf_velocity
+ del hdf_temperature
+ del hdf_viscosity
+
+ ##Benchmark Point 2 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 3 Start##
+ d1 = datetime.now()
+ ############################
+
+ # rearange vtk data - xyz (x fastest).
+ for n0 in xrange(el_nz_redu*el_ny_redu*el_nx_redu):
+ iter = vtk_i.next()
+ #print iter
+ #Get Cartesian Coords from Coords
+ #zxy Citcom to xyz Vtk
+ colat, lon, r = temp_coords[iter]
+ x_coord, y_coord, z_coord = self.RTF2XYZ(colat,lon,r)
+ ordered_points.append((x_coord,y_coord,z_coord))
+
+ #Get Vectors in Cartesian Coords from Velocity
+ vel_colat,vel_lon,vel_r = temp_vel[iter]
+ x_velo, y_velo, z_velo = self.velocity2cart(vel_colat,vel_lon,vel_r, colat,lon , r)
+ ordered_velocity.append((x_velo,y_velo,z_velo))
+
+ ################################################
+ vtkordered_temp.insert_next_tuple1(temp_temp[iter])
+ vtkordered_visc.insert_next_tuple1(temp_visc[iter])
+
+ vtkordered_velo.from_array(ordered_velocity)
+
+ ##Delete Unused Object for GC
+ del temp_coords
+ del temp_vel
+ del temp_temp
+ del temp_visc
+
+ ##Benchmark Point 3 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 4 Start##
+ d1 = datetime.now()
+ ############################
+
+ #Bottom Information from hdf
+ if bottom == True:
+ try:
+ hdf_bottom_coord = cap.botm.coord[:]
+ hdf_bottom_heatflux = cap.botm.heatflux[t]
+ hdf_bottom_topography = cap.botm.topography[t]
+ hdf_bottom_velocity = cap.botm.velocity[t]
+ except:
+ bottom = False
+ #Surface Information from hdf
+ if surface==True:
+ try:
+ hdf_surface_coord = cap.surf.coord[:]
+ hdf_surface_heatflux = cap.surf.heatflux[t]
+ hdf_surface_topography = cap.surf.topography[t]
+ hdf_surface_velocity = cap.surf.velocity[t]
+ except:
+ surface = False
+
+ ##Benchmark Point 4 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 5 Start##
+ d1 = datetime.now()
+ ############################
+
+ #Compute surface/bottom topography mean
+ if bottom==True or surface==True:
+ surf_mean=0.0
+ botm_mean=0.0
+
+ for i in xrange(ny):
+ if surface == True:
+ surf_mean += numpy.mean(hdf_surface_topography[i])
+ if bottom == True:
+ botm_mean += numpy.mean(hdf_bottom_topography[i])
+
+ surf_mean = surf_mean/ny
+ botm_mean = botm_mean/ny
+ #print "Mean Surface:",surf_mean
+
+ ##Benchmark Point 5 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 6 Start##
+ d1 = datetime.now()
+ ############################
+
+ #Read Surface and Bottom Data
+ if bottom==True or surface == True:
+ for i in xrange(ny):
+ for j in xrange(nx):
+
+
+ if bottom==True:
+ #Bottom Coordinates
+ if create_topo==True:
+ colat, lon = hdf_bottom_coord[i][j]
+ x,y,z = self.RTF2XYZ(colat,lon,radius_inner+float( (hdf_bottom_topography[i][j]-botm_mean)*(10**21)/(6371000**2/10**(-6))/(3300*10)/1000 ))
+ botm_points.append((x,y,z))
+ else:
+ colat, lon = hdf_bottom_coord[i][j]
+ x,y,z = self.RTF2XYZ(colat, lon,radius_inner)
+ botm_points.append((x,y,z))
+
+ #Bottom Heatflux
+ botm_hflux.append(float(hdf_bottom_heatflux[i][j]))
+
+ #Bottom Velocity
+ vel_colat, vel_lon = map(float,hdf_bottom_velocity[i][j])
+ x,y,z = self.velocity2cart(vel_colat,vel_lon, radius_inner, colat, lon, radius_inner)
+ botm_vec.append((x,y,z))
+
+ if surface==True:
+ #Surface Information
+ if create_topo==True:
+ colat,lon = hdf_surface_coord[i][j]
+ #637100 = Earth radius, 33000 = ?
+ x,y,z = self.RTF2XYZ(colat,lon,radius_outer+float( (hdf_surface_topography[i][j]-surf_mean)*(10**21)/(6371000**2/10**(-6))/(3300*10)/1000 ))
+ surf_points.append((x,y,z))
+ else:
+ colat, lon = hdf_surface_coord[i][j]
+ x,y,z = self.RTF2XYZ(colat, lon,radius_outer)
+ surf_points.append((x,y,z))
+
+ #Surface Heatflux
+ surf_hflux.append(float(hdf_surface_heatflux[i][j]))
+
+ #Surface Velocity
+ vel_colat, vel_lon = map(float,hdf_surface_velocity[i][j])
+ x,y,z = self.velocity2cart(vel_colat,vel_lon, radius_outer, colat, lon, radius_outer)
+ surf_vec.append((x,y,z))
+
+ vtk_botm_vec.from_array(botm_vec)
+ vtk_surf_vec.from_array(surf_vec)
+
+ #del variables for GC
+ if bottom==True:
+ del hdf_bottom_coord
+ del hdf_bottom_heatflux
+ del hdf_bottom_velocity
+ if surface==True:
+ del hdf_surface_coord
+ del hdf_surface_heatflux
+ del hdf_surface_velocity
+
+ ##Benchmark Point 6 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 7 Start##
+ d1 = datetime.now()
+ ############################
+##################################################################
+ #Create Connectivity info
+ if counter==0:
+ #For 3d Data
+ i=1 #Counts X Direction
+ j=1 #Counts Y Direction
+ k=1 #Counts Z Direction
+
+ for n in xrange(((el_nx_redu*el_ny_redu*el_nz_redu)-(el_nz_redu*el_ny_redu))):
+ if (i%el_nz_redu)==0: #X-Values!!!
+ j+=1 #Count Y-Values
+
+ if (j%el_ny_redu)==0:
+ k+=1 #Count Z-Values
+
+ if i%el_nz_redu!=0 and j%el_ny_redu!=0: #Check if Box can be created
+ #Get Vertnumbers
+ n0 = n+(capnr*(el_nx_redu*el_ny_redu*el_nz_redu))
+ n1 = n0+1
+ n2 = n1+el_nz_redu
+ n3 = n0+el_nz_redu
+ n4 = n0+(el_ny_redu*el_nz_redu)
+ n5 = n4+1
+ n6 = n4+el_nz_redu+1
+ n7 = n4+el_nz_redu
+
+ #Created Polygon Box
+ hexagrid.insert_next_cell(12,[n0,n1,n2,n3,n4,n5,n6,n7])
+
+ i+=1
+
+ if bottom==True or surface==True:
+ #Connectivity for 2d-Data
+ i=1
+ for n in xrange((nx)*(ny) - nx):
+ if i%nx!=0 :
+ n0 = n+(capnr*((nx)*(ny)))
+ n1 = n0+1
+ n2 = n0+ny
+ n3 = n2+1
+ surfPixelGrid.insert_next_cell(8 , [n0,n1,n2,n3])
+ botmPixelGrid.insert_next_cell(8 , [n0,n1,n2,n3])
+ i+=1
+
+ ##Benchmark Point 7 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf \n" % (delta.seconds + float(delta.microseconds)/1e6)
+
+ fd.write(benchmarkstr)
+
+ benchmarkstr = '\n\nIO: '
+ ###Benchmark Point 1O Start##
+ d1 = datetime.now()
+ ############################
+ vtkordered_temp.name = 'Temperature'
+ hexagrid.point_data.scalars = vtkordered_temp
+ vtkordered_velo.name = 'Velocity'
+ hexagrid.point_data.vectors = vtkordered_velo
+ hexagrid.points = ordered_points
+ ##Benchmark Point 1O Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf" % (delta.seconds + float(delta.microseconds)/1e6)
+ fd.write(benchmarkstr)
+
+ return hexagrid
+
+
+ def initialize(self,filename,timestep,nx_redu,ny_redu,nz_redu,surface,bottom):
+
+ hdf=tables.openFile(filename,'r')
+ self._nx = int(hdf.root.input._v_attrs.nodex)
+ self._ny = int(hdf.root.input._v_attrs.nodey)
+ self._nz = int(hdf.root.input._v_attrs.nodez)
+
+ #Clip against boundaries
+ if nx_redu>=0 or nx_redu>=self._nx:
+ nx_redu = self._nx-1
+ if ny_redu==0 or ny_redu>=self._ny:
+ ny_redu = self._ny-1
+ if nz_redu==0 or nz_redu>=self._nz:
+ nz_redu = self._nz-1
+
+
+ self._nx_redu = nx_redu
+ self._ny_redu = ny_redu
+ self._nz_redu = nz_redu
+ #Number of Timesteps in scene \
+ self.timesteps = int(hdf.root.time.nrows)
+ #self._radius_inner = float(hdf.root.input._v_attrs.radius_inner) #Only important for displaying data.
+ #self._radius_outer = float(hdf.root.input._v_attrs.radius_outer)
+ nproc_surf = int(hdf.root.input._v_attrs.nproc_surf)
+
+ hexgrid = self.citcom2vtk(timestep,hdf,nproc_surf,nx_redu,ny_redu,nz_redu,surface,bottom)
+
+ hdf.close()
+ return hexgrid
+
+
\ No newline at end of file
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/core/CitcomSHDFUgrid.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/core/CitcomSHDFUgrid.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/core/__init__.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/core/__init__.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/core/__init__.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,40 @@
+#------------------------------------------------------------------------------
+# Copyright 2003, Enthought, Inc.
+# All rights reserved.
+#
+# This software is provided without warranty under the terms of the BSD
+# license included in enthought/LICENSE.txt and may be redistributed only
+# under the conditions described in the aforementioned license. The license
+# is also available online at http://www.enthought.com/licenses/BSD.txt
+# Thanks for using Enthought open source!
+#
+# Author: Enthought, Inc.
+# Description: <Enthought library component>
+#------------------------------------------------------------------------------
+"""
+==========================
+Enthought Library
+==========================
+
+The Enthought Open Source Library
+
+Copyright 2003-2005, Enthought, Inc.
+
+
+"""
+
+try:
+ import __config__
+except ImportError:
+ __config__ = None
+
+if __config__ is not None:
+ if __config__.get_info('numpy'):
+ import os
+ if os.environ.get('NUMERIX','numpy').lower() not in ['','numpy']:
+ print 55*'*'
+ print "*** This enthought installation is built against numpy\n"\
+ "*** but the current environment is for %r.\n"\
+ "*** Resetting NUMERIX variable to 'numpy'."% (os.environ['NUMERIX'])
+ print 55*'*'
+ os.environ['NUMERIX'] = 'numpy'
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/core/__init__.py
___________________________________________________________________
Name: svn:executable
+ *
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/core/__init__.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/core/__init__.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSFilterActions.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSFilterActions.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSFilterActions.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,38 @@
+"""Actions to start the CitcomS filter.
+
+"""
+# Author: Martin Weier
+# Copyright (c)
+# License:
+
+# Enthought library imports.
+# Local imports.
+from enthought.mayavi.action.common import WorkbenchAction, get_imayavi
+
+class CitcomSreduce(WorkbenchAction):
+ """ An action that starts a delaunay 2d filter. """
+
+ ###########################################################################
+ # 'Action' interface.
+ ###########################################################################
+
+ def perform(self):
+ """ Performs the action. """
+ from CitcomSreduce import CitcomSreduce
+ f = CitcomSreduce()
+ mv = get_imayavi(self.window)
+ mv.add_filter(f)
+
+class CitcomSshowCaps(WorkbenchAction):
+ """ An action that starts a delaunay 2d filter. """
+
+ ###########################################################################
+ # 'Action' interface.
+ ###########################################################################
+
+ def perform(self):
+ """ Performs the action. """
+ from CitcomSshowCaps import CitcomSshowCaps
+ f = CitcomSshowCaps()
+ mv = get_imayavi(self.window)
+ mv.add_filter(f)
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSFilterActions.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSFilterActions.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSSphere.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSSphere.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSSphere.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,142 @@
+from math import sqrt,acos,pi,atan, atan2, sin, cos
+
+
+class CitcomSSphere:
+
+ lookup_table = [( (0.013497673906385899, 0.0, 0.54983437061309814) ,
+ (0.0077419690787792206, 0.4505336582660675, 0.31537202000617981) ,
+ (0.45813989639282227, 0.0, 0.30431538820266724) ,
+ (0.38879159092903137, 0.3889087438583374, -0.0095440549775958061) ),
+
+ ( (0.0077419690787792206, 0.4505336582660675, 0.31537202000617981) ,
+ (-0.38879168033599854, 0.38890865445137024, 0.0095444004982709885) ,
+ (0.38879159092903137, 0.3889087438583374, -0.0095440549775958061) ,
+ (-0.007742113433778286, 0.45053350925445557, -0.31537219882011414) ),
+
+ ( (-0.38879168033599854, 0.38890865445137024, 0.0095444004982709885) ,
+ (-0.45813983678817749, -1.4928090763532964e-07, -0.3043154776096344) ,
+ (-0.007742113433778286, 0.45053350925445557, -0.31537219882011414) ,
+ (-0.013497666455805302, -4.3980978858826347e-09, -0.54983437061309814) ),
+
+ ( (0.013497673906385899, 0.0, 0.54983437061309814) ,
+ (-0.44265598058700562, -1.4423562788579147e-07, 0.32642868161201477) ,
+ (0.0077419690787792206, 0.4505336582660675, 0.31537202000617981) ,
+ (-0.38879168033599854, 0.38890865445137024, 0.0095444004982709885) ),
+
+ ( (-0.44265598058700562, -1.4423562788579147e-07, 0.32642868161201477) ,
+ (-0.38879179954528809, -0.38890856504440308, 0.0095444004982709885) ,
+ (-0.38879168033599854, 0.38890865445137024, 0.0095444004982709885) ,
+ (-0.45813983678817749, -1.4928090763532964e-07, -0.3043154776096344) ),
+
+ ( (-0.38879179954528809, -0.38890856504440308, 0.0095444004982709885) ,
+ (-0.0077417660504579544, -0.45053350925445557, -0.31537219882011414) ,
+ (-0.45813983678817749, -1.4928090763532964e-07, -0.3043154776096344) ,
+ (-0.013497666455805302, -4.3980978858826347e-09, -0.54983437061309814) ),
+
+ ( (0.013497673906385899, 0.0, 0.54983437061309814) ,
+ (0.0077417795546352863, -0.4505336582660675, 0.31537202000617981) ,
+ (-0.44265598058700562, -1.4423562788579147e-07, 0.32642868161201477) ,
+ (-0.38879179954528809, -0.38890856504440308, 0.0095444004982709885) ),
+
+ ( (0.0077417795546352863, -0.4505336582660675, 0.31537202000617981) ,
+ (0.38879171013832092, -0.38890862464904785, -0.0095440549775958061) ,
+ (-0.38879179954528809, -0.38890856504440308, 0.0095444004982709885) ,
+ (-0.0077417660504579544, -0.45053350925445557, -0.31537219882011414) ),
+
+ ( (0.38879171013832092, -0.38890862464904785, -0.0095440549775958061) ,
+ (0.44265609979629517, -1.3367842655043205e-07, -0.32642853260040283) ,
+ (-0.0077417660504579544, -0.45053350925445557, -0.31537219882011414) ,
+ (-0.013497666455805302, -4.3980978858826347e-09, -0.54983437061309814) ),
+
+ ( (0.013497673906385899, 0.0, 0.54983437061309814) ,
+ (0.45813989639282227, -1.3835439460763155e-07, 0.30431538820266724) ,
+ (0.0077417795546352863, -0.4505336582660675, 0.31537202000617981) ,
+ (0.38879171013832092, -0.38890862464904785, -0.0095440549775958061) ),
+
+ ( (0.45813989639282227, -1.3835439460763155e-07, 0.30431538820266724) ,
+ (0.38879159092903137, 0.3889087438583374, -0.0095440549775958061) ,
+ (0.38879171013832092, -0.38890862464904785, -0.0095440549775958061) ,
+ (0.44265609979629517, -1.3367842655043205e-07, -0.32642853260040283) ),
+
+ ( (0.38879159092903137, 0.3889087438583374, -0.0095440549775958061) ,
+ (-0.007742113433778286, 0.45053350925445557, -0.31537219882011414) ,
+ (0.44265609979629517, 0.0, -0.32642853260040283) ,
+ (-0.013497666455805302, -4.3980978858826347e-09, -0.54983437061309814) )]
+
+
+ def cart2spherical(self,x,y,z):
+ xypow = x**x+y**y
+ r = sqrt(xypow+z**z)
+ if y >= 0:
+ phi = acos(x/sqrt(x/xypow))
+ else:
+ phi = 2*pi-acos(x/sqrt(xypow))
+ theta = pi/2-atan(z/sqrt(xypow))
+ return r,phi,theta
+
+
+ def coords_of_cap(self,radius,resolution_x,resolution_y,cap):
+ coords = []
+ #radius = sqrt(c1x**2+c1y**2+c1z**2)
+
+
+ c1x = self.lookup_table[cap][0][0]
+ c1y = self.lookup_table[cap][0][1]
+ c1z = self.lookup_table[cap][0][2]
+
+ c2x = self.lookup_table[cap][1][0]
+ c2y = self.lookup_table[cap][1][1]
+ c2z = self.lookup_table[cap][1][2]
+
+ c3x = self.lookup_table[cap][2][0]
+ c3y = self.lookup_table[cap][2][1]
+ c3z = self.lookup_table[cap][2][2]
+
+ c4x = self.lookup_table[cap][3][0]
+ c4y = self.lookup_table[cap][3][1]
+ c4z = self.lookup_table[cap][3][2]
+
+ coords1,theta,phi = self.evenly_divide_arc(resolution_x, c1x, c1y, c1z, c2x, c2y, c2z)
+ coords2,theta,phi = self.evenly_divide_arc(resolution_x, c3x, c3y, c3z, c4x, c4y, c4z)
+
+
+
+ for i in xrange(len(coords1)):
+ temp,theta,phi = self.evenly_divide_arc(resolution_y, coords1[i][0],coords1[i][1],coords1[i][2], coords2[i][0],coords2[i][1],coords2[i][2])
+
+ for j in xrange(len(theta)):
+ x,y,z = self.RTF2XYZ(theta[j],phi[j],radius)
+ coords.append((x,y,z))
+ return coords
+
+ def evenly_divide_arc(self,elx,x1,y1,z1,x2,y2,z2):
+ nox=elx+1
+ dx = (x2-x1)/elx
+ dy = (y2-y1)/elx
+ dz = (z2-z1)/elx
+ theta = []
+ phi = []
+ coords = []
+ for j in xrange(1,nox+1):
+ x_temp = x1 + dx * (j-1) + 5.0e-32
+ y_temp = y1 + dy * (j-1)
+ z_temp = z1 + dz * (j-1)
+ coords.append((x_temp,y_temp,z_temp))
+ theta.append(acos(z_temp/sqrt(x_temp**2+y_temp**2+z_temp**2)))
+ phi.append(self.myatan(y_temp,x_temp))
+ return coords,theta,phi
+
+ def RTF2XYZ(self,thet, phi, r):
+ x = r * sin(thet) * cos(phi)
+ y = r * sin(thet) * sin(phi)
+ z = r * cos(thet)
+ return x, y, z
+
+ def myatan(self,y,x):
+ fi = atan2(y,x)
+ if fi<0.0:
+ fi += 2*pi
+ return fi
+
+
+
\ No newline at end of file
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSSphere.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSSphere.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSreduce.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSreduce.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSreduce.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,199 @@
+"""A filter that reduces CitcomS vtk input data.
+"""
+
+# Author: Martin Weier
+# Copyright (c) 2006, California Institute of Technology
+
+
+# Enthought library imports.
+from enthought.traits import Instance, Range, Int, Float, Enum, Trait, Button
+from enthought.traits.ui import View, Group, Item
+from enthought.tvtk.api import tvtk
+
+# Local imports
+from enthought.mayavi.core.filter import Filter
+
+from CitcomSSphere import *
+
+######################################################################
+# `Threshold` class.
+######################################################################
+class CitcomSreduce(Filter):
+
+ # The version of this class. Used for persistence.
+ __version__ = 0
+
+ # The threshold filter.
+
+ probe_filter = Instance(tvtk.ProbeFilter, ())
+
+ citcomsgrid = CitcomSSphere()
+
+ # Upper threshold (this is a dynamic trait that is changed when
+ # input data changes).
+ Radius = Range(0.0, 1.0, 0.80,
+ desc='adjust radius')
+
+ theta = Range(0, 40, 10,
+ desc='the theta resolution')
+ phi = Range(0, 40, 10,
+ desc='the upper threshold of the filter')
+
+ Selected_Source = Enum( 'Sphere', 'CitcomSGrid',)
+
+ radius_max = Float(1.0)
+ set_radius_max = Button('Set Radius Max')
+ # Our view.
+ view = View(Item(name="Selected_Source"),
+ Group(Item(name='Radius'),
+ Item(name='theta'),
+ Item(name='phi'),
+ Item(name='radius_max'),
+ Item(name='set_radius_max', style='simple', label='Simple'),
+ show_border = True
+ ),
+ )
+
+ grid_source = True
+
+ ######################################################################
+ # `Filter` interface.
+ ######################################################################
+ def setvalues(self,nx,ny,nz):
+ pass
+
+ def setup_pipeline(self):
+ """Override this method so that it *creates* its tvtk
+ pipeline.
+
+ This method is invoked when the object is initialized via
+ `__init__`. Note that at the time this method is called, the
+ tvtk data pipeline will *not* yet be setup. So upstream data
+ will not be available. The idea is that you simply create the
+ basic objects and setup those parts of the pipeline not
+ dependent on upstream sources and filters.
+ """
+ # Just setup the default output of this filter.
+ self.outputs = [self.probe_filter.output]
+
+ def update_pipeline(self):
+ """Override this method so that it *updates* the tvtk pipeline
+ when data upstream is known to have changed.
+
+ This method is invoked (automatically) when the input fires a
+ `pipeline_changed` event.
+ """
+ # By default we set the input to the first output of the first
+ # input.
+ fil = self.probe_filter
+
+ #Filter needs to be connected to the unfiltered Dataset.
+ #If the filter above has changed its data connect to output port 1 instead of 2
+ fil.source = self.inputs[0].outputs[0]
+
+ #self.sphere.radius = 0.98
+ #self.sphere.theta_resolution = 24
+ #self.sphere.phi_resolution = 24
+ #fil.input = self.sphere.output
+
+ self._calc_grid(0,self.theta,self.phi)
+ fil.update()
+ # We force the ranges to be reset to the limits of the data.
+ # This is because if the data has changed upstream, then the
+ # limits of the data must be changed.
+ #self._update_ranges(reset=True)
+ #fil.update()
+ self.outputs[0] = fil.output
+ self.pipeline_changed = True
+
+ def update_data(self):
+ """Override this method to do what is necessary when upstream
+ data changes.
+
+ This method is invoked (automatically) when any of the inputs
+ sends a `data_changed` event.
+ """
+
+ #self._update_ranges(reset=True)
+ self.probe_filter.source = self.inputs[0].outputs[0]
+ self.probe_filter.update()
+ # Propagate the data_changed event.
+ self.data_changed = True
+
+
+ def _calc_grid(self,radius,resolution_x,resolution_y):
+
+ fil = self.probe_filter
+
+ coords = []
+
+ if self.Selected_Source == 'CitcomSGrid':
+
+ for i in xrange(12):
+
+ coords += self.citcomsgrid.coords_of_cap(radius,self.theta,self.phi,i)
+
+ grid = tvtk.UnstructuredGrid()
+ grid.points = coords
+ #dl = tvtk.Delaunay3D()
+ #dl.input = grid
+ #fil.input = dl.output
+ fil.input = grid
+
+ if self.Selected_Source == 'Sphere':
+ sphere = tvtk.SphereSource()
+ sphere.radius = radius
+ sphere.theta_resolution = resolution_x
+ sphere.phi_resolution = resolution_y
+ fil.input = sphere.output
+
+
+
+ fil.update()
+
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+ def _Radius_changed(self, new_value):
+ fil = self.probe_filter
+ #self.sphere.radius = new_value
+ self._calc_grid(new_value,self.theta,self.phi)
+ fil.update()
+ self.data_changed = True
+
+
+ def _theta_changed(self, new_value):
+ fil = self.probe_filter
+ self._calc_grid(self.Radius,new_value,self.phi)
+ fil.update()
+ self.data_changed = True
+
+
+
+ def _phi_changed(self, new_value):
+ fil = self.probe_filter
+ self._calc_grid(self.Radius,self.phi,new_value)
+ fil.update()
+ self.data_changed = True
+
+ def _Selected_Source_changed(self,new_value):
+ self._calc_grid(self.Radius, self.theta, self.phi)
+ self.outputs[0] = self.probe_filter.output
+ self.data_changed = True
+ self.pipeline_changed = True
+
+ def _radius_max_changed(self,new_value):
+ if l > new_value:
+ self.Radius = new_value
+ if new_value <= 0.0:
+ self.radius_max = 0.0
+
+ def _set_radius_max_fired(self):
+ trait = Range(0.0, new_value, self.Radius,
+ desc='adjust radius')
+ self.add_trait('Radius', trait)
+
+
+ def _update_ranges(self, reset=False):
+ pass
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSreduce.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSreduce.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowCaps.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowCaps.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowCaps.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,139 @@
+"""A simple filter that thresholds on input data.
+
+"""
+# Author: Prabhu Ramachandran <prabhu_r at users.sf.net>
+# Copyright (c) 2005, Enthought, Inc.
+# License: BSD Style.
+
+# Enthought library imports.
+from enthought.traits import Instance, Range, Int
+from enthought.traits.ui import View, Group, Item
+from enthought.tvtk.api import tvtk
+
+# Local imports
+from enthought.mayavi.core.filter import Filter
+
+
+######################################################################
+# `Threshold` class.
+######################################################################
+class CitcomSshowCaps(Filter):
+
+ # The version of this class. Used for persistence.
+ __version__ = 0
+
+ # The threshold filter.
+ ugrid_filter = Instance(tvtk.ExtractUnstructuredGrid, ())
+
+ # Lower threshold (this is a dynamic trait that is changed when
+ # input data changes).
+ lower_threshold = Range(0, 13, 0,
+ desc='the lower threshold of the filter')
+
+ # Upper threshold (this is a dynamic trait that is changed when
+ # input data changes).
+ upper_threshold = Range(0, 13, 13,
+ desc='the upper threshold of the filter')
+
+ # Our view.
+ view = View(Group(Item(name='lower_threshold'),
+ Item(name='upper_threshold'))
+ )
+
+ nx = Int()
+ ny = Int()
+ nz = Int()
+ n = Int()
+ caps = Int()
+
+ def setvalues(self,nxin,nyin,nzin):
+ self.nx = nxin
+ self.ny = nyin
+ self.nz = nzin
+
+ ######################################################################
+ # `Filter` interface.
+ ######################################################################
+ def setup_pipeline(self):
+ """Override this method so that it *creates* its tvtk
+ pipeline.
+
+ This method is invoked when the object is initialized via
+ `__init__`. Note that at the time this method is called, the
+ tvtk data pipeline will *not* yet be setup. So upstream data
+ will not be available. The idea is that you simply create the
+ basic objects and setup those parts of the pipeline not
+ dependent on upstream sources and filters.
+ """
+ # Just setup the default output of this filter.
+ self.ugrid_filter.point_clipping = 1
+ self.ugrid_filter.merging = 0
+ self.outputs = [self.ugrid_filter.output]
+
+ def update_pipeline(self):
+ """Override this method so that it *updates* the tvtk pipeline
+ when data upstream is known to have changed.
+
+ This method is invoked (automatically) when the input fires a
+ `pipeline_changed` event.
+ """
+ # By default we set the input to the first output of the first
+ # input.
+ fil = self.ugrid_filter
+ fil.input = self.inputs[0].outputs[0]
+ self.caps = 12
+ self.n = self.inputs[0].outputs[0].number_of_points/12
+ #self.inputs[0].outputs[0].number_of_points/(self.nx*self.ny*self.nz)
+ # We force the ranges to be reset to the limits of the data.
+ # This is because if the data has changed upstream, then the
+ # limits of the data must be changed.
+ #self._update_ranges(reset=True)
+
+ #fil.threshold_between(self.lower_threshold, self.upper_threshold)
+ #fil.update()
+ self.outputs[0] = fil.output
+ self.outputs.append(self.inputs[0].outputs[0])
+ self.pipeline_changed = True
+
+ def update_data(self):
+ """Override this method to do what is necessary when upstream
+ data changes.
+
+ This method is invoked (automatically) when any of the inputs
+ sends a `data_changed` event.
+ """
+
+ #self._update_ranges(reset=True)
+
+ # XXX: These are commented since updating the ranges does
+ # everything for us.
+
+ #fil = self.threshold_filter
+ #fil.threshold_between(self.lower_threshold, self.upper_threshold)
+ #fil.update()
+ # Propagate the data_changed event.
+ self.data_changed = True
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+ def _lower_threshold_changed(self,old_value, new_value):
+ #if new_value <> self.upper_threshold and new_value<upper_threshold:
+ fil = self.ugrid_filter
+ fil.point_minimum = (self.lower_threshold)*(self.n)
+ fil.update()
+ self.data_changed = True
+ #else: #Create a single point to prevent that other filters crash because of missing input
+ # self.outputs[0].points = [(100,100,100)]
+
+ def _upper_threshold_changed(self, old_value, new_value):
+ #if new_value <> self.lower_threshold and new_value>lower_threshold:
+ fil = self.ugrid_filter
+ fil.point_maximum = self.upper_threshold*(self.n)
+ fil.update()
+ self.data_changed = True
+ #else:
+ #self.outputs[0].points = [(100,100,100)]
+
+
+
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowCaps.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowCaps.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowSurface.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowSurface.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/filter/CitcomSshowSurface.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,212 @@
+"""A simple filter that thresholds on input data.
+
+"""
+# Author: Prabhu Ramachandran <prabhu_r at users.sf.net>
+# Copyright (c) 2005, Enthought, Inc.
+# License: BSD Style.
+
+# Enthought library imports.
+from enthought.traits import Instance, Range, Int, Float
+from enthought.traits.ui import View, Group, Item
+from enthought.tvtk import tvtk
+
+# Local imports
+from enthought.mayavi.core.filter import Filter
+
+
+######################################################################
+# `Threshold` class.
+######################################################################
+class ShowSurface(Filter):
+
+ # The version of this class. Used for persistence.
+ __version__ = 0
+
+ # The threshold filter.
+
+ prog_filter = Instance(tvtk.ProgrammableFilter, ())
+
+
+ # Upper threshold (this is a dynamic trait that is changed when
+ # input data changes).
+ surfacelevel = Range(1, 17, 1,
+ desc='the surface filter')
+
+ # Our view.
+ view = View(Group(Item(name='surfacelevel')
+ ))
+
+ current_level=Int()
+ nx = Int()
+ ny = Int()
+ nz = Int()
+
+
+
+
+ def setvalues(self,nx,ny,nz,level):
+ """This Method needs to be set before the execution of the filter
+ it accepts nx,ny,nz,level"""
+ self.nx = nx
+ self.ny = ny
+ self.nz = nz
+ self.current_level = level
+ ######################################################################
+ # `Filter` interface.
+ ######################################################################
+ def setup_pipeline(self):
+ """Override this method so that it *creates* its tvtk
+ pipeline.
+
+ This method is invoked when the object is initialized via
+ `__init__`. Note that at the time this method is called, the
+ tvtk data pipeline will *not* yet be setup. So upstream data
+ will not be available. The idea is that you simply create the
+ basic objects and setup those parts of the pipeline not
+ dependent on upstream sources and filters.
+ """
+ # Just setup the default output of this filter.
+ self.prog_filter.set_execute_method(self._showsurface)
+ self.outputs = [self.prog_filter.output]
+
+ def update_pipeline(self):
+ """Override this method so that it *updates* the tvtk pipeline
+ when data upstream is known to have changed.
+
+ This method is invoked (automatically) when the input fires a
+ `pipeline_changed` event.
+ """
+ # By default we set the input to the first output of the first
+ # input.
+ fil = self.prog_filter
+ fil.input = self.inputs[0].outputs[0]
+
+ # We force the ranges to be reset to the limits of the data.
+ # This is because if the data has changed upstream, then the
+ # limits of the data must be changed.
+ #self._update_ranges(reset=True)
+
+ #fil.threshold_between(self.lower_threshold, self.upper_threshold)
+ #fil.update()
+ self.outputs[0] = fil.output
+ self.pipeline_changed = True
+
+ def update_data(self):
+ """Override this method to do what is necessary when upstream
+ data changes.
+
+ This method is invoked (automatically) when any of the inputs
+ sends a `data_changed` event.
+ """
+
+ #self._update_ranges(reset=True)
+
+
+ # Propagate the data_changed event.
+ self.prog_filter.set_execute_method(self._showsurface)
+ self.outputs = [self.prog_filter.output]
+ self.data_changed = True
+
+
+ def _showsurface(self):
+ print "showsurface update"
+ print self.current_level
+ input = self.prog_filter.unstructured_grid_input
+ numCells = input.number_of_cells
+ quadgrid = tvtk.UnstructuredGrid()
+ quadgrid.allocate(1,1)
+
+ reduced_points = []
+ reduced_scalars = []
+ reduced_vectors = []
+ j = 1
+ cell_count=0
+ for i in xrange(numCells):
+ if j==self.current_level:
+ cell = input.get_cell(i)
+ scalars = input.point_data.scalars
+ vectors = input.point_data.vectors
+ point_ids = cell.point_ids
+ points = cell.points
+ reduced_points.append(points[2])
+ reduced_points.append(points[1])
+ reduced_points.append(points[5])
+ reduced_points.append(points[6])
+
+ reduced_scalars.append(scalars[point_ids[2]])
+ reduced_scalars.append(scalars[point_ids[1]])
+ reduced_scalars.append(scalars[point_ids[5]])
+ reduced_scalars.append(scalars[point_ids[6]])
+
+
+ reduced_vectors.append(vectors[point_ids[2]])
+ reduced_vectors.append(vectors[point_ids[1]])
+ reduced_vectors.append(vectors[point_ids[5]])
+ reduced_vectors.append(vectors[point_ids[6]])
+
+ quadgrid.insert_next_cell(9,[cell_count,cell_count+1,cell_count+2,cell_count+3])
+ cell_count+=4
+
+ if j == self.nx:
+ j=1
+
+ j+=1
+
+ vtkReduced_vectors = tvtk.FloatArray()
+ vtkReduced_scalars = tvtk.FloatArray()
+ vtkReduced_vectors.from_array(reduced_vectors)
+ vtkReduced_scalars.from_array(reduced_scalars)
+
+ vtkReduced_scalars.name = 'Scalars'
+ vtkReduced_vectors.name = 'Vectors'
+
+ #showsurfF.unstructured_grid_output = quadgrid
+ self.prog_filter.unstructured_grid_output.set_cells(9,quadgrid.get_cells())
+ self.prog_filter.unstructured_grid_output.point_data.scalars = vtkReduced_scalars
+ self.prog_filter.unstructured_grid_output.point_data.vectors = vtkReduced_vectors
+ self.prog_filter.unstructured_grid_output.points = reduced_points
+
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+ def _surfacelevel_changed(self, new_value):
+ fil = self.prog_filter
+ print self.current_level
+ self.current_level = new_value-1
+ self._showsurface()
+ fil.update()
+ self.data_changed = True
+
+ def _update_ranges(self, reset=False):
+ """Updates the ranges of the input. When `reset` is True, the
+ lower and upper thresholds are automatically set to the limits
+ of the input data."""
+
+ input = self.inputs[0].outputs[0]
+ data_range = []
+ ps = input.point_data.scalars
+ cs = input.cell_data.scalars
+
+ # FIXME: need to be able to handle cell and point data
+ # together.
+ if ps:
+ data_range = ps.range
+ elif cs:
+ data_range = cs.range
+
+ if data_range:
+ dr = data_range
+ l = max(self.lower_threshold, dr[0])
+ trait = Range(dr[0], dr[1], l,
+ desc='the lower threshold of the filter')
+ self.add_trait('lower_threshold', trait)
+
+ h = min(dr[1], self.upper_threshold)
+ trait = Range(dr[0], dr[1], h,
+ desc='the upper threshold of the filter')
+ self.add_trait('upper_threshold', trait)
+
+ if reset:
+ self.lower_threshold = dr[0]
+ self.upper_threshold = dr[1]
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/__init__.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/filter/__init__.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/filter/__init__.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,40 @@
+#------------------------------------------------------------------------------
+# Copyright 2003, Enthought, Inc.
+# All rights reserved.
+#
+# This software is provided without warranty under the terms of the BSD
+# license included in enthought/LICENSE.txt and may be redistributed only
+# under the conditions described in the aforementioned license. The license
+# is also available online at http://www.enthought.com/licenses/BSD.txt
+# Thanks for using Enthought open source!
+#
+# Author: Enthought, Inc.
+# Description: <Enthought library component>
+#------------------------------------------------------------------------------
+"""
+==========================
+Enthought Library
+==========================
+
+The Enthought Open Source Library
+
+Copyright 2003-2005, Enthought, Inc.
+
+
+"""
+
+try:
+ import __config__
+except ImportError:
+ __config__ = None
+
+if __config__ is not None:
+ if __config__.get_info('numpy'):
+ import os
+ if os.environ.get('NUMERIX','numpy').lower() not in ['','numpy']:
+ print 55*'*'
+ print "*** This enthought installation is built against numpy\n"\
+ "*** but the current environment is for %r.\n"\
+ "*** Resetting NUMERIX variable to 'numpy'."% (os.environ['NUMERIX'])
+ print 55*'*'
+ os.environ['NUMERIX'] = 'numpy'
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/__init__.py
___________________________________________________________________
Name: svn:executable
+ *
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/__init__.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/filter/__init__.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomSHDFUgrid.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomSHDFUgrid.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomSHDFUgrid.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,419 @@
+from enthought.tvtk.api import tvtk
+import tables #For HDF support
+import numpy
+from math import *
+from datetime import datetime
+
+class CitcomSHDFUgrid:
+
+ data = None
+ _nx = None
+ _ny = None
+ _nz = None
+ _nx_redu = None
+ _ny_redu = None
+ _nz_redu = None
+ _radius_inner = None
+ _radius_outer = None
+ timesteps = None
+ frequency = None
+
+ #Iterator for CitcomDataRepresentation(yxz) to VTK(xyz)
+ def vtk_iter(self,nx,ny,nz):
+ for i in xrange(nx):
+ for j in xrange(ny):
+ for k in xrange(nz):
+ yield k + nz * i + nz * nx * j
+
+ #Reduces the CitcomS grid
+ def reduce_iter(self,n,nredu):
+ i=0
+ n_f=float(n)
+ nredu_f=float(nredu)
+ fl=(n_f-1)/nredu_f
+ redu = 0
+ for i in xrange(nredu+1):
+ yield int(round(redu))
+ redu = redu + fl
+
+
+ def velocity2cart(self,vel_colat,vel_long,r, x, y, z):
+ x1 = r*sin(x)*cos(y)+vel_colat*cos(x)*cos(y)-vel_long*sin(y)
+ y1 = r*sin(x)*sin(y)+vel_colat*cos(x)*sin(y)+vel_long*cos(y)
+ z1 = r*cos(x)-vel_colat*sin(x)
+ return x1, y1, z1
+
+
+ #Converts Spherical to Cartesian Coordinates
+ def RTF2XYZ(self,thet, phi, r):
+ x = r * sin(thet) * cos(phi)
+ y = r * sin(thet) * sin(phi)
+ z = r * cos(thet)
+ return x, y, z
+
+
+
+ def citcom2vtk(self,t,f,nproc_surf,nx_redu,ny_redu,nz_redu,bottom,surface):
+ #Assign create_bottom and create_surface to bottom and surface
+ #to make them valid in methods namespace
+
+ benchmarkstr = ""
+ fd = open('/home/maweier/benchmark.txt','w')
+
+ hexagrid = tvtk.UnstructuredGrid()
+ surfPixelGrid = tvtk.UnstructuredGrid()
+ botmPixelGrid = tvtk.UnstructuredGrid()
+
+ vtkordered_temp = tvtk.FloatArray()
+ vtkordered_velo = tvtk.FloatArray()
+ vtkordered_visc = tvtk.FloatArray()
+
+ hexagrid.allocate(1,1)
+ surfPixelGrid.allocate(1, 1)
+ botmPixelGrid.allocate(1,1)
+
+ nx = self._nx
+ ny = self._ny
+ nz = self._nz
+ counter = 0
+ el_nx_redu = nx_redu + 1
+ el_ny_redu = ny_redu + 1
+ el_nz_redu = nz_redu + 1
+
+ ordered_points = [] #reset Sequences for points
+ ordered_temperature = []
+ ordered_velocity = []
+ ordered_visc = []
+
+ #Surface and Bottom Points
+ #Initialize empty sequences
+ surf_vec = []
+ botm_vec = []
+ surf_topo = []
+ surf_hflux = []
+ botm_topo = []
+ botm_hflux = []
+
+ surf_points = []
+ botm_points = []
+
+ for capnr in xrange(nproc_surf):
+
+ ###Benchmark Point 1 Start##
+ d1 = datetime.now()
+ ############################
+
+ cap = f.root._f_getChild("cap%02d" % capnr)
+
+ temp_coords = [] # reset Coordinates, Velocity, Temperature Sequence
+ temp_vel = []
+ temp_temp = []
+ temp_visc = []
+
+ #Information from hdf
+ #This information needs to be read only once
+ hdf_coords = cap.coord[:]
+
+ hdf_velocity = cap.velocity[t]
+ hdf_temperature = cap.temperature[t]
+ hdf_viscosity = cap.viscosity[t]
+
+
+
+ #Create Iterator to change data representation
+ nx_redu_iter = self.reduce_iter(nx,nx_redu)
+ ny_redu_iter = self.reduce_iter(ny,ny_redu)
+ nz_redu_iter = self.reduce_iter(nz,nz_redu)
+
+ vtk_i = self.vtk_iter(el_nx_redu,el_ny_redu,el_nz_redu)
+
+ ##Benchmark Point 1 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 2 Start##
+ d1 = datetime.now()
+ ############################
+
+ # read citcom data - zxy (z fastest)
+ for j in xrange(el_ny_redu):
+ j_redu = ny_redu_iter.next()
+ nx_redu_iter = self.reduce_iter(nx,nx_redu)
+ for i in xrange(el_nx_redu):
+ i_redu = nx_redu_iter.next()
+ nz_redu_iter = self.reduce_iter(nz,nz_redu)
+ for k in xrange(el_nz_redu):
+ k_redu = nz_redu_iter.next()
+ thet , phi, r = map(float,hdf_coords[i_redu][j_redu][k_redu])
+ temp_coords.append((thet,phi,r))
+
+ vel_colat, vel_lon , vel_r = map(float,hdf_velocity[i][j][k])
+ temperature = float(hdf_temperature[i][j][k])
+ visc = float(hdf_viscosity[i][j][k])
+
+ temp_vel.append((vel_colat,vel_lon,vel_r))
+ temp_temp.append(temperature)
+ temp_visc.append(visc)
+
+ ##Delete Objects for GC
+ del hdf_coords
+ del hdf_velocity
+ del hdf_temperature
+ del hdf_viscosity
+
+ ##Benchmark Point 2 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 3 Start##
+ d1 = datetime.now()
+ ############################
+
+ # rearange vtk data - xyz (x fastest).
+ for n0 in xrange(el_nz_redu*el_ny_redu*el_nx_redu):
+ iter = vtk_i.next()
+ #print iter
+ #Get Cartesian Coords from Coords
+ #zxy Citcom to xyz Vtk
+ colat, lon, r = temp_coords[iter]
+ x_coord, y_coord, z_coord = self.RTF2XYZ(colat,lon,r)
+ ordered_points.append((x_coord,y_coord,z_coord))
+
+ #Get Vectors in Cartesian Coords from Velocity
+ vel_colat,vel_lon,vel_r = temp_vel[iter]
+ x_velo, y_velo, z_velo = self.velocity2cart(vel_colat,vel_lon,vel_r, colat,lon , r)
+ ordered_velocity.append((x_velo,y_velo,z_velo))
+
+ ################################################
+ vtkordered_temp.insert_next_tuple1(temp_temp[iter])
+ vtkordered_visc.insert_next_tuple1(temp_visc[iter])
+
+ vtkordered_velo.from_array(ordered_velocity)
+
+ ##Delete Unused Object for GC
+ del temp_coords
+ del temp_vel
+ del temp_temp
+ del temp_visc
+
+ ##Benchmark Point 3 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 4 Start##
+ d1 = datetime.now()
+ ############################
+
+ #Bottom Information from hdf
+ if bottom == True:
+ try:
+ hdf_bottom_coord = cap.botm.coord[:]
+ hdf_bottom_heatflux = cap.botm.heatflux[t]
+ hdf_bottom_topography = cap.botm.topography[t]
+ hdf_bottom_velocity = cap.botm.velocity[t]
+ except:
+ bottom = False
+ #Surface Information from hdf
+ if surface==True:
+ try:
+ hdf_surface_coord = cap.surf.coord[:]
+ hdf_surface_heatflux = cap.surf.heatflux[t]
+ hdf_surface_topography = cap.surf.topography[t]
+ hdf_surface_velocity = cap.surf.velocity[t]
+ except:
+ surface = False
+
+ ##Benchmark Point 4 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 5 Start##
+ d1 = datetime.now()
+ ############################
+
+ #Compute surface/bottom topography mean
+ if bottom==True or surface==True:
+ surf_mean=0.0
+ botm_mean=0.0
+
+ for i in xrange(ny):
+ if surface == True:
+ surf_mean += numpy.mean(hdf_surface_topography[i])
+ if bottom == True:
+ botm_mean += numpy.mean(hdf_bottom_topography[i])
+
+ surf_mean = surf_mean/ny
+ botm_mean = botm_mean/ny
+ #print "Mean Surface:",surf_mean
+
+ ##Benchmark Point 5 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 6 Start##
+ d1 = datetime.now()
+ ############################
+
+ #Read Surface and Bottom Data
+ if bottom==True or surface == True:
+ for i in xrange(ny):
+ for j in xrange(nx):
+
+
+ if bottom==True:
+ #Bottom Coordinates
+ if create_topo==True:
+ colat, lon = hdf_bottom_coord[i][j]
+ x,y,z = self.RTF2XYZ(colat,lon,radius_inner+float( (hdf_bottom_topography[i][j]-botm_mean)*(10**21)/(6371000**2/10**(-6))/(3300*10)/1000 ))
+ botm_points.append((x,y,z))
+ else:
+ colat, lon = hdf_bottom_coord[i][j]
+ x,y,z = self.RTF2XYZ(colat, lon,radius_inner)
+ botm_points.append((x,y,z))
+
+ #Bottom Heatflux
+ botm_hflux.append(float(hdf_bottom_heatflux[i][j]))
+
+ #Bottom Velocity
+ vel_colat, vel_lon = map(float,hdf_bottom_velocity[i][j])
+ x,y,z = self.velocity2cart(vel_colat,vel_lon, radius_inner, colat, lon, radius_inner)
+ botm_vec.append((x,y,z))
+
+ if surface==True:
+ #Surface Information
+ if create_topo==True:
+ colat,lon = hdf_surface_coord[i][j]
+ #637100 = Earth radius, 33000 = ?
+ x,y,z = self.RTF2XYZ(colat,lon,radius_outer+float( (hdf_surface_topography[i][j]-surf_mean)*(10**21)/(6371000**2/10**(-6))/(3300*10)/1000 ))
+ surf_points.append((x,y,z))
+ else:
+ colat, lon = hdf_surface_coord[i][j]
+ x,y,z = self.RTF2XYZ(colat, lon,radius_outer)
+ surf_points.append((x,y,z))
+
+ #Surface Heatflux
+ surf_hflux.append(float(hdf_surface_heatflux[i][j]))
+
+ #Surface Velocity
+ vel_colat, vel_lon = map(float,hdf_surface_velocity[i][j])
+ x,y,z = self.velocity2cart(vel_colat,vel_lon, radius_outer, colat, lon, radius_outer)
+ surf_vec.append((x,y,z))
+
+ vtk_botm_vec.from_array(botm_vec)
+ vtk_surf_vec.from_array(surf_vec)
+
+ #del variables for GC
+ if bottom==True:
+ del hdf_bottom_coord
+ del hdf_bottom_heatflux
+ del hdf_bottom_velocity
+ if surface==True:
+ del hdf_surface_coord
+ del hdf_surface_heatflux
+ del hdf_surface_velocity
+
+ ##Benchmark Point 6 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf," % (delta.seconds + float(delta.microseconds)/1e6)
+
+ ###Benchmark Point 7 Start##
+ d1 = datetime.now()
+ ############################
+##################################################################
+ #Create Connectivity info
+ if counter==0:
+ #For 3d Data
+ i=1 #Counts X Direction
+ j=1 #Counts Y Direction
+ k=1 #Counts Z Direction
+
+ for n in xrange(((el_nx_redu*el_ny_redu*el_nz_redu)-(el_nz_redu*el_ny_redu))):
+ if (i%el_nz_redu)==0: #X-Values!!!
+ j+=1 #Count Y-Values
+
+ if (j%el_ny_redu)==0:
+ k+=1 #Count Z-Values
+
+ if i%el_nz_redu!=0 and j%el_ny_redu!=0: #Check if Box can be created
+ #Get Vertnumbers
+ n0 = n+(capnr*(el_nx_redu*el_ny_redu*el_nz_redu))
+ n1 = n0+1
+ n2 = n1+el_nz_redu
+ n3 = n0+el_nz_redu
+ n4 = n0+(el_ny_redu*el_nz_redu)
+ n5 = n4+1
+ n6 = n4+el_nz_redu+1
+ n7 = n4+el_nz_redu
+
+ #Created Polygon Box
+ hexagrid.insert_next_cell(12,[n0,n1,n2,n3,n4,n5,n6,n7])
+
+ i+=1
+
+ if bottom==True or surface==True:
+ #Connectivity for 2d-Data
+ i=1
+ for n in xrange((nx)*(ny) - nx):
+ if i%nx!=0 :
+ n0 = n+(capnr*((nx)*(ny)))
+ n1 = n0+1
+ n2 = n0+ny
+ n3 = n2+1
+ surfPixelGrid.insert_next_cell(8 , [n0,n1,n2,n3])
+ botmPixelGrid.insert_next_cell(8 , [n0,n1,n2,n3])
+ i+=1
+
+ ##Benchmark Point 7 Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf \n" % (delta.seconds + float(delta.microseconds)/1e6)
+
+ fd.write(benchmarkstr)
+
+ benchmarkstr = '\n\nIO: '
+ ###Benchmark Point IO Start##
+ d1 = datetime.now()
+ ############################
+ vtkordered_temp.name = 'Temperature'
+ hexagrid.point_data.scalars = vtkordered_temp
+ vtkordered_velo.name = 'Velocity'
+ hexagrid.point_data.vectors = vtkordered_velo
+ hexagrid.points = ordered_points
+ ##Benchmark Point IO Stop##
+ delta = datetime.now() - d1
+ benchmarkstr += "%.5lf" % (delta.seconds + float(delta.microseconds)/1e6)
+ fd.write(benchmarkstr)
+
+ return hexagrid
+
+
+ def initialize(self,filename,timestep,nx_redu,ny_redu,nz_redu,surface,bottom):
+
+ hdf=tables.openFile(filename,'r')
+ self._nx = int(hdf.root.input._v_attrs.nodex)
+ self._ny = int(hdf.root.input._v_attrs.nodey)
+ self._nz = int(hdf.root.input._v_attrs.nodez)
+
+ #Clip against boundaries
+ if nx_redu>=0 or nx_redu>=self._nx:
+ nx_redu = self._nx-1
+ if ny_redu==0 or ny_redu>=self._ny:
+ ny_redu = self._ny-1
+ if nz_redu==0 or nz_redu>=self._nz:
+ nz_redu = self._nz-1
+
+
+ self._nx_redu = nx_redu
+ self._ny_redu = ny_redu
+ self._nz_redu = nz_redu
+ #Number of Timesteps in scene \
+ self.timesteps = int(hdf.root.time.nrows)
+ #self._radius_inner = float(hdf.root.input._v_attrs.radius_inner) #Only important for displaying data.
+ #self._radius_outer = float(hdf.root.input._v_attrs.radius_outer)
+ nproc_surf = int(hdf.root.input._v_attrs.nproc_surf)
+
+ hexgrid = self.citcom2vtk(timestep,hdf,nproc_surf,nx_redu,ny_redu,nz_redu,surface,bottom)
+
+ hdf.close()
+ return hexgrid
+
+
\ No newline at end of file
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomSHDFUgrid.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomSHDFUgrid.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_hdf_file_reader.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_hdf_file_reader.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_hdf_file_reader.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,262 @@
+"""This source manages a CitcomS Hdf file given to it.
+"""
+# Author: Martin Weier
+# Copyright (c)
+
+# Enthought library imports.
+from enthought.traits import Trait, TraitPrefixList, Instance, Int, Str, Button
+from enthought.traits.ui import View, Group, Item
+from enthought.traits.ui.menu import OKButton
+from enthought.persistence.state_pickler \
+ import gzip_string, gunzip_string, set_state
+from enthought.tvtk.api import tvtk
+from enthought.mayavi.plugins.CitcomSHDFUgrid import CitcomSHDFUgrid
+
+# Local imports.
+from enthought.mayavi.core.source import Source
+from enthought.mayavi.core.common import handle_children_state
+from enthought.mayavi.sources.vtk_xml_file_reader import get_all_attributes
+import tables
+
+######################################################################
+# `CitcomSVTKDataSource` class
+######################################################################
+class CitcomSHDFFileReader(Source):
+
+ """This source manages a CitcomS Hdf file given to it. """
+
+ # The version of this class. Used for persistence.
+ __version__ = 0
+
+ # The VTK dataset to manage.
+ data = Instance(tvtk.DataSet)
+ citcomshdftougrid = CitcomSHDFUgrid()
+ current_timestep = Int(0)
+ nx = Int()
+ ny = Int()
+ nz = Int()
+
+ nx_redu = Int()
+ ny_redu = Int()
+ nz_redu = Int()
+
+ timesteps = Int()
+ frequency = Int()
+ read_timestep = Button('Read timestep')
+ filename = Str()
+ ########################################
+ # Dynamic traits: These traits are dummies and are dynamically
+ # updated depending on the contents of the file.
+
+ # The active point scalar name.
+ point_scalars_name = Trait('', TraitPrefixList(['']))
+ # The active point vector name.
+ point_vectors_name = Trait('', TraitPrefixList(['']))
+ # The active point tensor name.
+ point_tensors_name = Trait('', TraitPrefixList(['']))
+
+ # The active cell scalar name.
+ cell_scalars_name = Trait('', TraitPrefixList(['']))
+ # The active cell vector name.
+ cell_vectors_name = Trait('', TraitPrefixList(['']))
+ # The active cell tensor name.
+ cell_tensors_name = Trait('', TraitPrefixList(['']))
+ ########################################
+
+ # Our view.
+ view = View(Group(Item(name='current_timestep'),
+ Item(name='nx_redu'),
+ Item(name='ny_redu'),
+ Item(name='nz_redu'),
+ Item(name='read_timestep', style='simple', label='Simple'),
+ Item(name='point_scalars_name'),
+ Item(name='point_vectors_name'),
+ Item(name='point_tensors_name'),
+ Item(name='cell_scalars_name'),
+ Item(name='cell_vectors_name'),
+ Item(name='cell_tensors_name'),
+
+ ),
+
+ )
+
+ ######################################################################
+ # `object` interface
+ ######################################################################
+ def __get_pure_state__(self):
+ d = super(VTKDataSource, self).__get_pure_state__()
+ data = self.data
+ if data:
+ w = tvtk.DataSetWriter(write_to_output_string=1)
+ warn = w.global_warning_display
+ w.set_input(data)
+ w.global_warning_display = 0
+ w.update()
+ w.global_warning_display = warn
+ z = gzip_string(w.output_string)
+ d['data'] = z
+ return d
+
+ def __set_pure_state__(self, state):
+ z = state.data
+ if z:
+ d = gunzip_string(z)
+ r = tvtk.DataSetReader(read_from_input_string=1,
+ input_string=d)
+ r.update()
+ self.data = r.output
+ # Now set the remaining state without touching the children.
+ set_state(self, state, ignore=['children', 'data'])
+ # Setup the children.
+ handle_children_state(self.children, state.children)
+ # Setup the children's state.
+ set_state(self, state, first=['children'], ignore=['*'])
+
+ ######################################################################
+ # `Base` interface
+ ######################################################################
+ def start(self):
+ """This is invoked when this object is added to the mayavi
+ pipeline.
+ """
+ # Do nothing if we are already running.
+ if self.running:
+ return
+
+ # Update the data just in case.
+ self._update_data()
+
+ # Call the parent method to do its thing. This will typically
+ # start all our children.
+ super(CitcomSHDFFileReader, self).start()
+
+ def update(self):
+ """Invoke this to flush data changes downstream."""
+ self.data_changed = True
+
+
+ def initialize(self,file_name):
+ self.filename = file_name
+
+ #self.data = self.citcomshdftougrid.initialize(self.filename,0,0,0,0,False,False)
+ f = tables.openFile(file_name,'r')
+ self.nx = int(f.root.input._v_attrs.nodex)
+ self.ny = int(f.root.input._v_attrs.nodey)
+ self.nz = int(f.root.input._v_attrs.nodez)
+
+ self.nx_redu = self.nx
+ self.ny_redu = self.ny
+ self.nz_redu = self.nz
+
+ self.timesteps = int(f.root.input._v_attrs.steps)
+ self.frequency = int(f.root.input._v_attrs.monitoringFrequency)
+
+ ######################################################################
+ # `TreeNodeObject` interface
+ ######################################################################
+ def tno_get_label(self, node):
+ """ Gets the label to display for a specified object.
+ """
+ ret = "CitcomS HDF Data (uninitialized)"
+ if self.data:
+ typ = self.data.__class__.__name__
+ ret = "CitcomS HDF Data (%d)"%self.current_timestep
+ return ret
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+ def _data_changed(self, data):
+ self._update_data()
+ self.outputs = [data]
+ self.data_changed = True
+ # Fire an event so that our label on the tree is updated.
+ self.trait_property_changed('name', '',
+ self.tno_get_label(None))
+
+ def _current_timestep_changed(self,new_value):
+ if new_value < 0:
+ current_timestep = 0
+ if new_value > self.timesteps:
+ current_timestep = 100
+
+ def _read_timestep_fired(self):
+ self.data = self.citcomshdftougrid.initialize(self.filename,self.current_timestep,self.nx_redu,self.ny_redu,self.nz_redu,False,False)
+
+ def _nx_redu_changed(self, new_value):
+ if new_value < 1:
+ self.nx_redu = 1
+ if new_value > self.nx:
+ self.nx_redu = self.nx
+
+ def _ny_redu_changed(self, new_value):
+ if new_value < 1:
+ self.ny_redu = 1
+ if new_value > self.ny:
+ self.ny_redu = self.ny
+
+
+ def _nz_redu_changed(self, new_value):
+ if new_value < 1:
+ self.nz_redu = 1
+ if new_value > self.nz:
+ self.nz_redu = self.nz
+
+ def _set_data_name(self, data_type, attr_type, value):
+ if not value:
+ return
+ dataset = self.data
+ data = None
+ if attr_type == 'point':
+ data = dataset.point_data
+ elif attr_type == 'cell':
+ data = dataset.cell_data
+ meth = getattr(data, 'set_active_%s'%data_type)
+ meth(value)
+ self.update()
+ # Fire an event, so the changes propagate.
+ self.data_changed = True
+
+ def _point_scalars_name_changed(self, value):
+ self._set_data_name('scalars', 'point', value)
+
+ def _point_vectors_name_changed(self, value):
+ self._set_data_name('vectors', 'point', value)
+
+ def _point_tensors_name_changed(self, value):
+ self._set_data_name('tensors', 'point', value)
+
+ def _cell_scalars_name_changed(self, value):
+ self._set_data_name('scalars', 'cell', value)
+
+ def _cell_vectors_name_changed(self, value):
+ self._set_data_name('vectors', 'cell', value)
+
+ def _cell_tensors_name_changed(self, value):
+ self._set_data_name('tensors', 'cell', value)
+
+ def _update_data(self):
+ if not self.data:
+ return
+ pnt_attr, cell_attr = get_all_attributes(self.data)
+
+ def _setup_data_traits(obj, attributes, d_type):
+ attrs = ['scalars', 'vectors', 'tensors']
+ data = getattr(obj.data, '%s_data'%d_type)
+ for attr in attrs:
+ values = attributes[attr]
+ if values:
+ default = getattr(obj, '%s_%s_name'%(d_type, attr))
+ if default and default in values:
+ pass
+ else:
+ default = values[0]
+ trait = Trait(default, TraitPrefixList(values))
+ getattr(data, 'set_active_%s'%attr)(default)
+ else:
+ trait = Trait('', TraitPrefixList(['']))
+ obj.add_trait('%s_%s_name'%(d_type, attr), trait)
+
+ _setup_data_traits(self, pnt_attr, 'point')
+ _setup_data_traits(self, cell_attr, 'cell')
+
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_hdf_file_reader.py
___________________________________________________________________
Name: svn:executable
+ *
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_hdf_file_reader.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_hdf_file_reader.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_vtk_file_reader.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_vtk_file_reader.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_vtk_file_reader.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,381 @@
+"""A VTK file reader object.
+
+"""
+# Author: Prabhu Ramachandran <prabhu_r at users.sf.net>
+# Copyright (c) 2005, Enthought, Inc.
+# License: BSD Style.
+
+
+# Standard library imports.
+import re
+from os.path import split, join, isfile
+from glob import glob
+from os.path import basename
+
+# Enthought library imports.
+from enthought.traits import Trait, TraitPrefixList,List, Str, Range, Instance, Int, Float
+from enthought.traits.ui import View, Group, Item, Include
+from enthought.persistence.state_pickler import set_state
+from enthought.persistence.file_path import FilePath
+from enthought.tvtk.api import tvtk
+
+# Local imports
+from enthought.mayavi.core.source import Source
+from enthought.mayavi.core.common import handle_children_state
+
+
+######################################################################
+# Utility functions.
+######################################################################
+def get_file_list(file_name):
+ """ Given a file name, this function treats the file as a part of
+ a series of files based on the index of the file and tries to
+ determine the list of files in the series. The file name of a
+ file in a time series must be of the form 'some_name[0-9]*.ext'.
+ That is the integers at the end of the file determine what part of
+ the time series the file belongs to. The files are then sorted as
+ per this index."""
+
+ # The matching is done only for the basename of the file.
+ f_dir, f_base = split(file_name)
+ # Find the head and tail of the file pattern.
+ head = re.sub("[0-9]+[^0-9]*$", "", f_base)
+ tail = re.sub("^.*[0-9]+", "", f_base)
+ pattern = head+"[0-9]*"+tail
+ # Glob the files for the pattern.
+ _files = glob(join(f_dir, pattern))
+
+ # A simple function to get the index from the file.
+ def _get_index(f, head=head, tail=tail):
+ base = split(f)[1]
+ result = base.replace(head, '')
+ return float(result.replace(tail, ''))
+
+ # Before sorting make sure the files in the globbed series are
+ # really part of a timeseries. This can happen in cases like so:
+ # 5_2_1.vtk and 5_2_1s.vtk will be globbed but 5_2_1s.vtk is
+ # obviously not a valid time series file.
+ files = []
+ for x in _files:
+ try:
+ _get_index(x)
+ except ValueError:
+ pass
+ else:
+ files.append(x)
+
+ # Sort the globbed files based on the index value.
+ def file_sort(x, y):
+ x1 = _get_index(x)
+ y1 = _get_index(y)
+ if x1 > y1:
+ return 1
+ elif y1 > x1:
+ return -1
+ else:
+ return 0
+
+ files.sort(file_sort)
+ return files
+
+
+class CitcomSVTKFileReader(Source):
+
+ """A CitcomS VTK file reader.
+ """
+
+ # The version of this class. Used for persistence.
+ __version__ = 0
+ nx = Int()
+ ny = Int()
+ nz = Int()
+ radius_inner = Float()
+
+ # The list of file names for the timeseries.
+ file_list = List(Str, desc='a list of files belonging to a time series')
+
+ # The current time step (starts with 0). This trait is a dummy
+ # and is dynamically changed when the `file_list` trait changes.
+ # This is done so the timestep bounds are linked to the number of
+ # the files in the file list.
+ timestep = Range(0, 0, desc='the current time step')
+
+ # A timestep view group that may be included by subclasses.
+ time_step_group = Group(Item(name='_file_path', style='readonly'),
+ Item(name='timestep',
+ defined_when='len(object.file_list) > 1')
+ )
+
+ ##################################################
+ # Private traits.
+ ##################################################
+
+ # The current file name. This is not meant to be touched by the
+ # user.
+ _file_path = Instance(FilePath, (), desc='the current file name')
+
+
+ ########################################
+ # Dynamic traits: These traits are dummies and are dynamically
+ # updated depending on the contents of the file.
+
+ # The active scalar name.
+ scalars_name = Trait('', TraitPrefixList(['']))
+ # The active vector name.
+ vectors_name = Trait('', TraitPrefixList(['']))
+ # The active tensor name.
+ tensors_name = Trait('', TraitPrefixList(['']))
+
+ # The active normals name.
+ normals_name = Trait('', TraitPrefixList(['']))
+ # The active tcoord name.
+ t_coords_name = Trait('', TraitPrefixList(['']))
+ # The active field_data name.
+ field_data_name = Trait('', TraitPrefixList(['']))
+ ########################################
+
+ # The VTK data file reader.
+ reader = Instance(tvtk.DataSetReader, ())
+
+ # Our view.
+ view = View(Group(Include('time_step_group'),
+ Item(name='scalars_name'),
+ Item(name='vectors_name'),
+ Item(name='tensors_name'),
+ Item(name='normals_name'),
+ Item(name='t_coords_name'),
+ Item(name='field_data_name'),
+ Item(name='reader'),
+ ))
+
+ ######################################################################
+ # `object` interface
+ ######################################################################
+ ######################################################################
+ # `object` interface
+ ######################################################################
+ def __get_pure_state__(self):
+ d = super(FileDataSource, self).__get_pure_state__()
+ # These are obtained dynamically, so don't pickle them.
+ for x in ['file_list', 'timestep']:
+ d.pop(x, None)
+ return d
+
+ def __set_pure_state__(self, state):
+ # The reader has its own file_name which needs to be fixed.
+ state.reader.file_name = state._file_path.abs_pth
+ # Now call the parent class to setup everything.
+ # Use the saved path to initialize the file_list and timestep.
+ fname = state._file_path.abs_pth
+ if not isfile(fname):
+ msg = 'Could not find file at %s\n'%fname
+ msg += 'Please move the file there and try again.'
+ raise IOError, msg
+
+ self.initialize(fname)
+ # Now set the remaining state without touching the children.
+ set_state(self, state, ignore=['children', '_file_path'])
+ # Setup the children.
+ handle_children_state(self.children, state.children)
+ # Setup the children's state.
+ set_state(self, state, first=['children'], ignore=['*'])
+
+ ######################################################################
+ # `Base` interface
+ ######################################################################
+ def start(self):
+ """This is invoked when this object is added to the mayavi
+ pipeline.
+ """
+ # Do nothing if we are already running.
+ if self.running:
+ return
+
+ # Update the data just in case.
+ self.update_data()
+ self.update()
+
+ # Call the parent method to do its thing. This will typically
+ # start all our children.
+ super(CitcomSVTKFileReader, self).start()
+
+ def stop(self):
+ """Invoked when this object is removed from the mayavi
+ pipeline.
+ """
+ if not self.running:
+ return
+
+ # Call the parent method to do its thing.
+ super(CitcomSVTKFileReader, self).stop()
+
+
+ ######################################################################
+ # `FileDataSource` interface
+ ######################################################################
+ def update(self):
+ if not self._file_path.get():
+ return
+ reader = self.reader
+ reader.update()
+ self.render()
+
+ def update_data(self):
+ if not self._file_path.get():
+ return
+ attrs = ['scalars', 'vectors', 'tensors', 'normals',
+ 't_coords', 'field_data']
+ reader = self.reader
+ for attr in attrs:
+ n = getattr(reader, 'number_of_%s_in_file'%attr)
+ method = getattr(reader, 'get_%s_name_in_file'%attr)
+ values = [method(x) for x in range(n)]
+ if values:
+ trait = Trait(values[0], TraitPrefixList(values))
+ else:
+ trait = Trait('', TraitPrefixList(['']))
+
+ self.add_trait('%s_name'%attr, trait)
+
+
+ ######################################################################
+ # `TreeNodeObject` interface
+ ######################################################################
+ def tno_get_label(self, node):
+ """ Gets the label to display for a specified object.
+ """
+ fname = basename(self._file_path.get())
+ ret = "CitcomS VTK file (%s)"%fname
+ if len(self.file_list) > 1:
+ return ret + " (timeseries)"
+ else:
+ return ret
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+
+ ######################################################################
+ # `FileDataSource` interface
+ ######################################################################
+ def initialize(self, base_file_name):
+ """Given a single filename which may or may not be part of a
+ time series, this initializes the list of files. This method
+ need not be called to initialize the data.
+ """
+ self.file_list = get_file_list(base_file_name)
+ ################
+ #Read Meta information
+ meta = ""
+ try:
+ vtk = open(base_file_name, "r")
+ vtk.readline()
+ meta = vtk.readline()
+ except IOError:
+ print 'cannot open file'
+ try:
+ ##
+ m = re.search('(?<=NX:)\d+', meta)
+ self.nx = int(m.group(0))
+ ##
+ m = re.search('(?<=NY:)\d+', meta)
+ self.ny = int(m.group(0))
+ ##
+ m = re.search('(?<=NZ:)\d+', meta)
+ self.nz = int(m.group(0))
+ ##
+ m = re.search('(?<=Radius_Inner:)(\d+|.)+', meta)
+ self.radius_inner = float(m.group(0))
+ ##
+ except ValueError:
+ print "Non-valid meta information in file..."
+
+ vtk.close()
+ if len(self.file_list) == 0:
+ self.file_list = [base_file_name]
+ try:
+ self.timestep = self.file_list.index(base_file_name)
+ except ValueError:
+ self.timestep = 0
+
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+ def _file_list_changed(self, value):
+ # Change the range of the timestep suitably to reflect new list.
+ n_files = len(self.file_list)
+ timestep = min(self.timestep, n_files)
+ trait = Range(0, n_files - 1, timestep)
+ self.add_trait('timestep', trait)
+ if self.timestep == timestep:
+ self._timestep_changed(timestep)
+ else:
+ self.timestep = timestep
+
+ def _file_list_items_changed(self, list_event):
+ self._file_list_changed(self.file_list)
+
+ def _timestep_changed(self, value):
+ file_list = self.file_list
+ if len(file_list):
+ self._file_path = FilePath(file_list[value])
+ else:
+ self._file_path = FilePath('')
+
+ def __file_path_changed(self, fpath):
+ value = fpath.get()
+ if not value:
+ return
+ else:
+ self.reader.file_name = value
+ self.update_data()
+ self.update()
+
+ # Setup the outputs by resetting self.outputs. Changing
+ # the outputs automatically fires a pipeline_changed
+ # event.
+ try:
+ n = self.reader.number_of_outputs
+ except AttributeError: # for VTK >= 4.5
+ n = self.reader.number_of_output_ports
+ outputs = []
+ for i in range(n):
+ outputs.append(self.reader.get_output(i))
+ self.outputs = outputs
+
+ # Fire data_changed just in case the outputs are not
+ # really changed. This can happen if the dataset is of
+ # the same type as before.
+ self.data_changed = True
+
+ # Fire an event so that our label on the tree is updated.
+ self.trait_property_changed('name', '',
+ self.tno_get_label(None))
+
+ def _set_data_name(self, data_type, value):
+ if not value or not data_type:
+ return
+ reader = self.reader
+ setattr(reader, data_type, value)
+ self.update()
+ # Fire an event, so the changes propagate.
+ self.data_changed = True
+
+ def _scalars_name_changed(self, value):
+ self._set_data_name('scalars_name', value)
+
+ def _vectors_name_changed(self, value):
+ self._set_data_name('vectors_name', value)
+
+ def _tensors_name_changed(self, value):
+ self._set_data_name('tensors_name', value)
+
+ def _normals_name_changed(self, value):
+ self._set_data_name('normals_name', value)
+
+ def _t_coords_name_changed(self, value):
+ self._set_data_name('t_coords_name', value)
+
+ def _field_data_name_changed(self, value):
+ self._set_data_name('field_data_name', value)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_vtk_file_reader.py
___________________________________________________________________
Name: svn:executable
+ *
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_vtk_file_reader.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/CitcomS_vtk_file_reader.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/OpenCitcomSFILES.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/OpenCitcomSFILES.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/OpenCitcomSFILES.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,66 @@
+# Standard library imports.
+from os.path import isfile
+
+# Enthought library imports.
+from enthought.pyface import FileDialog, OK
+
+# Local imports
+from enthought.mayavi.script import get_imayavi
+from enthought.mayavi.core.common import error
+from enthought.mayavi.action.common import WorkbenchAction, get_imayavi
+
+######################################################################
+# `OpenCitcomSVtkFile` class.
+######################################################################
+class OpenCitcomSVTKFILE(WorkbenchAction):
+ """ An action that opens a new VTK file. """
+
+ ###########################################################################
+ # 'Action' interface.
+ ###########################################################################
+
+ def perform(self):
+ """ Performs the action. """
+ wildcard = 'VTK files (*.vtk)|*.vtk|' + FileDialog.WILDCARD_ALL
+ parent = self.window.control
+ dialog = FileDialog(parent=parent,
+ title='Open CitcomS VTK file',
+ action='open', wildcard=wildcard
+ )
+ if dialog.open() == OK:
+ if not isfile(dialog.path):
+ error("File '%s' does not exist!"%dialog.path, parent)
+ return
+ from enthought.mayavi.plugins.CitcomS_vtk_file_reader import CitcomSVTKFileReader
+ r = CitcomSVTKFileReader()
+ r.initialize(dialog.path)
+ mv = get_imayavi(self.window)
+ mv.add_source(r)
+
+######################################################################
+# `OpenCitcomSVtkFile` class.
+######################################################################
+class OpenCitcomSHDFFILE(WorkbenchAction):
+ """ An action that opens a new VTK file. """
+
+ ###########################################################################
+ # 'Action' interface.
+ ###########################################################################
+
+ def perform(self):
+ """ Performs the action. """
+ wildcard = 'HDF files (*.h5)|*.h5|' + FileDialog.WILDCARD_ALL
+ parent = self.window.control
+ dialog = FileDialog(parent=parent,
+ title='Open CitcomS H5 file',
+ action='open', wildcard=wildcard
+ )
+ if dialog.open() == OK:
+ if not isfile(dialog.path):
+ error("File '%s' does not exist!"%dialog.path, parent)
+ return
+ from enthought.mayavi.plugins.CitcomS_hdf_file_reader import CitcomSHDFFileReader
+ r = CitcomSHDFFileReader()
+ r.initialize(dialog.path)
+ mv = get_imayavi(self.window)
+ mv.add_source(r)
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/OpenCitcomSFILES.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/OpenCitcomSFILES.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/__init__.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/__init__.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/__init__.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1 @@
+# Author: Martin Weier
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/__init__.py
___________________________________________________________________
Name: svn:executable
+ *
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/__init__.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/__init__.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSFilterActions.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSFilterActions.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSFilterActions.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,38 @@
+"""Actions to start the CitcomS filter.
+
+"""
+# Author: Martin Weier
+# Copyright (c)
+# License:
+
+# Enthought library imports.
+# Local imports.
+from enthought.mayavi.action.common import WorkbenchAction, get_imayavi
+
+class CitcomSreduce(WorkbenchAction):
+ """ An action that starts a delaunay 2d filter. """
+
+ ###########################################################################
+ # 'Action' interface.
+ ###########################################################################
+
+ def perform(self):
+ """ Performs the action. """
+ from CitcomSreduce import CitcomSreduce
+ f = CitcomSreduce()
+ mv = get_imayavi(self.window)
+ mv.add_filter(f)
+
+class CitcomSshowCaps(WorkbenchAction):
+ """ An action that starts a delaunay 2d filter. """
+
+ ###########################################################################
+ # 'Action' interface.
+ ###########################################################################
+
+ def perform(self):
+ """ Performs the action. """
+ from CitcomSshowCaps import CitcomSshowCaps
+ f = CitcomSshowCaps()
+ mv = get_imayavi(self.window)
+ mv.add_filter(f)
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSFilterActions.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSFilterActions.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSSphere.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSSphere.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSSphere.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,142 @@
+from math import sqrt,acos,pi,atan, atan2, sin, cos
+
+
+class CitcomSSphere:
+
+ lookup_table = [( (0.013497673906385899, 0.0, 0.54983437061309814) ,
+ (0.0077419690787792206, 0.4505336582660675, 0.31537202000617981) ,
+ (0.45813989639282227, 0.0, 0.30431538820266724) ,
+ (0.38879159092903137, 0.3889087438583374, -0.0095440549775958061) ),
+
+ ( (0.0077419690787792206, 0.4505336582660675, 0.31537202000617981) ,
+ (-0.38879168033599854, 0.38890865445137024, 0.0095444004982709885) ,
+ (0.38879159092903137, 0.3889087438583374, -0.0095440549775958061) ,
+ (-0.007742113433778286, 0.45053350925445557, -0.31537219882011414) ),
+
+ ( (-0.38879168033599854, 0.38890865445137024, 0.0095444004982709885) ,
+ (-0.45813983678817749, -1.4928090763532964e-07, -0.3043154776096344) ,
+ (-0.007742113433778286, 0.45053350925445557, -0.31537219882011414) ,
+ (-0.013497666455805302, -4.3980978858826347e-09, -0.54983437061309814) ),
+
+ ( (0.013497673906385899, 0.0, 0.54983437061309814) ,
+ (-0.44265598058700562, -1.4423562788579147e-07, 0.32642868161201477) ,
+ (0.0077419690787792206, 0.4505336582660675, 0.31537202000617981) ,
+ (-0.38879168033599854, 0.38890865445137024, 0.0095444004982709885) ),
+
+ ( (-0.44265598058700562, -1.4423562788579147e-07, 0.32642868161201477) ,
+ (-0.38879179954528809, -0.38890856504440308, 0.0095444004982709885) ,
+ (-0.38879168033599854, 0.38890865445137024, 0.0095444004982709885) ,
+ (-0.45813983678817749, -1.4928090763532964e-07, -0.3043154776096344) ),
+
+ ( (-0.38879179954528809, -0.38890856504440308, 0.0095444004982709885) ,
+ (-0.0077417660504579544, -0.45053350925445557, -0.31537219882011414) ,
+ (-0.45813983678817749, -1.4928090763532964e-07, -0.3043154776096344) ,
+ (-0.013497666455805302, -4.3980978858826347e-09, -0.54983437061309814) ),
+
+ ( (0.013497673906385899, 0.0, 0.54983437061309814) ,
+ (0.0077417795546352863, -0.4505336582660675, 0.31537202000617981) ,
+ (-0.44265598058700562, -1.4423562788579147e-07, 0.32642868161201477) ,
+ (-0.38879179954528809, -0.38890856504440308, 0.0095444004982709885) ),
+
+ ( (0.0077417795546352863, -0.4505336582660675, 0.31537202000617981) ,
+ (0.38879171013832092, -0.38890862464904785, -0.0095440549775958061) ,
+ (-0.38879179954528809, -0.38890856504440308, 0.0095444004982709885) ,
+ (-0.0077417660504579544, -0.45053350925445557, -0.31537219882011414) ),
+
+ ( (0.38879171013832092, -0.38890862464904785, -0.0095440549775958061) ,
+ (0.44265609979629517, -1.3367842655043205e-07, -0.32642853260040283) ,
+ (-0.0077417660504579544, -0.45053350925445557, -0.31537219882011414) ,
+ (-0.013497666455805302, -4.3980978858826347e-09, -0.54983437061309814) ),
+
+ ( (0.013497673906385899, 0.0, 0.54983437061309814) ,
+ (0.45813989639282227, -1.3835439460763155e-07, 0.30431538820266724) ,
+ (0.0077417795546352863, -0.4505336582660675, 0.31537202000617981) ,
+ (0.38879171013832092, -0.38890862464904785, -0.0095440549775958061) ),
+
+ ( (0.45813989639282227, -1.3835439460763155e-07, 0.30431538820266724) ,
+ (0.38879159092903137, 0.3889087438583374, -0.0095440549775958061) ,
+ (0.38879171013832092, -0.38890862464904785, -0.0095440549775958061) ,
+ (0.44265609979629517, -1.3367842655043205e-07, -0.32642853260040283) ),
+
+ ( (0.38879159092903137, 0.3889087438583374, -0.0095440549775958061) ,
+ (-0.007742113433778286, 0.45053350925445557, -0.31537219882011414) ,
+ (0.44265609979629517, 0.0, -0.32642853260040283) ,
+ (-0.013497666455805302, -4.3980978858826347e-09, -0.54983437061309814) )]
+
+
+ def cart2spherical(self,x,y,z):
+ xypow = x**x+y**y
+ r = sqrt(xypow+z**z)
+ if y >= 0:
+ phi = acos(x/sqrt(x/xypow))
+ else:
+ phi = 2*pi-acos(x/sqrt(xypow))
+ theta = pi/2-atan(z/sqrt(xypow))
+ return r,phi,theta
+
+
+ def coords_of_cap(self,radius,resolution_x,resolution_y,cap):
+ coords = []
+ #radius = sqrt(c1x**2+c1y**2+c1z**2)
+
+
+ c1x = self.lookup_table[cap][0][0]
+ c1y = self.lookup_table[cap][0][1]
+ c1z = self.lookup_table[cap][0][2]
+
+ c2x = self.lookup_table[cap][1][0]
+ c2y = self.lookup_table[cap][1][1]
+ c2z = self.lookup_table[cap][1][2]
+
+ c3x = self.lookup_table[cap][2][0]
+ c3y = self.lookup_table[cap][2][1]
+ c3z = self.lookup_table[cap][2][2]
+
+ c4x = self.lookup_table[cap][3][0]
+ c4y = self.lookup_table[cap][3][1]
+ c4z = self.lookup_table[cap][3][2]
+
+ coords1,theta,phi = self.evenly_divide_arc(resolution_x, c1x, c1y, c1z, c2x, c2y, c2z)
+ coords2,theta,phi = self.evenly_divide_arc(resolution_x, c3x, c3y, c3z, c4x, c4y, c4z)
+
+
+
+ for i in xrange(len(coords1)):
+ temp,theta,phi = self.evenly_divide_arc(resolution_y, coords1[i][0],coords1[i][1],coords1[i][2], coords2[i][0],coords2[i][1],coords2[i][2])
+
+ for j in xrange(len(theta)):
+ x,y,z = self.RTF2XYZ(theta[j],phi[j],radius)
+ coords.append((x,y,z))
+ return coords
+
+ def evenly_divide_arc(self,elx,x1,y1,z1,x2,y2,z2):
+ nox=elx+1
+ dx = (x2-x1)/elx
+ dy = (y2-y1)/elx
+ dz = (z2-z1)/elx
+ theta = []
+ phi = []
+ coords = []
+ for j in xrange(1,nox+1):
+ x_temp = x1 + dx * (j-1) + 5.0e-32
+ y_temp = y1 + dy * (j-1)
+ z_temp = z1 + dz * (j-1)
+ coords.append((x_temp,y_temp,z_temp))
+ theta.append(acos(z_temp/sqrt(x_temp**2+y_temp**2+z_temp**2)))
+ phi.append(self.myatan(y_temp,x_temp))
+ return coords,theta,phi
+
+ def RTF2XYZ(self,thet, phi, r):
+ x = r * sin(thet) * cos(phi)
+ y = r * sin(thet) * sin(phi)
+ z = r * cos(thet)
+ return x, y, z
+
+ def myatan(self,y,x):
+ fi = atan2(y,x)
+ if fi<0.0:
+ fi += 2*pi
+ return fi
+
+
+
\ No newline at end of file
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSSphere.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSSphere.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSreduce.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSreduce.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSreduce.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,187 @@
+"""A filter that reduces CitcomS vtk input data.
+"""
+
+# Author: Martin Weier
+# Copyright (c) 2006, California Institute of Technology
+
+
+# Enthought library imports.
+from enthought.traits import Instance, Range, Int, Float, Enum
+from enthought.traits.ui import View, Group, Item
+from enthought.tvtk.api import tvtk
+
+# Local imports
+from enthought.mayavi.core.filter import Filter
+
+from CitcomSSphere import *
+
+######################################################################
+# `Threshold` class.
+######################################################################
+class CitcomSreduce(Filter):
+
+ # The version of this class. Used for persistence.
+ __version__ = 0
+
+ # The threshold filter.
+
+ probe_filter = Instance(tvtk.ProbeFilter, ())
+
+
+
+ citcomsgrid = CitcomSSphere()
+
+ # Upper threshold (this is a dynamic trait that is changed when
+ # input data changes).
+ Radius = Range(0.55, 1.0, 0.825,
+ desc='adjust radius')
+ theta = Range(0, 40, 10,
+ desc='the theta resolution')
+ phi = Range(0, 40, 10,
+ desc='the upper threshold of the filter')
+
+ Selected_Source = Enum( 'Sphere', 'CitcomSGrid',)
+
+
+ # Our view.
+ view = View(Item(name="Selected_Source"),
+ Group(Item(name='Radius'),
+ Item(name='theta'),
+ Item(name='phi'),
+ show_border = True
+ ),
+ )
+
+ grid_source = True
+
+ ######################################################################
+ # `Filter` interface.
+ ######################################################################
+ def setvalues(self,nx,ny,nz):
+ pass
+
+ def setup_pipeline(self):
+ """Override this method so that it *creates* its tvtk
+ pipeline.
+
+ This method is invoked when the object is initialized via
+ `__init__`. Note that at the time this method is called, the
+ tvtk data pipeline will *not* yet be setup. So upstream data
+ will not be available. The idea is that you simply create the
+ basic objects and setup those parts of the pipeline not
+ dependent on upstream sources and filters.
+ """
+ # Just setup the default output of this filter.
+ self.outputs = [self.probe_filter.output]
+
+ def update_pipeline(self):
+ """Override this method so that it *updates* the tvtk pipeline
+ when data upstream is known to have changed.
+
+ This method is invoked (automatically) when the input fires a
+ `pipeline_changed` event.
+ """
+ # By default we set the input to the first output of the first
+ # input.
+ fil = self.probe_filter
+
+ #Filter needs to be connected to the unfiltered Dataset.
+ #If the filter above has changed its data connect to output port 1 instead of 2
+ fil.source = self.inputs[0].outputs[0]
+
+ #self.sphere.radius = 0.98
+ #self.sphere.theta_resolution = 24
+ #self.sphere.phi_resolution = 24
+ #fil.input = self.sphere.output
+
+
+
+ self._calc_grid(0,self.theta,self.phi)
+ fil.update()
+ # We force the ranges to be reset to the limits of the data.
+ # This is because if the data has changed upstream, then the
+ # limits of the data must be changed.
+ #self._update_ranges(reset=True)
+ #fil.update()
+ self.outputs[0] = fil.output
+ self.pipeline_changed = True
+
+ def update_data(self):
+ """Override this method to do what is necessary when upstream
+ data changes.
+
+ This method is invoked (automatically) when any of the inputs
+ sends a `data_changed` event.
+ """
+
+ #self._update_ranges(reset=True)
+ self.probe_filter.source = self.inputs[0].outputs[0]
+ self.probe_filter.update()
+ # Propagate the data_changed event.
+ self.data_changed = True
+
+
+ def _calc_grid(self,radius,resolution_x,resolution_y):
+
+ fil = self.probe_filter
+
+ coords = []
+
+ if self.Selected_Source == 'CitcomSGrid':
+
+ for i in xrange(12):
+
+ coords += self.citcomsgrid.coords_of_cap(radius,self.theta,self.phi,i)
+
+ grid = tvtk.UnstructuredGrid()
+ grid.points = coords
+ #dl = tvtk.Delaunay3D()
+ #dl.input = grid
+ #fil.input = dl.output
+ fil.input = grid
+
+ if self.Selected_Source == 'Sphere':
+ sphere = tvtk.SphereSource()
+ sphere.radius = radius
+ sphere.theta_resolution = resolution_x
+ sphere.phi_resolution = resolution_y
+ fil.input = sphere.output
+ self.update_data()
+
+
+ fil.update()
+
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+ def _Radius_changed(self, new_value):
+ fil = self.probe_filter
+ #self.sphere.radius = new_value
+ self._calc_grid(new_value,self.theta,self.phi)
+ fil.update()
+ self.data_changed = True
+
+
+ def _theta_changed(self, new_value):
+ fil = self.probe_filter
+ self._calc_grid(self.Radius,new_value,self.phi)
+ fil.update()
+ self.data_changed = True
+
+
+
+ def _phi_changed(self, new_value):
+ fil = self.probe_filter
+ self._calc_grid(self.Radius,new_value,self.phi)
+ fil.update()
+ self.data_changed = True
+
+ def _Selected_Source_changed(self,new_value):
+ self._calc_grid(self.Radius, self.theta, self.phi)
+ self.outputs[0] = self.probe_filter.output
+ self.data_changed = True
+ self.pipeline_changed = True
+
+ def _update_ranges(self, reset=False):
+ pass
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSreduce.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSreduce.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowCaps.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowCaps.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowCaps.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,139 @@
+"""A simple filter that thresholds on input data.
+
+"""
+# Author: Prabhu Ramachandran <prabhu_r at users.sf.net>
+# Copyright (c) 2005, Enthought, Inc.
+# License: BSD Style.
+
+# Enthought library imports.
+from enthought.traits import Instance, Range, Int
+from enthought.traits.ui import View, Group, Item
+from enthought.tvtk.api import tvtk
+
+# Local imports
+from enthought.mayavi.core.filter import Filter
+
+
+######################################################################
+# `Threshold` class.
+######################################################################
+class CitcomSshowCaps(Filter):
+
+ # The version of this class. Used for persistence.
+ __version__ = 0
+
+ # The threshold filter.
+ ugrid_filter = Instance(tvtk.ExtractUnstructuredGrid, ())
+
+ # Lower threshold (this is a dynamic trait that is changed when
+ # input data changes).
+ lower_threshold = Range(0, 13, 0,
+ desc='the lower threshold of the filter')
+
+ # Upper threshold (this is a dynamic trait that is changed when
+ # input data changes).
+ upper_threshold = Range(0, 13, 13,
+ desc='the upper threshold of the filter')
+
+ # Our view.
+ view = View(Group(Item(name='lower_threshold'),
+ Item(name='upper_threshold'))
+ )
+
+ nx = Int()
+ ny = Int()
+ nz = Int()
+ n = Int()
+ caps = Int()
+
+ def setvalues(self,nxin,nyin,nzin):
+ self.nx = nxin
+ self.ny = nyin
+ self.nz = nzin
+
+ ######################################################################
+ # `Filter` interface.
+ ######################################################################
+ def setup_pipeline(self):
+ """Override this method so that it *creates* its tvtk
+ pipeline.
+
+ This method is invoked when the object is initialized via
+ `__init__`. Note that at the time this method is called, the
+ tvtk data pipeline will *not* yet be setup. So upstream data
+ will not be available. The idea is that you simply create the
+ basic objects and setup those parts of the pipeline not
+ dependent on upstream sources and filters.
+ """
+ # Just setup the default output of this filter.
+ self.ugrid_filter.point_clipping = 1
+ self.ugrid_filter.merging = 0
+ self.outputs = [self.ugrid_filter.output]
+
+ def update_pipeline(self):
+ """Override this method so that it *updates* the tvtk pipeline
+ when data upstream is known to have changed.
+
+ This method is invoked (automatically) when the input fires a
+ `pipeline_changed` event.
+ """
+ # By default we set the input to the first output of the first
+ # input.
+ fil = self.ugrid_filter
+ fil.input = self.inputs[0].outputs[0]
+ self.caps = 12
+ self.n = self.inputs[0].outputs[0].number_of_points/12
+ #self.inputs[0].outputs[0].number_of_points/(self.nx*self.ny*self.nz)
+ # We force the ranges to be reset to the limits of the data.
+ # This is because if the data has changed upstream, then the
+ # limits of the data must be changed.
+ #self._update_ranges(reset=True)
+
+ #fil.threshold_between(self.lower_threshold, self.upper_threshold)
+ #fil.update()
+ self.outputs[0] = fil.output
+ self.outputs.append(self.inputs[0].outputs[0])
+ self.pipeline_changed = True
+
+ def update_data(self):
+ """Override this method to do what is necessary when upstream
+ data changes.
+
+ This method is invoked (automatically) when any of the inputs
+ sends a `data_changed` event.
+ """
+
+ #self._update_ranges(reset=True)
+
+ # XXX: These are commented since updating the ranges does
+ # everything for us.
+
+ #fil = self.threshold_filter
+ #fil.threshold_between(self.lower_threshold, self.upper_threshold)
+ #fil.update()
+ # Propagate the data_changed event.
+ self.data_changed = True
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+ def _lower_threshold_changed(self,old_value, new_value):
+ #if new_value <> self.upper_threshold and new_value<upper_threshold:
+ fil = self.ugrid_filter
+ fil.point_minimum = (self.lower_threshold)*(self.n)
+ fil.update()
+ self.data_changed = True
+ #else: #Create a single point to prevent that other filters crash because of missing input
+ # self.outputs[0].points = [(100,100,100)]
+
+ def _upper_threshold_changed(self, old_value, new_value):
+ #if new_value <> self.lower_threshold and new_value>lower_threshold:
+ fil = self.ugrid_filter
+ fil.point_maximum = self.upper_threshold*(self.n)
+ fil.update()
+ self.data_changed = True
+ #else:
+ #self.outputs[0].points = [(100,100,100)]
+
+
+
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowCaps.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowCaps.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowSurface.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowSurface.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/CitcomSshowSurface.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,212 @@
+"""A simple filter that thresholds on input data.
+
+"""
+# Author: Prabhu Ramachandran <prabhu_r at users.sf.net>
+# Copyright (c) 2005, Enthought, Inc.
+# License: BSD Style.
+
+# Enthought library imports.
+from enthought.traits import Instance, Range, Int, Float
+from enthought.traits.ui import View, Group, Item
+from enthought.tvtk import tvtk
+
+# Local imports
+from enthought.mayavi.core.filter import Filter
+
+
+######################################################################
+# `Threshold` class.
+######################################################################
+class ShowSurface(Filter):
+
+ # The version of this class. Used for persistence.
+ __version__ = 0
+
+ # The threshold filter.
+
+ prog_filter = Instance(tvtk.ProgrammableFilter, ())
+
+
+ # Upper threshold (this is a dynamic trait that is changed when
+ # input data changes).
+ surfacelevel = Range(1, 17, 1,
+ desc='the surface filter')
+
+ # Our view.
+ view = View(Group(Item(name='surfacelevel')
+ ))
+
+ current_level=Int()
+ nx = Int()
+ ny = Int()
+ nz = Int()
+
+
+
+
+ def setvalues(self,nx,ny,nz,level):
+ """This Method needs to be set before the execution of the filter
+ it accepts nx,ny,nz,level"""
+ self.nx = nx
+ self.ny = ny
+ self.nz = nz
+ self.current_level = level
+ ######################################################################
+ # `Filter` interface.
+ ######################################################################
+ def setup_pipeline(self):
+ """Override this method so that it *creates* its tvtk
+ pipeline.
+
+ This method is invoked when the object is initialized via
+ `__init__`. Note that at the time this method is called, the
+ tvtk data pipeline will *not* yet be setup. So upstream data
+ will not be available. The idea is that you simply create the
+ basic objects and setup those parts of the pipeline not
+ dependent on upstream sources and filters.
+ """
+ # Just setup the default output of this filter.
+ self.prog_filter.set_execute_method(self._showsurface)
+ self.outputs = [self.prog_filter.output]
+
+ def update_pipeline(self):
+ """Override this method so that it *updates* the tvtk pipeline
+ when data upstream is known to have changed.
+
+ This method is invoked (automatically) when the input fires a
+ `pipeline_changed` event.
+ """
+ # By default we set the input to the first output of the first
+ # input.
+ fil = self.prog_filter
+ fil.input = self.inputs[0].outputs[0]
+
+ # We force the ranges to be reset to the limits of the data.
+ # This is because if the data has changed upstream, then the
+ # limits of the data must be changed.
+ #self._update_ranges(reset=True)
+
+ #fil.threshold_between(self.lower_threshold, self.upper_threshold)
+ #fil.update()
+ self.outputs[0] = fil.output
+ self.pipeline_changed = True
+
+ def update_data(self):
+ """Override this method to do what is necessary when upstream
+ data changes.
+
+ This method is invoked (automatically) when any of the inputs
+ sends a `data_changed` event.
+ """
+
+ #self._update_ranges(reset=True)
+
+
+ # Propagate the data_changed event.
+ self.prog_filter.set_execute_method(self._showsurface)
+ self.outputs = [self.prog_filter.output]
+ self.data_changed = True
+
+
+ def _showsurface(self):
+ print "showsurface update"
+ print self.current_level
+ input = self.prog_filter.unstructured_grid_input
+ numCells = input.number_of_cells
+ quadgrid = tvtk.UnstructuredGrid()
+ quadgrid.allocate(1,1)
+
+ reduced_points = []
+ reduced_scalars = []
+ reduced_vectors = []
+ j = 1
+ cell_count=0
+ for i in xrange(numCells):
+ if j==self.current_level:
+ cell = input.get_cell(i)
+ scalars = input.point_data.scalars
+ vectors = input.point_data.vectors
+ point_ids = cell.point_ids
+ points = cell.points
+ reduced_points.append(points[2])
+ reduced_points.append(points[1])
+ reduced_points.append(points[5])
+ reduced_points.append(points[6])
+
+ reduced_scalars.append(scalars[point_ids[2]])
+ reduced_scalars.append(scalars[point_ids[1]])
+ reduced_scalars.append(scalars[point_ids[5]])
+ reduced_scalars.append(scalars[point_ids[6]])
+
+
+ reduced_vectors.append(vectors[point_ids[2]])
+ reduced_vectors.append(vectors[point_ids[1]])
+ reduced_vectors.append(vectors[point_ids[5]])
+ reduced_vectors.append(vectors[point_ids[6]])
+
+ quadgrid.insert_next_cell(9,[cell_count,cell_count+1,cell_count+2,cell_count+3])
+ cell_count+=4
+
+ if j == self.nx:
+ j=1
+
+ j+=1
+
+ vtkReduced_vectors = tvtk.FloatArray()
+ vtkReduced_scalars = tvtk.FloatArray()
+ vtkReduced_vectors.from_array(reduced_vectors)
+ vtkReduced_scalars.from_array(reduced_scalars)
+
+ vtkReduced_scalars.name = 'Scalars'
+ vtkReduced_vectors.name = 'Vectors'
+
+ #showsurfF.unstructured_grid_output = quadgrid
+ self.prog_filter.unstructured_grid_output.set_cells(9,quadgrid.get_cells())
+ self.prog_filter.unstructured_grid_output.point_data.scalars = vtkReduced_scalars
+ self.prog_filter.unstructured_grid_output.point_data.vectors = vtkReduced_vectors
+ self.prog_filter.unstructured_grid_output.points = reduced_points
+
+
+ ######################################################################
+ # Non-public interface
+ ######################################################################
+ def _surfacelevel_changed(self, new_value):
+ fil = self.prog_filter
+ print self.current_level
+ self.current_level = new_value-1
+ self._showsurface()
+ fil.update()
+ self.data_changed = True
+
+ def _update_ranges(self, reset=False):
+ """Updates the ranges of the input. When `reset` is True, the
+ lower and upper thresholds are automatically set to the limits
+ of the input data."""
+
+ input = self.inputs[0].outputs[0]
+ data_range = []
+ ps = input.point_data.scalars
+ cs = input.cell_data.scalars
+
+ # FIXME: need to be able to handle cell and point data
+ # together.
+ if ps:
+ data_range = ps.range
+ elif cs:
+ data_range = cs.range
+
+ if data_range:
+ dr = data_range
+ l = max(self.lower_threshold, dr[0])
+ trait = Range(dr[0], dr[1], l,
+ desc='the lower threshold of the filter')
+ self.add_trait('lower_threshold', trait)
+
+ h = min(dr[1], self.upper_threshold)
+ trait = Range(dr[0], dr[1], h,
+ desc='the upper threshold of the filter')
+ self.add_trait('upper_threshold', trait)
+
+ if reset:
+ self.lower_threshold = dr[0]
+ self.upper_threshold = dr[1]
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/__init__.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/__init__.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/__init__.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,40 @@
+#------------------------------------------------------------------------------
+# Copyright 2003, Enthought, Inc.
+# All rights reserved.
+#
+# This software is provided without warranty under the terms of the BSD
+# license included in enthought/LICENSE.txt and may be redistributed only
+# under the conditions described in the aforementioned license. The license
+# is also available online at http://www.enthought.com/licenses/BSD.txt
+# Thanks for using Enthought open source!
+#
+# Author: Enthought, Inc.
+# Description: <Enthought library component>
+#------------------------------------------------------------------------------
+"""
+==========================
+Enthought Library
+==========================
+
+The Enthought Open Source Library
+
+Copyright 2003-2005, Enthought, Inc.
+
+
+"""
+
+try:
+ import __config__
+except ImportError:
+ __config__ = None
+
+if __config__ is not None:
+ if __config__.get_info('numpy'):
+ import os
+ if os.environ.get('NUMERIX','numpy').lower() not in ['','numpy']:
+ print 55*'*'
+ print "*** This enthought installation is built against numpy\n"\
+ "*** but the current environment is for %r.\n"\
+ "*** Resetting NUMERIX variable to 'numpy'."% (os.environ['NUMERIX'])
+ print 55*'*'
+ os.environ['NUMERIX'] = 'numpy'
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/__init__.py
___________________________________________________________________
Name: svn:executable
+ *
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/__init__.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/__init__.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/showcaps.pyc
===================================================================
(Binary files differ)
Property changes on: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/filter/showcaps.pyc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/plugin_defs/mayavi_ui_plugin_definition.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/plugin_defs/mayavi_ui_plugin_definition.py 2006-08-28 22:04:20 UTC (rev 4443)
+++ mc/3D/CitcomS/trunk/visual/Mayavi2/plugins/plugin_defs/mayavi_ui_plugin_definition.py 2006-08-28 23:17:45 UTC (rev 4444)
@@ -0,0 +1,907 @@
+"""The MayaVi plugin definition.
+
+"""
+# Author: Prabhu Ramachandran <prabhu_r at users.sf.net>
+# Copyright (c) 2005, Enthought, Inc.
+# License: BSD Style.
+
+# Enthought library imports.
+from enthought.envisage import PluginDefinition, get_using_workbench
+
+# Are we using the old UI plugin, or the shiny new Workbench plugin?
+USING_WORKBENCH = get_using_workbench()
+
+if USING_WORKBENCH:
+ from enthought.envisage.workbench.action.action_plugin_definition import \
+ Action, Group, Location, Menu, WorkbenchActionSet
+ from enthought.envisage.workbench.workbench_plugin_definition import \
+ View, Workbench
+else:
+ from enthought.envisage.ui.ui_plugin_definition \
+ import Action, Group, Menu, UIActions, UIViews, View
+
+# The plugin's globally unique identifier should really be
+# enthought.mayavi_ui. However this will break the module names that
+# we use to define the actions. We therefore fix the ID in the plugin
+# definition. This ID is used as the prefix for all identifiers
+# defined in this module.
+ID = "enthought.mayavi"
+
+######################################################################
+# Actions.
+
+if USING_WORKBENCH:
+ groups = [Group(id="M2FileGroup",
+ location=Location(path="MenuBar/FileMenu",
+ before="TVTKFileGroup")),
+ Group(id="VisualizeMenuGroup",
+ location=Location(path="MenuBar", before="ViewMenuGroup")),
+ ]
+ ########################################
+ # Menus
+ open_menu = Menu(
+ id = "OpenMenu",
+ name = "&Open",
+ location = Location(path="MenuBar/FileMenu/M2FileGroup"),
+ groups = [Group(id = "M2OpenGroup"),
+ ]
+ )
+
+ visualize_menu = Menu(
+ id = "VisualizeMenu",
+ name = "Visuali&ze",
+ location = Location(path="MenuBar/VisualizeMenuGroup"),
+ groups = [Group(id = "M2VizGroup"),
+ ]
+ )
+
+ modules_menu = Menu(
+ id = "ModulesMenu",
+ name = "&Modules",
+ location = Location(path="MenuBar/VisualizeMenu/M2VizGroup"),
+ groups = [Group(id = "M2ModulesGroup"),
+ ]
+ )
+
+ filters_menu = Menu(
+ id = "FiltersMenu",
+ name = "&Filters",
+ location = Location(path="MenuBar/VisualizeMenu/M2VizGroup"),
+ groups = [Group(id = "M2FiltersGroup"),
+ ]
+ )
+
+ ########################################
+ # File menu items.
+ open_vtk = Action(
+ id = ID + ".action.sources.OpenVTKFile",
+ class_name = ID + ".action.sources.OpenVTKFile",
+ name = "&VTK file",
+ #image = "images/new_scene.png",
+ tooltip = "Open a VTK data file",
+ description = "Open a VTK data file",
+ locations = [Location(path="MenuBar/FileMenu/OpenMenu/M2OpenGroup"),]
+ )
+
+ open_vtk_xml = Action(
+ id = ID + ".action.sources.OpenVTKXMLFile",
+ class_name = ID + ".action.sources.OpenVTKXMLFile",
+ name = "VTK &XML file",
+ #image = "images/new_scene.png",
+ tooltip = "Open a VTK XML data file",
+ description = "Open a VTK XML data file",
+ locations = [Location(path="MenuBar/FileMenu/OpenMenu/M2OpenGroup"),]
+ )
+
+ open_citcoms_vtk = Action(
+ id = ID + ".plugins.OpenCitcomSFILES.OpenCitcomSVTKFILE",
+ class_name = ID + ".plugins.OpenCitcomSFILES.OpenCitcomSVTKFILE",
+ name = "&Citcoms VTK file",
+ #image = "images/new_scene.png",
+ tooltip = "Open a CitcomS VTK data file",
+ description = "Open a CitcomS VTK data file",
+ locations = [Location(path="MenuBar/FileMenu/OpenMenu/M2OpenGroup"),]
+ )
+
+ open_citcoms_hdf = Action(
+ id = ID + ".plugins.OpenCitcomSFILES.OpenCitcomSHDFFILE",
+ class_name = ID + ".plugins.OpenCitcomSFILES.OpenCitcomSHDFFILE",
+ name = "Citcoms &HDF file",
+ #image = "images/new_scene.png",
+ tooltip = "Open a CitcomS HDF data file",
+ description = "Open a CitcomS HDF data file",
+ locations = [Location(path="MenuBar/FileMenu/OpenMenu/M2OpenGroup"),]
+ )
+ save_viz = Action(
+ id = ID + ".action.save_load.SaveVisualization",
+ class_name = ID + ".action.save_load.SaveVisualization",
+ name = "&Save Visualization",
+ #image = "images/new_scene.png",
+ tooltip = "Save current visualization",
+ description = "Save current visualization to a MayaVi2 file",
+ locations = [Location(path="MenuBar/FileMenu/M2FileGroup",
+ after="OpenMenu"),]
+ )
+
+ load_viz = Action(
+ id = ID + ".action.save_load.LoadVisualization",
+ class_name = ID + ".action.save_load.LoadVisualization",
+ name = "&Load Visualization",
+ #image = "images/new_scene.png",
+ tooltip = "Load saved visualization",
+ description = "Load saved visualization from a MayaVi2 file",
+ locations = [Location(path="MenuBar/FileMenu/M2FileGroup",
+ after="OpenMenu"),]
+ )
+
+ ########################################
+ # Visualize/Module menu items.
+ axes_module = Action(
+ id = ID + ".action.modules.AxesModule",
+ class_name = ID + ".action.modules.AxesModule",
+ name = "&Axes",
+ #image = "images/new_scene.png",
+ tooltip = "Draw axes on the outline of input data",
+ description = "Draw cubical axes on the outline for given input",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ contour_grid_plane_module = Action(
+ id = ID + ".action.modules.ContourGridPlaneModule",
+ class_name = ID + ".action.modules.ContourGridPlaneModule",
+ name = "&ContourGridPlane",
+ #image = "images/new_scene.png",
+ tooltip = "Shows a contour grid plane for the given input",
+ description = "Shows a contour grid plane for the given input",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ glyph_module = Action(
+ id = ID + ".action.modules.GlyphModule",
+ class_name = ID + ".action.modules.GlyphModule",
+ name = "Gl&yph",
+ #image = "images/new_scene.png",
+ tooltip = "Creates colored and scaled glyphs at at input points",
+ description = "Creates colored and scaled glyphs at at input points",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ grid_plane_module = Action(
+ id = ID + ".action.modules.GridPlaneModule",
+ class_name = ID + ".action.modules.GridPlaneModule",
+ name = "&GridPlane",
+ #image = "images/new_scene.png",
+ tooltip = "Shows a grid plane for the given input",
+ description = "Shows a grid plane for the given input",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ image_plane_widget_module = Action(
+ id = ID + ".action.modules.ImagePlaneWidgetModule",
+ class_name = ID + ".action.modules.ImagePlaneWidgetModule",
+ name = "I&magePlaneWidget",
+ #image = "images/new_scene.png",
+ tooltip = "Shows an image plane widget for image data",
+ description = "Shows an image plane widget for image data",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ isosurface_module = Action(
+ id = ID + ".action.modules.IsoSurfaceModule",
+ class_name = ID + ".action.modules.IsoSurfaceModule",
+ name = "&IsoSurface",
+ #image = "images/new_scene.png",
+ tooltip = "Creates an iso-surface for the given input",
+ description = "Creates an iso-surface for the given input",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ orientation_axes_module = Action(
+ id = ID + ".action.modules.OrientationAxesModule",
+ class_name = ID + ".action.modules.OrientationAxesModule",
+ name = "Orientation A&xes",
+ #image = "images/new_scene.png",
+ tooltip = "Show an axes indicating the current orientation",
+ description = "Show an axes indicating the current orientation",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ outline_module = Action(
+ id = ID + ".action.modules.OutlineModule",
+ class_name = ID + ".action.modules.OutlineModule",
+ name = "&Outline",
+ #image = "images/new_scene.png",
+ tooltip = "Draw an outline for given input",
+ description = "Draw an outline for given input",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ scalar_cut_plane_module = Action(
+ id = ID + ".action.modules.ScalarCutPlaneModule",
+ class_name = ID + ".action.modules.ScalarCutPlaneModule",
+ name = "Scalar Cut &Plane",
+ #image = "images/new_scene.png",
+ tooltip = "Slice through the data with optional contours",
+ description = "Slice through the data with optional contours",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ slice_ug_module = Action(
+ id = ID + ".action.modules.SliceUnstructuredGridModule",
+ class_name = ID + ".action.modules.SliceUnstructuredGridModule",
+ name = "S&lice Unstructured Grid",
+ #image = "images/new_scene.png",
+ tooltip = "Slice an unstructured grid to show cells",
+ description = "Slice an unstructured grid to show cells",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ streamline_module = Action(
+ id = ID + ".action.modules.StreamlineModule",
+ class_name = ID + ".action.modules.StreamlineModule",
+ name = "Stream&line",
+ #image = "images/new_scene.png",
+ tooltip = "Generate streamlines for the vectors",
+ description = "Generate streamlines for the vectors",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ surface_module = Action(
+ id = ID + ".action.modules.SurfaceModule",
+ class_name = ID + ".action.modules.SurfaceModule",
+ name = "&Surface",
+ #image = "images/new_scene.png",
+ tooltip = "Creates a surface for the given input",
+ description = "Creates a surface for the given input",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ text_module = Action(
+ id = ID + ".action.modules.TextModule",
+ class_name = ID + ".action.modules.TextModule",
+ name = "&Text",
+ #image = "images/new_scene.png",
+ tooltip = "Displays text on screen",
+ description = "Displays user specified text on screen",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ vector_cut_plane_module = Action(
+ id = ID + ".action.modules.VectorCutPlaneModule",
+ class_name = ID + ".action.modules.VectorCutPlaneModule",
+ name = "&VectorCutPlane",
+ #image = "images/new_scene.png",
+ tooltip = "Display vectors along a cut plane",
+ description = "Display vectors along a cut plane",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ vectors_module = Action(
+ id = ID + ".action.modules.VectorsModule",
+ class_name = ID + ".action.modules.VectorsModule",
+ name = "V&ectors",
+ #image = "images/new_scene.png",
+ tooltip = "Display input vectors using arrows or other glyphs",
+ description = "Display input vectors using arrows or other glyphs",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ ########################################
+ # Visualize/Filter menu items.
+ cell_to_point_data_filter = Action(
+ id = ID + ".action.filters.CellToPointDataFilter",
+ class_name = ID + ".action.filters.CellToPointDataFilter",
+ name = "&CellToPointData",
+ #image = "images/new_scene.png",
+ tooltip = "Convert cell data to point data for the active data",
+ description = "Convert cell data to point data for the active data",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ delaunay2d_filter = Action(
+ id = ID + ".action.filters.Delaunay2DFilter",
+ class_name = ID + ".action.filters.Delaunay2DFilter",
+ name = "&Delaunay2D",
+ #image = "images/new_scene.png",
+ tooltip = "Perform a 2D Delaunay triangulation for the given data",
+ description = "Perform a 2D Delaunay triangulation for the given data",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ delaunay3d_filter = Action(
+ id = ID + ".action.filters.Delaunay3DFilter",
+ class_name = ID + ".action.filters.Delaunay3DFilter",
+ name = "Delaunay&3D",
+ #image = "images/new_scene.png",
+ tooltip = "Perform a 3D Delaunay triangulation for the given data",
+ description = "Perform a 3D Delaunay triangulation for the given data",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ extract_unstructured_grid_filter = Action(
+ id = ID + ".action.filters.ExtractUnstructuredGridFilter",
+ class_name = ID + ".action.filters.ExtractUnstructuredGridFilter",
+ name = "Extract &Unstructured Grid",
+ #image = "images/new_scene.png",
+ tooltip = "Extract part of an unstructured grid",
+ description = "Extract part of an unstructured grid",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ extract_vector_norm_filter = Action(
+ id = ID + ".action.filters.ExtractVectorNormFilter",
+ class_name = ID + ".action.filters.ExtractVectorNormFilter",
+ name = "Extract &Vector Norm",
+ #image = "images/new_scene.png",
+ tooltip = "Compute the vector norm for the current vector data",
+ description = "Compute the vector norm for the current vector data",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ mask_points_filter = Action(
+ id = ID + ".action.filters.MaskPointsFilter",
+ class_name = ID + ".action.filters.MaskPointsFilter",
+ name = "&Mask Points",
+ #image = "images/new_scene.png",
+ tooltip = "Mask the input points in the data",
+ description = "Mask the input points in the data",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ poly_data_normals_filter = Action(
+ id = ID + ".action.filters.PolyDataNormalsFilter",
+ class_name = ID + ".action.filters.PolyDataNormalsFilter",
+ name = "Compute &Normals",
+ #image = "images/new_scene.png",
+ tooltip = "Compute normals and smooth the appearance",
+ description = "Compute normals and smooth the appearance",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ threshold_filter = Action(
+ id = ID + ".action.filters.ThresholdFilter",
+ class_name = ID + ".action.filters.ThresholdFilter",
+ name = "&Threshold",
+ #image = "images/new_scene.png",
+ tooltip = "Threshold input data based on scalar values",
+ description = "Threshold input data based on scalar values",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ warp_scalar_filter = Action(
+ id = ID + ".action.filters.WarpScalarFilter",
+ class_name = ID + ".action.filters.WarpScalarFilter",
+ name = "Warp S&calar",
+ #image = "images/new_scene.png",
+ tooltip = "Move points of data along normals by the scalar data",
+ description = "Move points of data along normals by the scalar data",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ warp_vector_filter = Action(
+ id = ID + ".action.filters.WarpVectorFilter",
+ class_name = ID + ".action.filters.WarpVectorFilter",
+ name = "Warp &Vector",
+ #image = "images/new_scene.png",
+ tooltip = "Move points of data along the vector data at point",
+ description = "Move points of data along the vector data at point",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ warp_vector_filter = Action(
+ id = ID + ".action.filters.WarpVectorFilter",
+ class_name = ID + ".action.filters.WarpVectorFilter",
+ name = "Warp &Vector",
+ #image = "images/new_scene.png",
+ tooltip = "Move points of data along the vector data at point",
+ description = "Move points of data along the vector data at point",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ citcoms_cap_filter = Action(
+ id = ID + ".plugins.filter.CitcomSFilterActions.CitcomSshowCaps",
+ class_name = ID + ".plugins.filter.CitcomSFilterActions.CitcomSshowCaps",
+ name = "CitcomS &ShowCaps",
+ #image = "images/new_scene.png",
+ tooltip = "Dispaly a specified range of caps",
+ description = "Dispaly a specified range of caps",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ citcoms_reduce_filter = Action(
+ id = ID + ".plugins.filter.CitcomSFilterActions.CitcomSreduce",
+ class_name = ID + ".plugins.filter.CitcomSFilterActions.CitcomSreduce",
+ name = "CitcomS &Reduce",
+ #image = "images/new_scene.png",
+ tooltip = "Dispaly a Reduce Grid for interpolation",
+ description = "Dispaly a Reduce Grid for interpolation",
+ locations = [Location(path="MenuBar/VisualizeMenu/FiltersMenu/M2FiltersGroup"),]
+ )
+
+ ########################################
+ # List of all actions.
+ action_set = WorkbenchActionSet(
+ id = ID + '.action_set',
+ name = 'Mayavi2ActionSet',
+ groups = groups,
+ menus = [open_menu,
+ visualize_menu,
+ modules_menu,
+ filters_menu
+ ],
+
+ actions = [open_vtk, # File menu
+ open_vtk_xml,
+ open_citcoms_vtk,
+ open_citcoms_hdf,
+ save_viz,
+ load_viz,
+ # Modules.
+ axes_module,
+ contour_grid_plane_module,
+ glyph_module,
+ grid_plane_module,
+ image_plane_widget_module,
+ isosurface_module,
+ orientation_axes_module,
+ outline_module,
+ scalar_cut_plane_module,
+ slice_ug_module,
+ streamline_module,
+ surface_module,
+ text_module,
+ vector_cut_plane_module,
+ vectors_module,
+ # Filters.
+ cell_to_point_data_filter,
+ delaunay2d_filter,
+ delaunay3d_filter,
+ extract_unstructured_grid_filter,
+ extract_vector_norm_filter,
+ mask_points_filter,
+ poly_data_normals_filter,
+ threshold_filter,
+ warp_scalar_filter,
+ citcoms_cap_filter,
+ citcoms_reduce_filter,
+ ]
+ )
+
+ ######################################################################
+ # Views.
+ views = [View(name="MayaVi",
+ #image="images/project_view.png",
+ id=ID + ".view.engine_view.EngineView",
+ class_name=ID + ".view.engine_view.EngineView",
+ position="left",
+ )
+ ]
+ workbench = Workbench(views=views)
+
+ requires = ["enthought.envisage.workbench",
+ "enthought.plugins.python_shell",
+ "enthought.tvtk.plugins.scene",
+ ]
+ extensions = [action_set, workbench ]
+else:
+ ########################################
+ # Code for older UI plugin.
+
+ ########################################
+ # Menus
+ open_menu = Menu(
+ id = "OpenMenu",
+ name = "&Open",
+ path = "FileMenu/Start",
+ groups = [
+ Group(id = "Start"),
+ Group(id = "End"),
+ ]
+ )
+
+ visualize_menu = Menu(
+ id = "VisualizeMenu",
+ name = "Visuali&ze",
+ path = "ToolsGroup",
+ groups = [Group(id = "Start"),
+ Group(id = "End"),
+ ]
+ )
+
+ modules_menu = Menu(
+ id = "ModulesMenu",
+ name = "&Modules",
+ path = "VisualizeMenu/Start",
+ groups = [Group(id = "Start"),
+ Group(id = "End"),
+ ]
+ )
+
+ filters_menu = Menu(
+ id = "FiltersMenu",
+ name = "&Filters",
+ path = "VisualizeMenu/Start",
+ groups = [Group(id = "Start"),
+ Group(id = "End"),
+ ]
+ )
+
+ ########################################
+ # File menu items.
+ open_vtk = Action(
+ id = ID + ".action.sources.OpenVTKFile",
+ class_name = ID + ".action.sources.OpenVTKFile",
+ name = "&VTK file",
+ #image = "images/new_scene.png",
+ tooltip = "Open a VTK data file",
+ description = "Open a VTK data file",
+ menu_bar_path = "FileMenu/OpenMenu/Start"
+ )
+
+ open_vtk_xml = Action(
+ id = ID + ".action.sources.OpenVTKXMLFile",
+ class_name = ID + ".action.sources.OpenVTKXMLFile",
+ name = "VTK &XML file",
+ #image = "images/new_scene.png",
+ tooltip = "Open a VTK XML data file",
+ description = "Open a VTK XML data file",
+ menu_bar_path = "FileMenu/OpenMenu/Start"
+ )
+
+ save_viz = Action(
+ id = ID + ".action.save_load.SaveVisualization",
+ class_name = ID + ".action.save_load.SaveVisualization",
+ name = "&Save Visualization",
+ #image = "images/new_scene.png",
+ tooltip = "Save current visualization",
+ description = "Save current visualization to a MayaVi2 file",
+ menu_bar_path = "FileMenu/Start"
+ )
+
+ load_viz = Action(
+ id = ID + ".action.save_load.LoadVisualization",
+ class_name = ID + ".action.save_load.LoadVisualization",
+ name = "&Load Visualization",
+ #image = "images/new_scene.png",
+ tooltip = "Load saved visualization",
+ description = "Load saved visualization from a MayaVi2 file",
+ menu_bar_path = "FileMenu/Start"
+ )
+
+ ########################################
+ # Visualize/Module menu items.
+ axes_module = Action(
+ id = ID + ".action.modules.AxesModule",
+ class_name = ID + ".action.modules.AxesModule",
+ name = "&Axes",
+ #image = "images/new_scene.png",
+ tooltip = "Draw axes on the outline of input data",
+ description = "Draw cubical axes on the outline for given input",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ contour_grid_plane_module = Action(
+ id = ID + ".action.modules.ContourGridPlaneModule",
+ class_name = ID + ".action.modules.ContourGridPlaneModule",
+ name = "&ContourGridPlane",
+ #image = "images/new_scene.png",
+ tooltip = "Shows a contour grid plane for the given input",
+ description = "Shows a contour grid plane for the given input",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ glyph_module = Action(
+ id = ID + ".action.modules.GlyphModule",
+ class_name = ID + ".action.modules.GlyphModule",
+ name = "Gl&yph",
+ #image = "images/new_scene.png",
+ tooltip = "Creates colored and scaled glyphs at at input points",
+ description = "Creates colored and scaled glyphs at at input points",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ grid_plane_module = Action(
+ id = ID + ".action.modules.GridPlaneModule",
+ class_name = ID + ".action.modules.GridPlaneModule",
+ name = "&GridPlane",
+ #image = "images/new_scene.png",
+ tooltip = "Shows a grid plane for the given input",
+ description = "Shows a grid plane for the given input",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ image_plane_widget_module = Action(
+ id = ID + ".action.modules.ImagePlaneWidgetModule",
+ class_name = ID + ".action.modules.ImagePlaneWidgetModule",
+ name = "I&magePlaneWidget",
+ #image = "images/new_scene.png",
+ tooltip = "Shows an image plane widget for image data",
+ description = "Shows an image plane widget for image data",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ isosurface_module = Action(
+ id = ID + ".action.modules.IsoSurfaceModule",
+ class_name = ID + ".action.modules.IsoSurfaceModule",
+ name = "&IsoSurface",
+ #image = "images/new_scene.png",
+ tooltip = "Creates an iso-surface for the given input",
+ description = "Creates an iso-surface for the given input",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ orientation_axes_module = Action(
+ id = ID + ".action.modules.OrientationAxesModule",
+ class_name = ID + ".action.modules.OrientationAxesModule",
+ name = "Orientation A&xes",
+ #image = "images/new_scene.png",
+ tooltip = "Show an axes indicating the current orientation",
+ description = "Show an axes indicating the current orientation",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ outline_module = Action(
+ id = ID + ".action.modules.OutlineModule",
+ class_name = ID + ".action.modules.OutlineModule",
+ name = "&Outline",
+ #image = "images/new_scene.png",
+ tooltip = "Draw an outline for given input",
+ description = "Draw an outline for given input",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ scalar_cut_plane_module = Action(
+ id = ID + ".action.modules.ScalarCutPlaneModule",
+ class_name = ID + ".action.modules.ScalarCutPlaneModule",
+ name = "Scalar Cut &Plane",
+ #image = "images/new_scene.png",
+ tooltip = "Slice through the data with optional contours",
+ description = "Slice through the data with optional contours",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ slice_ug_module = Action(
+ id = ID + ".action.modules.SliceUnstructuredGridModule",
+ class_name = ID + ".action.modules.SliceUnstructuredGridModule",
+ name = "S&lice Unstructured Grid",
+ #image = "images/new_scene.png",
+ tooltip = "Slice an unstructured grid to show cells",
+ description = "Slice an unstructured grid to show cells",
+ locations = [Location(path="MenuBar/VisualizeMenu/ModulesMenu/M2ModulesGroup"),]
+ )
+
+ streamline_module = Action(
+ id = ID + ".action.modules.StreamlineModule",
+ class_name = ID + ".action.modules.StreamlineModule",
+ name = "Stream&line",
+ #image = "images/new_scene.png",
+ tooltip = "Generate streamlines for the vectors",
+ description = "Generate streamlines for the vectors",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ surface_module = Action(
+ id = ID + ".action.modules.SurfaceModule",
+ class_name = ID + ".action.modules.SurfaceModule",
+ name = "&Surface",
+ #image = "images/new_scene.png",
+ tooltip = "Creates a surface for the given input",
+ description = "Creates a surface for the given input",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ text_module = Action(
+ id = ID + ".action.modules.TextModule",
+ class_name = ID + ".action.modules.TextModule",
+ name = "&Text",
+ #image = "images/new_scene.png",
+ tooltip = "Displays text on screen",
+ description = "Displays user specified text on screen",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ vector_cut_plane_module = Action(
+ id = ID + ".action.modules.VectorCutPlaneModule",
+ class_name = ID + ".action.modules.VectorCutPlaneModule",
+ name = "&VectorCutPlane",
+ #image = "images/new_scene.png",
+ tooltip = "Display vectors along a cut plane",
+ description = "Display vectors along a cut plane",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ vectors_module = Action(
+ id = ID + ".action.modules.VectorsModule",
+ class_name = ID + ".action.modules.VectorsModule",
+ name = "V&ectors",
+ #image = "images/new_scene.png",
+ tooltip = "Display input vectors using arrows or other glyphs",
+ description = "Display input vectors using arrows or other glyphs",
+ menu_bar_path = "VisualizeMenu/ModulesMenu/Start"
+ )
+
+ ########################################
+ # Visualize/Filter menu items.
+ cell_to_point_data_filter = Action(
+ id = ID + ".action.filters.CellToPointDataFilter",
+ class_name = ID + ".action.filters.CellToPointDataFilter",
+ name = "&CellToPointData",
+ #image = "images/new_scene.png",
+ tooltip = "Convert cell data to point data for the active data",
+ description = "Convert cell data to point data for the active data",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ delaunay2d_filter = Action(
+ id = ID + ".action.filters.Delaunay2DFilter",
+ class_name = ID + ".action.filters.Delaunay2DFilter",
+ name = "&Delaunay2D",
+ #image = "images/new_scene.png",
+ tooltip = "Perform a 2D Delaunay triangulation for the given data",
+ description = "Perform a 2D Delaunay triangulation for the given data",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ delaunay3d_filter = Action(
+ id = ID + ".action.filters.Delaunay3DFilter",
+ class_name = ID + ".action.filters.Delaunay3DFilter",
+ name = "Delaunay&3D",
+ #image = "images/new_scene.png",
+ tooltip = "Perform a 3D Delaunay triangulation for the given data",
+ description = "Perform a 3D Delaunay triangulation for the given data",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ extract_unstructured_grid_filter = Action(
+ id = ID + ".action.filters.ExtractUnstructuredGridFilter",
+ class_name = ID + ".action.filters.ExtractUnstructuredGridFilter",
+ name = "Extract &Unstructured Grid",
+ #image = "images/new_scene.png",
+ tooltip = "Extract part of an unstructured grid",
+ description = "Extract part of an unstructured grid",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ extract_vector_norm_filter = Action(
+ id = ID + ".action.filters.ExtractVectorNormFilter",
+ class_name = ID + ".action.filters.ExtractVectorNormFilter",
+ name = "Extract &Vector Norm",
+ #image = "images/new_scene.png",
+ tooltip = "Compute the vector norm for the current vector data",
+ description = "Compute the vector norm for the current vector data",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ mask_points_filter = Action(
+ id = ID + ".action.filters.MaskPointsFilter",
+ class_name = ID + ".action.filters.MaskPointsFilter",
+ name = "&Mask Points",
+ #image = "images/new_scene.png",
+ tooltip = "Mask the input points in the data",
+ description = "Mask the input points in the data",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ poly_data_normals_filter = Action(
+ id = ID + ".action.filters.PolyDataNormalsFilter",
+ class_name = ID + ".action.filters.PolyDataNormalsFilter",
+ name = "Compute &Normals",
+ #image = "images/new_scene.png",
+ tooltip = "Compute normals and smooth the appearance",
+ description = "Compute normals and smooth the appearance",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ threshold_filter = Action(
+ id = ID + ".action.filters.ThresholdFilter",
+ class_name = ID + ".action.filters.ThresholdFilter",
+ name = "&Threshold",
+ #image = "images/new_scene.png",
+ tooltip = "Threshold input data based on scalar values",
+ description = "Threshold input data based on scalar values",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ warp_scalar_filter = Action(
+ id = ID + ".action.filters.WarpScalarFilter",
+ class_name = ID + ".action.filters.WarpScalarFilter",
+ name = "Warp S&calar",
+ #image = "images/new_scene.png",
+ tooltip = "Move points of data along normals by the scalar data",
+ description = "Move points of data along normals by the scalar data",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ warp_vector_filter = Action(
+ id = ID + ".action.filters.WarpVectorFilter",
+ class_name = ID + ".action.filters.WarpVectorFilter",
+ name = "Warp &Vector",
+ #image = "images/new_scene.png",
+ tooltip = "Move points of data along the vector data at point",
+ description = "Move points of data along the vector data at point",
+ menu_bar_path = "VisualizeMenu/FiltersMenu/Start"
+ )
+
+ ########################################
+ # List of all actions.
+ ui_actions = UIActions(
+ menus = [open_menu,
+ visualize_menu,
+ modules_menu,
+ filters_menu
+ ],
+
+ actions = [open_vtk, # File menu
+ open_vtk_xml,
+ save_viz,
+ load_viz,
+ # Modules.
+ axes_module,
+ contour_grid_plane_module,
+ glyph_module,
+ grid_plane_module,
+ image_plane_widget_module,
+ isosurface_module,
+ orientation_axes_module,
+ outline_module,
+ scalar_cut_plane_module,
+ slice_ug_module,
+ streamline_module,
+ surface_module,
+ text_module,
+ vector_cut_plane_module,
+ vectors_module,
+ # Filters.
+ cell_to_point_data_filter,
+ delaunay2d_filter,
+ delaunay3d_filter,
+ extract_unstructured_grid_filter,
+ extract_vector_norm_filter,
+ mask_points_filter,
+ poly_data_normals_filter,
+ threshold_filter,
+ warp_scalar_filter,
+ warp_vector_filter,
+ ]
+ )
+
+ ######################################################################
+ # Views.
+ views = [View(name="MayaVi",
+ #image="images/project_view.png",
+ id=ID + ".view.engine_view.EngineView",
+ class_name=ID + ".view.engine_view.EngineView"
+ )
+ ]
+ ui_views = UIViews(views=views)
+
+ requires = ["enthought.envisage.ui",
+ "enthought.envisage.ui.preference",
+ "enthought.envisage.ui.python_shell",
+ "enthought.tvtk.plugins.scene",
+ ]
+ extensions = [ui_views, ui_actions, ]
+
+
+PluginDefinition(
+ # This plugins unique identifier.
+ id = ID + '_ui',
+
+ # General info.
+ name = "The MayaVi UI Plugin",
+ version = "2.0",
+ provider_name = "Prabhu Ramachandran",
+ provider_url = "www.enthought.com",
+ enabled = True,
+ autostart = True,
+
+ # Id's of plugin that this one requires.
+ requires = requires + ['enthought.mayavi'],
+
+ # The extension points that we provide.
+ extension_points = [],
+
+ # The contributions that this plugin makes to extension points offered by
+ # either itself or other plugins.
+ extensions = extensions
+)
More information about the cig-commits
mailing list