# Gridgen Journal File V1 (Gridgen 15.11 REL 1) # Created Fri Dec 28 09:16:20 2007 # package require PWI_Glyph 1.6.9 gg::tkLoad ####################################################### # # ---------------------------- # p2/ \p3 # / \ # p1 p4 # # Extend both ends of a DB curve to a given length. # # U is within the range [0.0,1.0] # ####################################################### set dbList [gg::dbGetAll -enabled] set extensionLength 10.0 set U 0.001 set select {} proc accuracyAdj {} { # Decrease U for better accuracy. global U db_extension1 db_extension2 set U [expr $U/10.0] gg::dbDelete $db_extension1 gg::dbDelete $db_extension2 } proc dbCurveExt {} { global selected conDim extensionLength endSpacing U global db_extension1 db_extension2 # Calculate the unit vector of the slopes of the two ends. set p1 [gg::dbUVToXYZ [list 0.0 0.0 $selected]] set p2 [gg::dbUVToXYZ [list $U 0.0 $selected]] set normal12 [ggu::vec3Normalize [ggu::vec3Sub $p1 $p2]] set p3 [gg::dbUVToXYZ [list [expr 1.0-$U] 0.0 $selected]] set p4 [gg::dbUVToXYZ [list 1.0 0.0 $selected]] set normal34 [ggu::vec3Normalize [ggu::vec3Sub $p4 $p3]] set cosAlpha_End_1 [lindex $normal12 0] set cosBeta_End_1 [lindex $normal12 1] set cosGama_End_1 [lindex $normal12 2] set cosAlpha_End_2 [lindex $normal34 0] set cosBeta_End_2 [lindex $normal34 1] set cosGama_End_2 [lindex $normal34 2] # Obtain the XYZ coordinates of the other node of the extension. set x_Extension1 [expr [lindex $p1 0] + $extensionLength * $cosAlpha_End_1] set y_Extension1 [expr [lindex $p1 1] + $extensionLength * $cosBeta_End_1] set z_Extension1 [expr [lindex $p1 2] + $extensionLength * $cosGama_End_1] set x_Extension2 [expr [lindex $p4 0] + $extensionLength * $cosAlpha_End_2] set y_Extension2 [expr [lindex $p4 1] + $extensionLength * $cosBeta_End_2] set z_Extension2 [expr [lindex $p4 2] + $extensionLength * $cosGama_End_2] set extension_Pt1 [list $x_Extension1 $y_Extension1 $z_Extension1] set extension_Pt2 [list $x_Extension2 $y_Extension2 $z_Extension2] # Create two DB extensions. gg::dbCurveBegin -type 3D_LINE gg::dbCurveAddPt $p1 gg::dbCurveAddPt $extension_Pt1 set db_extension1 [gg::dbCurveEnd] gg::dbCurveBegin -type 3D_LINE gg::dbCurveAddPt $p4 gg::dbCurveAddPt $extension_Pt2 set db_extension2 [gg::dbCurveEnd] } proc select {} { global selected dbList wm withdraw . set selected [gg::dispPick DATABASE -multiple false -explicit $dbList \ -message "Select the database curve for which you want to extend."] if {[winfo exists .]} { wm deiconify . } } proc makeInputField {parent name title variable {width 7} {valid ""}} { frame $parent.$name label .lbl$name -text $title entry .ent$name -textvariable $variable -width $width if { [string compare $valid ""]!=0 } { .ent$name configure -validate all .ent$name configure -validatecommand $valid } pack ".lbl$name" -side left -padx 3 -pady 1 -in $parent.$name pack ".ent$name" -side right -padx 3 -pady 1 -in $parent.$name return $parent.$name } proc makeWindow { } { global conDim endSpacing extensionLength pack [frame .top] -fill x -padx 1 -pady 2 pack [label .top.lbl1 -text "Extend a selected DB curve on both ends" \ -wraplength 330 -justify center] set font [.top.lbl1 cget -font] .top.lbl1 configure -font [font create -family [font actual $font -family] \ -weight bold] pack [frame .buttons -width 300 -height 400] -padx 2 -pady 5 pack [button .buttons.enterSelect -text "Select a DB Curve" \ -command { select} -width 20] -pady 4 -padx 2 pack [makeInputField .buttons inp1 "Extension Length" extensionLength 7] -pady 4 pack [button .buttons.ok -text "Extend selected DB curve" -command { dbCurveExt }] \ -side left -padx 10 -pady 4 pack [button .buttons.accu -text "Click to adjust acccuracy" \ -command {accuracyAdj; dbCurveExt}] -side left pack [frame .bottom] -pady 5 pack [button .bottom.cancel -text "Exit" -command { exit } -width 10] } makeWindow ::tk::PlaceWindow . widget gg::tkLoop