source: utils/developer/tcl/convexizing.tcl

Candidate_v1.6.1
Last change on this file was 991c35, checked in by Frederik Heber <heber@…>, 10 years ago

Added tcl scripts for viewing and debugging convexized surfaces.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#!/usr/bin/tclsh
2#
3# This scripts parses a series of tecplot style files of triangles and displays them via VMD's graphics interface
4
5# fname is the filename prefix of the tecplot .dat files, e.g. "convex" for "convex-0.dat"
6proc convexizing { fname steps} {
7 global framesteps
8 global fileprefix
9 set framesteps $steps
10 set fileprefix $fname
11
12 # avoid some 'animate dup' bug
13 set molid [molinfo top]
14 if {$steps < 2} {
15 error "steps should be greater than 2."
16 }
17 # make tcount-1 copies of current frame
18 for {set i 0} {$i <$steps} {incr i} {
19 animate dup frame 0 $molid
20 }
21 animate goto 0
22
23 global vmd_frame
24 trace variable vmd_frame([molinfo top]) w update_current_surface
25 display update
26 return
27}
28
29proc update_current_surface {name index op} {
30 global fileprefix
31
32 draw delete all
33 set frame [molinfo $index get frame]
34 # open file
35 set fname "$fileprefix-$frame.dat"
36 #puts "Opening new file $fname."
37 set file [open $fname r]
38 gets $file title
39 gets $file variables
40 gets $file zone
41 # parse nodes
42 set ncount 1
43 gets $file line
44 while { $line != {} } {
45 set nodes($ncount) $line
46 incr ncount
47 gets $file line
48 }
49 set ncount [ expr $ncount -1 ]
50 # there's a blank line in between
51 # parse triangles
52 set tcount 0
53 gets $file line
54 while { $line != {} } {
55 set triangles [ split $line " "]
56 set first [ lrange $nodes([ lindex $triangles 0 ]) 0 2 ]
57 set second [ lrange $nodes([ lindex $triangles 1 ]) 0 2 ]
58 set third [ lrange $nodes([ lindex $triangles 2 ]) 0 2 ]
59 draw color blue
60 draw material Transparent
61 draw triangle $first $second $third
62 incr tcount
63 gets $file line
64 }
65 close $file
66 #puts "There are $tcount triangles."
67
68 return
69}
70
71proc convexizing_off {} {
72 global vmd_frame
73 global framesteps
74 trace vdelete vmd_frame([molinfo top]) w update_current_surface
75 draw delete all
76 animate delete beg 1 end $framesteps skip 0 [molinfo top]
77 return
78}
79
Note: See TracBrowser for help on using the repository browser.