[37] | 1 | |
---|
| 2 | proc usage args { |
---|
| 3 | puts "" |
---|
| 4 | puts "vripupdate <vrip_file> <conf_file> \[options\]" |
---|
| 5 | puts "" |
---|
| 6 | puts " Options:" |
---|
| 7 | puts " -carve_conservative" |
---|
| 8 | puts " -carve_agressive" |
---|
| 9 | puts " -carve_only" |
---|
| 10 | puts " -show_render" |
---|
| 11 | puts " -persp" |
---|
| 12 | puts " -linepersp" |
---|
| 13 | puts " -slicer" |
---|
| 14 | puts " -rampscale <scale factor>" |
---|
| 15 | puts " -ramplength <length>" |
---|
| 16 | puts "" |
---|
| 17 | exit |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | # Print usage if necessary... |
---|
| 21 | if {$argc == 0 || [lindex $argv 0] == "-h"} { |
---|
| 22 | usage |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | vrip_param -quiet 1 |
---|
| 27 | |
---|
| 28 | set doChangeScale 0 |
---|
| 29 | set haveRampLength 0 |
---|
| 30 | |
---|
| 31 | set gridFile [lindex $argv 0] |
---|
| 32 | set confFile [lindex $argv 1] |
---|
| 33 | |
---|
| 34 | # Check arguments, to avoid obscure error messages later. |
---|
| 35 | if {![file isfile $gridFile]} { |
---|
| 36 | puts stderr "Error: Could not open grid file: $gridFile" |
---|
| 37 | usage |
---|
| 38 | } |
---|
| 39 | if {![file isfile $confFile]} { |
---|
| 40 | puts stderr "Error: Could not open conf file: $confFile" |
---|
| 41 | usage |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | set bmeshCmd bmesh |
---|
| 45 | set warp 0 |
---|
| 46 | set doSil 0 |
---|
| 47 | |
---|
| 48 | if {$argc > 2} { |
---|
| 49 | for {set i 2} {$i < $argc} {incr i} { |
---|
| 50 | set arg [lindex $argv $i] |
---|
| 51 | if {$arg == "-carve_conservative"} { |
---|
| 52 | set bmeshCmd bmeshlin |
---|
| 53 | vrip_param -use_tails 1 |
---|
| 54 | } elseif {$arg == "-carve_semi"} { |
---|
| 55 | set bmeshCmd bmeshlin |
---|
| 56 | vrip_param -use_tails 1 |
---|
| 57 | param -maxedge 0.01 |
---|
| 58 | } elseif {$arg == "-carve_agressive"} { |
---|
| 59 | set bmeshCmd bmeshlin |
---|
| 60 | vrip_param -use_tails 1 -fill_gaps 1 |
---|
| 61 | } elseif {$arg == "-carve_only"} { |
---|
| 62 | set bmeshCmd bmeshlin |
---|
| 63 | vrip_param -use_tails 1 -tails_only 1 |
---|
| 64 | } elseif {$arg == "-show_render"} { |
---|
| 65 | show_render |
---|
| 66 | } elseif {$arg == "-slicer"} { |
---|
| 67 | slicer |
---|
| 68 | } elseif {$arg == "-linepersp"} { |
---|
| 69 | set bmeshCmd bmeshlin |
---|
| 70 | } elseif {$arg == "-persp"} { |
---|
| 71 | set bmeshCmd bmeshp |
---|
| 72 | } elseif {$arg == "-rampscale"} { |
---|
| 73 | incr i |
---|
| 74 | set scaleFactor [lindex $argv $i] |
---|
| 75 | set doChangeScale 1 |
---|
| 76 | } elseif {$arg == "-ramplength"} { |
---|
| 77 | incr i |
---|
| 78 | set RampLength [lindex $argv $i] |
---|
| 79 | set haveRampLength 1 |
---|
| 80 | } elseif {$arg == "-stzoom"} { |
---|
| 81 | incr i |
---|
| 82 | set arg [lindex $argv $i] |
---|
| 83 | set CywarpSTZoom $arg |
---|
| 84 | set warp 1 |
---|
| 85 | } elseif {$arg == "-yzoom"} { |
---|
| 86 | incr i |
---|
| 87 | set arg [lindex $argv $i] |
---|
| 88 | set CywarpYZoom $arg |
---|
| 89 | set warp 1 |
---|
| 90 | } elseif {$arg == "-wangle"} { |
---|
| 91 | incr i |
---|
| 92 | set arg [lindex $argv $i] |
---|
| 93 | set CywarpAngle $arg |
---|
| 94 | set warp 1 |
---|
| 95 | } elseif {$arg == "-sil"} { |
---|
| 96 | set doSil 1 |
---|
| 97 | set bmeshCmd bmeshlin |
---|
| 98 | } |
---|
| 99 | } |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | if {$warp} { |
---|
| 103 | set bmeshCmd "${bmeshCmd}warp" |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | if {$bmeshCmd != "bmesh"} { |
---|
| 107 | alias bmesh $bmeshCmd |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | update |
---|
| 111 | |
---|
| 112 | catch {exec vriphead $gridFile} msg |
---|
| 113 | set x [string last Resolution: $msg] |
---|
| 114 | set x [expr $x + [string length Resolution:] + 1] |
---|
| 115 | set voxelSize [string range $msg $x end] |
---|
| 116 | set voxelSize [format "%g" $voxelSize] |
---|
| 117 | |
---|
| 118 | if {[info exists resToScaleMap($voxelSize)]} { |
---|
| 119 | changeRampScale $resToScaleMap($voxelSize) |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | if {$doChangeScale} { |
---|
| 123 | changeRampScale $scaleFactor |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | if {$haveRampLength} { |
---|
| 127 | vrip_param -ramp_width $RampLength |
---|
| 128 | vrip_param -w1 [expr $RampLength * 1.5] |
---|
| 129 | vrip_param -w2 [expr $RampLength * 1.25] |
---|
| 130 | vrip_param -w3 [expr $RampLength * -0.5] |
---|
| 131 | vrip_param -w4 [expr $RampLength * -0.75] |
---|
| 132 | vrip_param -w5 [expr $RampLength * -1.0] |
---|
| 133 | set boundary [expr int(3 * ($RampLength / $voxelSize + 1))] |
---|
| 134 | vrip_param -max_boundary_steps $boundary |
---|
| 135 | puts "Using ramps of length $RampLength, with $boundary boundary steps" |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | if {$doSil} { |
---|
| 139 | param -use_length 0 |
---|
| 140 | updateSilFromConf $gridFile $confFile |
---|
| 141 | } else { |
---|
| 142 | updateFromConf $gridFile $confFile |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | exit |
---|
| 146 | |
---|