~ubuntu-branches/ubuntu/wily/pygts/wily

« back to all changes in this revision

Viewing changes to .pc/fix_examples.patch/examples/plotgts.py

  • Committer: Package Import Robot
  • Author(s): Anton Gladky, Václav Šmilauer
  • Date: 2013-01-26 21:22:37 UTC
  • Revision ID: package-import@ubuntu.com-20130126212237-5l783abxeg1k9iuh
Tags: 0.3.1-1
[ Václav Šmilauer ]
Initial debian package. (Closes: #691799)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
3
"""plotgts - plots the contents of a gts file
 
4
 
 
5
  Copyright (C) 2009 Thomas J. Duck
 
6
  All rights reserved.
 
7
 
 
8
  Thomas J. Duck <tom.duck@dal.ca>
 
9
  Department of Physics and Atmospheric Science,
 
10
  Dalhousie University, Halifax, Nova Scotia, Canada, B3H 3J5
 
11
 
 
12
NOTICE
 
13
 
 
14
  This library is free software; you can redistribute it and/or
 
15
  modify it under the terms of the GNU Library General Public
 
16
  License as published by the Free Software Foundation; either
 
17
  version 2 of the License, or (at your option) any later version.
 
18
 
 
19
  This library is distributed in the hope that it will be useful,
 
20
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
22
  Library General Public License for more details.
 
23
 
 
24
  You should have received a copy of the GNU Library General Public
 
25
  License along with this library; if not, write to the
 
26
  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
27
  Boston, MA 02111-1307, USA.
 
28
"""
 
29
 
 
30
import sys
 
31
 
 
32
import numpy
 
33
 
 
34
from enthought.mayavi import mlab
 
35
import gts
 
36
 
 
37
if len(sys.argv)!=2:
 
38
    print 'Usage: python plotfile GTSFILE'
 
39
fname = sys.argv[1]
 
40
 
 
41
print '\n\nReading',fname,'...',
 
42
sys.stdout.flush()
 
43
 
 
44
f = open(fname)
 
45
s = gts.Surface()
 
46
s = gts.read(f)
 
47
f.close()
 
48
 
 
49
print 'Done.'
 
50
sys.stdout.flush()
 
51
 
 
52
print 'Splitting into separate connected and manifold surfaces...',
 
53
sys.stdout.flush()
 
54
 
 
55
surfaces = s.split()
 
56
 
 
57
print 'Done.'
 
58
sys.stdout.flush()
 
59
 
 
60
#for i,s in enumerate(surfaces):
 
61
#    print '\tSurface',i,'is',
 
62
#    if s.is_closed():
 
63
#        print 'closed.'
 
64
#    else:
 
65
#        print 'open.'
 
66
 
 
67
print 'Retrieving mayavi data...',
 
68
sys.stdout.flush()
 
69
 
 
70
args = []
 
71
for s in surfaces:
 
72
    args.append(gts.get_coords_and_face_indices(s,True))
 
73
 
 
74
print 'Done.'
 
75
sys.stdout.flush()
 
76
 
 
77
# Plot the surfaces
 
78
print 'Plotting...',
 
79
sys.stdout.flush()
 
80
for s,arg in zip(surfaces,args):
 
81
    x,y,z,t = arg
 
82
    mlab.triangular_mesh(x,y,z,t,color=(0.5,0.5,0.75))
 
83
mlab.show()
 
84
print 'Done.'
 
85
sys.stdout.flush()