source: utils/developer/tcl/analyseconvexizing.tcl@ 72b467

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 72b467 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: 4.2 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 set frame [molinfo $index get frame]
33 set oldncount 0
34 set oldtriangles {}
35 if {$frame > 0} {
36 # open file
37 set previousframe [expr $frame - 1]
38 set fname "$fileprefix-$previousframe.dat"
39 #puts "Opening old file $fname."
40 set file [open $fname r]
41 gets $file title
42 gets $file variables
43 gets $file zone
44 # parse nodes
45 set ncount 1
46 gets $file line
47 while { $line != {} } {
48 set nodes($ncount) $line
49 incr ncount
50 gets $file line
51 }
52 set ncount [ expr $ncount -1 ]
53 set oldncount $ncount
54 #puts "There are $ncount nodes."
55 # there's a blank line in between
56 # parse triangles
57 set tcount 0
58 gets $file line
59 while { $line != {} } {
60 set triangles [ split $line " "]
61 set oldtriangles [lappend oldtriangles $triangles]
62 incr tcount
63 gets $file line
64 }
65 close $file
66 }
67 # open file
68 set fname "$fileprefix-$frame.dat"
69 #puts "Opening new file $fname."
70 set file [open $fname r]
71 gets $file title
72 gets $file variables
73 gets $file zone
74 # parse nodes
75 set ncount 1
76 gets $file line
77 while { $line != {} } {
78 set nodes($ncount) $line
79 incr ncount
80 gets $file line
81 }
82 set ncount [ expr $ncount -1 ]
83 puts "There are $ncount nodes, and $oldncount old ones."
84 # there's a blank line in between
85 # parse triangles
86 set tcount 0
87 gets $file line
88 set newtriangles {}
89 set commontriangles {}
90 while { $line != {} } {
91 set triangles [ split $line " "]
92 if {$ncount == $oldncount} {
93 # search in oldtriangles
94 set index [lsearch $oldtriangles $triangles]
95 if {$index == -1} {
96 # not present, then mind in new ones
97 #puts "$triangles not present in old ones."
98 set newtriangles [lappend newtriangles $triangles]
99 } else {
100 # present in both, hence remove in old ones
101 #puts "$triangles present in old ones."
102 set commontriangles [lappend commontriangles $triangles]
103 set oldtriangles [lreplace $oldtriangles[set oldtriangles {}] $index $index]
104 }
105 } else {
106 set newtriangles [lappend newtriangles $triangles]
107 }
108 incr tcount
109 gets $file line
110 }
111 close $file
112 #puts "There are $tcount triangles."
113
114 # draw all remaining old and new ones
115 draw delete all
116 foreach triangles $commontriangles {
117 set first [ lrange $nodes([ lindex $triangles 0 ]) 0 2 ]
118 set second [ lrange $nodes([ lindex $triangles 1 ]) 0 2 ]
119 set third [ lrange $nodes([ lindex $triangles 2 ]) 0 2 ]
120 draw color green
121 draw material Transparent
122 #puts "common: $first $second $third"
123 #draw line $first $second style dashed
124 #draw line $first $third style dashed
125 #draw line $second $third style dashed
126 draw triangle $first $second $third
127 }
128
129 if {$ncount == $oldncount} {
130 foreach triangles $oldtriangles {
131 set first [ lrange $nodes([ lindex $triangles 0 ]) 0 2 ]
132 set second [ lrange $nodes([ lindex $triangles 1 ]) 0 2 ]
133 set third [ lrange $nodes([ lindex $triangles 2 ]) 0 2 ]
134 draw color blue
135 draw material Diffuse
136 #puts "old: $first $second $third"
137 draw triangle $first $second $third
138 }
139 }
140 foreach triangles $newtriangles {
141 set first [ lrange $nodes([ lindex $triangles 0 ]) 0 2 ]
142 set second [ lrange $nodes([ lindex $triangles 1 ]) 0 2 ]
143 set third [ lrange $nodes([ lindex $triangles 2 ]) 0 2 ]
144 draw color red
145 draw material Transparent
146 #puts "new: $first $second $third"
147 draw triangle $first $second $third
148 }
149
150 return
151}
152
153proc convexizing_off {} {
154 global vmd_frame
155 global framesteps
156 trace vdelete vmd_frame([molinfo top]) w update_current_surface
157 draw delete all
158 animate delete beg 1 end $framesteps skip 0 [molinfo top]
159 return
160}
161
Note: See TracBrowser for help on using the repository browser.