Thread: [brlcad-commits] SF.net SVN: brlcad:[33290] brlcad/trunk/src (Page 2)
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <bo...@us...> - 2008-12-04 20:55:58
|
Revision: 33290 http://brlcad.svn.sourceforge.net/brlcad/?rev=33290&view=rev Author: bob1961 Date: 2008-12-04 20:55:44 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Mods to get control-c working with "more args" commands in archer. Modified Paths: -------------- brlcad/trunk/src/libtclcad/ged_obj.c brlcad/trunk/src/tclscripts/lib/Command.tcl Modified: brlcad/trunk/src/libtclcad/ged_obj.c =================================================================== --- brlcad/trunk/src/libtclcad/ged_obj.c 2008-12-04 19:52:19 UTC (rev 33289) +++ brlcad/trunk/src/libtclcad/ged_obj.c 2008-12-04 20:55:44 UTC (rev 33290) @@ -5015,6 +5015,7 @@ bu_vls_addr(&gedp->ged_result_str)); if (Tcl_Eval(go_current_gop->go_interp, bu_vls_addr(&callback_cmd)) != TCL_OK) { + bu_vls_trunc(&gedp->ged_result_str, 0); bu_vls_printf(&gedp->ged_result_str, "%s", Tcl_GetStringResult(go_current_gop->go_interp)); Tcl_ResetResult(go_current_gop->go_interp); return BRLCAD_ERROR; Modified: brlcad/trunk/src/tclscripts/lib/Command.tcl =================================================================== --- brlcad/trunk/src/tclscripts/lib/Command.tcl 2008-12-04 19:52:19 UTC (rev 33289) +++ brlcad/trunk/src/tclscripts/lib/Command.tcl 2008-12-04 20:55:44 UTC (rev 33290) @@ -116,6 +116,7 @@ private variable search_char "" private variable search_dir "" + private variable more_args_interrupted 0 private variable more_args_list {} private variable more_args_var "" private variable more_args_begin_index "" @@ -254,6 +255,7 @@ } ::itcl::body Command::get_more_args {} { + set more_args_interrupted 0 set more_args_var "" set more_args_begin_index [$itk_component(text) index insert] set w $itk_component(text) @@ -263,8 +265,12 @@ bind $w <Return> "[::itcl::code $this doReturn]; break" bind $w <KP_Enter> "[::itcl::code $this doReturn]; break" - eval lappend more_args_list $more_args_var - return $more_args_var + if {$more_args_interrupted} { + error "" + } else { + eval lappend more_args_list $more_args_var + return $more_args_var + } } ::itcl::body Command::putstring {str} { @@ -334,8 +340,13 @@ eval lappend cmd $more_args_list $hist add $cmd } - print_prompt + if {$more_args_interrupted} { + set more_args_interrupted 0 + } else { + print_prompt + } + # get rid of oldest output set nlines [expr int([$w index end])] if {$nlines > $itk_option(-maxlines)} { @@ -1237,6 +1248,9 @@ if {$itk_option(-edit_style) == "vi"} { vi_insert_mode } + + set more_args_interrupted 1 + set more_args_var "" } ::itcl::body Command::doMeta_d {} { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-12-05 21:07:52
|
Revision: 33299 http://brlcad.svn.sourceforge.net/brlcad/?rev=33299&view=rev Author: bob1961 Date: 2008-12-05 21:07:38 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Minor mods to ArcherCore - consolidate the command lists and a few name changes. Modified Paths: -------------- brlcad/trunk/src/archer/plugins/Wizards/tankwizardIA/TankWizardIA.tcl brlcad/trunk/src/tclscripts/archer/Archer.tcl brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl Modified: brlcad/trunk/src/archer/plugins/Wizards/tankwizardIA/TankWizardIA.tcl =================================================================== --- brlcad/trunk/src/archer/plugins/Wizards/tankwizardIA/TankWizardIA.tcl 2008-12-05 18:28:32 UTC (rev 33298) +++ brlcad/trunk/src/archer/plugins/Wizards/tankwizardIA/TankWizardIA.tcl 2008-12-05 21:07:38 UTC (rev 33299) @@ -476,7 +476,7 @@ grid columnconfigure $itk_interior 0 -weight 1 set archer $_archer - set archersMged [Archer::pluginMged $archer] + set archersMged [Archer::pluginGed $archer] # process options eval itk_initialize $args Modified: brlcad/trunk/src/tclscripts/archer/Archer.tcl =================================================================== --- brlcad/trunk/src/tclscripts/archer/Archer.tcl 2008-12-05 18:28:32 UTC (rev 33298) +++ brlcad/trunk/src/tclscripts/archer/Archer.tcl 2008-12-05 21:07:38 UTC (rev 33299) @@ -119,7 +119,7 @@ proc pluginDialog {_w} proc pluginLoadCWDFiles {} proc pluginLoader {} - proc pluginMged {_archer} + proc pluginGed {_archer} proc pluginQuery {_name} proc pluginRegister {_majorType _minorType _name _class _file \ {_description ""} \ @@ -158,7 +158,7 @@ # ArcherCore Override Section method dblClick {_tags} method initDefaultBindings {{_comp ""}} - method initMged {} + method initGed {} method selectNode {_tags {_rflag 1}} method toggleTreeView {_state} @@ -900,11 +900,11 @@ ::cd $pwd } -::itcl::body Archer::pluginMged {_archer} { - if {[catch {$_archer component mged} mged]} { +::itcl::body Archer::pluginGed {_archer} { + if {[catch {$_archer component ged} ged]} { return "" } else { - return $mged + return $ged } } @@ -960,12 +960,12 @@ error "importFg4Sections: wlist is missing the WizardTop key and its corresponding value" } - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { SetWaitCursor - set savedUnits [$itk_component(mged) units -s] - $itk_component(mged) units in - $itk_component(mged) configure -autoViewEnable 0 - $itk_component(mged) detachObservers + set savedUnits [$itk_component(ged) units -s] + $itk_component(ged) units in + $itk_component(ged) configure -autoViewEnable 0 + $itk_component(ged) detachObservers set pname "" set firstName "" @@ -988,22 +988,22 @@ set solidName "$lastName\.s" } - if {![catch {$itk_component(mged) get_type $solidName} ret]} { - #$itk_component(mged) attachObservers - $itk_component(mged) units $savedUnits + if {![catch {$itk_component(ged) get_type $solidName} ret]} { + #$itk_component(ged) attachObservers + $itk_component(ged) units $savedUnits error "importFg4Sections: $solidName already exists!" } - if {[catch {$itk_component(mged) importFg4Section $solidName $sdata} ret]} { - #$itk_component(mged) attachObservers - $itk_component(mged) units $savedUnits + if {[catch {$itk_component(ged) importFg4Section $solidName $sdata} ret]} { + #$itk_component(ged) attachObservers + $itk_component(ged) units $savedUnits error "importFg4Sections: $ret" } - eval $itk_component(mged) otranslate $solidName $delta + eval $itk_component(ged) otranslate $solidName $delta # Add to the region - $itk_component(mged) r $regionName u $solidName + $itk_component(ged) r $regionName u $solidName if {$firstName == $lastName} { continue @@ -1017,43 +1017,43 @@ set gmember $regionName foreach gname $reversedGnames { - if {[catch {$itk_component(mged) get_type $gname} ret]} { - $itk_component(mged) g $gname $gmember + if {[catch {$itk_component(ged) get_type $gname} ret]} { + $itk_component(ged) g $gname $gmember } else { - if {[catch {dbCmd get $gname tree} tree]} { - #$itk_component(mged) attachObservers - $itk_component(mged) units $savedUnits + if {[catch {gedCmd get $gname tree} tree]} { + #$itk_component(ged) attachObservers + $itk_component(ged) units $savedUnits error "importFg4Sections: $gname is not a group!" } # Add gmember only if its not already there set tmembers [regsub -all {(\{[ul] )|([{}]+)} $tree " "] if {[lsearch $tmembers $gmember] == -1} { - $itk_component(mged) g $gname $gmember + $itk_component(ged) g $gname $gmember } } # Add WizardTop attribute - $itk_component(mged) attr set $gname WizardTop $wizTop + $itk_component(ged) attr set $gname WizardTop $wizTop set gmember $gname } # Add WizardTop attribute to the region and its solid - $itk_component(mged) attr set $regionName WizardTop $wizTop - $itk_component(mged) attr set $solidName WizardTop $wizTop + $itk_component(ged) attr set $regionName WizardTop $wizTop + $itk_component(ged) attr set $solidName WizardTop $wizTop # Add wizard attributes #foreach {key val} $wlist { - #$itk_component(mged) attr set $wizTop $key $val + #$itk_component(ged) attr set $wizTop $key $val #} # Add other attributes that are specific to this region foreach {key val} $attrList { - $itk_component(mged) attr set $regionName $key $val + $itk_component(ged) attr set $regionName $key $val } - if {[catch {$itk_component(mged) attr get $regionName transparency} tr]} { + if {[catch {$itk_component(ged) attr get $regionName transparency} tr]} { set tr 1.0 } else { if {![string is double $tr] || $tr < 0.0 || 1.0 < $tr} { @@ -1061,7 +1061,7 @@ } } - if {[catch {$itk_component(mged) attr get $regionName vmode} vmode]} { + if {[catch {$itk_component(ged) attr get $regionName vmode} vmode]} { set vmode 0 } else { switch -- $vmode { @@ -1079,7 +1079,7 @@ # Add wizard attributes foreach {key val} $wlist { - $itk_component(mged) attr set $wizTop $key $val + $itk_component(ged) attr set $wizTop $key $val } refreshTree @@ -1093,21 +1093,21 @@ set mNeedSave 1 updateSaveMode - $itk_component(mged) units $savedUnits - $itk_component(mged) attachObservers - $itk_component(mged) refreshAll - $itk_component(mged) configure -autoViewEnable 1 + $itk_component(ged) units $savedUnits + $itk_component(ged) attachObservers + $itk_component(ged) refreshAll + $itk_component(ged) configure -autoViewEnable 1 SetNormalCursor } } ::itcl::body Archer::purgeHistory {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } - foreach obj [$itk_component(mged) ls] { + foreach obj [$itk_component(ged) ls] { set obj [regsub {(/)|(/R)} $obj ""] purgeObjHistory $obj } @@ -1166,32 +1166,32 @@ } # Load MGED database - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { if {$mDbShared} { - $itk_component(mged) sharedGed $mTarget + $itk_component(ged) sharedGed $mTarget } elseif {$mDbNoCopy || $mDbReadOnly} { - $itk_component(mged) open $mTarget + $itk_component(ged) open $mTarget } else { - $itk_component(mged) open $mTargetCopy + $itk_component(ged) open $mTargetCopy } } else { - initMged + initGed grid forget $itk_component(canvas) if {!$mViewOnly} { - grid $itk_component(mged) -row 1 -column 0 -columnspan 3 -sticky news + grid $itk_component(ged) -row 1 -column 0 -columnspan 3 -sticky news after idle "$this component cmd configure -cmd_prefix \"[namespace tail $this] cmd\"" } else { - grid $itk_component(mged) -row 1 -column 0 -sticky news + grid $itk_component(ged) -row 1 -column 0 -sticky news } } -# setColorOption dbCmd -primitiveLabelColor $mPrimitiveLabelColor -# setColorOption dbCmd -scaleColor $mScaleColor -# setColorOption dbCmd -viewingParamsColor $mViewingParamsColor +# setColorOption gedCmd -primitiveLabelColor $mPrimitiveLabelColor +# setColorOption gedCmd -scaleColor $mScaleColor +# setColorOption gedCmd -viewingParamsColor $mViewingParamsColor - set mDbTitle [$itk_component(mged) title] - set mDbUnits [$itk_component(mged) units] + set mDbTitle [$itk_component(ged) title] + set mDbUnits [$itk_component(ged) units] if {!$mViewOnly} { initDbAttrView $mTarget @@ -1401,8 +1401,8 @@ ::itcl::body Archer::initDefaultBindings {{_comp ""}} { if {$_comp == ""} { - if {[info exists itk_component(mged)]} { - set _comp $itk_component(mged) + if {[info exists itk_component(ged)]} { + set _comp $itk_component(ged) } else { return } @@ -1437,8 +1437,8 @@ } } -::itcl::body Archer::initMged {} { - ArcherCore::initMged +::itcl::body Archer::initGed {} { + ArcherCore::initGed if {!$mViewOnly} { if {$ArcherCore::inheritFromToplevel} { @@ -1511,7 +1511,7 @@ # tag refers to a node in the previous database. set savePwd "" - if {[catch {dbCmd get_type $node} ret]} { + if {[catch {gedCmd get_type $node} ret]} { if {$savePwd != ""} { cd $savePwd } @@ -1543,16 +1543,16 @@ } # label the object if it's being drawn - set mRenderMode [dbCmd how $node] + set mRenderMode [gedCmd how $node] if {$mShowPrimitiveLabels && 0 <= $mRenderMode} { - dbCmd configure -primitiveLabels $node + gedCmd configure -primitiveLabels $node } else { - dbCmd configure -primitiveLabels {} + gedCmd configure -primitiveLabels {} } if {$rflag} { - dbCmd refresh + gedCmd refresh } set mPrevSelectedObjPath $mSelectedObjPath @@ -1705,15 +1705,15 @@ # First, apply the command to hobj if necessary. # Note - we're making the (ass)umption that the object # name is the first item in the "expandedArgs" list. - if {![catch {dbCmd attr get $obj history} hobj] && + if {![catch {gedCmd attr get $obj history} hobj] && $obj != $hobj} { set tmpArgs [lreplace $expandedArgs 0 0 $hobj] - catch {eval dbCmd $cmd $options $tmpArgs} + catch {eval gedCmd $cmd $options $tmpArgs} } } } - if {[catch {eval dbCmd $cmd $options $expandedArgs} ret]} { + if {[catch {eval gedCmd $cmd $options $expandedArgs} ret]} { SetNormalCursor return $ret } @@ -1723,7 +1723,7 @@ updateSaveMode } - dbCmd configure -primitiveLabels {} + gedCmd configure -primitiveLabels {} if {$tflag} { catch {refreshTree} } @@ -3533,7 +3533,7 @@ -variable [::itcl::scope mMode] \ -command [::itcl::code $this setMode 1] - if {[info exists itk_component(mged)] && $mMode != 0} { + if {[info exists itk_component(ged)] && $mMode != 0} { $itk_component(modesmenu) add separator $itk_component(modesmenu) add cascade \ -label "Active Pane" \ @@ -3591,14 +3591,14 @@ -variable [::itcl::scope mLighting] \ -command [::itcl::code $this doLighting] - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { # Disable a few entries until we read a database #$itk_component(modesmenu) entryconfigure "Active Pane" -state disabled $itk_component(modesmenu) entryconfigure "View Axes" -state disabled $itk_component(modesmenu) entryconfigure "Model Axes" -state disabled } } else { - if {[info exists itk_component(mged)] && $mMode != 0} { + if {[info exists itk_component(ged)] && $mMode != 0} { $itk_component(menubar) menuconfigure .modes \ -text "Modes" \ -menu { @@ -3696,7 +3696,7 @@ -variable [::itcl::scope mMode] \ -command [::itcl::code $this setMode 1] - if {[info exists itk_component(mged)] && $mMode != 0} { + if {[info exists itk_component(ged)] && $mMode != 0} { set i 0 $itk_component(menubar) menuconfigure .modes.activePane.ul \ -value $i \ @@ -3725,7 +3725,7 @@ -command [::itcl::code $this doMultiPane] } - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { $itk_component(menubar) menuconfigure .modes.viewaxes \ -offvalue 0 \ -onvalue 1 \ @@ -4187,14 +4187,14 @@ } ::itcl::body Archer::initEdit {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } - set mSelectedObjType [dbCmd get_type $mSelectedObj] + set mSelectedObjType [gedCmd get_type $mSelectedObj] if {$mSelectedObjType != "bot"} { - set odata [lrange [dbCmd get $mSelectedObj] 1 end] + set odata [lrange [gedCmd get $mSelectedObj] 1 end] } else { set odata "" } @@ -4338,17 +4338,17 @@ ::itcl::body Archer::finalizeObjEdit {obj path} { if {$obj == "" || - [catch {dbCmd get_type $obj} stuff]} { + [catch {gedCmd get_type $obj} stuff]} { return } - if {[catch {dbCmd attr get $obj history} hname]} { + if {[catch {gedCmd attr get $obj history} hname]} { set hname "" } # No history if {$hname == "" || - [catch {dbCmd get_type $hname} stuff]} { + [catch {gedCmd get_type $hname} stuff]} { return } @@ -4358,42 +4358,42 @@ # contains the only known valid version of # the object. We now copy the valid version # in place of the object. - set renderData [dbCmd how -b $path] + set renderData [gedCmd how -b $path] set renderMode [lindex $renderData 0] set renderTrans [lindex $renderData 1] - dbCmd configure -autoViewEnable 0 - dbCmd kill $obj - dbCmd cp $hname $obj - dbCmd unhide $obj - dbCmd attr rm $obj previous - dbCmd attr rm $obj next + gedCmd configure -autoViewEnable 0 + gedCmd kill $obj + gedCmd cp $hname $obj + gedCmd unhide $obj + gedCmd attr rm $obj previous + gedCmd attr rm $obj next render $path $renderMode $renderTrans 0 - dbCmd configure -autoViewEnable 1 + gedCmd configure -autoViewEnable 1 } ::itcl::body Archer::gotoNextObj {} { set obj $mSelectedObj if {$obj == "" || - [catch {dbCmd get_type $obj} stuff]} { + [catch {gedCmd get_type $obj} stuff]} { return } - if {[catch {dbCmd attr get $obj history} hname]} { + if {[catch {gedCmd attr get $obj history} hname]} { set hname "" } if {$hname == "" || - [catch {dbCmd get_type $hname} stuff]} { + [catch {gedCmd get_type $hname} stuff]} { return } - if {[catch {dbCmd attr get $hname next} next]} { + if {[catch {gedCmd attr get $hname next} next]} { set next "" } if {$next == "" || - [catch {dbCmd get_type $next} stuff]} { + [catch {gedCmd get_type $next} stuff]} { return } @@ -4410,25 +4410,25 @@ set obj $mSelectedObj if {$obj == "" || - [catch {dbCmd get_type $obj} stuff]} { + [catch {gedCmd get_type $obj} stuff]} { return } - if {[catch {dbCmd attr get $obj history} hname]} { + if {[catch {gedCmd attr get $obj history} hname]} { set hname "" } if {$hname == "" || - [catch {dbCmd get_type $hname} stuff]} { + [catch {gedCmd get_type $hname} stuff]} { return } - if {[catch {dbCmd attr get $hname previous} previous]} { + if {[catch {gedCmd attr get $hname previous} previous]} { set previous "" } if {$previous == "" || - [catch {dbCmd get_type $previous} stuff]} { + [catch {gedCmd get_type $previous} stuff]} { return } @@ -4452,38 +4452,38 @@ ::itcl::body Archer::purgeObjHistory {obj} { # Nothing to do - if {[catch {dbCmd attr get $obj history} hobj]} { + if {[catch {gedCmd attr get $obj history} hobj]} { return } # Remove obj's history attribute - $itk_component(mged) attr rm $obj history + $itk_component(ged) attr rm $obj history # March backwards in the list removing obj's history - if {![catch {dbCmd attr get $hobj previous} prev]} { + if {![catch {gedCmd attr get $hobj previous} prev]} { while {$prev != ""} { - if {[catch {dbCmd attr get $prev previous} pprev]} { + if {[catch {gedCmd attr get $prev previous} pprev]} { set pprev "" } - $itk_component(mged) kill $prev + $itk_component(ged) kill $prev set prev $pprev } } # March forward in the list removing obj's history - if {![catch {dbCmd attr get $hobj next} next]} { + if {![catch {gedCmd attr get $hobj next} next]} { while {$next != ""} { - if {[catch {dbCmd attr get $next next} nnext]} { + if {[catch {gedCmd attr get $next next} nnext]} { set nnext "" } - $itk_component(mged) kill $next + $itk_component(ged) kill $next set next $nnext } } - $itk_component(mged) kill $hobj + $itk_component(ged) kill $hobj } @@ -4491,16 +4491,16 @@ set obj $mSelectedObj if {$obj == "" || - [catch {dbCmd get_type $obj} stuff]} { + [catch {gedCmd get_type $obj} stuff]} { return } - if {[catch {dbCmd attr get $obj history} hname]} { + if {[catch {gedCmd attr get $obj history} hname]} { set hname "" } if {$hname == "" || - [catch {dbCmd get_type $hname} stuff]} { + [catch {gedCmd get_type $hname} stuff]} { return } @@ -4516,31 +4516,31 @@ ::itcl::body Archer::updateNextObjButton {obj} { if {$obj == "" || - [catch {dbCmd get_type $obj} stuff]} { + [catch {gedCmd get_type $obj} stuff]} { $itk_component(objEditToolbar) itemconfigure next \ -state disabled return } - if {[catch {dbCmd attr get $obj history} hname]} { + if {[catch {gedCmd attr get $obj history} hname]} { set hname "" } if {$hname == "" || - [catch {dbCmd get_type $hname} stuff]} { + [catch {gedCmd get_type $hname} stuff]} { $itk_component(objEditToolbar) itemconfigure next \ -state disabled return } - if {[catch {dbCmd attr get $hname next} next]} { + if {[catch {gedCmd attr get $hname next} next]} { set next "" } if {$next == "" || - [catch {dbCmd get_type $next} stuff]} { + [catch {gedCmd get_type $next} stuff]} { $itk_component(objEditToolbar) itemconfigure next \ -state disabled } else { @@ -4551,88 +4551,88 @@ ::itcl::body Archer::updateObjHistory {obj} { if {$obj == "" || - [catch {dbCmd get_type $obj} stuff]} { + [catch {gedCmd get_type $obj} stuff]} { return } - dbCmd make_name -s 1 - set new_hname [dbCmd make_name $obj.version] - dbCmd cp $obj $new_hname - dbCmd hide $new_hname + gedCmd make_name -s 1 + set new_hname [gedCmd make_name $obj.version] + gedCmd cp $obj $new_hname + gedCmd hide $new_hname - if {[catch {dbCmd attr get $obj history} old_hname]} { + if {[catch {gedCmd attr get $obj history} old_hname]} { set old_hname "" } if {$old_hname != "" && - ![catch {dbCmd get_type $old_hname} stuff]} { + ![catch {gedCmd get_type $old_hname} stuff]} { # Insert into the history list - if {[catch {dbCmd attr get $old_hname next} next]} { + if {[catch {gedCmd attr get $old_hname next} next]} { set next "" } # Delete the future if {$next != "" && - ![catch {dbCmd get_type $next} stuff]} { + ![catch {gedCmd get_type $next} stuff]} { while {$next != ""} { set deadObj $next - if {[catch {dbCmd attr get $next next} next]} { + if {[catch {gedCmd attr get $next next} next]} { set next "" - } elseif {[catch {dbCmd get_type $next} stuff]} { + } elseif {[catch {gedCmd get_type $next} stuff]} { set next "" } - dbCmd kill $deadObj + gedCmd kill $deadObj } } - dbCmd attr set $old_hname next $new_hname - dbCmd attr set $new_hname previous $old_hname + gedCmd attr set $old_hname next $new_hname + gedCmd attr set $new_hname previous $old_hname } else { # Initialize the history list # Note - we shouldn't get here - dbCmd attr set $new_hname previous "" - dbCmd attr set $new_hname history $new_hname + gedCmd attr set $new_hname previous "" + gedCmd attr set $new_hname history $new_hname } - dbCmd attr set $new_hname next "" - dbCmd attr set $new_hname history $new_hname - dbCmd attr set $obj history $new_hname + gedCmd attr set $new_hname next "" + gedCmd attr set $new_hname history $new_hname + gedCmd attr set $obj history $new_hname updatePrevObjButton $obj updateNextObjButton $obj } ::itcl::body Archer::updatePrevObjButton {obj} { if {$obj == "" || - [catch {dbCmd get_type $obj} stuff]} { + [catch {gedCmd get_type $obj} stuff]} { $itk_component(objEditToolbar) itemconfigure prev \ -state disabled return } - if {[catch {dbCmd attr get $obj history} hname]} { + if {[catch {gedCmd attr get $obj history} hname]} { set hname "" } if {$hname == "" || - [catch {dbCmd get_type $hname} stuff]} { + [catch {gedCmd get_type $hname} stuff]} { $itk_component(objEditToolbar) itemconfigure prev \ -state disabled return } - if {[catch {dbCmd attr get $hname previous} previous]} { + if {[catch {gedCmd attr get $hname previous} previous]} { set previous "" } if {$previous == "" || - [catch {dbCmd get_type $previous} stuff]} { + [catch {gedCmd get_type $previous} stuff]} { $itk_component(objEditToolbar) itemconfigure prev \ -state disabled } else { @@ -4646,7 +4646,7 @@ ################################### Object Edit via Mouse Section ################################### ::itcl::body Archer::beginObjRotate {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } @@ -4659,14 +4659,14 @@ } foreach dname {ul ur ll lr} { - set win [$itk_component(mged) component $dname] - bind $win <1> "$itk_component(mged) pane_orotate_mode $dname $obj %x %y; break" + set win [$itk_component(ged) component $dname] + bind $win <1> "$itk_component(ged) pane_orotate_mode $dname $obj %x %y; break" bind $win <ButtonRelease-1> "[::itcl::code $this endObjRotate $dname $obj]; break" } } ::itcl::body Archer::beginObjScale {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } @@ -4679,14 +4679,14 @@ } foreach dname {ul ur ll lr} { - set win [$itk_component(mged) component $dname] - bind $win <1> "$itk_component(mged) pane_oscale_mode $dname $obj %x %y; break" + set win [$itk_component(ged) component $dname] + bind $win <1> "$itk_component(ged) pane_oscale_mode $dname $obj %x %y; break" bind $win <ButtonRelease-1> "[::itcl::code $this endObjScale $dname $obj]; break" } } ::itcl::body Archer::beginObjTranslate {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } @@ -4699,14 +4699,14 @@ } foreach dname {ul ur ll lr} { - set win [$itk_component(mged) component $dname] - bind $win <1> "$itk_component(mged) pane_otranslate_mode $dname $obj %x %y; break" + set win [$itk_component(ged) component $dname] + bind $win <1> "$itk_component(ged) pane_otranslate_mode $dname $obj %x %y; break" bind $win <ButtonRelease-1> "[::itcl::code $this endObjTranslate $dname $obj]; break" } } ::itcl::body Archer::beginObjCenter {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } @@ -4719,89 +4719,89 @@ } foreach dname {ul ur ll lr} { - set win [$itk_component(mged) component $dname] + set win [$itk_component(ged) component $dname] bind $win <1> "[::itcl::code $this handleObjCenter $obj %x %y]; break" bind $win <ButtonRelease-1> "[::itcl::code $this endObjCenter $dname $obj]; break" } } ::itcl::body Archer::endObjCenter {dname obj} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } - $itk_component(mged) pane_idle_mode $dname + $itk_component(ged) pane_idle_mode $dname set mNeedSave 1 updateSaveMode - set center [$itk_component(mged) ocenter $obj] + set center [$itk_component(ged) ocenter $obj] addHistory "ocenter $center" } ::itcl::body Archer::endObjRotate {dname obj} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } - $itk_component(mged) pane_idle_mode $dname + $itk_component(ged) pane_idle_mode $dname set mNeedSave 1 updateSaveMode #XXX Need code to track overall transformation - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { #addHistory "orotate obj rx ry rz" } } ::itcl::body Archer::endObjScale {dname obj} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } - $itk_component(mged) pane_idle_mode $dname + $itk_component(ged) pane_idle_mode $dname set mNeedSave 1 updateSaveMode #XXX Need code to track overall transformation - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { #addHistory "oscale obj sf" } } ::itcl::body Archer::endObjTranslate {dname obj} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } - $itk_component(mged) pane_idle_mode $dname + $itk_component(ged) pane_idle_mode $dname set mNeedSave 1 updateSaveMode #XXX Need code to track overall transformation - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { #addHistory "otranslate obj dx dy dz" } } ::itcl::body Archer::handleObjCenter {obj x y} { - if {[info exists itk_component(mged)]} { - set ocenter [dbCmd ocenter $obj] + if {[info exists itk_component(ged)]} { + set ocenter [gedCmd ocenter $obj] } else { set savePwd [pwd] cd / - set ocenter [dbCmd ocenter $obj] + set ocenter [gedCmd ocenter $obj] } - set ocenter [vscale $ocenter [dbCmd local2base]] - set ovcenter [eval dbCmd m2v_point $ocenter] + set ocenter [vscale $ocenter [gedCmd local2base]] + set ovcenter [eval gedCmd m2v_point $ocenter] # This is the updated view center (i.e. we keep the original view Z) - set vcenter [dbCmd screen2view $x $y] + set vcenter [gedCmd screen2view $x $y] set vcenter [list [lindex $vcenter 0] [lindex $vcenter 1] [lindex $ovcenter 2]] - set ocenter [vscale [eval dbCmd v2m_point $vcenter] [dbCmd base2local]] + set ocenter [vscale [eval gedCmd v2m_point $vcenter] [gedCmd base2local]] - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { eval archerWrapper ocenter 0 0 0 0 $obj $ocenter } else { eval archerWrapper ocenter 0 0 0 0 $obj $ocenter @@ -4812,7 +4812,7 @@ } ::itcl::body Archer::handleObjRotate {obj rx ry rz kx ky kz} { - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { eval archerWrapper orotate 0 0 1 0 $obj $rx $ry $rz } else { set savePwd [pwd] @@ -4825,7 +4825,7 @@ } ::itcl::body Archer::handleObjScale {obj sf kx ky kz} { - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { eval archerWrapper oscale 0 0 1 0 $obj $sf } else { set savePwd [pwd] @@ -4838,7 +4838,7 @@ } ::itcl::body Archer::handleObjTranslate {obj dx dy dz} { - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { eval archerWrapper otranslate 0 0 1 0 $obj $dx $dy $dz } else { set savePwd [pwd] @@ -5225,7 +5225,7 @@ $itk_component(arb4View) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5240,7 +5240,7 @@ $itk_component(arb5View) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5255,7 +5255,7 @@ $itk_component(arb6View) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5270,7 +5270,7 @@ $itk_component(arb7View) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5285,7 +5285,7 @@ $itk_component(arb8View) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5303,7 +5303,7 @@ $itk_component(botView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5318,7 +5318,7 @@ $itk_component(combView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5330,7 +5330,7 @@ } ::itcl::body Archer::initDbAttrView {name} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } @@ -5375,7 +5375,7 @@ $itk_component(ehyView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5390,7 +5390,7 @@ $itk_component(ellView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5405,7 +5405,7 @@ $itk_component(epaView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5420,7 +5420,7 @@ $itk_component(etoView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5435,7 +5435,7 @@ $itk_component(extrudeView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5450,7 +5450,7 @@ $itk_component(gripView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5465,7 +5465,7 @@ $itk_component(halfView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5495,7 +5495,7 @@ } ::itcl::body Archer::initObjAttrView {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } @@ -5530,7 +5530,7 @@ $itk_component(objAttrText) configure \ -state normal $itk_component(objAttrText) delete 1.0 end - set odata [$itk_component(mged) l $mSelectedObj] + set odata [$itk_component(ged) l $mSelectedObj] $itk_component(objAttrText) insert end "$odata" # The scrollmode options are needed so that the @@ -5546,7 +5546,7 @@ } ::itcl::body Archer::initObjEdit {obj} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } @@ -5565,7 +5565,7 @@ } ::itcl::body Archer::initObjEditView {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return } @@ -5604,10 +5604,10 @@ set mWizardState "" } - if {[catch {$itk_component(mged) attr get $mSelectedObj WizardTop} mWizardTop]} { + if {[catch {$itk_component(ged) attr get $mSelectedObj WizardTop} mWizardTop]} { set mWizardTop "" } else { - if {[catch {$itk_component(mged) attr get $mWizardTop WizardClass} mWizardClass]} { + if {[catch {$itk_component(ged) attr get $mWizardTop WizardClass} mWizardClass]} { set mWizardClass "" } } @@ -5621,7 +5621,7 @@ initEdit - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { pack $itk_component(objViewToolbar) -expand no -fill x -anchor n pack $itk_component(objEditView) -expand yes -fill both -anchor n pack $itk_component(objEditToolbarF) -expand no -fill x -anchor s @@ -5638,11 +5638,11 @@ ::itcl::body Archer::initObjHistory {obj} { if {$obj == "" || - [catch {dbCmd get_type $obj} stuff]} { + [catch {gedCmd get_type $obj} stuff]} { return } - if {[catch {dbCmd attr get $obj history} hname]} { + if {[catch {gedCmd attr get $obj history} hname]} { set hname "" } @@ -5650,17 +5650,17 @@ # the link to it is broken, so create # a new one. if {$hname == "" || - [catch {dbCmd get_type $hname} stuff]} { - dbCmd make_name -s 1 - set hname [dbCmd make_name $obj.version] - #dbCmd attr set $obj history $hname + [catch {gedCmd get_type $hname} stuff]} { + gedCmd make_name -s 1 + set hname [gedCmd make_name $obj.version] + #gedCmd attr set $obj history $hname - dbCmd cp $obj $hname - dbCmd hide $hname - dbCmd attr set $hname previous "" - dbCmd attr set $hname next "" - dbCmd attr set $hname history $hname - dbCmd attr set $obj history $hname + gedCmd cp $obj $hname + gedCmd hide $hname + gedCmd attr set $hname previous "" + gedCmd attr set $hname next "" + gedCmd attr set $hname history $hname + gedCmd attr set $obj history $hname } } @@ -5673,7 +5673,7 @@ ::itcl::body Archer::initObjWizard {obj wizardLoaded} { set parent [$itk_component(vpane) childsite attrView] - if {[catch {$itk_component(mged) attr get $mWizardTop WizardState} mWizardState]} { + if {[catch {$itk_component(ged) attr get $mWizardTop WizardState} mWizardState]} { set wizardStateFound 0 } else { set wizardStateFound 1 @@ -5692,10 +5692,10 @@ initNoWizard $parent $msg } else { - if {[catch {$itk_component(mged) attr get $mWizardTop WizardOrigin} wizOrigin]} { - set wizOrigin [dbCmd center] - set wizUnits [dbCmd units -s] - } elseif {[catch {$itk_component(mged) attr get $mWizardTop WizardUnits} wizUnits]} { + if {[catch {$itk_component(ged) attr get $mWizardTop WizardOrigin} wizOrigin]} { + set wizOrigin [gedCmd center] + set wizUnits [gedCmd units -s] + } elseif {[catch {$itk_component(ged) attr get $mWizardTop WizardUnits} wizUnits]} { set wizUnits mm } @@ -5731,7 +5731,7 @@ $itk_component(partView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5749,7 +5749,7 @@ $itk_component(pipeView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5764,7 +5764,7 @@ $itk_component(rhcView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5779,7 +5779,7 @@ $itk_component(rpcView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5797,7 +5797,7 @@ $itk_component(sketchView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5812,7 +5812,7 @@ $itk_component(sphView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5827,7 +5827,7 @@ $itk_component(tgcView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5842,7 +5842,7 @@ $itk_component(torView) configure \ -geometryObject $mSelectedObj \ -geometryChangedCallback [::itcl::code $this updateObjEditView] \ - -mged $itk_component(mged) \ + -mged $itk_component(ged) \ -labelFont $mFontText \ -boldLabelFont $mFontTextBold \ -entryFont $mFontText @@ -5854,15 +5854,15 @@ } ::itcl::body Archer::updateObjEdit {updateObj needInit needSave} { - set renderData [dbCmd how -b $mSelectedObjPath] + set renderData [gedCmd how -b $mSelectedObjPath] set renderMode [lindex $renderData 0] set renderTrans [lindex $renderData 1] - dbCmd configure -autoViewEnable 0 - dbCmd kill $mSelectedObj - dbCmd cp $updateObj $mSelectedObj - dbCmd unhide $mSelectedObj - dbCmd attr rm $mSelectedObj previous - dbCmd attr rm $mSelectedObj next + gedCmd configure -autoViewEnable 0 + gedCmd kill $mSelectedObj + gedCmd cp $updateObj $mSelectedObj + gedCmd unhide $mSelectedObj + gedCmd attr rm $mSelectedObj previous + gedCmd attr rm $mSelectedObj next if {$needInit} { initEdit @@ -5874,7 +5874,7 @@ } render $mSelectedObjPath $renderMode $renderTrans 0 - dbCmd configure -autoViewEnable 1 + gedCmd configure -autoViewEnable 1 } ::itcl::body Archer::updateObjEditView {} { @@ -6021,19 +6021,19 @@ } ::itcl::body Archer::invokeWizardDialog {class action wname} { - dbCmd make_name -s 1 + gedCmd make_name -s 1 set name [string tolower $class] set name [regsub wizard $name ""] #XXX Temporary special case for TankWizardI #if {$class == "TankWizardI"} { #set name "simpleTank" #} else { - #set name [dbCmd make_name $name] + #set name [gedCmd make_name $name] #} - set name [dbCmd make_name $name] + set name [gedCmd make_name $name] set oname $name - set origin [dbCmd center] - set units [dbCmd units -s] + set origin [gedCmd center] + set units [gedCmd units -s] set dialog $itk_interior.wizardDialog ::iwidgets::dialog $dialog \ @@ -6089,18 +6089,18 @@ if {[namespace tail [$wizard info class]] != "TankWizardI"} { # Here we have the case where the name is being # changed to an object that already exists. - if {$oname != $name && ![catch {dbCmd get_type $name} stuff]} { + if {$oname != $name && ![catch {gedCmd get_type $name} stuff]} { ::sdialogs::Stddlgs::errordlg "User Error" \ "$name already exists!" return } } - dbCmd erase $oname - dbCmd killtree $oname - dbCmd configure -autoViewEnable 0 + gedCmd erase $oname + gedCmd killtree $oname + gedCmd configure -autoViewEnable 0 set obj [$wizard $action] - dbCmd configure -autoViewEnable 1 + gedCmd configure -autoViewEnable 1 set mNeedSave 1 updateSaveMode @@ -6118,12 +6118,12 @@ } ::itcl::body Archer::pluginGetMinAllowableRid {} { - if {![info exists itk_component(mged)]} { + if {![info exists itk_component(ged)]} { return 0 } set maxRid 0 - foreach {rid rname} [$itk_component(mged) rmap] { + foreach {rid rname} [$itk_component(ged) rmap] { if {$maxRid < $rid} { set maxRid $rid } @@ -6198,7 +6198,7 @@ } set minorType [$plugin get -minorType] - if {[info exists itk_component(mged)] && + if {[info exists itk_component(ged)] && ($minorType == $pluginMinorTypeAll || $minorType == $pluginMinorTypeMged)} { lappend uplugins $plugin @@ -6250,7 +6250,7 @@ set minorType [$plugin get -minorType] - if {[info exists itk_component(mged)] && + if {[info exists itk_component(ged)] && ($minorType == $pluginMinorTypeAll || $minorType == $pluginMinorTypeMged)} { lappend wplugins $plugin @@ -6307,11 +6307,11 @@ backgroundColor [lindex $mBackground 0] \ [lindex $mBackground 1] \ [lindex $mBackground 2] - dbCmd configure -measuringStickColor $mMeasuringStickColor - dbCmd configure -measuringStickMode $mMeasuringStickMode - dbCmd configure -primitiveLabelColor $mPrimitiveLabelColor - dbCmd configure -scaleColor $mScaleColor - dbCmd configure -viewingParamsColor $mViewingParamsColor + gedCmd configure -measuringStickColor $mMeasuringStickColor + gedCmd configure -measuringStickMode $mMeasuringStickMode + gedCmd configure -primitiveLabelColor $mPrimitiveLabelColor + gedCmd configure -scaleColor $mScaleColor + gedCmd configure -viewingParamsColor $mViewingParamsColor } @@ -6354,17 +6354,17 @@ if {$mPrimitiveLabelColor != $mPrimitiveLabelColorPref} { set mPrimitiveLabelColor $mPrimitiveLabelColorPref -# setColorOption dbCmd -primitiveLabelColor $mPrimitiveLabelColor +# setColorOption gedCmd -primitiveLabelColor $mPrimitiveLabelColor } if {$mViewingParamsColor != $mViewingParamsColorPref} { set mViewingParamsColor $mViewingParamsColorPref -# setColorOption dbCmd -viewingParamsColor $mViewingParamsColor +# setColorOption gedCmd -viewingParamsColor $mViewingParamsColor } if {$mScaleColor != $mScaleColorPref} { set mScaleColor $mScaleColorPref -# setColorOption dbCmd -scaleColor $mScaleColor +# setColorOption gedCmd -scaleColor $mScaleColor } if {$mMeasuringStickColor != $mMeasuringStickColorPref} { @@ -6402,43 +6402,43 @@ ::itcl::body Archer::applyModelAxesPreferences {} { switch -- $mModelAxesSize { "Small" { - dbCmd configure -modelAxesSize 0.2 + gedCmd configure -modelAxesSize 0.2 } "Medium" { - dbCmd configure -modelAxesSize 0.4 + gedCmd configure -modelAxesSize 0.4 } "Large" { - dbCmd configure -modelAxesSize 0.8 + gedCmd configure -modelAxesSize 0.8 } "X-Large" { - dbCmd configure -modelAxesSize 1.6 + gedCmd configure -modelAxesSize 1.6 } "View (1x)" { - dbCmd configure -modelAxesSize 2.0 + gedCmd configure -modelAxesSize 2.0 } "View (2x)" { - dbCmd configure -modelAxesSize 4.0 + gedCmd configure -modelAxesSize 4.0 } "View (4x)" { - dbCmd configure -modelAxesSize 8.0 + gedCmd configure -modelAxesSize 8.0 } "View (8x)" { - dbCmd configure -modelAxesSize 16.0 + gedCmd configure -modelAxesSize 16.0 } } - dbCmd configure -modelAxesPosition $mModelAxesPosition - dbCmd configure -modelAxesLineWidth $mModelAxesLineWidth - dbCmd configure -modelAxesColor $mModelAxesColor - dbCmd configure -modelAxesLabelColor $mModelAxesLabelColor + gedCmd configure -modelAxesPosition $mModelAxesPosition + gedCmd configure -modelAxesLineWidth $mModelAxesLineWidth + gedCmd configure -modelAxesColor $mModelAxesColor + gedCmd configure -modelAxesLabelColor $mModelAxesLabelColor - dbCmd configure -modelAxesTickInterval $mModelAxesTickInterval - dbCmd configure -modelAxesTicksPerMajor $mModelAxesTicksPerMajor - dbCmd configure -modelAxesTickThreshold $mModelAxesTickThreshold - dbCmd configure -modelAxesTickLength $mModelAxesTickLength - dbCmd configure -modelAxesTickMajorLength $mModelAxesTickMajorLength - dbCmd configure -modelAxesTickColor $mModelAxesTickColor - dbCmd configure -modelAxesTickMajorColor $mModelAxesTickMajorColor + gedCmd configure -modelAxesTickInterval $mModelAxesTickInterval + gedCmd configure -modelAxesTicksPerMajor $mModelAxesTicksPerMajor + gedCmd configure -modelAxesTickThreshold $mModelAxesTickThreshold + gedCmd configure -modelAxesTickLength $mModelAxesTickLength + gedCmd configure -modelAxesTickMajorLength $mModelAxesTickMajorLength + gedCmd configure -modelAxesTickColor $mModelAxesTickColor + gedCmd configure -modelAxesTickMajorColor $mModelAxesTickMajorColor } @@ -6446,31 +6446,31 @@ if {$mModelAxesSizePref != $mModelAxesSize} { set mModelAxesSize $mModelAxesSizePref - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { switch -- $mModelAxesSize { "Small" { - dbCmd configure -modelAxesSize 0.2 + gedCmd configure -modelAxesSize 0.2 } "Medium" { - dbCmd configure -modelAxesSize 0.4 + gedCmd configure -modelAxesSize 0.4 } "Large" { - dbCmd configure -modelAxesSize 0.8 + gedCmd configure -modelAxesSize 0.8 } "X-Large" { - dbCmd configure -modelAxesSize 1.6 + gedCmd configure -modelAxesSize 1.6 } "View (1x)" { - dbCmd configure -modelAxesSize 2.0 + gedCmd configure -modelAxesSize 2.0 } "View (2x)" { - dbCmd configure -modelAxesSize 4.0 + gedCmd configure -modelAxesSize 4.0 } "View (4x)" { - dbCmd configure -modelAxesSize 8.0 + gedCmd configure -modelAxesSize 8.0 } "View (8x)" { - dbCmd configure -modelAxesSize 16.0 + gedCmd configure -modelAxesSize 16.0 } } } @@ -6485,88 +6485,88 @@ set mModelAxesPosition \ "$mModelAxesPositionXPref $mModelAxesPositionYPref $mModelAxesPositionZPref" - if {[info exists itk_component(mged)]} { - dbCmd configure -modelAxesPosition $mModelAxesPosition + if {[info exists itk_component(ged)]} { + gedCmd configure -modelAxesPosition $mModelAxesPosition } } if {$mModelAxesLineWidthPref != $mModelAxesLineWidth} { set mModelAxesLineWidth $mModelAxesLineWidthPref - if {[info exists itk_component(mged)]} { - dbCmd configure -modelAxesLineWidth $mModelAxesLineWidth + if {[info exists itk_component(ged)]} { + gedCmd configure -modelAxesLineWidth $mModelAxesLineWidth } } if {$mModelAxesColorPref != $mModelAxesColor} { set mModelAxesColor $mModelAxesColorPref -# if {[info exists itk_component(mged)]} { -# setColorOption dbCmd -modelAxesColor $mModelAxesColor -modelAxesTripleColor +# if {[info exists itk_component(ged)]} { +# setColorOption gedCmd -modelAxesColor $mModelAxesColor -modelAxesTripleColor # } } if {$mModelAxesLabelColorPref != $mModelAxesLabelColor} { set mModelAxesLabelColor $mModelAxesLabelColorPref -# if {[info exists itk_component(mged)]} { -# setColorOption dbCmd -modelAxesLabelColor $mModelAxesLabelColor +# if {[info exists itk_component(ged)]} { +# setColorOption gedCmd -modelAxesLabelColor $mModelAxesLabelColor # } } if {$mModelAxesTickIntervalPref != $mModelAxesTickInterval} { set mModelAxesTickInterval $mModelAxesTickIntervalPref - if {[info exists itk_component(mged)]} { - dbCmd configure -modelAxesTickInterval $mModelAxesTickInterval + if {[info exists itk_component(ged)]} { + gedCmd configure -modelAxesTickInterval $mModelAxesTickInterval } } if {$mModelAxesTicksPerMajorPref != $mModelAxesTicksPerMajor} { set mModelAxesTicksPerMajor $mModelAxesTicksPerMajorPref - if {[info exists itk_component(mged)]} { - dbCmd configure -modelAxesTicksPerMajor $mModelAxesTicksPerMajor + if {[info exists itk_component(ged)]} { + gedCmd configure -modelAxesTicksPerMajor $mModelAxesTicksPerMajor } } if {$mModelAxesTickThresholdPref != $mModelAxesTickThreshold} { set mModelAxesTickThreshold $mModelAxesTickThresholdPref - if {[info exists itk_component(mged)]} { - dbCmd configure -modelAxesTickThreshold $mModelAxesTickThreshold + if {[info exists itk_component(ged)]} { + gedCmd configure -modelAxesTickThreshold $mModelAxesTickThreshold } } if {$mModelAxesTickLengthPref != $mModelAxesTickLength} { set mModelAxesTickLength $mModelAxesTickLengthPref - if {[info exists itk_component(mged)]} { - dbCmd configure -modelAxesTickLength $mModelAxesTickLength + if {[info exists itk_component(ged)]} { + gedCmd configure -modelAxesTickLength $mModelAxesTickLength } } if {$mModelAxesTickMajorLengthPref != $mModelAxesTickMajorLength} { set mModelAxesTickMajorLength $mModelAxesTickMajorLengthPref - if {[info exists itk_component(mged)]} { - dbCmd configure -modelAxesTickMajorLength $mModelAxesTickMajorLength + if {[info exists itk_component(ged)]} { + gedCmd configure -modelAxesTickMajorLength $mModelAxesTickMajorLength } } if {$mModelAxesTickColorPref != $mModelAxesTickColor} { set mModelAxesTickColor $mModelAxesTickColorPref -# if {[info exists itk_component(mged)]} { -# setColorOption dbCmd -modelAxesTickColor $mModelAxesTickColor +# if {[info exists itk_component(ged)]} { +# setColorOption gedCmd -modelAxesTickColor $mModelAxesTickColor # } } if {$mModelAxesTickMajorColorPref != $mModelAxesTickMajorColor} { set mModelAxesTickMajorColor $mModelAxesTickMajorColorPref -# if {[info exists itk_component(mged)]} { -# setColorOption dbCmd -modelAxesTickMajorColor $mModelAxesTickMajorColor +# if {[info exists itk_component(ged)]} { +# setColorOption gedCmd -modelAxesTickMajorColor $mModelAxesTickMajorColor # } } } @@ -6596,50 +6596,50 @@ switch -- $mViewAxesSize { "Small" { set offset 0.85 - dbCmd configure -viewAxesSize 0.2 + gedCmd configure -viewAxesSize 0.2 } "Medium" { set offset 0.75 - dbCmd configure -viewAxesSize 0.4 + gedCmd configure -viewAxesSize 0.4 } "Large" { set offset 0.55 - dbCmd configure -viewAxesSize 0.8 + gedCmd configure -viewAxesSize 0.8 } "X-Large" { set offset 0.0 - dbCmd configure -viewAxesSize 1.6 + gedCmd configure -viewAxesSize 1.6 } } switch -- $mViewAxesPosition { default - "Center" { - dbCmd configure -viewAxesPosition {0 0 0} + gedCmd configure -viewAxesPosition {0 0 0} } "Upper Left" { - dbCmd configure -viewAxesPosition "-$offset $offset 0" + gedCmd configure -viewAxesPosition "-$offset $offset 0" } "Upper Right" { - dbCmd configure -viewAxesPosition "$offset $offset 0" + gedCmd configure -viewAxesPosition "$offset $offset 0" } "Lower Left" { - dbCmd configure -viewAxesPosition "-$offset -$offset 0" + gedCmd configure -viewAxesPosition "-$offset -$offset 0" } "Lower Right" { - dbCmd configure -viewAxesPosition "$offset -$offset 0" + gedCmd configure -viewAxesPosition "$offset -$offset 0" } } if {$mViewAxesColor == "Triple"} { - dbCmd configure -viewAxesTripleColor 1 + gedCmd configure -viewAxesTripleColor 1 } else { - dbCmd configure -viewAxesTripleColor 0 - dbCmd configure -viewAxesColor $mViewAxesColor + gedCmd configure -viewAxesTripleColor 0 + gedCmd configure -viewAxesColor $mViewAxesColor } - dbCmd configure -viewAxesLineWidth $mViewAxesLineWidth - dbCmd configure -viewAxesLabelColor $mViewAxesLabelColor + gedCmd configure -viewAxesLineWidth $mViewAxesLineWidth + gedCmd configure -viewAxesLabelColor $mViewAxesLabelColor } @@ -6649,25 +6649,25 @@ if {$mViewAxesSizePref != $mViewAxesSize} { set mViewAxesSize $mViewAxesSizePref - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { # sanity set offset 0.0 switch -- $mViewAxesSize { "Small" { set offset 0.85 - dbCmd configure -viewAxesSize 0.2 + gedCmd configure -viewAxesSize 0.2 } "Medium" { set offset 0.75 - dbCmd configure -viewAxesSize 0.4 + gedCmd configure -viewAxesSize 0.4 } "Large" { set offset 0.55 - dbCmd configure -viewAxesSize 0.8 + gedCmd configure -viewAxesSize 0.8 } "X-Large" { set offset 0.0 - dbCmd configure -viewAxesSize 1.6 + gedCmd configure -viewAxesSize 1.6 } } } @@ -6675,23 +6675,23 @@ set positionNotSet 0 set mViewAxesPosition $mViewAxesPositionPref - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { switch -- $mViewAxesPosition { default - "Center" { - dbCmd configure -viewAxesPosition {0 0 0} + gedCmd configure -viewAxesPosition {0 0 0} } "Upper Left" { - dbCmd configure -viewAxesPosition "-$offset $offset 0" + gedCmd configure -viewAxesPosition "-$offset $offset 0" } "Upper Right" { - dbCmd configure -viewAxesPosition "$offset $offset 0" + gedCmd configure -viewAxesPosition "$offset $offset 0" } "Lower Left" { - dbCmd configure -viewAxesPosition "-$offset -$offset 0" + gedCmd configure -viewAxesPosition "-$offset -$offset 0" } "Lower Right" { - dbCmd configure -viewAxesPosition "$offset -$offset 0" + gedCmd configure -viewAxesPosition "$offset -$offset 0" } } } @@ -6701,7 +6701,7 @@ $mViewAxesPositionPref != $mViewAxesPosition} { set mViewAxesPosition $mViewAxesPositionPref - if {[info exists itk_component(mged)]} { + if {[info exists itk_component(ged)]} { # sanity set offset 0.0 switch -- $mViewAxesSize { @@ -6722,19 +6722,19 @@ switch -- $mViewAxesPosition { default - "Center" { - dbCmd configure -viewAxesPosition {0 0 0} + gedCmd configure -viewAxesPosition {0 0 0} } "Upper Left" { - dbCmd configure -viewAxesPosition "-$offset $offset 0" + gedCmd configure -viewAxesPosition "-$offset $offset 0" } "Upper Right" { - dbCmd configure -viewAxesPosition "$offset $offset 0" + gedCmd configure -viewAxesPosition "$offset $offset 0" } "Lower Left" { - dbCmd configure -viewAxesPosition "-$offset -$offset 0" + gedCmd configure -viewAxesPosition "-$offset -$offset 0" } "Lower Right" { - dbCmd configure -viewAxesPosition "$offset -$offset 0" + gedCmd configure -viewAxesPosition "$offset -$offset 0" } } } @@ -6743,24 +6743,24 @@ if {$mViewAxesLineWidthPref != $mViewAxesLineWidth} { set mViewAxesLineWidth $mViewAxesLineWidthPref - if {[info exists itk_component(mged)]} { - dbCmd configure -viewAxesLineWidth $mViewAxesLineWidth + if {[info exists itk_component(ged)]} { + gedCmd configure -viewAxesLineWidth $mViewAxesLineWidth } } if {$mViewAxesColorPref != $mViewAxesColor} { set mViewAxesColor $mViewAxesColorPref -# if {[info exists itk_component(mged)]} { -# setColorOption dbCmd -viewAxesColor $mViewAxesColor -viewAxesTripleColor +# if {[info exists itk_component(ged)]} { +# setColorOption gedCmd -viewAxesColor $mViewAxesColor -viewAxesTripleColor # } } if {$mViewAxesLabelColorPref != $mViewAxesLabelColor} { set mViewAxesLabelColor $mViewAxesLabelColorPref -# if {[info exists itk_component(mged)]} { -# setColorOption dbCmd -viewAxesLabelColor $mViewAxesLabelColor +# if {[info exists itk_component(ged)]} { +# setColorOption gedCmd -viewAxesLabelColor $mViewAxesLabelColor # } } } @@ -6846,9 +6846,9 @@ backgroundColor [lindex $mBackground 0] \ [lindex $mBackground 1] \ [lindex $mBackground 2] -# setColorOption dbCmd -primitiveLabelColor $mPrimitiveLabelColor -# setColorOption dbCmd -viewingParamsColor $mViewingParamsColor -# setColorOption dbCmd -scaleColor $mScaleColor +# setColorOption gedCmd -primitiveLabelColor $mPrimitiveLabelColor +# setColorOption gedCmd -viewingParamsColor $mViewingParamsColor +# setColorOption gedCmd -scaleColor $mScaleColor update setMode @@ -6941,104 +6941,104 @@ ################################### Primitive Creation Section ################################### ::itcl::body Archer::createObj {type} { - dbCmd make_name -s 1 + gedCmd make_name -s 1 switch -- $type { "arb4" { - set name [dbCmd make_name "arb4."] + set name [gedCmd make_name "arb4."] createArb4 $name } "arb5" { - set name [dbCmd make_name "arb5."] + set name [gedCmd make_name "arb5."] createArb5 $name } "arb6" { - set name [dbCmd make_name "arb6."] + set name [gedCmd make_name "arb6."] createArb6 $name } "arb7" { - set name [dbCmd make_name "arb7."] + set name [gedCmd make_name "arb7."] createArb7 $name } "arb8" { - set name [dbCmd make_name "arb8."] + set name [gedCmd make_name "arb8."] createArb8 $name } "bot" { #XXX Not ready yet return - set name [dbCmd make_name "bot."] + set name [gedCmd make_name "bot."] createBot $name } "comb" { - set name [dbCmd make_name "comb."] + set name [gedCmd make_name "comb."] createComb $name } "ehy" { - set name [dbCmd make_name "ehy."] + set name [gedCmd make_name "ehy."] createEhy $name } "ell" { - set name [dbCmd make_name "ell."] + set name [gedCmd make_name "ell."] createEll $name } "epa" { - set name [dbCmd make_name "epa."] + set name [gedCmd make_name "epa."] createEpa $name } "eto" { - set name [dbCmd make_name "eto."] + set name [gedCmd make_name "eto."] createEto $name } "extrude" { #XXX Not ready yet return - set name [dbCmd make_name "extrude."] + set name [gedCmd make_name "extrude."] createExtrude $name } "grip" { - set name [dbCmd make_name "grip."] + set name [gedCmd make_name "grip."] createGrip $name } "half" { - set name [dbCmd make_name "half."] + set name [gedCmd make_name "half."] createHalf $name } "part" { - set name [dbCmd make_name "part."] + set name [gedCmd make_name "part."] createPart $name } "pipe" { #XXX Not ready yet return - set name [dbCmd make_name "pipe."] + set name [gedCmd make_name "pipe."] createPipe $name } "rhc" { - set name [dbCmd make_name "rhc."] + set name [gedCmd make_name "rhc."] createRhc $name } "rpc" { - set name [dbCmd make_name "rpc."] + set name [gedCmd make_name "rpc."] createRpc $name } "sketch" { - set name [dbCmd make_name "sketch."] + set name [gedCmd make_name "sketch."] createSketch $name } "sph" { - set name [dbCmd make_name "sph."] + set name [gedCmd make_name "sph."] createSphere $name } "tgc" { - set name [dbCmd make_name "tgc."] + set name [gedCmd make_name "tgc."] createTgc $name } "tor" { - set name [dbCmd make_name "tor."] + set name [gedCmd make_name "tor."] createTorus $name } default { @@ -7053,9 +7053,9 @@ # make sure stuff is there to select $itk_component(tree) selection set $node - dbCmd configure -autoViewEnable 0 + gedCmd configure -autoViewEnable 0 dblClick [$itk_component(tree) selection get] - dbCmd configure -autoViewEnable 1 + gedCmd configure -autoViewEnable 1 set mNeedSave 1 ... [truncated message content] |
From: <bo...@us...> - 2008-12-10 22:22:10
|
Revision: 33345 http://brlcad.svn.sourceforge.net/brlcad/?rev=33345&view=rev Author: bob1961 Date: 2008-12-10 21:35:06 +0000 (Wed, 10 Dec 2008) Log Message: ----------- Make use of libged's tire functionality. Modified Paths: -------------- brlcad/trunk/src/libtclcad/ged_obj.c brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl brlcad/trunk/src/tclscripts/archer/CombEditFrame.tcl brlcad/trunk/src/tclscripts/lib/Ged.tcl Modified: brlcad/trunk/src/libtclcad/ged_obj.c =================================================================== --- brlcad/trunk/src/libtclcad/ged_obj.c 2008-12-10 21:33:24 UTC (rev 33344) +++ brlcad/trunk/src/libtclcad/ged_obj.c 2008-12-10 21:35:06 UTC (rev 33345) @@ -687,6 +687,7 @@ {"solids_on_ray", (char *)0, MAXARGS, go_pass_through_func, ged_solids_on_ray}, {"summary", (char *)0, MAXARGS, go_pass_through_func, ged_summary}, {"sync", (char *)0, MAXARGS, go_pass_through_func, ged_sync}, + {"tire", (char *)0, MAXARGS, go_pass_through_func, ged_tire}, {"title", (char *)0, MAXARGS, go_pass_through_func, ged_title}, {"tol", (char *)0, MAXARGS, go_pass_through_func, ged_tol}, {"tops", (char *)0, MAXARGS, go_pass_through_func, ged_tops}, Modified: brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl =================================================================== --- brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl 2008-12-10 21:33:24 UTC (rev 33344) +++ brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl 2008-12-10 21:35:06 UTC (rev 33345) @@ -188,6 +188,7 @@ method rotate_arb_face {args} method shader {args} method shells {args} + method tire {args} method title {args} method track {args} method unhide {args} @@ -400,7 +401,7 @@ mv mvall nmg_collapse nmg_simplify \ ocenter orotate oscale otranslate packTree prefix push \ put put_comb putmat pwd r rcodes red rfarb rm rmater \ - rotate_arb_face shader shells title track unhide units unpackTree \ + rotate_arb_face shader shells tire title track unhide units unpackTree \ vmake wmater xpush Z zap } variable mUnwrappedDbCommands {} @@ -4163,6 +4164,10 @@ eval gedWrapper shells 0 0 1 0 $args } +::itcl::body ArcherCore::tire {args} { + eval gedWrapper tire 0 0 1 1 $args +} + ::itcl::body ArcherCore::title {args} { if {$args == {}} { return [gedCmd title] Modified: brlcad/trunk/src/tclscripts/archer/CombEditFrame.tcl =================================================================== --- brlcad/trunk/src/tclscripts/archer/CombEditFrame.tcl 2008-12-10 21:33:24 UTC (rev 33344) +++ brlcad/trunk/src/tclscripts/archer/CombEditFrame.tcl 2008-12-10 21:35:06 UTC (rev 33345) @@ -118,7 +118,11 @@ # Initialize the variables containing the object's specification. # ::itcl::body CombEditFrame::initGeometry {gdata} { - set mRegion [bu_get_value_by_keyword region $gdata] + if {![catch {bu_get_value_by_keyword region $gdata} _region]} { + set mRegion $_region + } else { + set mRegion "" + } if {![catch {bu_get_value_by_keyword id $gdata} _id]} { set mId $_id Modified: brlcad/trunk/src/tclscripts/lib/Ged.tcl =================================================================== --- brlcad/trunk/src/tclscripts/lib/Ged.tcl 2008-12-10 21:33:24 UTC (rev 33344) +++ brlcad/trunk/src/tclscripts/lib/Ged.tcl 2008-12-10 21:35:06 UTC (rev 33345) @@ -393,6 +393,7 @@ method solids_on_ray {args} method summary {args} method sync {args} + method tire {args} method title {args} method tol {args} method tops {args} @@ -1929,6 +1930,10 @@ eval $mGed sync $args } +::itcl::body cadwidgets::Ged::tire {args} { + eval $mGed tire $args +} + ::itcl::body cadwidgets::Ged::title {args} { eval $mGed title $args } @@ -2868,6 +2873,7 @@ $help add solids {{file object(s)} {returns an ascii summary of solids}} $help add summary {{[s r g]} {count/list solid/reg/groups}} $help add sync {{} {sync the in memory database to disk}} + $help add tire {{[options] tire_top} {create a tire}} $help add title {{?string?} {print or change the title}} $help add tol {{"[abs #] [rel #] [norm #] [dist #] [perp #]"} {show/set tessellation and calculation tolerances}} $help add tops {{} {find all top level objects}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-12-23 19:29:31
|
Revision: 33432 http://brlcad.svn.sourceforge.net/brlcad/?rev=33432&view=rev Author: bob1961 Date: 2008-12-23 19:29:12 +0000 (Tue, 23 Dec 2008) Log Message: ----------- Moved some initialization code for "struct ged_view" from libtclcad/ged_obj.c to libged/ged.c Modified Paths: -------------- brlcad/trunk/src/libged/ged.c brlcad/trunk/src/libtclcad/ged_obj.c Modified: brlcad/trunk/src/libged/ged.c =================================================================== --- brlcad/trunk/src/libged/ged.c 2008-12-23 19:24:17 UTC (rev 33431) +++ brlcad/trunk/src/libged/ged.c 2008-12-23 19:29:12 UTC (rev 33432) @@ -190,6 +190,65 @@ gvp->gv_maxMouseDelta = 20; gvp->gv_rscale = 0.4; gvp->gv_sscale = 2.0; + + gvp->gv_adc.gas_a1 = 45.0; + gvp->gv_adc.gas_a2 = 45.0; + VSET(gvp->gv_adc.gas_line_color, 255, 255, 0); + VSET(gvp->gv_adc.gas_tick_color, 255, 255, 255); + + VSET(gvp->gv_grid.ggs_anchor, 0.0, 0.0, 0.0); + gvp->gv_grid.ggs_res_h = 1.0; + gvp->gv_grid.ggs_res_v = 1.0; + gvp->gv_grid.ggs_res_major_h = 5; + gvp->gv_grid.ggs_res_major_v = 5; + VSET(gvp->gv_grid.ggs_color, 255, 255, 255); + + gvp->gv_rect.grs_draw = 0; + gvp->gv_rect.grs_pos[0] = 128; + gvp->gv_rect.grs_pos[1] = 128; + gvp->gv_rect.grs_dim[0] = 256; + gvp->gv_rect.grs_dim[1] = 256; + VSET(gvp->gv_rect.grs_color, 255, 255, 255); + + gvp->gv_view_axes.gas_draw = 0; + VSET(gvp->gv_view_axes.gas_axes_pos, 0.85, -0.85, 0.0); + gvp->gv_view_axes.gas_axes_size = 0.2; + gvp->gv_view_axes.gas_line_width = 0; + gvp->gv_view_axes.gas_pos_only = 1; + VSET(gvp->gv_view_axes.gas_axes_color, 255, 255, 255); + VSET(gvp->gv_view_axes.gas_label_color, 255, 255, 0); + gvp->gv_view_axes.gas_triple_color = 1; + + gvp->gv_model_axes.gas_draw = 0; + VSET(gvp->gv_model_axes.gas_axes_pos, 0.0, 0.0, 0.0); + gvp->gv_model_axes.gas_axes_size = 2.0; + gvp->gv_model_axes.gas_line_width = 0; + gvp->gv_model_axes.gas_pos_only = 0; + VSET(gvp->gv_model_axes.gas_axes_color, 255, 255, 255); + VSET(gvp->gv_model_axes.gas_label_color, 255, 255, 0); + gvp->gv_model_axes.gas_triple_color = 0; + gvp->gv_model_axes.gas_tick_enabled = 1; + gvp->gv_model_axes.gas_tick_length = 4; + gvp->gv_model_axes.gas_tick_major_length = 8; + gvp->gv_model_axes.gas_tick_interval = 100; + gvp->gv_model_axes.gas_ticks_per_major = 10; + gvp->gv_model_axes.gas_tick_threshold = 8; + VSET(gvp->gv_model_axes.gas_tick_color, 255, 255, 0); + VSET(gvp->gv_model_axes.gas_tick_major_color, 255, 0, 0); + + gvp->gv_center_dot.gos_draw = 0; + VSET(gvp->gv_center_dot.gos_line_color, 255, 255, 0); + + gvp->gv_prim_labels.gos_draw = 0; + VSET(gvp->gv_prim_labels.gos_text_color, 255, 255, 0); + + gvp->gv_view_params.gos_draw = 0; + VSET(gvp->gv_view_params.gos_text_color, 255, 255, 0); + + gvp->gv_view_scale.gos_draw = 0; + VSET(gvp->gv_view_scale.gos_line_color, 255, 255, 0); + VSET(gvp->gv_view_scale.gos_text_color, 255, 255, 255); + ged_view_update(gvp); } Modified: brlcad/trunk/src/libtclcad/ged_obj.c =================================================================== --- brlcad/trunk/src/libtclcad/ged_obj.c 2008-12-23 19:24:17 UTC (rev 33431) +++ brlcad/trunk/src/libtclcad/ged_obj.c 2008-12-23 19:29:12 UTC (rev 33432) @@ -3603,65 +3603,6 @@ new_gdvp->gdv_fbs.fbs_clientData = new_gdvp; new_gdvp->gdv_fbs.fbs_interp = go_current_gop->go_interp; - new_gdvp->gdv_view->gv_adc.gas_a1 = 45.0; - new_gdvp->gdv_view->gv_adc.gas_a2 = 45.0; - VSET(new_gdvp->gdv_view->gv_adc.gas_line_color, 255, 255, 0); - VSET(new_gdvp->gdv_view->gv_adc.gas_tick_color, 255, 255, 255); - - VSET(new_gdvp->gdv_view->gv_grid.ggs_anchor, 0.0, 0.0, 0.0); - new_gdvp->gdv_view->gv_grid.ggs_res_h = 1.0; - new_gdvp->gdv_view->gv_grid.ggs_res_v = 1.0; - new_gdvp->gdv_view->gv_grid.ggs_res_major_h = 5; - new_gdvp->gdv_view->gv_grid.ggs_res_major_v = 5; - VSET(new_gdvp->gdv_view->gv_grid.ggs_color, 255, 255, 255); - - new_gdvp->gdv_view->gv_rect.grs_draw = 0; - new_gdvp->gdv_view->gv_rect.grs_pos[0] = 128; - new_gdvp->gdv_view->gv_rect.grs_pos[1] = 128; - new_gdvp->gdv_view->gv_rect.grs_dim[0] = 256; - new_gdvp->gdv_view->gv_rect.grs_dim[1] = 256; - VSET(new_gdvp->gdv_view->gv_rect.grs_color, 255, 255, 255); - - new_gdvp->gdv_view->gv_view_axes.gas_draw = 0; - VSET(new_gdvp->gdv_view->gv_view_axes.gas_axes_pos, 0.85, -0.85, 0.0); - new_gdvp->gdv_view->gv_view_axes.gas_axes_size = 0.2; - new_gdvp->gdv_view->gv_view_axes.gas_line_width = 0; - new_gdvp->gdv_view->gv_view_axes.gas_pos_only = 1; - VSET(new_gdvp->gdv_view->gv_view_axes.gas_axes_color, 255, 255, 255); - VSET(new_gdvp->gdv_view->gv_view_axes.gas_label_color, 255, 255, 0); - new_gdvp->gdv_view->gv_view_axes.gas_triple_color = 1; - - new_gdvp->gdv_view->gv_model_axes.gas_draw = 0; - VSET(new_gdvp->gdv_view->gv_model_axes.gas_axes_pos, 0.0, 0.0, 0.0); - new_gdvp->gdv_view->gv_model_axes.gas_axes_size = 2.0; - new_gdvp->gdv_view->gv_model_axes.gas_line_width = 0; - new_gdvp->gdv_view->gv_model_axes.gas_pos_only = 0; - VSET(new_gdvp->gdv_view->gv_model_axes.gas_axes_color, 255, 255, 255); - VSET(new_gdvp->gdv_view->gv_model_axes.gas_label_color, 255, 255, 0); - new_gdvp->gdv_view->gv_model_axes.gas_triple_color = 0; - new_gdvp->gdv_view->gv_model_axes.gas_tick_enabled = 1; - new_gdvp->gdv_view->gv_model_axes.gas_tick_length = 4; - new_gdvp->gdv_view->gv_model_axes.gas_tick_major_length = 8; - new_gdvp->gdv_view->gv_model_axes.gas_tick_interval = 100; - new_gdvp->gdv_view->gv_model_axes.gas_ticks_per_major = 10; - new_gdvp->gdv_view->gv_model_axes.gas_tick_threshold = 8; - VSET(new_gdvp->gdv_view->gv_model_axes.gas_tick_color, 255, 255, 0); - VSET(new_gdvp->gdv_view->gv_model_axes.gas_tick_major_color, 255, 0, 0); - - new_gdvp->gdv_view->gv_center_dot.gos_draw = 0; - VSET(new_gdvp->gdv_view->gv_center_dot.gos_line_color, 255, 255, 0); - - new_gdvp->gdv_view->gv_prim_labels.gos_draw = 0; - VSET(new_gdvp->gdv_view->gv_prim_labels.gos_text_color, 255, 255, 0); - - new_gdvp->gdv_view->gv_view_params.gos_draw = 0; - VSET(new_gdvp->gdv_view->gv_view_params.gos_text_color, 255, 255, 0); - - new_gdvp->gdv_view->gv_view_scale.gos_draw = 0; - VSET(new_gdvp->gdv_view->gv_view_scale.gos_line_color, 255, 255, 0); - VSET(new_gdvp->gdv_view->gv_view_scale.gos_text_color, 255, 255, 255); - - /* open the framebuffer */ go_open_fbs(new_gdvp, go_current_gop->go_interp); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-01-08 14:34:16
|
Revision: 33489 http://brlcad.svn.sourceforge.net/brlcad/?rev=33489&view=rev Author: bob1961 Date: 2009-01-08 14:33:53 +0000 (Thu, 08 Jan 2009) Log Message: ----------- More mods related to MGED using libged. Modified Paths: -------------- brlcad/trunk/src/libged/color.c brlcad/trunk/src/libged/kill.c brlcad/trunk/src/mged/Makefile.am brlcad/trunk/src/mged/chgtree.c brlcad/trunk/src/mged/clone.c brlcad/trunk/src/mged/cmd.c brlcad/trunk/src/mged/cmd.h brlcad/trunk/src/mged/dir.c brlcad/trunk/src/mged/dodraw.c brlcad/trunk/src/mged/mater.c brlcad/trunk/src/mged/overlay.c brlcad/trunk/src/mged/rtif.c brlcad/trunk/src/mged/setup.c brlcad/trunk/src/mged/utility1.c brlcad/trunk/src/mged/utility2.c Modified: brlcad/trunk/src/libged/color.c =================================================================== --- brlcad/trunk/src/libged/color.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/libged/color.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -48,7 +48,6 @@ char line[128]; static char hdr[] = "LOW\tHIGH\tRed\tGreen\tBlue\n"; char tmpfil[MAXPATHLEN]; - static const char *usage = ""; GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); GED_CHECK_READ_ONLY(gedp, BRLCAD_ERROR); @@ -157,6 +156,28 @@ int +ged_edcolor(struct ged *gedp, int argc, const char *argv[]) +{ + register struct mater *newp; + register struct mater *mp; + register struct mater *next_mater; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_READ_ONLY(gedp, BRLCAD_ERROR); + GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + + if (argc != 1) { + bu_vls_printf(&gedp->ged_result_str, "Usage: %s", argv[0]); + return BRLCAD_ERROR; + } + + return _ged_edcolor(gedp, argc, argv); +} + +int ged_color(struct ged *gedp, int argc, const char *argv[]) { register struct mater *newp; Modified: brlcad/trunk/src/libged/kill.c =================================================================== --- brlcad/trunk/src/libged/kill.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/libged/kill.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -38,6 +38,7 @@ register int i; int is_phony; int verbose = LOOKUP_NOISY; + int force = 0; static const char *usage = "object(s)"; GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); @@ -61,6 +62,7 @@ /* skip past "-f" */ if (argc > 1 && strcmp(argv[1], "-f") == 0) { verbose = LOOKUP_QUIET; + force = 1; argc--; argv++; } @@ -69,6 +71,14 @@ if ((dp = db_lookup(gedp->ged_wdbp->dbip, argv[i], verbose)) != DIR_NULL) { struct directory *dpp[2]; + if ( !force && dp->d_major_type == DB5_MAJORTYPE_ATTRIBUTE_ONLY && dp->d_minor_type == 0 ) { + bu_vls_printf(&gedp->ged_result_str, "You attempted to delete the _GLOBAL object.\n"); + bu_vls_printf(&gedp->ged_result_str, "\tIf you delete the \"_GLOBAL\" object you will be losing some important information\n" ); + bu_vls_printf(&gedp->ged_result_str, "\tsuch as your preferred units and the title of the database.\n" ); + bu_vls_printf(&gedp->ged_result_str, "\tUse the \"-f\" option, if you really want to do this.\n" ); + continue; + } + is_phony = (dp->d_addr == RT_DIR_PHONY_ADDR); /* don't worry about phony objects */ Modified: brlcad/trunk/src/mged/Makefile.am =================================================================== --- brlcad/trunk/src/mged/Makefile.am 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/Makefile.am 2009-01-08 14:33:53 UTC (rev 33489) @@ -102,7 +102,6 @@ predictor.c \ qray.c \ rect.c \ - red.c \ rtif.c \ scroll.c \ set.c \ Modified: brlcad/trunk/src/mged/chgtree.c =================================================================== --- brlcad/trunk/src/mged/chgtree.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/chgtree.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -57,94 +57,6 @@ -/* Remove an object or several from the description */ -/* Format: kill [-f] object1 object2 .... objectn */ -int -cmd_kill(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ -#if 0 - int ret; - - CHECK_DBI_NULL; - - ret = wdb_kill_cmd(wdbp, interp, argc, argv); - solid_list_callback(); - - return ret; -#else - register int i; - struct directory *dp; - struct directory *dpp[2] = {DIR_NULL, DIR_NULL}; - int is_phony; - int verbose = LOOKUP_NOISY; - int force=0; - - CHECK_DBI_NULL; - CHECK_READ_ONLY; - - if (argc < 2) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help kill"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - if ( argc > 1 && strcmp( argv[1], "-f" ) == 0 ) { - verbose = LOOKUP_QUIET; - force = 1; - argc--; - argv++; - } - - for ( i = 1; i < argc; i++ ) { - if ( (dp = db_lookup( dbip, argv[i], verbose )) != DIR_NULL ) { - if ( !force && dp->d_major_type == DB5_MAJORTYPE_ATTRIBUTE_ONLY && dp->d_minor_type == 0 ) { - /* kill the _GLOBAL object?? */ - if ( classic_mged || tkwin == NULL ) { - /* Tk is not available */ - bu_log( "You attempted to delete the _GLOBAL object.\n" ); - bu_log( "\tIf you delete the \"_GLOBAL\" object you will be losing some important information\n" ); - bu_log( "\tsuch as your preferred units and the title of the database.\n" ); - bu_log( "\tUse the \"-f\" option, if you really want to do this.\n" ); - continue; - } else { - /* Use tk_messageBox to question user */ - Tcl_ResetResult( interp ); - if ( Tcl_Eval( interp, really_delete ) != TCL_OK ) { - bu_exit(EXIT_FAILURE, "Tcl_Eval() failed!!!\n" ); - } - if ( strcmp( Tcl_GetStringResult( interp ), "yes" ) ) { - Tcl_ResetResult( interp ); - continue; - } - Tcl_ResetResult( interp ); - } - } - is_phony = (dp->d_addr == RT_DIR_PHONY_ADDR); - dpp[0] = dp; - eraseobjall(dpp); - /* eraseobjall() does db_dirdelete() on phony entries, don't re-do. */ - if ( is_phony ) continue; - - if ( db_delete( dbip, dp ) < 0 || - db_dirdelete( dbip, dp ) < 0 ) { - /* Abort kill processing on first error */ - TCL_DELETE_ERR_return(argv[i]); - } - } - } - - solid_list_callback(); - return TCL_OK; -#endif -} - /* Copy a cylinder and position at end of original cylinder * Used in making "wires" @@ -234,66 +146,6 @@ } /* - * F _ A R C E D - * - * Allow editing of the matrix, etc., along an arc in the database - * from the command line, when NOT in an edit state. - * Used mostly to facilitate shell script writing. - * - * Syntax: arced a/b ("anim" command) - * arced a/b matrix rmul translate dx dy dz - * - * Extensions should be formulated along the lines of the "anim" - * commands from the script language. - */ -int -f_arced(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - Tcl_DString ds; - int ret; - struct ged ged; - - CHECK_DBI_NULL; - CHECK_READ_ONLY; - - /*XXX Temporary */ -#if 1 - GED_INIT(&ged, wdbp); -#endif - - ret = ged_arced(&ged, argc, (const char **)argv); - - Tcl_DStringInit(&ds); - Tcl_DStringAppend(&ds, bu_vls_addr(&ged.ged_result_str), -1); - Tcl_DStringResult(interp, &ds); - - /* Convert to Tcl codes */ - if (ret == BRLCAD_ERROR) - return TCL_ERROR; - - return TCL_OK; -} - -/* - * C M D _ P A T H L I S T - * - * Given the name(s) of a database node(s), return a TCL list of all - * paths from there to each leaf below it. - * - * Similar to the "tree" command, only suitable for programs, not humans. - */ -int -cmd_pathlist(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ - CHECK_DBI_NULL; - - return wdb_pathlist_cmd(wdbp, interp, argc, argv); -} - -/* * F I N D _ S O L I D _ W I T H _ P A T H */ struct solid * @@ -433,247 +285,6 @@ } /* - * F _ P U T M A T - * - * Replace the matrix on an arc in the database from the command line, - * when NOT in an edit state. Used mostly to facilitate writing shell - * scripts. There are two valid syntaxes, each of which is implemented - * as an appropriate call to f_arced. Commands of the form - * - * putmat a/b m0 m1 ... m15 - * - * are converted to - * - * arced a/b matrix rarc m0 m1 ... m15, - * - * while commands of the form - * - * putmat a/b I - * - * are converted to - * - * arced a/b matrix rarc 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1. - * - */ -int -f_putmat (ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - int result = TCL_OK; /* Return code */ - char *newargv[20+2]; - struct bu_vls *avp; - int got; - - CHECK_DBI_NULL; - CHECK_READ_ONLY; - - if (argc < 3 || 18 < argc) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help putmat"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - if (not_state( ST_VIEW, "Command-line matrix replace")) - return TCL_ERROR; - - if (!strchr( argv[1], '/')) - { - Tcl_AppendResult(interp, "putmat: bad path specification '", - argv[1], "'\n", (char *)NULL); - return TCL_ERROR; - } - switch (argc) - { - case 18: - avp = bu_vls_vlsinit(); - bu_vls_from_argv(avp, 16, (const char **)argv + 2); - break; - case 3: - if ((argv[2][0] == 'I') && (argv[2][1] == '\0')) - { - avp = bu_vls_vlsinit(); - bu_vls_printf(avp, "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 "); - break; - } - /* Sometimes the matrix is sent through Tcl as one long string. - * Copy it so we can crack it, below. - */ - avp = bu_vls_vlsinit(); - bu_vls_strcat(avp, argv[2]); - break; - default: - Tcl_AppendResult(interp, "putmat: error in matrix specification (wrong number of args)\n", (char *)NULL); - return TCL_ERROR; - } - newargv[0] = "arced"; - newargv[1] = argv[1]; - newargv[2] = "matrix"; - newargv[3] = "rarc"; - - got = bu_argv_from_string( &newargv[4], 16, bu_vls_addr(avp) ); - if ( got != 16 ) { - struct bu_vls tmp_vls; - - bu_vls_init(&tmp_vls); - bu_vls_printf(&tmp_vls, "putmat: %s:%d: bad matrix, only got %d elements: %s\n", - __FILE__, __LINE__, got, bu_vls_addr(&tmp_vls)); - Tcl_AppendResult(interp, bu_vls_addr(&tmp_vls), (char *)NULL); - bu_vls_free(&tmp_vls); - result = TCL_ERROR; - } - - if (result != TCL_ERROR) - result = f_arced(clientData, interp, 20, newargv); - - bu_vls_vlsfree(avp); - return result; -} - -/* - * F _ C O P Y M A T - * - * Copy the matrix on one arc in the database to another arc. - * - */ -int -f_copymat(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - char *child; - char *parent; - struct bu_vls pvls; - int i; - int sep; - int status; - struct db_tree_state ts; - struct directory *dp; - struct rt_comb_internal *comb; - struct rt_db_internal intern; - struct animate *anp; - union tree *tp; - - CHECK_DBI_NULL; - CHECK_READ_ONLY; - - if (argc < 3 || 3 < argc) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help copymat"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - if (not_state( ST_VIEW, "Command-line matrix copy")) - return TCL_ERROR; - - /* - * Ensure that each argument contains exactly one slash - */ - for (i = 1; i <= 2; ++i) - if (((child = strchr(argv[i], '/')) == NULL) - || (strchr(++child, '/') != NULL)) - { - Tcl_AppendResult(interp, - "copymat: bad arc: '", argv[i], "'\n", (char *) NULL); - return TCL_ERROR; - } - - BU_GETSTRUCT(anp, animate); - anp -> magic = ANIMATE_MAGIC; - - ts = mged_initial_tree_state; /* struct copy */ - ts.ts_dbip = dbip; - ts.ts_resp = &rt_uniresource; - MAT_IDN(ts.ts_mat); - db_full_path_init(&anp -> an_path); - if (db_follow_path_for_state(&ts, &(anp -> an_path), argv[1], LOOKUP_NOISY) - < 0 ) - { - Tcl_AppendResult(interp, - "copymat: cannot follow path for arc: '", argv[1], "'\n", - (char *) NULL); - return TCL_ERROR; - } - - bu_vls_init(&pvls); - bu_vls_strcat(&pvls, argv[2]); - parent = bu_vls_addr(&pvls); - sep = strchr(parent, '/') - parent; - bu_vls_trunc(&pvls, sep); - switch (rt_db_lookup_internal(dbip, parent, &dp, &intern, LOOKUP_NOISY, &rt_uniresource)) - { - case ID_COMBINATION: - if (dp -> d_flags & DIR_COMB) - break; - else - { - struct bu_vls tmp_vls; - - bu_vls_init(&tmp_vls); - bu_vls_printf(&tmp_vls, "Non-combination directory <x%lx> '%s' for combination rt_db_internal <x%lx>\nThis should not happen\n", - (long)dp, dp -> d_namep, &intern); - Tcl_AppendResult(interp, bu_vls_addr(&tmp_vls), (char *) NULL); - } - /* Fall through this case */ - default: - Tcl_AppendResult(interp, - "copymat: Object '", parent, "' is not a combination\n", - (char *) NULL); - /* Fall through this case */ - case ID_NULL: - bu_vls_free(&pvls); - return TCL_ERROR; - } - comb = (struct rt_comb_internal *) intern.idb_ptr; - RT_CK_COMB(comb); - - if ((tp = db_find_named_leaf(comb -> tree, child)) == TREE_NULL) - { - Tcl_AppendResult(interp, "copymat: unable to find instance of '", - child, "' in combination '", dp -> d_namep, - "'\n", (char *)NULL); - status = TCL_ERROR; - goto wrapup; - } - - /* - * Finally, copy the matrix - */ - if (!bn_mat_is_identity(ts.ts_mat)) - { - if (tp -> tr_l.tl_mat == NULL) - tp -> tr_l.tl_mat = bn_mat_dup(ts.ts_mat); - else - MAT_COPY(tp -> tr_l.tl_mat, ts.ts_mat); - } - else if (tp -> tr_l.tl_mat != NULL) - { - bu_free((genptr_t) tp -> tr_l.tl_mat, "tl_mat"); - tp -> tr_l.tl_mat = (matp_t) 0; - } - - if (rt_db_put_internal(dp, dbip, &intern, &rt_uniresource) < 0) - { - TCL_WRITE_ERR; - status = TCL_ERROR; - goto wrapup; - } - - status = TCL_OK; - - wrapup: - - bu_vls_free(&pvls); - if (status == TCL_ERROR) - rt_db_free_internal(&intern, &rt_uniresource); - return status; -} - -/* * Local Variables: * mode: C * tab-width: 8 Modified: brlcad/trunk/src/mged/clone.c =================================================================== --- brlcad/trunk/src/mged/clone.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/clone.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -807,189 +807,6 @@ } /** - * how to use clone. blissfully simple interface. - */ -void -print_usage(Tcl_Interp *interp) -{ - Tcl_AppendResult(interp, "Usage: clone [-abfhimnprtv] <object>\n\n", (char *)NULL); - Tcl_AppendResult(interp, "-a <n> <x> <y> <z>\t- Specifies a translation split between n copies.\n", (char*)NULL); - Tcl_AppendResult(interp, "-b <n> <x> <y> <z>\t- Specifies a rotation around x, y, and z axes \n\t\t\t split between n copies.\n", (char*)NULL); - Tcl_AppendResult(interp, "-c\t\t\t- Increment the second number in object names.\n", (char *)NULL); - Tcl_AppendResult(interp, "-f\t\t\t- Don't draw the new object.\n", (char *)NULL); - Tcl_AppendResult(interp, "-g\t\t\t- Don't resize the view after drawing new objects.\n", (char *)NULL); - Tcl_AppendResult(interp, "-h\t\t\t- Prints this message.\n", (char*)NULL); - Tcl_AppendResult(interp, "-i <n>\t\t\t- Specifies the increment between each copy.\n", (char*)NULL); - Tcl_AppendResult(interp, "-m <axis> <pos>\t\t- Specifies the axis and point to mirror the group.\n", (char*)NULL); - Tcl_AppendResult(interp, "-n <# copies>\t\t- Specifies the number of copies to make.\n", (char*)NULL); - Tcl_AppendResult(interp, "-p <x> <y> <z>\t\t- Specifies point to rotate around for -r. \n\t\t\t Default is 0 0 0.\n", (char*)NULL); - Tcl_AppendResult(interp, "-r <x> <y> <z>\t\t- Specifies the rotation around x, y, and z axes.\n", (char*)NULL); - Tcl_AppendResult(interp, "-t <x> <y> <z>\t\t- Specifies translation between each copy.\n", (char*)NULL); - Tcl_AppendResult(interp, "-v\t\t\t- Prints version info.\n", (char*)NULL); - return; -} - -/** - * process the user-provided arguments. stash their operations into - * our state structure. - */ -int -get_args(Tcl_Interp *interp, int argc, char **argv, struct clone_state *state) -{ - int i, k; - - bu_optind = 1; - - state->interp = interp; - state->incr = 100; - state->n_copies = 1; - state->draw_obj = 1; - state->autoview = 1; - state->rot[W] = 0; - state->rpnt[W] = 0; - state->trans[W] = 0; - state->miraxis = W; - state->updpos = 0; - while ((k = bu_getopt(argc, argv, "a:b:cfhgi:m:n:p:r:t:v")) != EOF) { - switch (k) { - case 'a': - state->n_copies = atoi(bu_optarg); - state->trans[X] = atof(argv[bu_optind++]) / state->n_copies; - state->trans[Y] = atof(argv[bu_optind++]) / state->n_copies; - state->trans[Z] = atof(argv[bu_optind++]) / state->n_copies; - state->trans[W] = 1; - break; - case 'b': - state->n_copies = atoi(bu_optarg); - state->rot[X] = atof(argv[bu_optind++]) / state->n_copies; - state->rot[Y] = atof(argv[bu_optind++]) / state->n_copies; - state->rot[Z] = atof(argv[bu_optind++]) / state->n_copies; - state->rot[W] = 1; - break; - case 'c': - /* I'd like to have an optional argument to -c, but for now, - * just let multiple -c's add it up as a hack. I believe the - * variant of this that was lost used this as a binary - * operation, so it SHOULD be functionally equivelant for a user - * who's dealt with this before. */ - state->updpos++; - break; - case 'f': - state->draw_obj = 0; - break; - case 'g': - state->autoview = 0; - break; - case 'h': - print_usage(interp); - return TCL_ERROR; - break; - case 'i': - state->incr = atoi(bu_optarg); - break; - case 'm': - state->miraxis = bu_optarg[0] - 'x'; - state->mirpos = atof(argv[bu_optind++]); - break; - case 'n': - state->n_copies = atoi(bu_optarg); - break; - case 'p': - state->rpnt[X] = atof(bu_optarg); - state->rpnt[Y] = atof(argv[bu_optind++]); - state->rpnt[Z] = atof(argv[bu_optind++]); - state->rpnt[W] = 1; - break; - case 'r': - state->rot[X] = atof(bu_optarg); - state->rot[Y] = atof(argv[bu_optind++]); - state->rot[Z] = atof(argv[bu_optind++]); - state->rot[W] = 1; - break; - case 't': - state->trans[X] = atof(bu_optarg); - state->trans[Y] = atof(argv[bu_optind++]); - state->trans[Z] = atof(argv[bu_optind++]); - state->trans[W] = 1; - break; - case 'v': - Tcl_AppendResult(interp, CLONE_VERSION, (char *)NULL); - return TCL_ERROR; - break; - default: - print_usage(interp); - return TCL_ERROR; - } - } - - /* make sure not too few/many args */ - if ((argc - bu_optind) == 0) { - Tcl_AppendResult(interp, "clone: Need to specify an <object> to be cloned.\n", (char*)NULL); - print_usage(interp); - return TCL_ERROR; - } else if (bu_optind + 1 < argc) { - Tcl_AppendResult(interp, "clone: Can only clone exactly one <object> at a time right now.\n", (char*)NULL); - print_usage(interp); - return TCL_ERROR; - } - - /* sanity */ - if (!argv[bu_optind]) - return TCL_ERROR; - - /* use global dbip; we make sure the lookup succeeded in f_clone() */ - state->src = db_lookup(dbip, argv[bu_optind], LOOKUP_QUIET); - if (!state->src) { - Tcl_AppendResult(interp, "clone: Cannot find source object\n", (char*)NULL); - return TCL_ERROR; - } - - VSCALE(state->trans, state->trans, local2base); - VSCALE(state->rpnt, state->rpnt, local2base); - state->mirpos *= local2base; - - return TCL_OK; -} - -/** - * master hook function for the 'clone' command. clones an object, - * optionally * rotating or translating the copies - */ -int -f_clone(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - struct clone_state state; - struct directory *copy; - - /* allow interrupts */ - if ( setjmp( jmp_env ) == 0 ) - (void)signal( SIGINT, sig3); - else - return TCL_OK; - - if (argc < 2) { - Tcl_AppendResult(interp, "clone: Not enough args. Use -h for help\n", (char*)NULL); - return TCL_ERROR; - } - - /* validate user options */ - if (get_args(interp, argc, argv, &state) == TCL_ERROR) - return TCL_ERROR; - - /* do it, use global dbip */ - if ((copy = copy_object(dbip, &rt_uniresource, &state)) != (struct directory *)NULL) { - Tcl_DString ds; - - Tcl_DStringInit(&ds); - Tcl_DStringAppend(&ds, copy->d_namep, -1); - Tcl_DStringResult(interp, &ds); - } - - (void)signal( SIGINT, SIG_IGN ); - return TCL_OK; -} - -/** * helper function that computes where a point is along a spline * given some distance 't'. * Modified: brlcad/trunk/src/mged/cmd.c =================================================================== --- brlcad/trunk/src/mged/cmd.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/cmd.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -1019,29 +1019,6 @@ } /** - * sync the database to disk - */ -int -f_sync(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - int ret; - Tcl_DString ds; - - if (gedp == GED_NULL) - return TCL_OK; - - ret = ged_sync(gedp, argc, (const char **)argv); - Tcl_DStringInit(&ds); - Tcl_DStringAppend(&ds, bu_vls_addr(&gedp->ged_result_str), -1); - Tcl_DStringResult(interp, &ds); - - if (ret == BRLCAD_OK) - return TCL_OK; - - return TCL_ERROR; -} - -/** * H E L P C O M M * * Common code for help commands Modified: brlcad/trunk/src/mged/cmd.h =================================================================== --- brlcad/trunk/src/mged/cmd.h 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/cmd.h 2009-01-08 14:33:53 UTC (rev 33489) @@ -36,6 +36,8 @@ ged_func_ptr ged_func; }; +extern struct cmdtab mged_cmdtab[]; + /* Commands */ BU_EXTERN(int cmd_ged_edit_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); Modified: brlcad/trunk/src/mged/dir.c =================================================================== --- brlcad/trunk/src/mged/dir.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/dir.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -321,237 +321,7 @@ comb_leaf->tr_l.tl_name = bu_strdup( new_name ); } -/* F _ K I L L A L L - * - * kill object[s] and - * remove all references to the object[s] - * format: killall obj1 ... objn - * - */ int -cmd_killall(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ - int ret; - - CHECK_DBI_NULL; - CHECK_READ_ONLY; - - if (argc < 2) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help killall"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - if ( setjmp( jmp_env ) == 0 ) - (void)signal( SIGINT, sig3); /* allow interupts */ - else { - /* Free intern? */ - return TCL_OK; - } - - ret = cmd_killrefs(clientData, interp, argc, argv); - - if ( ret != TCL_OK ) { - Tcl_AppendResult(interp, "KILL skipped because of earlier errors.\n", (char *)NULL); - return ret; - } - - /* ALL references removed...now KILL the object[s] */ - /* reuse argv[] */ - argv[0] = "kill"; - (void)signal( SIGINT, SIG_IGN ); - return cmd_kill( clientData, interp, argc, argv ); -} - - -int -cmd_killrefs(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ - register int k; - register struct directory *dp; - struct rt_db_internal intern; - struct rt_comb_internal *comb; - int ret; - - if (argc < 2) { - Tcl_AppendResult(interp, "Usage: killrefs object(s)", (char *)0); - return TCL_ERROR; - } - - /* Examine all COMB nodes */ - FOR_ALL_DIRECTORY_START(dp, dbip) { - if ( !(dp->d_flags & DIR_COMB) ) - continue; - - if ( rt_db_get_internal( &intern, dp, dbip, (fastf_t *)NULL, &rt_uniresource ) < 0 ) { - Tcl_AppendResult(interp, "rt_db_get_internal(", dp->d_namep, - ") failure", (char *)NULL ); - ret = TCL_ERROR; - continue; - } - comb = (struct rt_comb_internal *)intern.idb_ptr; - RT_CK_COMB(comb); - - for ( k=1; k<argc; k++ ) { - int code; - - code = db_tree_del_dbleaf( &(comb->tree), argv[k], &rt_uniresource ); - if ( code == -1 ) continue; /* not found */ - if ( code == -2 ) continue; /* empty tree */ - if ( code < 0 ) { - Tcl_AppendResult(interp, " ERROR_deleting ", - dp->d_namep, "/", argv[k], - "\n", (char *)NULL); - ret = TCL_ERROR; - } else { - Tcl_AppendResult(interp, "deleted ", - dp->d_namep, "/", argv[k], - "\n", (char *)NULL); - } - } - - if ( rt_db_put_internal( dp, dbip, &intern, &rt_uniresource ) < 0 ) { - Tcl_AppendResult(interp, "ERROR: Unable to write new combination into database.\n", (char *)NULL); - ret = TCL_ERROR; - continue; - } - } FOR_ALL_DIRECTORY_END; - - return TCL_OK; -} - -struct mged_killtree_data { - Tcl_Interp *interp; - int killrefs; - int ac; - char *av[MAXARGS]; -}; - -/* F _ K I L L T R E E ( ) - * - * Kill ALL paths belonging to an object - * - */ -int -cmd_killtree(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ -#if 0 - CHECK_DBI_NULL; - - return wdb_kill_cmd(wdbp, interp, argc, argv); -#else - struct mged_killtree_data mktd; - register struct directory *dp; - register int i; - - CHECK_DBI_NULL; - CHECK_READ_ONLY; - - if (argc < 2) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help killtree"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - if ( setjmp( jmp_env ) == 0 ) - (void)signal( SIGINT, sig3); /* allow interupts */ - else - return TCL_OK; - - mktd.interp = interp; - mktd.ac = 1; - mktd.av[0] = "killrefs"; - mktd.av[1] = (char *)0; - - if (argv[1][0] == '-' && argv[1][1] == 'a' && argv[1][2] == '\0') { - mktd.killrefs = 1; - --argc; - ++argv; - } else - mktd.killrefs = 0; - - for (i=1; i<argc; i++) { - if ( (dp = db_lookup( dbip, argv[i], LOOKUP_NOISY) ) == DIR_NULL ) - continue; - db_functree( dbip, dp, killtree, killtree, &rt_uniresource, (genptr_t)&mktd ); - } - - if (mktd.killrefs && mktd.ac > 1) { - (void)cmd_killrefs(clientData, interp, mktd.ac, mktd.av); - - for (i=1; i<mktd.ac; i++) { - bu_free((genptr_t)mktd.av[i], "ged_killtree_data"); - } - } - - (void)signal( SIGINT, SIG_IGN ); - solid_list_callback(); - return TCL_OK; -#endif -} - -/* - * K I L L T R E E - */ -void -killtree(struct db_i *dbip, struct directory *dp, genptr_t ptr) -{ - struct mged_killtree_data *mktdp = (struct mged_killtree_data *)ptr; - struct directory *dpp[2] = {DIR_NULL, DIR_NULL}; - - if (dbip == DBI_NULL) - return; - - Tcl_AppendResult(mktdp->interp, "KILL ", (dp->d_flags & DIR_COMB) ? "COMB" : "Solid", - ": ", dp->d_namep, "\n", (char *)NULL); - - dpp[0] = dp; - eraseobjall(dpp); - - if (!mktdp->killrefs) { - if (db_delete(dbip, dp) < 0 || db_dirdelete(dbip, dp) < 0) { - Tcl_AppendResult(mktdp->interp, "an error occurred while deleting ", dp->d_namep, "\n", (char *)0); - } - } else { - if (mktdp->ac < MAXARGS-1) { - mktdp->av[mktdp->ac++] = bu_strdup(dp->d_namep); - mktdp->av[mktdp->ac] = (char *)0; - - if (db_delete(dbip, dp) < 0 || db_dirdelete(dbip, dp) < 0) { - Tcl_AppendResult(mktdp->interp, "an error occurred while deleting ", dp->d_namep, "\n", (char *)0); - - /* Remove from list */ - bu_free((genptr_t)mktdp->av[--mktdp->ac], "ged_killtree_callback"); - mktdp->av[mktdp->ac] = (char *)0; - } - } else { - Tcl_AppendResult(mktdp->interp, "MAXARGS exceeded while scheduling ", dp->d_namep, " for a killrefs\n", (char *)0); - - if (db_delete(dbip, dp) < 0 || db_dirdelete(dbip, dp) < 0) { - Tcl_AppendResult(mktdp->interp, "an error occurred while deleting ", dp->d_namep, "\n", (char *)0); - } - } - } -} - -int f_debugdir(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { CHECK_DBI_NULL; Modified: brlcad/trunk/src/mged/dodraw.c =================================================================== --- brlcad/trunk/src/mged/dodraw.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/dodraw.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -1123,13 +1123,13 @@ av[0] = "d"; av[1] = shortname; av[2] = NULL; - (void)cmd_ged_erase_wrapper((ClientData)NULL, interp, 2, av); + (void)cmd_ged_erase_wrapper((ClientData)mged_cmdtab, interp, 2, av); } else { av[0] = "kill"; av[1] = "-f"; av[2] = shortname; av[3] = NULL; - (void)cmd_kill((ClientData)NULL, interp, 3, av); + (void)cmd_ged_erase_wrapper((ClientData)mged_cmdtab, interp, 3, av); } for ( i=0; i < vbp->nused; i++ ) { Modified: brlcad/trunk/src/mged/mater.c =================================================================== --- brlcad/trunk/src/mged/mater.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/mater.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -50,134 +50,7 @@ static char tmpfil[MAXPATHLEN]; -/* - * F _ E D C O L O R - * - * Print color table in easy to scanf() format, - * invoke favorite text editor to allow user to - * fiddle, then reload incore structures from file, - * and update database. - */ -int -f_edcolor(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - register struct mater *mp; - register struct mater *zot; - register FILE *fp; - register int fd; - char line[128]; - static char hdr[] = "LOW\tHIGH\tRed\tGreen\tBlue\n"; - int ret = TCL_OK; - CHECK_DBI_NULL; - CHECK_READ_ONLY; - - if (argc < 1 || 1 < argc) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help edcolor"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - fp = bu_temp_file(tmpfil, MAXPATHLEN); - if (fp == NULL) - return TCL_ERROR; - - fprintf( fp, "%s", hdr ); - for (mp = rt_material_head(); mp != MATER_NULL; mp = mp->mt_forw) { - (void)fprintf( fp, "%d\t%d\t%3d\t%3d\t%3d", - mp->mt_low, mp->mt_high, - mp->mt_r, mp->mt_g, mp->mt_b); - (void)fprintf(fp, "\n"); - } - (void)fclose(fp); - - if (!editit( tmpfil)) { - Tcl_AppendResult(interp, "Editor returned bad status. Aborted\n", (char *)NULL); - return TCL_ERROR; - } - - /* Read file and process it */ - if ((fp = fopen( tmpfil, "r")) == NULL) { - perror(tmpfil); - return TCL_ERROR; - } - - if (bu_fgets(line, sizeof (line), fp) == NULL || - line[0] != hdr[0]) { - Tcl_AppendResult(interp, "Header line damaged, aborting\n", (char *)NULL); - return TCL_ERROR; - } - - if (dbip->dbi_version < 5) { - /* Zap all the current records, both in core and on disk */ - while (rt_material_head() != MATER_NULL) { - zot = rt_material_head(); - rt_new_material_head(zot->mt_forw); - color_zaprec(zot); - bu_free((genptr_t)zot, "mater rec"); - } - - while (bu_fgets(line, sizeof (line), fp) != NULL) { - int cnt; - int low, hi, r, g, b; - - cnt = sscanf(line, "%d %d %d %d %d", - &low, &hi, &r, &g, &b); - if (cnt != 5) { - Tcl_AppendResult(interp, "Discarding ", - line, "\n", (char *)NULL); - continue; - } - BU_GETSTRUCT(mp, mater); - mp->mt_low = low; - mp->mt_high = hi; - mp->mt_r = r; - mp->mt_g = g; - mp->mt_b = b; - mp->mt_daddr = MATER_NO_ADDR; - rt_insert_color(mp); - color_putrec(mp); - } - } else { - struct bu_vls vls; - - /* free colors in rt_material_head */ - rt_color_free(); - - bu_vls_init(&vls); - - while (bu_fgets(line, sizeof (line), fp) != NULL) { - int cnt; - int low, hi, r, g, b; - - /* check to see if line is reasonable */ - cnt = sscanf(line, "%d %d %d %d %d", - &low, &hi, &r, &g, &b); - if (cnt != 5) { - Tcl_AppendResult(interp, "Discarding ", - line, "\n", (char *)NULL); - continue; - } - bu_vls_printf(&vls, "{%d %d %d %d %d} ", low, hi, r, g, b); - } - - db5_update_attribute("_GLOBAL", "regionid_colortable", bu_vls_addr(&vls), dbip); - db5_import_color_table(bu_vls_addr(&vls)); - bu_vls_free(&vls); - } - - (void)fclose(fp); - (void)unlink(tmpfil); - - color_soltab(); - - return ret; -} - /* * C O L O R _ P U T R E C * Modified: brlcad/trunk/src/mged/overlay.c =================================================================== --- brlcad/trunk/src/mged/overlay.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/overlay.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -43,13 +43,23 @@ int argc, char **argv) { - int ret; - struct bu_vls char_size; - int ac; - char *av[5]; + int ret; + Tcl_DString ds; + int ac; + char *av[5]; + struct bu_vls char_size; - CHECK_DBI_NULL; + if (gedp == GED_NULL) + return TCL_OK; + Tcl_DStringInit(&ds); + + if (argc == 1) { + Tcl_DStringAppend(&ds, "file.pl [name]", -1); + Tcl_DStringResult(interp, &ds); + return TCL_OK; + } + ac = argc + 1; bu_vls_init(&char_size); bu_vls_printf(&char_size, "%lf", view_state->vs_gvp->gv_scale * 0.01); @@ -62,9 +72,15 @@ } else av[3] = (char *)0; - if ((ret = ged_overlay(gedp, ac, av)) == TCL_OK) - update_views = 1; + ret = ged_overlay(gedp, ac, av); + Tcl_DStringAppend(&ds, bu_vls_addr(&gedp->ged_result_str), -1); + Tcl_DStringResult(interp, &ds); + if (ret != BRLCAD_OK) + return TCL_ERROR; + + update_views = 1; + bu_vls_free(&char_size); return ret; } Modified: brlcad/trunk/src/mged/rtif.c =================================================================== --- brlcad/trunk/src/mged/rtif.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/rtif.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -381,34 +381,6 @@ } } - -/** - * C M D _ R T A B O R T - * - * Abort any raytraces started through mged. - */ -int -cmd_rtabort(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ - int ret; - Tcl_DString ds; - - Tcl_DStringInit(&ds); - - ret = ged_rtabort(gedp, argc, (const char **)argv); - Tcl_DStringAppend(&ds, bu_vls_addr(&gedp->ged_result_str), -1); - Tcl_DStringResult(interp, &ds); - - if (ret == BRLCAD_OK) - return TCL_OK; - - return TCL_ERROR; -} - - void display_error() { @@ -2193,31 +2165,6 @@ /** - * List the objects currently being drawn. - */ -int -cmd_who (ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - int ret; - Tcl_DString ds; - - if (gedp == GED_NULL) - return TCL_OK; - - Tcl_DStringInit(&ds); - - ret = ged_who(gedp, argc, (const char **)argv); - Tcl_DStringAppend(&ds, bu_vls_addr(&gedp->ged_result_str), -1); - Tcl_DStringResult(interp, &ds); - - if (ret == BRLCAD_OK) - return TCL_OK; - - return TCL_ERROR; -} - - -/** * any commands that are not supported or implemented may call this null * routine to avoid rt_do_cmd() "command not found" error reporting */ Modified: brlcad/trunk/src/mged/setup.c =================================================================== --- brlcad/trunk/src/mged/setup.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/setup.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -47,7 +47,7 @@ extern void init_qray(void); extern void mged_global_variable_setup(Tcl_Interp *interp); -static struct cmdtab cmdtab[] = { +struct cmdtab mged_cmdtab[] = { {"%", f_comm, GED_FUNC_PTR_NULL}, {"35, 25", bv_35_25, GED_FUNC_PTR_NULL}, {"3ptarb", f_3ptarb, GED_FUNC_PTR_NULL}, @@ -60,14 +60,14 @@ {"ae2dir", cmd_ged_plain_wrapper, ged_ae2dir}, {"aip", f_aip, GED_FUNC_PTR_NULL}, {"analyze", cmd_ged_plain_wrapper, ged_analyze}, - {"arb", f_arbdef, GED_FUNC_PTR_NULL}, - {"arced", f_arced, GED_FUNC_PTR_NULL}, + {"arb", cmd_ged_edit_wrapper, ged_arb}, + {"arced", cmd_ged_plain_wrapper, ged_arced}, {"area", f_area, GED_FUNC_PTR_NULL}, {"arot", cmd_arot, GED_FUNC_PTR_NULL}, {"attach", f_attach, GED_FUNC_PTR_NULL}, {"attr", cmd_ged_plain_wrapper, ged_attr}, {"autoview", cmd_autoview, GED_FUNC_PTR_NULL}, - {"bev", f_bev, GED_FUNC_PTR_NULL}, + {"bev", cmd_ged_edit_wrapper, ged_bev}, {"bo", cmd_ged_plain_wrapper, ged_binary}, #if 0 {"import_body", cmd_import_body, GED_FUNC_PTR_NULL}, @@ -86,14 +86,14 @@ {"c", cmd_ged_plain_wrapper, ged_comb_std}, {"cat", cmd_ged_plain_wrapper, ged_cat}, {"center", cmd_center, GED_FUNC_PTR_NULL}, - {"clone", f_clone, GED_FUNC_PTR_NULL}, + {"clone", cmd_ged_edit_wrapper, ged_clone}, {"closedb", f_closedb, GED_FUNC_PTR_NULL}, {"cmd_win", cmd_cmd_win, GED_FUNC_PTR_NULL}, {"color", cmd_ged_plain_wrapper, ged_color}, {"comb", cmd_ged_plain_wrapper, ged_comb}, {"comb_color", cmd_ged_plain_wrapper, ged_comb_color}, {"copyeval", cmd_ged_plain_wrapper, ged_copyeval}, - {"copymat", f_copymat, GED_FUNC_PTR_NULL}, + {"copymat", cmd_ged_plain_wrapper, ged_copymat}, {"cp", cmd_ged_plain_wrapper, ged_copy}, {"cpi", f_copy_inv, GED_FUNC_PTR_NULL}, {"d", cmd_ged_erase_wrapper, ged_erase}, @@ -109,8 +109,8 @@ {"debuglib", f_debuglib, GED_FUNC_PTR_NULL}, {"debugmem", f_debugmem, GED_FUNC_PTR_NULL}, {"debugnmg", f_debugnmg, GED_FUNC_PTR_NULL}, - {"decompose", f_decompose, GED_FUNC_PTR_NULL}, - {"delay", f_delay, GED_FUNC_PTR_NULL}, + {"decompose", cmd_ged_plain_wrapper, ged_decompose}, + {"delay", cmd_ged_plain_wrapper, ged_delay}, {"dir2ae", cmd_ged_plain_wrapper, ged_dir2ae}, {"dump", cmd_ged_plain_wrapper, ged_dump}, {"dm", f_dm, GED_FUNC_PTR_NULL}, @@ -118,10 +118,11 @@ {"dup", cmd_ged_plain_wrapper, ged_dup}, {"E", cmd_E, GED_FUNC_PTR_NULL}, {"e", cmd_draw, GED_FUNC_PTR_NULL}, - {"eac", f_eac, GED_FUNC_PTR_NULL}, + {"eac", cmd_ged_view_wrapper, ged_eac}, {"echo", cmd_ged_plain_wrapper, ged_echo}, - {"edcodes", f_edcodes, GED_FUNC_PTR_NULL}, - {"edcolor", f_edcolor, GED_FUNC_PTR_NULL}, /* XXX kill this */ + {"edcodes", cmd_ged_plain_wrapper, ged_edcodes}, + {"color", cmd_ged_plain_wrapper, ged_color}, + {"edcolor", cmd_ged_plain_wrapper, ged_edcolor}, {"edcomb", cmd_ged_plain_wrapper, ged_edcomb}, {"edgedir", f_edgedir, GED_FUNC_PTR_NULL}, {"edmater", cmd_ged_plain_wrapper, ged_edmater}, @@ -136,15 +137,15 @@ {"extrude", f_extrude, GED_FUNC_PTR_NULL}, {"eye_pt", cmd_ged_view_wrapper, ged_eye}, {"facedef", f_facedef, GED_FUNC_PTR_NULL}, - {"facetize", f_facetize, GED_FUNC_PTR_NULL}, + {"facetize", cmd_ged_plain_wrapper, ged_facetize}, {"form", cmd_ged_plain_wrapper, ged_form}, {"fracture", cmd_ged_plain_wrapper, ged_fracture}, {"front", bv_front, GED_FUNC_PTR_NULL}, {"g", cmd_ged_plain_wrapper, ged_group}, {"get", cmd_ged_plain_wrapper, ged_get}, {"get_autoview", cmd_ged_plain_wrapper, ged_autoview}, - {"get_comb", cmd_get_comb, GED_FUNC_PTR_NULL}, - {"get_dbip", cmd_get_ptr, GED_FUNC_PTR_NULL}, + {"get_comb", cmd_ged_plain_wrapper, ged_get_comb}, + {"get_dbip", cmd_ged_plain_wrapper, ged_dbip}, {"get_dm_list", f_get_dm_list, GED_FUNC_PTR_NULL}, {"get_more_default", cmd_get_more_default, GED_FUNC_PTR_NULL}, {"get_sed", f_get_sedit, GED_FUNC_PTR_NULL}, @@ -161,7 +162,7 @@ {"hist", cmd_hist, GED_FUNC_PTR_NULL}, {"history", f_history, GED_FUNC_PTR_NULL}, {"i", cmd_ged_plain_wrapper, ged_instance}, - {"idents", f_tables, GED_FUNC_PTR_NULL}, + {"idents", cmd_ged_plain_wrapper, ged_tables}, {"ill", f_ill, GED_FUNC_PTR_NULL}, {"in", f_in, GED_FUNC_PTR_NULL}, {"inside", f_inside, GED_FUNC_PTR_NULL}, @@ -170,10 +171,10 @@ {"journal", f_journal, GED_FUNC_PTR_NULL}, {"keep", cmd_ged_plain_wrapper, ged_keep}, {"keypoint", f_keypoint, GED_FUNC_PTR_NULL}, - {"kill", cmd_kill, GED_FUNC_PTR_NULL}, - {"killall", cmd_killall, GED_FUNC_PTR_NULL}, - {"killrefs", cmd_killrefs, GED_FUNC_PTR_NULL}, - {"killtree", cmd_killtree, GED_FUNC_PTR_NULL}, + {"kill", cmd_ged_erase_wrapper, ged_kill}, + {"killall", cmd_ged_erase_wrapper, ged_killall}, + {"killrefs", cmd_ged_erase_wrapper, ged_killrefs}, + {"killtree", cmd_ged_erase_wrapper, ged_killtree}, {"knob", f_knob, GED_FUNC_PTR_NULL}, {"l", cmd_ged_plain_wrapper, ged_list}, {"l_muves", f_l_muves, GED_FUNC_PTR_NULL}, @@ -229,40 +230,40 @@ {"ozscale", be_o_zscale, GED_FUNC_PTR_NULL}, {"p", f_param, GED_FUNC_PTR_NULL}, {"parse_points", cmd_parse_points, GED_FUNC_PTR_NULL}, - {"pathlist", cmd_pathlist, GED_FUNC_PTR_NULL}, + {"pathlist", cmd_ged_plain_wrapper, ged_pathlist}, {"paths", cmd_ged_plain_wrapper, ged_pathsum}, {"permute", f_permute, GED_FUNC_PTR_NULL}, {"pl", f_pl, GED_FUNC_PTR_NULL}, - {"plot", f_plot, GED_FUNC_PTR_NULL}, + {"plot", cmd_ged_plain_wrapper, ged_plot}, {"polybinout", f_polybinout, GED_FUNC_PTR_NULL}, {"pov", cmd_pov, GED_FUNC_PTR_NULL}, {"prcolor", cmd_ged_plain_wrapper, ged_prcolor}, - {"prefix", f_prefix, GED_FUNC_PTR_NULL}, + {"prefix", cmd_ged_plain_wrapper, ged_prefix}, {"press", f_press, GED_FUNC_PTR_NULL}, {"preview", f_preview, GED_FUNC_PTR_NULL}, {"ps", f_ps, GED_FUNC_PTR_NULL}, {"push", cmd_ged_plain_wrapper, ged_push}, {"put", cmd_ged_plain_wrapper, ged_put}, - {"put_comb", cmd_put_comb, GED_FUNC_PTR_NULL}, + {"put_comb", cmd_ged_plain_wrapper, ged_put_comb}, {"put_sed", f_put_sedit, GED_FUNC_PTR_NULL}, - {"putmat", f_putmat, GED_FUNC_PTR_NULL}, + {"putmat", cmd_ged_plain_wrapper, ged_putmat}, {"q", f_quit, GED_FUNC_PTR_NULL}, {"qorot", f_qorot, GED_FUNC_PTR_NULL}, - {"qray", f_qray, GED_FUNC_PTR_NULL}, + {"qray", cmd_ged_plain_wrapper, ged_qray}, {"query_ray", f_nirt, GED_FUNC_PTR_NULL}, {"quit", f_quit, GED_FUNC_PTR_NULL}, {"qvrot", cmd_ged_view_wrapper, ged_qvrot}, {"r", cmd_ged_plain_wrapper, ged_region}, {"rate", bv_rate_toggle, GED_FUNC_PTR_NULL}, - {"rcodes", f_rcodes, GED_FUNC_PTR_NULL}, + {"rcodes", cmd_ged_plain_wrapper, ged_rcodes}, {"read_muves", f_read_muves, GED_FUNC_PTR_NULL}, {"rear", bv_rear, GED_FUNC_PTR_NULL}, - {"red", f_red, GED_FUNC_PTR_NULL}, + {"red", cmd_ged_plain_wrapper, ged_red}, {"redraw_vlist", cmd_redraw_vlist, GED_FUNC_PTR_NULL}, {"refresh", f_refresh, GED_FUNC_PTR_NULL}, {"regdebug", f_regdebug, GED_FUNC_PTR_NULL}, {"regdef", cmd_ged_plain_wrapper, ged_regdef}, - {"regions", f_tables, GED_FUNC_PTR_NULL}, + {"regions", cmd_ged_plain_wrapper, ged_tables}, {"reject", be_reject, GED_FUNC_PTR_NULL}, {"release", f_release, GED_FUNC_PTR_NULL}, {"reset", bv_reset, GED_FUNC_PTR_NULL}, @@ -278,14 +279,14 @@ {"rset", f_rset, GED_FUNC_PTR_NULL}, {"rt", cmd_rt, GED_FUNC_PTR_NULL}, {"rt_gettrees", cmd_rt_gettrees, GED_FUNC_PTR_NULL}, - {"rtabort", cmd_rtabort, GED_FUNC_PTR_NULL}, + {"rtabort", cmd_ged_plain_wrapper, ged_rtabort}, {"rtarea", cmd_rt, GED_FUNC_PTR_NULL}, {"rtcheck", cmd_rt, GED_FUNC_PTR_NULL}, {"rtedge", cmd_rt, GED_FUNC_PTR_NULL}, {"rtweight", cmd_rt, GED_FUNC_PTR_NULL}, {"save", bv_vsave, GED_FUNC_PTR_NULL}, - {"savekey", f_savekey, GED_FUNC_PTR_NULL}, - {"saveview", f_saveview, GED_FUNC_PTR_NULL}, + {"savekey", cmd_ged_plain_wrapper, ged_savekey}, + {"saveview", cmd_ged_plain_wrapper, ged_saveview}, {"sca", cmd_sca, GED_FUNC_PTR_NULL}, {"search", cmd_search, GED_FUNC_PTR_NULL}, {"sed", f_sed, GED_FUNC_PTR_NULL}, @@ -302,7 +303,7 @@ {"sill", be_s_illuminate, GED_FUNC_PTR_NULL}, {"size", cmd_size, GED_FUNC_PTR_NULL}, {"solid_report", cmd_ged_plain_wrapper, ged_report}, - {"solids", f_tables, GED_FUNC_PTR_NULL}, + {"solids", cmd_ged_plain_wrapper, ged_tables}, {"solids_on_ray", cmd_solids_on_ray, GED_FUNC_PTR_NULL}, {"srot", be_s_rotate, GED_FUNC_PTR_NULL}, {"sscale", be_s_scale, GED_FUNC_PTR_NULL}, @@ -312,7 +313,7 @@ {"sv", f_slewview, GED_FUNC_PTR_NULL}, {"svb", f_svbase, GED_FUNC_PTR_NULL}, {"sxy", be_s_trans, GED_FUNC_PTR_NULL}, - {"sync", f_sync, GED_FUNC_PTR_NULL}, + {"sync", cmd_ged_plain_wrapper, ged_sync}, {"t", cmd_ged_plain_wrapper, ged_ls}, {"t_muves", f_t_muves, GED_FUNC_PTR_NULL}, {"ted", f_tedit, GED_FUNC_PTR_NULL}, @@ -352,12 +353,12 @@ #if 0 {"vrot_center", f_vrot_center, GED_FUNC_PTR_NULL}, #endif - {"wcodes", f_wcodes, GED_FUNC_PTR_NULL}, + {"wcodes", cmd_ged_plain_wrapper, ged_wcodes}, {"whatid", cmd_ged_plain_wrapper, ged_whatid}, - {"which_shader", f_which_shader, GED_FUNC_PTR_NULL}, + {"which_shader", cmd_ged_plain_wrapper, ged_which_shader}, {"whichair", cmd_ged_plain_wrapper, ged_which}, {"whichid", cmd_ged_plain_wrapper, ged_which}, - {"who", cmd_who, GED_FUNC_PTR_NULL}, + {"who", cmd_ged_plain_wrapper, ged_who}, {"winset", f_winset, GED_FUNC_PTR_NULL}, {"wmater", cmd_ged_plain_wrapper, ged_wmater}, {"x", cmd_ged_plain_wrapper, ged_report}, @@ -395,7 +396,7 @@ extern int output_as_return; bu_vls_init(&temp); - for (ctp = cmdtab; ctp->name != NULL; ctp++) { + for (ctp = mged_cmdtab; ctp->name != NULL; ctp++) { bu_vls_strcpy(&temp, "_mged_"); bu_vls_strcat(&temp, ctp->name); Modified: brlcad/trunk/src/mged/utility1.c =================================================================== --- brlcad/trunk/src/mged/utility1.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/utility1.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -575,187 +575,6 @@ return TCL_OK; } -/* F _ D E C O M P O S E - * - * decompose an NMG object into shells, - * making a new NMG object for each shell. - * This is not just copying each shell from the NMG object into a new - * object. The NMG object is actually disassembled and each face - * is placed into an appropriate shell so that the end product is a - * group of shell(s) that can be described as exterior shells and interior - * void shells. - */ - -int -f_decompose(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - int count; - struct bu_vls solid_name; - char *nmg_solid_name; - char *prefix; - char *def_prefix="sh"; - struct model *m; - struct nmgregion *r; - struct model *new_m; - struct nmgregion *tmp_r; - struct shell *kill_s; - struct directory *dp; - struct rt_db_internal nmg_intern; - - CHECK_DBI_NULL; - CHECK_READ_ONLY; - - if (argc < 2 || 3 < argc) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help decompose"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - if ( setjmp( jmp_env ) == 0 ) - (void)signal( SIGINT, sig3); /* allow interupts */ - else - return TCL_OK; - - count = 0; - nmg_solid_name = argv[1]; - - if ( argc > 2 ) { - prefix = argv[2]; - if ( dbip->dbi_version < 5 && strlen(prefix) > NAMESIZE ) { - Tcl_AppendResult(interp, "Prefix ", prefix, " is too long", (char *)NULL ); - return TCL_ERROR; - } - } else { - prefix = def_prefix; - } - - if ( (dp=db_lookup( dbip, nmg_solid_name, LOOKUP_NOISY ) ) == DIR_NULL ) - return TCL_ERROR; - - if ( rt_db_get_internal( &nmg_intern, dp, dbip, bn_mat_identity, &rt_uniresource ) < 0 ) { - Tcl_AppendResult(interp, "rt_db_get_internal() error\n", (char *)NULL); - return TCL_ERROR; - } - - if ( nmg_intern.idb_type != ID_NMG ) { - Tcl_AppendResult(interp, nmg_solid_name, " is not an NMG solid!", (char *)NULL ); - return TCL_ERROR; - } - - bu_vls_init( &solid_name ); - - m = (struct model *)nmg_intern.idb_ptr; - NMG_CK_MODEL(m); - - /* create temp region to hold duplicate shell */ - tmp_r = nmg_mrsv( m ); /* temp nmgregion to hold dup shells */ - kill_s = BU_LIST_FIRST( shell, &tmp_r->s_hd ); - (void)nmg_ks( kill_s ); - - for ( BU_LIST_FOR( r, nmgregion, &m->r_hd ) ) { - struct shell *s; - - if ( r == tmp_r ) - continue; - - for ( BU_LIST_FOR( s, shell, &r->s_hd ) ) { - struct shell *tmp_s; - struct shell *decomp_s; - long **trans_tbl; - - /* duplicate shell */ - tmp_s = (struct shell *)nmg_dup_shell( s, &trans_tbl, &mged_tol ); - bu_free( (char *)trans_tbl, "trans_tbl" ); - - /* move duplicate to temp region */ - (void) nmg_mv_shell_to_region( tmp_s, tmp_r ); - - /* decompose this shell */ - (void) nmg_decompose_shell( tmp_s, &mged_tol ); - - /* move each decomposed shell to yet another region */ - decomp_s = BU_LIST_FIRST( shell, &tmp_r->s_hd ); - while ( BU_LIST_NOT_HEAD( &decomp_s->l, &tmp_r->s_hd ) ) { - struct shell *next_s; - struct shell *new_s; - struct rt_db_internal new_intern; - struct directory *new_dp; - struct nmgregion *decomp_r; - char shell_no[32]; - int end_prefix; - - next_s = BU_LIST_NEXT( shell, &decomp_s->l ); - - decomp_r = nmg_mrsv( m ); - kill_s = BU_LIST_FIRST( shell, &decomp_r->s_hd ); - (void)nmg_ks( kill_s ); - nmg_shell_a( decomp_s, &mged_tol ); - new_s = (struct shell *)nmg_dup_shell( decomp_s, &trans_tbl, &mged_tol ); - (void)nmg_mv_shell_to_region( new_s, decomp_r ); - - /* move this region to a different model */ - new_m = (struct model *)nmg_mk_model_from_region( decomp_r, 1 ); - (void)nmg_rebound( new_m, &mged_tol ); - - /* create name for this shell */ - count++; - bu_vls_strcpy( &solid_name, prefix ); - sprintf( shell_no, "_%d", count ); - if ( dbip->dbi_version < 5 ) { - end_prefix = strlen( prefix ); - if ( end_prefix + strlen( shell_no ) > NAMESIZE ) - end_prefix = NAMESIZE - strlen( shell_no ); - bu_vls_trunc( &solid_name, end_prefix ); - bu_vls_strncat( &solid_name, shell_no, NAMESIZE-bu_vls_strlen(&solid_name) ); - } else { - bu_vls_strcat( &solid_name, shell_no ); - } - - if ( db_lookup( dbip, bu_vls_addr( &solid_name ), LOOKUP_QUIET ) != DIR_NULL ) { - Tcl_AppendResult(interp, "decompose: cannot create unique solid name (", - bu_vls_addr( &solid_name ), ")", (char *)NULL ); - Tcl_AppendResult(interp, "decompose: failed" ); - return TCL_ERROR; - } - - /* write this model as a seperate nmg solid */ - RT_INIT_DB_INTERNAL( &new_intern ); - new_intern.idb_major_type = DB5_MAJORTYPE_BRLCAD; - new_intern.idb_type = ID_NMG; - new_intern.idb_meth = &rt_functab[ID_NMG]; - new_intern.idb_ptr = (genptr_t)new_m; - - if ( (new_dp=db_diradd( dbip, bu_vls_addr( &solid_name ), -1, 0, DIR_SOLID, - (genptr_t)&new_intern.idb_type)) == DIR_NULL ) { - bu_vls_free( &solid_name ); - TCL_ALLOC_ERR; - return TCL_ERROR;; - } - - if ( rt_db_put_internal( new_dp, dbip, &new_intern, &rt_uniresource ) < 0 ) { - (void)nmg_km( new_m ); - bu_vls_free( &solid_name ); - Tcl_AppendResult(interp, "rt_db_put_internal() failure\n", (char *)NULL); - return TCL_ERROR; - } - - (void)nmg_ks( decomp_s ); - decomp_s = next_s; - } - } - } - - rt_db_free_internal( &nmg_intern, &rt_uniresource ); - bu_vls_free( &solid_name ); - - (void)signal( SIGINT, SIG_IGN ); - return TCL_OK; -} - static int sol_number(const matp_t matrix, char *name, int *old) { Modified: brlcad/trunk/src/mged/utility2.c =================================================================== --- brlcad/trunk/src/mged/utility2.c 2009-01-08 12:53:35 UTC (rev 33488) +++ brlcad/trunk/src/mged/utility2.c 2009-01-08 14:33:53 UTC (rev 33489) @@ -49,91 +49,6 @@ #include "./cmd.h" -int -f_eac(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - int j; - int item; - struct directory *dp; - struct bu_vls v; - int new_argc; - int lim; - - CHECK_DBI_NULL; - - if (argc < 2) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help eac"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; - } - - bu_vls_init( &v ); - - if ( setjmp( jmp_env ) == 0 ) - (void)signal( SIGINT, sig3); /* allow interupts */ - else { - bu_vls_free( &v ); - return TCL_OK; - } - - bu_vls_strcat( &v, "e" ); - lim = 1; - - for ( j=1; j<argc; j++) - { - item = atoi( argv[j] ); - if ( item < 1 ) - continue; - - FOR_ALL_DIRECTORY_START(dp, dbip) { - struct rt_db_internal intern; - struct rt_comb_internal *comb; - - if ( !(dp->d_flags & DIR_REGION) ) - continue; - - if ( rt_db_get_internal( &intern, dp, dbip, (fastf_t *)NULL, &rt_uniresource ) < 0 ) - TCL_READ_ERR_return; - comb = (struct rt_comb_internal *)intern.idb_ptr; - if ( comb->region_id != 0 || - comb->aircode != item ) - { - rt_comb_ifree( &intern, &rt_uniresource ); - continue; - } - rt_comb_ifree( &intern, &rt_uniresource ); - - bu_vls_strcat( &v, " " ); - bu_vls_strcat( &v, dp->d_namep ); - lim++; - } FOR_ALL_DIRECTORY_END; - } - - if ( lim > 1 ) - { - int retval; - char **new_argv; - - new_argv = (char **)bu_calloc( lim+1, sizeof( char *), "f_eac: new_argv" ); - new_argc = bu_argv_from_string( new_argv, lim, bu_vls_addr( &v ) ); - retval = cmd_draw( clientData, interp, new_argc, (const char **)new_argv ); - bu_free( (genptr_t)new_argv, "f_eac: new_argv" ); - bu_vls_free( &v ); - (void)signal( SIGINT, SIG_IGN ); - return retval; - } - else - { - bu_vls_free( &v ); - (void)signal( SIGINT, SIG_IGN ); - return TCL_OK; - } -} - /* * Local Variables: * mode: C This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-01-09 19:55:55
|
Revision: 33500 http://brlcad.svn.sourceforge.net/brlcad/?rev=33500&view=rev Author: brlcad Date: 2009-01-09 19:55:50 +0000 (Fri, 09 Jan 2009) Log Message: ----------- move the tire tool into the 'new' shapes directory. Modified Paths: -------------- brlcad/trunk/src/proc-db/Makefile.am brlcad/trunk/src/shapes/Makefile.am Added Paths: ----------- brlcad/trunk/src/shapes/tire.c Removed Paths: ------------- brlcad/trunk/src/proc-db/tire.c Modified: brlcad/trunk/src/proc-db/Makefile.am =================================================================== --- brlcad/trunk/src/proc-db/Makefile.am 2009-01-09 19:52:37 UTC (rev 33499) +++ brlcad/trunk/src/proc-db/Makefile.am 2009-01-09 19:55:50 UTC (rev 33500) @@ -34,7 +34,6 @@ tea \ tea_nmg \ terrain \ - tire \ torii \ tube \ vegitation \ @@ -86,12 +85,6 @@ tea_SOURCES = tea.c tea_nmg_SOURCES = tea_nmg.c terrain_SOURCES = terrain.c - -tire_SOURCES = tire.c -tire_LDADD = \ - ${proc_db_libs} \ - ${GED} - torii_SOURCES = torii.c tube_SOURCES = tube.c vegitation_SOURCES = vegitation.c @@ -144,7 +137,6 @@ $(tea_OBJECTS) \ $(tea_nmg_OBJECTS) \ $(terrain_OBJECTS) \ - $(tire_OBJECTS) \ $(torii_OBJECTS) \ $(tube_OBJECTS) \ $(vegitation_OBJECTS) \ Deleted: brlcad/trunk/src/proc-db/tire.c =================================================================== --- brlcad/trunk/src/proc-db/tire.c 2009-01-09 19:52:37 UTC (rev 33499) +++ brlcad/trunk/src/proc-db/tire.c 2009-01-09 19:55:50 UTC (rev 33500) @@ -1,83 +0,0 @@ -/* T I R E . C - * BRL-CAD - * - * Copyright (c) 2008 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file tire.c - * - * Tire Generator - * - * Program to create basic tire shapes. - */ - -#include "common.h" - -#include <stdio.h> -#include <stdlib.h> -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif - -#include "wdb.h" -#include "ged.h" - -#define DEFAULT_TIRE_FILENAME "tire.g" - - -int main(int ac, char *av[]) -{ - struct rt_wdb *db_fp = NULL; - const char *filename = NULL; - struct ged ged; - int ret; - - filename = DEFAULT_TIRE_FILENAME; - - /* Just using "tire.g" for now. */ - if (!bu_file_exists(filename)) { - db_fp = wdb_fopen(filename); - } else { - bu_exit(1, "ERROR - refusing to overwrite existing [%s] file.", filename); - } - mk_id(db_fp, "Tire"); - - GED_INIT(&ged, db_fp); - - /* create the tire */ - ret = ged_tire(&ged, ac, (const char **)av); - - /* Close database */ - wdb_close(db_fp); - - if (ret) { - unlink(filename); - bu_exit(1, "%s", bu_vls_addr(&ged.ged_result_str)); - } - - return 0; -} - - -/* - * Local Variables: - * mode: C - * tab-width: 8 - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Modified: brlcad/trunk/src/shapes/Makefile.am =================================================================== --- brlcad/trunk/src/shapes/Makefile.am 2009-01-09 19:52:37 UTC (rev 33499) +++ brlcad/trunk/src/shapes/Makefile.am 2009-01-09 19:55:50 UTC (rev 33500) @@ -7,7 +7,8 @@ mk_window \ mk_winfrm \ mk_gastank \ - mk_wire + mk_wire \ + tire AM_CPPFLAGS = ${TCL_CPPFLAGS} LDADD = ${WDB} @@ -19,6 +20,11 @@ mk_winfrm_SOURCES = mk_winfrm.c mk_wire_SOURCES = mk_wire.c +tire_SOURCES = tire.c +tire_LDADD = \ + ${GED} \ + ${WDB} + man_MANS = \ mk_bolt.1 \ mk_gastank.1 \ @@ -33,9 +39,10 @@ FAST_OBJECTS = \ $(mk_bolt_OBJECTS) \ + $(mk_gastank_OBJECTS) \ $(mk_handle_OBJECTS) \ $(mk_window_OBJECTS) \ $(mk_winfrm_OBJECTS) \ - $(mk_gastank_OBJECTS) \ $(mk_wire_OBJECTS) \ + $(tire_OBJECTS) \ $(bin_PROGRAMS) Copied: brlcad/trunk/src/shapes/tire.c (from rev 33496, brlcad/trunk/src/proc-db/tire.c) =================================================================== --- brlcad/trunk/src/shapes/tire.c (rev 0) +++ brlcad/trunk/src/shapes/tire.c 2009-01-09 19:55:50 UTC (rev 33500) @@ -0,0 +1,83 @@ +/* T I R E . C + * BRL-CAD + * + * Copyright (c) 2008 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file tire.c + * + * Tire Generator + * + * Program to create basic tire shapes. + */ + +#include "common.h" + +#include <stdio.h> +#include <stdlib.h> +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif + +#include "wdb.h" +#include "ged.h" + +#define DEFAULT_TIRE_FILENAME "tire.g" + + +int main(int ac, char *av[]) +{ + struct rt_wdb *db_fp = NULL; + const char *filename = NULL; + struct ged ged; + int ret; + + filename = DEFAULT_TIRE_FILENAME; + + /* Just using "tire.g" for now. */ + if (!bu_file_exists(filename)) { + db_fp = wdb_fopen(filename); + } else { + bu_exit(1, "ERROR - refusing to overwrite existing [%s] file.", filename); + } + mk_id(db_fp, "Tire"); + + GED_INIT(&ged, db_fp); + + /* create the tire */ + ret = ged_tire(&ged, ac, (const char **)av); + + /* Close database */ + wdb_close(db_fp); + + if (ret) { + unlink(filename); + bu_exit(1, "%s", bu_vls_addr(&ged.ged_result_str)); + } + + return 0; +} + + +/* + * Local Variables: + * mode: C + * tab-width: 8 + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-01-09 20:11:45
|
Revision: 33502 http://brlcad.svn.sourceforge.net/brlcad/?rev=33502&view=rev Author: brlcad Date: 2009-01-09 20:11:39 +0000 (Fri, 09 Jan 2009) Log Message: ----------- move the fence tool from proc-db to shapes Modified Paths: -------------- brlcad/trunk/src/proc-db/Makefile.am brlcad/trunk/src/shapes/Makefile.am Added Paths: ----------- brlcad/trunk/src/shapes/fence.c brlcad/trunk/src/shapes/fence.h Removed Paths: ------------- brlcad/trunk/src/proc-db/fence.c brlcad/trunk/src/proc-db/fence.h Modified: brlcad/trunk/src/proc-db/Makefile.am =================================================================== --- brlcad/trunk/src/proc-db/Makefile.am 2009-01-09 20:02:11 UTC (rev 33501) +++ brlcad/trunk/src/proc-db/Makefile.am 2009-01-09 20:11:39 UTC (rev 33502) @@ -12,7 +12,6 @@ brickwall \ clutter \ contours \ - fence \ globe \ human \ kurt \ @@ -63,7 +62,6 @@ brickwall_SOURCES = brickwall.c clutter_SOURCES = clutter.c common.c contours_SOURCES = contours.c -fence_SOURCES = fence.c globe_SOURCES = globe.c human_SOURCES = human.c kurt_SOURCES = kurt.c @@ -92,7 +90,6 @@ noinst_HEADERS = \ ducks.h \ - fence.h \ patches.h \ tea.h \ vegitation.h @@ -116,7 +113,6 @@ $(brickwall_OBJECTS) \ $(clutter_OBJECTS) \ $(contours_OBJECTS) \ - $(fence_OBJECTS) \ $(globe_OBJECTS) \ $(human_OBJECTS) \ $(kurt_OBJECTS) \ Deleted: brlcad/trunk/src/proc-db/fence.c =================================================================== --- brlcad/trunk/src/proc-db/fence.c 2009-01-09 20:02:11 UTC (rev 33501) +++ brlcad/trunk/src/proc-db/fence.c 2009-01-09 20:11:39 UTC (rev 33502) @@ -1,2511 +0,0 @@ -/* BRL-CAD F E N C E . C - * - * - * Copyright (c) 2004-2008 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - * - */ -/** @file fence.c - * - * This program generages a chain-link fence. Every parameter of - * the fence may be adjusted. Default values are held in fence.h - * Be wary of long fences... - * - * Note: It would be much more optimal for there to be a fence - * object type (or a mesh object type) so that memory usage is - * minimized. I.e. instead of creating a thousand little - * translations, rotations, and copies of basic primitives for a - * short 5 foot fence, we would just store the height, width, - * and mesh parameters (angle of twists in xyz, vertical separation, - * horizontal separation, and depth). - * - ***********************************************************************/ - -#include "./fence.h" - - -/* command-line options are described in the parseArguments function - */ -char *options="IiDdVvO:o:N:n:U:u:H:h:L:l:R:r:J:j:A:a:T:t:B:b:C:c:F:f:P:p:M:m:W:w:S:s:E:e:G:g:XxZz"; - -/* these variables control the "behavior" of this program's output - * if debug is set, debug information (extra "useful" output is given) is - * displayed on stdout. - * if verbose is set, then all prompting and output that may be shown - * (such as results and errors) will be sent to stderr. this should - * probably be switched with debug (maybe) but convention was taken - * from another db program. - * if interactive is set, then the user will be prompted for values from - * stdin. - * - * the default output file pointers for debug and verbose can be set - * in the header file - */ -int debug=DEFAULT_DEBUG; -int verbose=DEFAULT_VERBOSE; -int interactive=DEFAULT_INTERACTIVE; - -/* start of variable definitions for the fence - * - * see the fence.h header file for a description of each of the default values - * that may be set. all default values should be set in the fence.h header - * file, not here. - */ -char outputFilename[DEFAULT_MAXNAMELENGTH]=DEFAULT_OUTPUTFILENAME; -char id[DEFAULT_MAXNAMELENGTH]=DEFAULT_ID; -char units[DEFAULT_MAXNAMELENGTH]=DEFAULT_UNITS; - -char fenceName[DEFAULT_MAXNAMELENGTH]=DEFAULT_FENCENAME; -point_t fenceStartPosition=DEFAULT_FENCESTARTPOSITION; -point_t fenceEndPosition=DEFAULT_FENCEENDPOSITION; -vect_t fenceWidth=DEFAULT_FENCEWIDTH; -vect_t fenceHeight=DEFAULT_FENCEHEIGHT; -double fencePoleSpacing=DEFAULT_FENCEPOLESPACING; -char fenceMaterial[DEFAULT_MAXNAMELENGTH*3]=DEFAULT_FENCEMATERIAL; -char fenceMaterialParams[DEFAULT_MAXNAMELENGTH*3]=DEFAULT_FENCEMATERIALPARAMS; -unsigned char fenceMaterialColor[3]=DEFAULT_FENCEMATERIALCOLOR; -int fenceFence=DEFAULT_FENCEFENCE; -int fencePoles=DEFAULT_FENCEPOLES; -int fenceMesh=DEFAULT_FENCEMESH; -int fenceWire=DEFAULT_FENCEWIRE; -int generateFenceParam=DEFAULT_GENERATEFENCE; -int generatePolesParam=DEFAULT_GENERATEPOLES; -int generateMeshParam=DEFAULT_GENERATEMESH; - -char poleName[DEFAULT_MAXNAMELENGTH]=DEFAULT_POLENAME; -double poleHeight=DEFAULT_POLEHEIGHT; -double poleRadius=DEFAULT_POLERADIUS; -char poleMaterial[DEFAULT_MAXNAMELENGTH*3]=DEFAULT_POLEMATERIAL; -char poleMaterialParams[DEFAULT_MAXNAMELENGTH*3]=DEFAULT_POLEMATERIALPARAMS; -unsigned char poleMaterialColor[3]=DEFAULT_POLEMATERIALCOLOR; - -char meshName[DEFAULT_MAXNAMELENGTH]=DEFAULT_MESHNAME; -double meshHeight=DEFAULT_MESHHEIGHT; -double meshWidth=DEFAULT_MESHWIDTH; -char meshMaterial[DEFAULT_MAXNAMELENGTH*3]=DEFAULT_MESHMATERIAL; -char meshMaterialParams[DEFAULT_MAXNAMELENGTH*3]=DEFAULT_MESHMATERIALPARAMS; -unsigned char meshMaterialColor[3]=DEFAULT_MESHMATERIALCOLOR; - -char wireName[DEFAULT_MAXNAMELENGTH]=DEFAULT_WIRENAME; -char segmentName[DEFAULT_MAXNAMELENGTH]=DEFAULT_SEGMENTNAME; -double wireRadius=DEFAULT_WIRERADIUS; -double wireAngle=DEFAULT_WIREANGLE; -double wireSegmentLength=DEFAULT_WIRESEGMENTLENGTH; -double wireSegmentSeparation=DEFAULT_WIRESEGMENTSEPARATION; -char wireMaterial[DEFAULT_MAXNAMELENGTH*3]=DEFAULT_WIREMATERIAL; -char wireMaterialParams[DEFAULT_MAXNAMELENGTH*3]=DEFAULT_WIREMATERIALPARAMS; -unsigned char wireMaterialColor[3]=DEFAULT_WIREMATERIALCOLOR; - -size_t maxWireSegments=DEFAULT_MAXWIRESEGMENTS; -/* end of variable definitions used for the fence generation - */ - - -/* - * argumentHelp() is the all encompassing help message that is displayed when - * an invalid command line argument is entered or if the user explicitly - * requests assistance. - ***************************************/ -void argumentHelp(FILE *fp, char *progname, char *message) -{ - - fflush(stdout); - if (message) { - fprintf(fp, "%s\n", message); - } - fflush(stdout); - - fprintf(fp, "Usage Format: \n%s %s\n\n", progname, \ - "-[ivdonuhHlLrRjatTbBcCfpmwseEgGxXzZ]" \ - ); - fprintf(fp, "\t-[ivd]\n\t\tspecifies interactive, verbose, and/or debug modes\n"); - fprintf(fp, "\t-[IVD]\n\t\ttoggles interactive, verbose, and/or debug modes\n"); - fprintf(fp, "\t-o filename\n\t\tspecifies the name of the file to output to\n"); - fprintf(fp, "\t-n 'string'\n\t\tthe 'string' name of the csg database\n"); - fprintf(fp, "\t-u 'units'\n\t\tthe units of the data in the csg database\n"); - fprintf(fp, "\t-[hH] ['xval yval zval' | val]\n\t\tspecifies the height as either vector or single value (z dir is up)\n"); - fprintf(fp, "\t-[lL] ['xval yval zval' | val]\n\t\tspecifies the length as either vector or single value (x dir is long)\n"); - fprintf(fp, "\t-r radius\n\t\tthe radius of the fence's mesh wires\n"); - fprintf(fp, "\t-R radius\n\t\tthe radius of the fence poles\n"); - fprintf(fp, "\t-a angle\n\t\tthe primary angle of the wire 'zig-zagging'\n"); - fprintf(fp, "\t-j distance\n\t\tthe maximum spacing between the poles\n"); - fprintf(fp, "\t-[tT] 'material'\n\t\tthe material of the fence (t) or \n\t\tthe material of all generated regions (T)\n"); - fprintf(fp, "\t-[bB] 'parameters'\n\t\tthe parameter string for the fence material(b)\n\t\tor of all region materials (B)\n"); - fprintf(fp, "\t-[cC] 'rval gval bval'\b\t\tthe RGB color of the fence (c)\n\t\tor of all region materials (C)\n\t\t(0 <= values <= 255)\n"); - fprintf(fp, "\t-f fencename\n\t\tthe base name of the fence objects in the database\n"); - fprintf(fp, "\t-p polename\n\t\tthe base name of the pole objects in the database\n"); - fprintf(fp, "\t-m meshname\n\t\tthe base name of the mesh objects in the database\n"); - fprintf(fp, "\t-w wirename\n\t\tthe base name of the wire objects in the database\n"); - fprintf(fp, "\t-s segmentname\n\t\tthe base name of the segment objects in the database\n"); - fprintf(fp, "\t-[eE] [fpmw]\n\t\tthe values for the fence, poles, mesh, and wires may be edited\n\t\t'e' specifies to edit while 'E' specifies the opposite of the defaults\n\t\tuseful for interactive mode only\n"); - fprintf(fp, "\t-[gG] [fpm]\n\t\tspecifies which parts of the fence object(s) to generate\n\t\t'g' specifies to generate the object(s)\n\t\t'G' specifies to do the opposite of the default(s)\n"); - fprintf(fp, "\t-[xX]\n\t\tdisplays some command-line parameter examples\n"); - fprintf(fp, "\t-[zZ]\n\t\tdisplays the default settings\n"); - fprintf(fp, "\n"); - - fflush(stdout); - - return; -} - -/* - * argumentExamples() outputs some examples of using the command line - * arguments in a useful manner - **********************************/ -void argumentExamples(FILE *fp, char *progname) -{ - fprintf(fp, "Usage Examples: \n\n"); - - fprintf(fp, "Simple Interactive-Mode Example: \n%s %s %s %s %s %s\n", - progname, \ - "-i -v", \ - "-o", outputFilename, \ - "-e", "f" \ - ); - fprintf(fp, "\n"); - - fprintf(fp, "Full Interactive-Mode Example: \n%s %s %s %s %s %s\n", - progname, \ - "-i -v", \ - "-o", outputFilename, \ - "-e", "fpmw" \ - ); - fprintf(fp, "\n"); - - fprintf(fp, "Simple Parameter-Specified Example: \n%s %s %s %s %.1f %s %.1f\n", - progname, \ - "-o", outputFilename, \ - "-H", MAGNITUDE(fenceHeight), \ - "-L", MAGNITUDE(fenceWidth) \ - ); - fprintf(fp, "\n"); - - fprintf(fp, "Extended Parameter-Specified Example: \n%s %s %s %s %s %s %s %s '%.1f %.1f %.1f' %s '%.1f %.1f %.1f' %s %.1f %s %.1f %s %.1f %s %.1f %s '%d %d %d' %s %s\n", - progname, \ - "-n", id, \ - "-u", units, \ - "-o", outputFilename, \ - "-h", fenceHeight[0], fenceHeight[1], fenceHeight[2], \ - "-l", fenceWidth[0], fenceWidth[1], fenceWidth[2], \ - "-r", wireRadius, \ - "-R", poleRadius, \ - "-a", wireAngle, \ - "-j", fencePoleSpacing, \ - "-c", fenceMaterialColor[0], fenceMaterialColor[1], fenceMaterialColor[2], \ - "-e", "fpm" \ - ); - fprintf(fp, "\n"); - - return; -} - - -/* - * defaultSettings() outputs the default values of the program to a - * given file pointer. - * - ***********************/ -void defaultSettings(FILE *fp) -{ - fprintf(fp, "Default values:\n\n"); - fprintf(fp, "\tVerbose mode is %s\n", verbose ? "on" : "off"); - fprintf(fp, "\tDebug mode is %s\n", debug ? "on" : "off"); - fprintf(fp, "\tInteractive mode is %s\n", interactive ? "on" : "off"); - if (interactive) fprintf(fp, "\t\tInteractive parameters for fence=%d poles=%d mesh=%d wire=%d\n", fenceFence, fencePoles, fenceMesh, fenceWire); - fprintf(fp, "\n\tOutput file name is %s\n", outputFilename); - fprintf(fp, "\t\tid='%s' units='%s'\n", id, units); - fprintf(fp, "\n\tSet to generate %s%s%s object(s)\n", generateFenceParam ? "fence " : "", generatePolesParam ? "poles " : "", generateMeshParam ? "& mesh" : ""); - fprintf(fp, "\n\tFence Properties:\n"); - fprintf(fp, "\t\tStart Position[%.1f %.1f %.1f] \n\t\tEnd Position[%.1f %.1f %.1f]\n", fenceStartPosition[0], fenceStartPosition[1], fenceStartPosition[2], fenceEndPosition[0], fenceEndPosition[1], fenceEndPosition[2]); - fprintf(fp, "\t\tHeight Vector[%.1f %.1f %.1f] \n\t\tWidth Vector[%.1f %.1f %.1f]\n", fenceHeight[0], fenceHeight[1], fenceHeight[2], fenceWidth[0], fenceWidth[1], fenceWidth[2]); - fprintf(fp, "\t\tHeight Magnitude[%f] \n\t\tWidth Magnitude[%f]\n", MAGNITUDE(fenceHeight), MAGNITUDE(fenceWidth)); - fprintf(fp, "\t\tMaterial[%s] \n\t\tMaterial Parameters[%s] \n\t\tMaterial Color[%d %d %d]\n\n", fenceMaterial, fenceMaterialParams, fenceMaterialColor[0], fenceMaterialColor[1], fenceMaterialColor[2]); - fprintf(fp, "\t\tPole:\n"); - fprintf(fp, "\t\t\tHeight[%f] \n\t\t\tRadius[%f] \n\t\t\tSpacing[%f] \n\n", poleHeight, poleRadius, fencePoleSpacing); - fprintf(fp, "\t\t\tMaterial[%s] \n\t\t\tMaterial Parameters[%s] \n\t\t\tMaterial Color[%d %d %d]\n\n", poleMaterial, poleMaterialParams, poleMaterialColor[0], poleMaterialColor[1], poleMaterialColor[2]); - fprintf(fp, "\t\tMesh:\n"); - fprintf(fp, "\t\t\tHeight[%f] \n\t\t\tWidth[%f] \n\n", meshHeight, meshWidth); - fprintf(fp, "\t\t\tMaterial[%s] \n\t\t\tMaterial Parameters[%s] \n\t\t\tMaterial Color[%d %d %d]\n\n", meshMaterial, meshMaterialParams, meshMaterialColor[0], meshMaterialColor[1], meshMaterialColor[2]); - fprintf(fp, "\t\t\tWire:\n"); - fprintf(fp, "\t\t\t\tWireRadius[%f] \n\t\t\t\tWireAngle[%f] \n\t\t\t\tWireSegmentLength[%f] \n\t\t\t\tWireSegmentSeparation[%f]\n\n", wireRadius, wireAngle, wireSegmentLength, wireSegmentSeparation); - fprintf(fp, "\t\t\t\tMaterial[%s] \n\t\t\t\tMaterial Parameters[%s] \n\t\t\t\tMaterial Color[%d %d %d]\n\n", wireMaterial, wireMaterialParams, wireMaterialColor[0], wireMaterialColor[1], wireMaterialColor[2]); - fprintf(fp, "\tCombination Names: \n"); - fprintf(fp, "\t\tFence: [%s] \n\t\tPoles: [%s] \n\t\tMesh: [%s] \n\t\tWires: [%s] \n\t\tSegments: [%s] \n\n", fenceName, poleName, meshName, wireName, segmentName); - fprintf(fp, "\n"); - fprintf(fp, "No action performed.\n"); -} - - -/* - * parseArguments() is called by main to take care of all of the command-line - * arguments that the user specifies. The args that are read set variables - * which, in turn, are used as fence parameters. - *****************************/ -int parseArguments(int argc, char **argv) -{ - int c = 0; - - double d=0.0; - char *progname; - int color[3]; - - progname = (char *) bu_calloc(DEFAULT_MAXNAMELENGTH, sizeof(char), "progname"); - - if (argc > 1) { - bu_strlcpy(progname, argv[0], (strlen(argv[0])+1>DEFAULT_MAXNAMELENGTH?DEFAULT_MAXNAMELENGTH:strlen(argv[0])+1)); - } - else { - bu_strlcpy(progname, "fence\0", 6); - } - fflush(stdout); - - bu_opterr = 0; - - while ((c=bu_getopt(argc, argv, options)) != EOF) { - switch (c) { - case 'I' : - interactive=(DEFAULT_INTERACTIVE) ? 0 : 1; - break; - - case 'i' : - interactive=1; - break; - - case 'D' : - debug=(DEFAULT_DEBUG) ? 0 : 1; - break; - - case 'd' : - debug=1; - break; - - case 'V' : - verbose=(DEFAULT_VERBOSE) ? 0 : 1; - break; - - case 'v' : - verbose=1; - break; - - case 'o' : - memset(outputFilename, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(outputFilename, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - case 'O' : - memset(outputFilename, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(outputFilename, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - - case 'n' : - memset(id, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(id, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - case 'N' : - memset(id, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(id, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - - case 'u' : - memset(units, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(units, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - case 'U' : - memset(units, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(units, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - - case 'h' : - if ((sscanf(bu_optarg, "%lf %lf %lf", &fenceHeight[0], &fenceHeight[1], &fenceHeight[2]))!=3) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Invalid number of parameters to height: need x, y, z values"); - bu_exit(1, NULL); - } - if ((double)MAGNITUDE(fenceHeight) == 0.0) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Fence height may not be set to zero"); - bu_exit(1, NULL); - } - poleHeight = (double) MAGNITUDE(fenceHeight); - meshHeight = (double) poleHeight; - break; - case 'H' : - if ((d=(double)atof(bu_optarg))!=0.0) { - fenceHeight[0]=0.0; - fenceHeight[1]=0.0; - fenceHeight[2]=d; - poleHeight=(double)MAGNITUDE(fenceHeight); - meshHeight=(double)poleHeight; - } - else { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Fence height may not be set to zero"); - bu_exit(1, NULL); - } - break; - - case 'l' : - if ((sscanf(bu_optarg, "%lf %lf %lf", &fenceWidth[0], &fenceWidth[1], &fenceWidth[2]))!=3) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Invalid number of parameters to width: need x, y, z values"); - bu_exit(1, NULL); - } - if ((double)MAGNITUDE(fenceWidth) == 0.0) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Fence width may not be set to zero"); - bu_exit(1, NULL); - } - meshWidth = (double) MAGNITUDE(fenceWidth); - break; - case 'L' : - if ((d=(double)atof(bu_optarg))!=0.0) { - fenceWidth[0]=d; - fenceWidth[1]=0.0; - fenceWidth[2]=0.0; - meshWidth=(double)MAGNITUDE(fenceWidth); - } - else { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Fence width may not be set to zero"); - bu_exit(1, NULL); - } - break; - - case 'r' : - if ((d=(double)atof(bu_optarg))!=0.0) { - wireRadius=d; - } - else { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Wire radius may not be set to zero"); - bu_exit(1, NULL); - } - break; - case 'R' : - if ((d=(double)atof(bu_optarg))!=0.0) { - poleRadius=d; - } - else { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Pole radius may not be set to zero"); - bu_exit(1, NULL); - } - break; - - case 'a' : - if ((d=(double)atof(bu_optarg))!=0.0) { - wireAngle=d; - } - else { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Wire angle may not be set to zero"); - bu_exit(1, NULL); - } - break; - case 'A' : - if ((d=(double)atof(bu_optarg))!=0.0) { - wireAngle=d; - } - else { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Wire angle may not be set to zero"); - bu_exit(1, NULL); - } - break; - - case 'j' : - if ((d=(double)atof(bu_optarg))!=0.0) { - fencePoleSpacing=d; - } - else { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Pole spacing may not be set to zero"); - bu_exit(1, NULL); - } - break; - case 'J' : - if ((d=(double)atof(bu_optarg))!=0.0) { - fencePoleSpacing=d; - } - else { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Pole spacing may not be set to zero"); - bu_exit(1, NULL); - } - break; - - case 't' : - memset(fenceMaterial, 0, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(fenceMaterial, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - break; - case 'T' : - memset(fenceMaterial, 0, DEFAULT_MAXNAMELENGTH*3); - memset(poleMaterial, 0, DEFAULT_MAXNAMELENGTH*3); - memset(meshMaterial, 0, DEFAULT_MAXNAMELENGTH*3); - memset(wireMaterial, 0, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(fenceMaterial, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(poleMaterial, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(meshMaterial, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(wireMaterial, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - break; - - case 'b' : - memset(fenceMaterialParams, 0, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(fenceMaterialParams, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - break; - case 'B' : - memset(fenceMaterialParams, 0, DEFAULT_MAXNAMELENGTH*3); - memset(poleMaterialParams, 0, DEFAULT_MAXNAMELENGTH*3); - memset(meshMaterialParams, 0, DEFAULT_MAXNAMELENGTH*3); - memset(wireMaterialParams, 0, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(fenceMaterialParams, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(poleMaterialParams, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(meshMaterialParams, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - bu_strlcpy(wireMaterialParams, bu_optarg, DEFAULT_MAXNAMELENGTH*3); - break; - - case 'c' : - if ((sscanf(bu_optarg, "%u %u %u", (unsigned int *)&color[0], (unsigned int *)&color[1], (unsigned int *)&color[2]))!=3) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Invalid number of parameters for material color: need r, g, b values"); - bu_exit(1, NULL); - } - if ((color[0]<0)|(color[0]>255)|(color[1]<0)|(color[1]>255)|(color[2]<0)|(color[2]>255)) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Fence material color values must be in the range of 0 to 255 inclusive"); - bu_exit(1, NULL); - } - fenceMaterialColor[0] = (unsigned char)color[0]; - fenceMaterialColor[1] = (unsigned char)color[1]; - fenceMaterialColor[2] = (unsigned char)color[2]; - break; - case 'C' : - if ((sscanf(bu_optarg, "%u %u %u", (unsigned int *)&color[0], (unsigned int *)&color[1], (unsigned int *)&color[2]))!=3) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Invalid number of parameters for material color: need r, g, b values"); - bu_exit(1, NULL); - } - if ((color[0]<0)|(color[0]>255)|(color[1]<0)|(color[1]>255)|(color[2]<0)|(color[2]>255)) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Fence material color values must be in the range of 0 to 255 inclusive"); - bu_exit(1, NULL); - } - fenceMaterialColor[0] = (unsigned char)color[0]; - fenceMaterialColor[1] = (unsigned char)color[1]; - fenceMaterialColor[2] = (unsigned char)color[2]; - poleMaterialColor[0] = fenceMaterialColor[0]; - poleMaterialColor[1] = fenceMaterialColor[1]; - poleMaterialColor[2] = fenceMaterialColor[2]; - meshMaterialColor[0] = fenceMaterialColor[0]; - meshMaterialColor[1] = fenceMaterialColor[1]; - meshMaterialColor[2] = fenceMaterialColor[2]; - wireMaterialColor[0] = fenceMaterialColor[0]; - wireMaterialColor[1] = fenceMaterialColor[1]; - wireMaterialColor[2] = fenceMaterialColor[2]; - break; - - - case 'f' : - memset(fenceName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(fenceName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - case 'F' : - memset(fenceName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(fenceName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - - case 'p' : - memset(poleName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(poleName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - case 'P' : - memset(poleName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(poleName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - - case 'm' : - memset(meshName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(meshName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - case 'M' : - memset(meshName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(meshName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - - case 'w' : - memset(wireName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(wireName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - case 'W' : - memset(wireName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(wireName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - - case 's' : - memset(segmentName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(segmentName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - case 'S' : - memset(segmentName, 0, DEFAULT_MAXNAMELENGTH); - bu_strlcpy(segmentName, bu_optarg, DEFAULT_MAXNAMELENGTH); - break; - - case 'e' : - fenceFence = 0; - fencePoles = 0; - fenceMesh = 0; - fenceWire = 0; - if (strchr(bu_optarg, 'f')!=NULL) fenceFence = 1; - if (strchr(bu_optarg, 'p')!=NULL) fencePoles = 1; - if (strchr(bu_optarg, 'm')!=NULL) fenceMesh = 1; - if (strchr(bu_optarg, 'w')!=NULL) fenceWire = 1; - if (strchr(bu_optarg, 'F')!=NULL) fenceFence = 1; - if (strchr(bu_optarg, 'P')!=NULL) fencePoles = 1; - if (strchr(bu_optarg, 'M')!=NULL) fenceMesh = 1; - if (strchr(bu_optarg, 'W')!=NULL) fenceWire = 1; - break; - case 'E' : - if (strchr(bu_optarg, 'f')!=NULL) fenceFence = (DEFAULT_FENCEFENCE) ? 0 : 1; - if (strchr(bu_optarg, 'p')!=NULL) fencePoles = (DEFAULT_FENCEPOLES) ? 0 : 1; - if (strchr(bu_optarg, 'm')!=NULL) fenceMesh = (DEFAULT_FENCEMESH) ? 0 : 1; - if (strchr(bu_optarg, 'w')!=NULL) fenceWire = (DEFAULT_FENCEWIRE) ? 0 : 1; - if (strchr(bu_optarg, 'F')!=NULL) fenceFence = (DEFAULT_FENCEFENCE) ? 0 : 1; - if (strchr(bu_optarg, 'P')!=NULL) fencePoles = (DEFAULT_FENCEPOLES) ? 0 : 1; - if (strchr(bu_optarg, 'M')!=NULL) fenceMesh = (DEFAULT_FENCEMESH) ? 0 : 1; - if (strchr(bu_optarg, 'W')!=NULL) fenceWire = (DEFAULT_FENCEWIRE) ? 0 : 1; - break; - - case 'g' : - generateFenceParam = 0; - generatePolesParam = 0; - generateMeshParam = 0; - if (strchr(bu_optarg, 'f')!=NULL) generateFenceParam = 1; - if (strchr(bu_optarg, 'p')!=NULL) generatePolesParam = 1; - if (strchr(bu_optarg, 'm')!=NULL) generateMeshParam = 1; - if (strchr(bu_optarg, 'F')!=NULL) generateFenceParam = 1; - if (strchr(bu_optarg, 'P')!=NULL) generatePolesParam = 1; - if (strchr(bu_optarg, 'M')!=NULL) generateMeshParam = 1; - if (generateFenceParam == 0 && generatePolesParam == 0 && generateMeshParam == 0) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Invalid generate parameters specified"); - bu_exit(1, NULL); - } - break; - case 'G' : - if (strchr(bu_optarg, 'f')!=NULL) generateFenceParam = (DEFAULT_GENERATEFENCE) ? 0 : 1; - if (strchr(bu_optarg, 'p')!=NULL) generatePolesParam = (DEFAULT_GENERATEPOLES) ? 0 : 1; - if (strchr(bu_optarg, 'm')!=NULL) generateMeshParam = (DEFAULT_GENERATEMESH) ? 0 : 1; - if (strchr(bu_optarg, 'F')!=NULL) generateFenceParam = (DEFAULT_GENERATEFENCE) ? 0 : 1; - if (strchr(bu_optarg, 'P')!=NULL) generatePolesParam = (DEFAULT_GENERATEPOLES) ? 0 : 1; - if (strchr(bu_optarg, 'M')!=NULL) generateMeshParam = (DEFAULT_GENERATEMESH) ? 0 : 1; - if (generateFenceParam == 0 && generatePolesParam == 0 && generateMeshParam == 0) { - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Invalid generate parameters specified or all specified to zero"); - bu_exit(1, NULL); - } - break; - - case 'x' : - (void)argumentExamples(DEFAULT_VERBOSE_OUTPUT, progname); - bu_exit(1, NULL); - break; - case 'X' : - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Example assistance"); - (void)argumentExamples(DEFAULT_VERBOSE_OUTPUT, progname); - bu_exit(1, NULL); - break; - - case 'z' : - (void)defaultSettings(DEFAULT_VERBOSE_OUTPUT); - bu_exit(1, NULL); - break; - case 'Z' : - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Full parameter assistance"); - (void)defaultSettings(DEFAULT_VERBOSE_OUTPUT); - bu_exit(1, NULL); - break; - - case '?' : - fflush(stdout); - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Command-line argument assistance"); - bu_exit(1, NULL); - break; - - default : /*shouldn't be reached since getopt throws a ? for args not found*/ - fflush(stdout); - (void)argumentHelp(DEFAULT_VERBOSE_OUTPUT, progname, "Illegal command-line argument"); - bu_exit(1, NULL); - break; - } - } - fflush(stdout); - - bu_free(progname, "progname"); - - return(bu_optind); -} - -/* - * printMatrix() does just that, it prints out a matrix and a label passed to - * some fp (usually DEFAULT_DEBUG_OUTPUT or DEFAULT_VERBOSE_OUTPUT). - *************************/ -void printMatrix(FILE *fp, char *n, fastf_t *m) -{ - int i = 0; - fprintf(fp, "\n-----%s------\n", n); - for (i = 0; i < 16; i++) { - if (i%4 == 0 && i != 0) fprintf(fp, "\n"); - fprintf(fp, "%6.2f ", m[i]); - } - fprintf(fp, "\n-----------\n"); -} - - -/* - * getName() returns a name back based on a base string, a numerical id and a - * parameter string for merging those two parameters. Basically it adds the - * id number to the end of the base so that we can set unique ids for our - * objects and groups. (i.e. base="rcc", id="5"==> returns "rcc005.s" or - * something like that) - ***********************************/ -char *getName(const char *base, int id, const char *paramstring) -{ - static char name[DEFAULT_MAXNAMELENGTH]; - - memset(name, 0, DEFAULT_MAXNAMELENGTH); - - if (id>=0) snprintf(name, DEFAULT_MAXNAMELENGTH, paramstring, base, id); - else snprintf(name, DEFAULT_MAXNAMELENGTH, paramstring, base); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "getName(): base[%s], id[%d]\n", base, id); - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "Using name[%s]\n", name); - - return name; -} - - -/* - * getPrePostName() returns a name for a region. the name is formed by - * simply appending three given strings passed. the three strings comprise - * the base, prefix, and suffix of the name. any three are optional by - * sending a NULL parameter - *****************************************/ -char *getPrePostName(char *prefix, char *base, char *suffix) -{ - static char newname[DEFAULT_MAXNAMELENGTH]; - - memset(newname, 0, DEFAULT_MAXNAMELENGTH); - - if (prefix) snprintf(newname, DEFAULT_MAXNAMELENGTH, "%s", prefix); - if (base) snprintf(newname, DEFAULT_MAXNAMELENGTH, "%s%s", newname, base); - if (suffix) snprintf(newname, DEFAULT_MAXNAMELENGTH, "%s%s", newname, suffix); - - return newname; -} - - -/* - * generateFence_s() is a simplified version of gererateFence() (this is the same for all - * members of the "generate" family). It's function is to provide a default-value based - * interface to generating fence. That is, the function may be called with as few parameters - * as necessary to actually generate the fence. - *************************************************************/ -int generateFence_s(struct rt_wdb *fp, char *fencename, fastf_t *startposition, fastf_t *endposition) -{ - vect_t widthvector; - vect_t heightvector; - - VSUB2(widthvector, endposition, startposition); - VMOVE(heightvector, fenceHeight); - - return generateFence(fp, fencename, startposition, heightvector, widthvector); -} - -int generateFence(struct rt_wdb *fp, char *fencename, fastf_t *startposition, fastf_t *heightvector, fastf_t *widthvector) -{ - int errors=0; - int poleerrors=0; - int mesherrors=0; - - struct wmember fencemembers; - struct wmember fenceregionmembers; - - BU_LIST_INIT(&fencemembers.l); - BU_LIST_INIT(&fenceregionmembers.l); - - VMOVE(fenceStartPosition, startposition); - VMOVE(fenceHeight, heightvector); - VMOVE(fenceWidth, widthvector); - - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "\nBeginning fence [%s] generation...\n", fencename); - - if ((mk_id_units(fp, id, units))==0) { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:id[%s], units[%s]\n", id, units); - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "\"%s\" (units==\"%s\")\n", id, units); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:mk_id_units FAILED with id[%s], units[%s]", id, units); - errors++; - } - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:generatePolesParam[%d], generateMeshParam[%d], generateFenceParam[%d]\n", generatePolesParam, generateMeshParam, generateFenceParam); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:startposition[%f][%f][%f]\n", startposition[0], startposition[1], startposition[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:fencewidth[%f][%f][%f]\n", widthvector[0], widthvector[1], widthvector[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:fenceheight[%f][%f][%f]\n", heightvector[0], heightvector[1], heightvector[2]); - - if (generatePolesParam) { - if ((poleerrors=generatePoles_s(fp, poleName))==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Pole generated\n"); - - if ((mk_addmember(poleName, &fencemembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building fence...poles added...\n"); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building fence...ERROR adding poles to fence combination\n"); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:mk_addmember poleName[%s] FAILED\n", poleName); - errors++; - } - if ((mk_addmember(poleName, &fenceregionmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building fence region...poles added...\n"); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building fence region...ERROR adding poles to fence region\n"); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:mk_addmember poleName[%s] FAILED\n", poleName); - errors++; - } - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Pole generation FAILED\n"); - errors+=poleerrors; - } - - - } - if (generateMeshParam) { - if ((mesherrors+=generateMesh_s(fp, meshName))==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Mesh generated\n"); - - if ((mk_addmember(meshName, &fencemembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building fence...mesh added...\n"); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building fence...ERROR adding mesh to fence combination\n"); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:mk_addmember meshName[%s] FAILED\n", meshName); - } - if ((mk_addmember(meshName, &fenceregionmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building fence region...mesh added...\n"); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building fence region...ERROR adding mesh to fence region\n"); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:mk_addmember meshName[%s] FAILED\n", meshName); - } - - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Mesh generation FAILED\n"); - errors+=mesherrors; - } - } - - if (generateFenceParam) { - if (mk_lcomb (fp, fencename, &fencemembers, 0, NULL, NULL, NULL, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...completed fence [%s] combination\n", fencename); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:fencename[%s]\n", fencename); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:mk_lcomb fencename[%s] FAILED\n", fencename); - errors++; - } - - if (mk_lcomb (fp, getPrePostName(NULL, fencename, DEFAULT_REGIONSUFFIX), &fenceregionmembers, 1, fenceMaterial, fenceMaterialParams, fenceMaterialColor, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...completed fence [%s] region\n", getPrePostName(NULL, fencename, DEFAULT_REGIONSUFFIX)); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:fencename[%s]\n", getPrePostName(NULL, fencename, DEFAULT_REGIONSUFFIX)); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateFence:mk_lcomb fencename[%s] FAILED (region)\n", getPrePostName(NULL, fencename, DEFAULT_REGIONSUFFIX)); - errors++; - } - } - - - return errors; -} - - -/* - * generatePoles() is the function that actually generates all of the - * poles for the scene - ********************************/ -int generatePoles_s(struct rt_wdb *fp, char *polename) -{ - vect_t polevector; - - VMOVE(polevector, fenceHeight); - VUNITIZE(polevector); - VSCALE(polevector, polevector, poleHeight); - - return generatePoles(fp, polename, fenceStartPosition, polevector, fenceWidth, poleRadius); -} - -int generatePoles(struct rt_wdb *fp, char *polename, fastf_t *startposition, fastf_t *heightvector, fastf_t *widthvector, double radius) -{ - int count=0; - int errors=0; - double step=0.0; - double steplocationlimit=0.0; - double fencepolespacing=(double)fencePoleSpacing; - point_t tempposition; - vect_t polespacingvector; - - struct wmember polemembers; - struct wmember poleregionmembers; - - BU_LIST_INIT(&polemembers.l); - BU_LIST_INIT(&poleregionmembers.l); - - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "\nBeginning pole [%s] generation...\n", polename); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles:polename[%s], startposition[%f][%f][%f], heightvector[%f][%f][%f], radius[%f]\n", polename, startposition[0], startposition[1], startposition[2], heightvector[0], heightvector[1], heightvector[2], radius); - - - VMOVE(tempposition, startposition); - steplocationlimit=MAGNITUDE(widthvector); - VMOVE(polespacingvector, widthvector); - VUNITIZE(polespacingvector); - VSCALE(polespacingvector, polespacingvector, fencepolespacing); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles:steplocationlimit[%f], polespacingvector[%f][%f][%f]\n", steplocationlimit, polespacingvector[0], polespacingvector[1], polespacingvector[2]); - - for (step=0.0, count=0; step<(steplocationlimit-(fencepolespacing/3)); step+=fencepolespacing, count++) { - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles: tempposition[%f][%f][%f]\n", tempposition[0], tempposition[1], tempposition[2]); - - if ((mk_rcc(fp, getName(polename, count, DEFAULT_POLEBASICPARAM), tempposition, heightvector, radius))==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Pole [%d] generated\n", count); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Pole [%d] generation FAILED\n", count); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles: polename[%s], count[%d], tempposition[%f][%f][%f], heightvector[%f][%f][%f], radius[%f]\n", polename, count, tempposition[0], tempposition[1], tempposition[2], heightvector[0], heightvector[1], heightvector[2], radius); - errors++; - } - - if ((mk_addmember(getName(polename, count, DEFAULT_POLEBASICPARAM), &polemembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...adding pole [%d] to pole list\n", count); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles:mk_addmember count[%d] FAILED\n", count); - errors++; - } - if ((mk_addmember(getName(polename, count, DEFAULT_POLEBASICPARAM), &poleregionmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...adding pole [%d] to pole region list\n", count); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles:mk_addmember count[%d] FAILED(region)\n", count); - errors++; - } - - VADD2(tempposition, tempposition, polespacingvector); - } - VMOVE(tempposition, startposition); - VADD2(tempposition, tempposition, widthvector); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles: tempposition[%f][%f][%f]\n", tempposition[0], tempposition[1], tempposition[2]); - - if ((mk_rcc(fp, getName(polename, count, DEFAULT_POLEBASICPARAM), tempposition, heightvector, radius))==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Pole [%d] generated\n", count); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Pole [%d] generation FAILED\n", count); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles: polename[%s], count[%d], tempposition[%f][%f][%f], heightvector[%f][%f][%f], radius[%f]\n", polename, count, tempposition[0], tempposition[1], tempposition[2], heightvector[0], heightvector[1], heightvector[2], radius); - errors++; - } - - if ((mk_addmember(getName(polename, count, DEFAULT_POLEBASICPARAM), &polemembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...adding pole [%d] to pole list\n", count); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles:mk_addmember count[%d] FAILED\n", count); - errors++; - } - if ((mk_addmember(getName(polename, count, DEFAULT_POLEBASICPARAM), &poleregionmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...adding pole [%d] to pole region list\n", count); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles:mk_addmember count[%d] FAILED (region)\n", count); - errors++; - } - - - if (mk_lcomb (fp, poleName, &polemembers, 0, NULL, NULL, NULL, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...pole [%s] combination completed\n", poleName); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles:mk_lcomb poleName[%s] FAILED\n", poleName); - errors++; - } - if (mk_lcomb (fp, getPrePostName(NULL, poleName, DEFAULT_REGIONSUFFIX), &poleregionmembers, 1, poleMaterial, poleMaterialParams, poleMaterialColor, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...pole [%s] region completed\n", getPrePostName(NULL, poleName, DEFAULT_REGIONSUFFIX)); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generatePoles:mk_lcomb poleName[%s] FAILED (region)\n", getPrePostName(NULL, poleName, DEFAULT_REGIONSUFFIX)); - errors++; - } - - - return errors; -} - - -/* - * generateMesh() generates the wire mesh (the actual fence mesh) that - * gets attached to the poles (if given). - *******************************/ -int generateMesh_s(struct rt_wdb *fp, char *meshname) -{ - point_t meshstartposition; - vect_t meshheightvector; - vect_t meshwidthvector; - - VMOVE(meshstartposition, fenceStartPosition); - VMOVE(meshheightvector, fenceHeight); - VMOVE(meshwidthvector, fenceWidth); - VUNITIZE(meshheightvector); - VUNITIZE(meshwidthvector); - VSCALE(meshheightvector, meshheightvector, meshHeight); - VSCALE(meshwidthvector, meshwidthvector, meshWidth); - - if (debug) printf("generateMesh_s:meshheightvector[%f][%f][%f], meshheight[%f]\n", meshheightvector[0], meshheightvector[1], meshheightvector[2], meshHeight); - - return generateMesh(fp, meshname, meshstartposition, meshheightvector, meshwidthvector); -} - -int generateMesh(struct rt_wdb *fp, char *meshname, fastf_t *startposition, fastf_t *heightvector, fastf_t *widthvector) -{ - int count=0; - int count2=0; - int errors=0; - double step=0.0; - double dx=0.0; - double dy=0.0; - double dz=0.0; - double width=0.0; - double angle=wireAngle; - double radius=wireRadius; - point_t tempposition; - vect_t incrementvector; - - struct wmember *matrixextractor; - struct wmember meshmembers; - struct wmember meshregionmembers; - - BU_LIST_INIT(&meshmembers.l); - BU_LIST_INIT(&meshregionmembers.l); - - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "\nBeginning mesh [%s] generation...\n", meshname); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:startposition[%f][%f][%f]\n", startposition[0], startposition[1], startposition[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:widthvector[%f][%f][%f]\n", widthvector[0], widthvector[1], widthvector[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:heightvector[%f][%f][%f]\n", heightvector[0], heightvector[1], heightvector[2]); - - - VMOVE(tempposition, startposition); - if ((generateWire_s(fp, wireName, tempposition))==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Base wire generated\n"); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Base wire generation FAILED\n"); - errors++; - } - - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "\nWeaving mesh...\n"); - - width=MAGNITUDE(widthvector); - VMOVE(incrementvector, widthvector); - VUNITIZE(incrementvector); - VSCALE(incrementvector, incrementvector, (double) 2.0 * ( cos((double)RADIAN(angle)) * (wireSegmentLength-(2*radius)) ) ); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh: angle[%f], radius[%f], wireSegmentLength[%f]\n", angle, radius, wireSegmentLength); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh: width[%f], MAGNITUDE(incrementvector)[%f]\n", width, MAGNITUDE(incrementvector)); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh: incrementvector[%f][%f][%f]\n", incrementvector[0], incrementvector[1], incrementvector[2]); - - if (MAGNITUDE(incrementvector)!=0) { - for (count2=0, step=0.0, dx=0, dy=0, dz=0; step <= width; step += (double) MAGNITUDE(incrementvector), count2++); - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "Mesh will require [%d] basic mesh wire-pairs to reach width [%f]\n", count2, width); - - for (count=0, step=0.0; step <= width; step += (double) MAGNITUDE(incrementvector), count++) { - - if ((matrixextractor=mk_addmember(wireName, &meshmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building mesh combination: wire [%d] of [%d]\n", count+1, count2); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:mk_addmember wireName[%s], count2[%d] FAILED\n", wireName, count); - errors++; - } - matrixextractor->wm_mat[3] = dx; - matrixextractor->wm_mat[7] = dy; - matrixextractor->wm_mat[11] = dz; - - if ((matrixextractor=mk_addmember(wireName, &meshregionmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building mesh region: wire [%d] of [%d]\n", count+1, count2); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:mk_addmember wireName[%s], count2[%d] FAILED (region)\n", wireName, count); - errors++; - } - matrixextractor->wm_mat[3] = dx; - matrixextractor->wm_mat[7] = dy; - matrixextractor->wm_mat[11] = dz; - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh: dx[%f], dy[%f], dz[%f]\n", dx, dy, dz); - - dx+=incrementvector[0]; - dy+=incrementvector[1]; - dz+=incrementvector[2]; - if (debug) printMatrix(DEFAULT_DEBUG_OUTPUT, "generateMesh: matrixextractor->wm_mat", matrixextractor->wm_mat); - else if (verbose) printMatrix(DEFAULT_VERBOSE_OUTPUT, "Translation matrix for mesh wire-pairs", matrixextractor->wm_mat); - } - - if (mk_lcomb (fp, meshname, &meshmembers, 0, NULL, NULL, NULL, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...completed mesh [%s] combination\n", meshname); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:meshname[%s]\n", meshname); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:mk_lcomb meshname[%s] FAILED\n", meshname); - errors++; - } - if (mk_lcomb (fp, getPrePostName(NULL, meshname, DEFAULT_REGIONSUFFIX), &meshregionmembers, 1, meshMaterial, meshMaterialParams, meshMaterialColor, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...completed mesh [%s] region\n", getPrePostName(NULL, meshname, DEFAULT_REGIONSUFFIX)); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:meshname[%s]\n", meshname); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:mk_lcomb meshname[%s] FAILED (region)\n", getPrePostName(NULL, meshname, DEFAULT_REGIONSUFFIX)); - errors++; - } - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "Error, incrementvector magnitude is zero:Cannot create mesh\n"); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateMesh:MAGNITUDE(incrementvector)==[%f]\n", MAGNITUDE(incrementvector)); - errors++; - } - return errors; -} - - -/* - * generateWire() generates a wire-pair (two wires intertwining) that serves to form the entire - * mesh of the fence. The two wires are generated as a single process and are generated by creating - * a basic segment of the fence mesh. - * - *****************************************/ - -int generateWire_s(struct rt_wdb *fp, char *wirename, fastf_t *position) -{ - vect_t wirevector; - vect_t widthvector; - - VMOVE(wirevector, fenceHeight); - VMOVE(widthvector, fenceWidth); - VUNITIZE(wirevector); - VSCALE(wirevector, wirevector, meshHeight); - - return generateWire(fp, wirename, position, wirevector, widthvector, wireRadius, wireAngle, wireSegmentLength); -} - -int generateWire(struct rt_wdb *fp, char *wirename, fastf_t *position, fastf_t *fenceheightvector, fastf_t *fencewidthvector, double radius, double angle, double segmentlength) -{ - double height; - vect_t heightvector, widthvector; - vect_t incrementvector; - int count=0; - int count2=0; - int errors=0; - double step=0.0; - double dx=0.0; - double dy=0.0; - double dz=0.0; - - struct wmember basicmeshmembers; - struct wmember wiremembers; - struct wmember basicmeshregionmembers; - struct wmember wireregionmembers; - struct wmember *matrixextractor; - - - if ((matrixextractor = (struct wmember *) malloc(sizeof(struct wmember)))==NULL) { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:(struct wmember *)matrixextractor malloc FAILED\n"); - errors++; - } - BU_LIST_INIT(&basicmeshmembers.l); - BU_LIST_INIT(&wiremembers.l); - BU_LIST_INIT(&basicmeshregionmembers.l); - BU_LIST_INIT(&wireregionmembers.l); - - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "\nBeginning wire [%s] generation...\n", wirename); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:wirename[%s], position[%f][%f][%f]\n", wirename, position[0], position[1], position[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:fenceheightvector[%f][%f][%f], fencewidthvector[%f][%f][%f]\n", fenceheightvector[0], fenceheightvector[1], fenceheightvector[2], fencewidthvector[0], fencewidthvector[1], fencewidthvector[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:radius[%f], angle[%f], segmentlength[%f]\n", radius, angle, segmentlength); - - - VMOVE(heightvector, fenceheightvector); - VUNITIZE(heightvector); - VMOVE(widthvector, fencewidthvector); - VUNITIZE(widthvector); - - if ((errors+=createWire(fp, segmentName, heightvector, widthvector, radius, angle, segmentlength, wireSegmentSeparation))!=0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "There were [%d] errors creating the basic unit...attempting to resolve with fewer units\n", errors); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:createWire:errors[%d]\n", errors); - } - for (count=0; count < DEFAULT_MESHPIECECOUNT; count++) { - if ((mk_addmember(getName(segmentName, count, DEFAULT_WIREBASICPARAM), &basicmeshmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...adding basic mesh segment component [%d] of [%d]\n", count, DEFAULT_MESHPIECECOUNT-1); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:mk_addmember count[%d] FAILED\n", count); - errors++; - } - if ((mk_addmember(getName(segmentName, count, DEFAULT_WIREBASICPARAM), &basicmeshregionmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...adding basic mesh segment region component [%d] of [%d]\n", count, DEFAULT_MESHPIECECOUNT-1); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:mk_addmember count[%d] FAILED (region)\n", count); - errors++; - } - } - if (mk_lcomb (fp, segmentName, &basicmeshmembers, 0, NULL, NULL, NULL, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...basic mesh segment [%s] combination completed\n", segmentName); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:mk_lcomb segmentName[%s] FAILED\n", segmentName); - errors++; - } - if (mk_lcomb (fp, getPrePostName(NULL, segmentName, DEFAULT_REGIONSUFFIX), &basicmeshregionmembers, 1, wireMaterial, wireMaterialParams, wireMaterialColor, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...basic mesh segment [%s] region completed\n", getPrePostName(NULL, segmentName, DEFAULT_REGIONSUFFIX)); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:mk_lcomb segmentName[%s] FAILED (region)\n", getPrePostName(NULL, segmentName, DEFAULT_REGIONSUFFIX)); - errors++; - } - - height=MAGNITUDE(fenceheightvector); - VSCALE(incrementvector, heightvector, (double) 2.0 * ( sin((double)RADIAN(angle)) * (segmentlength+((double)2.0 * radius)) ) ); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire: height[%f], incrementvector[%f][%f][%f], MAGNITUDE(incrementvector)[%f]\n", height, incrementvector[0], incrementvector[1], incrementvector[2], MAGNITUDE(incrementvector)); - - for (count2=0, step=0.0; step <= height; step += (double) MAGNITUDE(incrementvector), count2++); - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "Wire will require [%d] basic mesh pieces to reach height [%f]\n", count2, height); - - for (count=0, dx=0, dy=0, dz=0, step=0.0; step <= height; step += (double) MAGNITUDE(incrementvector), count++) { - - if ((matrixextractor=mk_addmember(segmentName, &wiremembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building base wire combination: piece [%d] of [%d]\n", count+1, count2); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:mk_addmember wirename[%s], count2[%d] FAILED\n", wirename, count); - errors++; - } - matrixextractor->wm_mat[3] = dx; - matrixextractor->wm_mat[7] = dy; - matrixextractor->wm_mat[11] = dz; - - if ((matrixextractor=mk_addmember(segmentName, &wireregionmembers.l, NULL, WMOP_UNION))!=NULL) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...building base wire region: piece [%d] of [%d]\n", count+1, count2); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:mk_addmember wirename[%s], count2[%d] FAILED (region)\n", wirename, count); - errors++; - } - matrixextractor->wm_mat[3] = dx; - matrixextractor->wm_mat[7] = dy; - matrixextractor->wm_mat[11] = dz; - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire: dx[%f], dy[%f], dz[%f]\n", dx, dy, dz); - - dx+=incrementvector[0]; - dy+=incrementvector[1]; - dz+=incrementvector[2]; - if (debug) printMatrix(DEFAULT_DEBUG_OUTPUT, "generateWire: matrixextractor->wm_mat", matrixextractor->wm_mat); - else if (verbose) printMatrix(DEFAULT_VERBOSE_OUTPUT, "Translation matrix of wire segments", matrixextractor->wm_mat); - } - - if (mk_lcomb (fp, wirename, &wiremembers, 0, NULL, NULL, NULL, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...completed basic wire [%s] combination\n", wirename); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:wirename[%s]\n", wirename); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:mk_lcomb wirename[%s] FAILED\n", wirename); - errors++; - } - if (mk_lcomb (fp, getPrePostName(NULL, wirename, DEFAULT_REGIONSUFFIX), &wireregionmembers, 1, wireMaterial, wireMaterialParams, wireMaterialColor, 0)==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...completed basic wire [%s] region\n", getPrePostName(NULL, wirename, DEFAULT_REGIONSUFFIX)); - } - else { - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "generateWire:mk_lcomb wirename[%s] FAILED (region)\n", getPrePostName(NULL, wirename, DEFAULT_REGIONSUFFIX)); - errors++; - } - - - return errors; -} - -/* - * createWire generates the basic "cell" of the fence which is physically a section of the fence - * mesh that forms the "honey-comb"-like appearance for a standard chain-link fence (the triangular - * subsections of the fence. the actual cell is what forms two entire and intertwining wires. the - * wire segment consists of exactly 20 "pieces" (currently) which are the cylinders and spheres that - * form the twists and straits of the wire. - * - ***************************************************************************************************************/ -int createWire(struct rt_wdb *fp, char *segmentname, fastf_t *heightvector, fastf_t *widthvector, double radius, double angle, double segmentlength, double segmentdepthseparation) -{ - int count=0; - int errors=0; - point_t position=DEFAULT_FENCESTARTPOSITION; - vect_t segmentvector=DEFAULT_FENCESTARTPOSITION; - - vect_t upvector=DEFAULT_FENCESTARTPOSITION; - vect_t sidevector=DEFAULT_FENCESTARTPOSITION; - - vect_t moveupvector=DEFAULT_FENCESTARTPOSITION; - vect_t movebackvector=DEFAULT_FENCESTARTPOSITION; - vect_t movesidevector=DEFAULT_FENCESTARTPOSITION; - - double anglex=0.0; - double angley=0.0; - - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "\nBeginning basic wire-mesh component [%s] creation...\n", segmentname); - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "createWire:heightvector[%f][%f][%f], widthvector[%f][%f][%f]\n", heightvector[0], heightvector[1], heightvector[2], widthvector[0], widthvector[1], widthvector[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "createWire:radius[%f], angle[%f], segmentlength[%f], segmentdepthseparation[%f]\n", radius, angle, segmentlength, segmentdepthseparation); - - - /*first segment going ne*/ - count=0; - - VMOVE(position, position); - - angley=(double) sin( (double) RADIAN(angle) ) * segmentlength; - anglex=(double) cos( (double) RADIAN(angle) ) * segmentlength; - - VSCALE(upvector, heightvector, angley); - VSCALE(sidevector, widthvector, anglex); - VADD2(segmentvector, upvector, sidevector); - - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "createWire:segmentvector[%f][%f][%f]\n", segmentvector[0], segmentvector[1], segmentvector[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "createWire:position[%f][%f][%f]\n", position[0], position[1], position[2]); - - if ((mk_rcc(fp, getName(segmentName, count, DEFAULT_WIREBASICPARAM), position, segmentvector, radius))==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Wire segment [%d] generated\n", count); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Wire segment [%d] generation FAILED\n", count); - errors++; - } - - - /*second segment going ne*/ - count++; - - angley=(double) sin( (double) RADIAN(angle) ) * segmentlength; - anglex=(double) cos( (double) RADIAN(angle) ) * segmentlength; - - VSCALE(upvector, heightvector, angley); - VSCALE(sidevector, widthvector, anglex); - VADD2(segmentvector, upvector, sidevector); - - VSCALE(movesidevector, widthvector, (anglex)); - VSCALE(moveupvector, heightvector, (angley)); - - VSUB2(position, moveupvector, movesidevector); - - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "createWire:segmentvector[%f][%f][%f]\n", segmentvector[0], segmentvector[1], segmentvector[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "createWire:position[%f][%f][%f]\n", position[0], position[1], position[2]); - - if ((mk_rcc(fp, getName(segmentName, count, DEFAULT_WIREBASICPARAM), position, segmentvector, radius))==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Wire segment [%d] generated\n", count); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Wire segment [%d] generation FAILED\n", count); - errors++; - } - - - /*third segment going nw*/ - count++; - - VCROSS(movebackvector, heightvector, widthvector); - VSCALE(movebackvector, movebackvector, (segmentdepthseparation+(2*radius)) ); - - VMOVE(position, movebackvector); - - angley=(double) sin( (double) RADIAN((double)180.0-angle) )*segmentlength; - anglex=(double) cos( (double) RADIAN((double)180.0-angle) )*segmentlength; - - VSCALE(upvector, heightvector, angley); - VSCALE(sidevector, widthvector, anglex); - VADD2(segmentvector, upvector, sidevector); - - - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "createWire:segmentvector[%f][%f][%f]\n", segmentvector[0], segmentvector[1], segmentvector[2]); - if (debug) fprintf(DEFAULT_DEBUG_OUTPUT, "createWire:position[%f][%f][%f]\n", position[0], position[1], position[2]); - - if ((mk_rcc(fp, getName(segmentName, count, DEFAULT_WIREBASICPARAM), position, segmentvector, radius))==0) { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Wire segment [%d] generated\n", count); - } - else { - if (verbose) fprintf(DEFAULT_VERBOSE_OUTPUT, "...Wire segment [%d] generation FAILED\n", count); - errors++; - } - - - /*fourth segment going nw*/ - count++; - - angley=(double) sin( (double) RADIAN(angle) ) * segmentlength; - anglex=(double) cos( (double) RADIAN(angle) ) * segmentlength; - - VSCALE(movesidevector, widthvector, (anglex)); - VSCALE(moveupvector, heightvector, (angley)); - - VADD2(position, moveupvector, movesidevector); - - VCROSS(movebackvector, heightvector, widthvector); - VSCALE(movebackvector, movebackvecto... [truncated message content] |
From: <bo...@us...> - 2009-01-09 20:36:33
|
Revision: 33505 http://brlcad.svn.sourceforge.net/brlcad/?rev=33505&view=rev Author: bob1961 Date: 2009-01-09 20:36:23 +0000 (Fri, 09 Jan 2009) Log Message: ----------- This fixes bug 2279400 (i.e. but_dump -u option problems) Modified Paths: -------------- brlcad/trunk/src/conv/bot_dump.c brlcad/trunk/src/libged/bot_dump.c Modified: brlcad/trunk/src/conv/bot_dump.c =================================================================== --- brlcad/trunk/src/conv/bot_dump.c 2009-01-09 20:35:26 UTC (rev 33504) +++ brlcad/trunk/src/conv/bot_dump.c 2009-01-09 20:36:23 UTC (rev 33505) @@ -48,7 +48,7 @@ bu_optind = 1; /* Get past command line options. */ - while ((c = bu_getopt(argc, argv, "bo:m:t:u")) != EOF) { + while ((c = bu_getopt(argc, argv, "bo:m:t:u:")) != EOF) { switch (c) { case 'b': case 'm': Modified: brlcad/trunk/src/libged/bot_dump.c =================================================================== --- brlcad/trunk/src/libged/bot_dump.c 2009-01-09 20:35:26 UTC (rev 33504) +++ brlcad/trunk/src/libged/bot_dump.c 2009-01-09 20:36:23 UTC (rev 33505) @@ -609,7 +609,7 @@ bu_optind = 1; /* Get command line options. */ - while ((c = bu_getopt(argc, (char * const *)argv, "bo:m:t:u")) != EOF) { + while ((c = bu_getopt(argc, (char * const *)argv, "bo:m:t:u:")) != EOF) { switch (c) { case 'b': /* Binary output file */ binary=1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-01-09 23:45:01
|
Revision: 33513 http://brlcad.svn.sourceforge.net/brlcad/?rev=33513&view=rev Author: brlcad Date: 2009-01-09 23:44:55 +0000 (Fri, 09 Jan 2009) Log Message: ----------- move picket_fence from proc_db over to the 'new' shapes directory. seems to work well enough now, minus one top-level bug with two points. Modified Paths: -------------- brlcad/trunk/src/proc-db/Makefile.am brlcad/trunk/src/shapes/Makefile.am Added Paths: ----------- brlcad/trunk/src/shapes/picket_fence.1 brlcad/trunk/src/shapes/picket_fence.c Removed Paths: ------------- brlcad/trunk/src/proc-db/picket_fence.1 brlcad/trunk/src/proc-db/picket_fence.c Modified: brlcad/trunk/src/proc-db/Makefile.am =================================================================== --- brlcad/trunk/src/proc-db/Makefile.am 2009-01-09 23:42:32 UTC (rev 33512) +++ brlcad/trunk/src/proc-db/Makefile.am 2009-01-09 23:44:55 UTC (rev 33513) @@ -20,7 +20,6 @@ metaball \ molecule \ nmgmodel \ - picket_fence \ pipe \ pipetest \ pix2g \ @@ -70,7 +69,6 @@ metaball_SOURCES = metaball.c molecule_SOURCES = molecule.c nmgmodel_SOURCES = nmgmodel.c -picket_fence_SOURCES = picket_fence.c pipe_SOURCES = pipe.c pipetest_SOURCES = pipetest.c pix2g_SOURCES = pix2g.c @@ -94,9 +92,6 @@ tea.h \ vegitation.h -man_MANS = \ - picket_fence.1 - EXTRA_DIST = \ $(man_MANS) \ sgi.sh @@ -120,7 +115,6 @@ $(masonry_OBJECTS) \ $(molecule_OBJECTS) \ $(nmgmodel_OBJECTS) \ - $(picket_fence_OBJECTS) \ $(pipe_OBJECTS) \ $(pipetest_OBJECTS) \ $(pix2g_OBJECTS) \ Deleted: brlcad/trunk/src/proc-db/picket_fence.1 =================================================================== --- brlcad/trunk/src/proc-db/picket_fence.1 2009-01-09 23:42:32 UTC (rev 33512) +++ brlcad/trunk/src/proc-db/picket_fence.1 2009-01-09 23:44:55 UTC (rev 33513) @@ -1,83 +0,0 @@ -.TH PICKETT_FENCE 1 BRL-CAD -.\" P I C K E T _ F E N C E . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 2005-2008 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.SH NAME -picket_fence \- Pickett fence geometry file generator -.SH SYNOPSIS -.B picket_fence -<filename> <prefix> <height> <spacing> <x0> <y0> <z0> ... <xn> <yn> <zn> [-r] -.SH DESCRIPTION -.I picket_fence\^ -creates a geometry file in -.I <filename>\^ -of a picket fence. All parameters for the fence are in mm. If more than two -points are specified it will generate a fence with multiple sections connecting -the points. Parts of the fence are created starting at the origin. The -two backing boards are created in the negative x halfspace. The pickets are -created in the positive x halfspace and translated down the y-axis to their -proper positions. The entire segment is then rotated and translated to the -position specified by the user. To create a box of fence with the -pickets on the outside, the points must be specified in a counter-clockwise -order. Parts of the model are named according to the format -.RS -<prefix><partname><sec_num>[-<part_num>].<obj_type> -.RE -The -.I <prefix>\^ -above is the second argument to the program. The -.I spacing\^ -parameter specifies the amount of space (in mm) between pickets. The -.I -r\^ -option specifies round fronts for the pickets. -.SH EXAMPLE -The following will create a picket fence two meters high and six meters long -with fifteen millimeter spaces between the pickets. It will start at -the origin and extend to the point (100, 6000, 0). -.RS -$ \|\fIpicket_fence \|fence.g \Imy\|2000 \|15 \|0 \|0 \|0 \|100 \|6000 \|0 \fP -.RE -.SH "SEE ALSO" -.I -.I mged\^(1) -.SH DIAGNOSTICS -Error messages are intended to be self-explanatory. -.SH "BUG REPORTS" -Reports of bugs or problems should be submitted via electronic -mail to <de...@br...>. Deleted: brlcad/trunk/src/proc-db/picket_fence.c =================================================================== --- brlcad/trunk/src/proc-db/picket_fence.c 2009-01-09 23:42:32 UTC (rev 33512) +++ brlcad/trunk/src/proc-db/picket_fence.c 2009-01-09 23:44:55 UTC (rev 33513) @@ -1,288 +0,0 @@ -/* P I C K E T _ F E N C E . C - * BRL-CAD - * - * Copyright (c) 2004-2008 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @file picket_fence.c - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <string.h> - -#include "vmath.h" -#include "raytrace.h" -#include "wdb.h" - - -int main(int argc, char *argv[]) -{ - long i, j, k, l; - struct rt_wdb *fp_db = NULL; - - char name[256] = {}; - char pname[256] = {}; - char w1name[256] = {}; - char w2name[256] = {}; - char firstname[256] = {}; - char prefix[256] = {}; - - struct wmember wm; - struct wmember wm2; - struct wmember fwm; - struct wmember swm; - struct wmember *nwm; - - fastf_t first_mat[16]; - - fastf_t s0[24] = {0, 0, 0, - 0, 0, 0, - 15, 0, 0, - 15, 0, 0, - 0, 0, 0, - 0, 0, 0, - 15, 0, 0, - 15, 0, 0}; - point_t c0 = {15, 0, 0}; - point_t w0 = {0, 0, 0}; - point_t w1 = {25, 0, 0}; - fastf_t s1[24] = {-0.001, 0, 0, - -0.001, 0, 0, - -12.6, 0, 0, - -12.6, 0, 0, - -0.001, 0, 0, - -0.001, 0, 0, - -12.6, 0, 0, - -12.6, 0, 0}; - fastf_t xlen = .0001; - fastf_t ylen = -26; - fastf_t zlen; - fastf_t xt, yt; - fastf_t x_top_len = 20; - vect_t w0x = {0, 1, 0}; - vect_t w0z = {0, 0, -1}; - vect_t w1x = {0, -1, 0}; - vect_t w1z = {0, 0, -1}; - vect_t c0a = {4, 0, 0}; - vect_t c0b = {0, 0, 0}; - vect_t c0c = {4, 0, 0}; - vect_t c0d = {0, 0, 0}; - vect_t c0h = {0, 0, 0}; - fastf_t x0, y0, z0, x1, y1, z1; - fastf_t height; - fastf_t width; - fastf_t pwidth; - fastf_t ps; - long numposts; - fastf_t zstep; - unsigned char matcolor[3] = {0, 0, 0}; - - int round = 0; - - if (argc < 11) { - bu_exit(1, "Usage: picket_fence <filename> <prefix> <height_in_mm> <spacing> [-r] <x0> <y0> <z0> ... <xn> <yn> <zn>\n"); - } - bu_strlcpy(prefix, argv[2], sizeof(prefix)); - - height = (fastf_t)atof(argv[3]); - if (height <= 0) { - bu_exit(1, "Invalid argument, height must be a positive value\n"); - } - - ps = atof(argv[4]); - if (ps < 0) { - bu_exit(1, "Invalid argument, spacing must be non-negative\n"); - } - - if (strcmp(argv[5], "-r") == 0) { - round = 1; - argc--; argv++; - } - - fp_db = wdb_fopen(argv[1]); - if (fp_db == NULL) { - perror(argv[1]); - bu_exit(2, NULL); - } - mk_id(fp_db, "Picket Fence"); - - argc-=5; argv+=5; /* chomp, leave just the waypoints */ - - BU_LIST_INIT(&wm.l); - BU_LIST_INIT(&wm2.l); - BU_LIST_INIT(&fwm.l); - BU_LIST_INIT(&swm.l); - - for (j = 0; j < (argc / 3) - 1; j++) { - x0 = (fastf_t)atof(argv[0 + (3 * j)]); - y0 = (fastf_t)atof(argv[1 + (3 * j)]); - z0 = (fastf_t)atof(argv[2 + (3 * j)]); - x1 = (fastf_t)atof(argv[3 + (3 * j)]); - y1 = (fastf_t)atof(argv[4 + (3 * j)]); - z1 = (fastf_t)atof(argv[5 + (3 * j)]); - if (isnan(x0) || isnan(y0) || isnan(z0) || isnan(x1) || isnan(y1) || isnan(z1)) { - bu_exit(1, "Invalid argument, position is not a valid coordiate\n"); - } - - width = sqrt(((x1 - x0) * (x1 - x0)) + ((y1 - y0) * (y1 - y0))); - pwidth = ((fastf_t)width / - (fastf_t)(((int)(width / (51+ps))) * (51+ps))) * (51+ps); - numposts = (width / pwidth); - zstep = (z1 - z0) / numposts; - zlen = -.076001 * height; - s0[4] = s0[7] = s0[16] = s0[19] = pwidth - ps; - s0[14] = s0[17] = s0[20] = s0[23] = height; - c0[1] = (pwidth - ps) / 2.0; - w0[2] = w1[2] = .924 * height; - w1[1] = pwidth - ps; - s1[2] = s1[11] = z0 + (height / 3); - s1[5] = s1[8] = z1 + (height / 3); - s1[14] = s1[23] = z0 + ((height / 3) + 102); - s1[17] = s1[20] = z1 + ((height / 3) + 102); - s1[4] = s1[7] = s1[16] = s1[19] = width; - c0b[1] = (pwidth - ps) / 2.0; - c0d[1] = (pwidth - ps) / 2.0; - c0h[2] = height; - - snprintf(w1name, sizeof(w1name), "%swedge1-%ld.s", prefix, j); - mk_wedge(fp_db, w1name, w0, w0x, w0z, xlen, ylen, zlen, x_top_len); - - snprintf(w2name, sizeof(w2name), "%swedge2-%ld.s", prefix, j); - mk_wedge(fp_db, w2name, w1, w1x, w1z, xlen, ylen, zlen, x_top_len); - - snprintf(name, sizeof(name), "%spost-%ld.s", prefix, j); - mk_arb8(fp_db, name, s0); - mk_addmember(name, &wm.l, NULL, WMOP_UNION); - mk_addmember(w1name, &wm.l, NULL, WMOP_SUBTRACT); - mk_addmember(w2name, &wm.l, NULL, WMOP_SUBTRACT); - - if (round) { - snprintf(name, sizeof(name), "%spost_c.s", prefix); - mk_tgc(fp_db, name, c0, c0h, c0a, c0b, c0c, c0d); - mk_addmember(name, &wm.l, NULL, WMOP_UNION); - mk_addmember(w1name, &wm.l, NULL, WMOP_SUBTRACT); - mk_addmember(w2name, &wm.l, NULL, WMOP_SUBTRACT); - } - - snprintf(name, sizeof(name), "%sls%ld.s", prefix, j); - mk_arb8(fp_db, name, s1); - mk_addmember(name, &swm.l, NULL, WMOP_UNION); - - for (k = 0; k < 8; k++) - s1[(3 * k) + 2] += (height / 3); - - snprintf(name, sizeof(name), "%shs%ld.s", prefix, j); - mk_arb8(fp_db, name, s1); - mk_addmember(name, &swm.l, NULL, WMOP_UNION); - - snprintf(pname, sizeof(pname), "%sp-%ld.c", prefix, j); - matcolor[0] = 50; - matcolor[1] = 30; - matcolor[2] = 10; - mk_lcomb(fp_db, pname, &wm, 0, "plastic", "", matcolor, 0); - - for (i = 0; i < numposts; i++) { - snprintf(name, sizeof(name), "%sp%ld-%ld.r", prefix, j, i); - mk_addmember(pname, &wm2.l, NULL, WMOP_UNION); - - matcolor[0] = 50; - matcolor[1] = 50; - matcolor[2] = 20; - mk_lcomb(fp_db, name, &wm2, 0, "plastic", "", matcolor, 0); - - nwm = mk_addmember(name, &swm.l, NULL, WMOP_UNION); - for (k = 0; k < 16; k++) - nwm->wm_mat[k] = 0; - nwm->wm_mat[0] = 1; - nwm->wm_mat[5] = 1; - nwm->wm_mat[7] = i * pwidth; - nwm->wm_mat[10] = 1; - nwm->wm_mat[11] = i * zstep; - nwm->wm_mat[15] = 1; - } - - snprintf(name, sizeof(name), "%ssec%ld.c", prefix, j); - matcolor[0] = 50; - matcolor[1] = 50; - matcolor[2] = 20; - mk_lcomb(fp_db, name, &swm, 0, "plastic", "", matcolor, 0); - - nwm = mk_addmember(name, &fwm.l, NULL, WMOP_SUBTRACT); - xt = x1 - x0; - yt = y1 - y0; - xt /= sqrt((xt * xt) + (yt * yt)); - yt /= sqrt((xt * xt) + (yt * yt)); - nwm->wm_mat[0] = nwm->wm_mat[5] = cos(atan2(-xt, yt)); - nwm->wm_mat[1] = -sin(atan2(-xt, yt)); - nwm->wm_mat[3] = x0; - nwm->wm_mat[4] = -(nwm->wm_mat[1]); - nwm->wm_mat[5] = nwm->wm_mat[0]; - nwm->wm_mat[7] = y0; - nwm->wm_mat[10] = 1; - nwm->wm_mat[11] = z0; - nwm->wm_mat[15] = 1; - - nwm = mk_addmember(name, &fwm.l, NULL, WMOP_UNION); - xt = x1 - x0; - yt = y1 - y0; - xt /= sqrt((xt * xt) + (yt * yt)); - yt /= sqrt((xt * xt) + (yt * yt)); - nwm->wm_mat[0] = nwm->wm_mat[5] = cos(atan2(-xt, yt)); - nwm->wm_mat[1] = -sin(atan2(-xt, yt)); - nwm->wm_mat[3] = x0; - nwm->wm_mat[4] = -(nwm->wm_mat[1]); - nwm->wm_mat[5] = nwm->wm_mat[0]; - nwm->wm_mat[7] = y0; - nwm->wm_mat[10] = 1; - nwm->wm_mat[11] = z0; - nwm->wm_mat[15] = 1; - - if (j == 0) { - bu_strlcpy(firstname, name, sizeof(firstname)); - for (l = 0; l < 16; l++) - first_mat[l] = nwm->wm_mat[l]; - } - } - - nwm = mk_addmember(firstname, &fwm.l, NULL, WMOP_SUBTRACT); - for (l = 0; l < 16; l++) - nwm->wm_mat[l] = first_mat[l]; - - snprintf(name, sizeof(name), "%sfence.c", prefix); - matcolor[0] = 50; - matcolor[1] = 50; - matcolor[2] = 20; - mk_lcomb(fp_db, name, &fwm, 0, "plastic", "", matcolor, 0); - - wdb_close(fp_db); - - return 0; -} - -/* - * Local Variables: - * mode: C - * tab-width: 8 - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Modified: brlcad/trunk/src/shapes/Makefile.am =================================================================== --- brlcad/trunk/src/shapes/Makefile.am 2009-01-09 23:42:32 UTC (rev 33512) +++ brlcad/trunk/src/shapes/Makefile.am 2009-01-09 23:44:55 UTC (rev 33513) @@ -4,6 +4,7 @@ fence \ gastank \ handle \ + picket_fence \ tire \ window \ winfrm \ @@ -16,6 +17,7 @@ fence_SOURCES = fence.c gastank_SOURCES = gastank.c handle_SOURCES = handle.c +picket_fence_SOURCES = picket_fence.c tire_SOURCES = tire.c tire_LDADD = \ @@ -32,6 +34,7 @@ bolt.1 \ gastank.1 \ handle.1 \ + picket_fence.1 \ window.1 \ winfrm.1 \ wire.1 @@ -45,6 +48,7 @@ $(fence_OBJECTS) \ $(gastank_OBJECTS) \ $(handle_OBJECTS) \ + $(picket_fence_OBJECTS) \ $(tire_OBJECTS) \ $(window_OBJECTS) \ $(winfrm_OBJECTS) \ Copied: brlcad/trunk/src/shapes/picket_fence.1 (from rev 33509, brlcad/trunk/src/proc-db/picket_fence.1) =================================================================== --- brlcad/trunk/src/shapes/picket_fence.1 (rev 0) +++ brlcad/trunk/src/shapes/picket_fence.1 2009-01-09 23:44:55 UTC (rev 33513) @@ -0,0 +1,83 @@ +.TH PICKETT_FENCE 1 BRL-CAD +.\" P I C K E T _ F E N C E . 1 +.\" BRL-CAD +.\" +.\" Copyright (c) 2005-2008 United States Government as represented by +.\" the U.S. Army Research Laboratory. +.\" +.\" Redistribution and use in source (Docbook format) and 'compiled' +.\" forms (PDF, PostScript, HTML, RTF, etc), with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" 1. Redistributions of source code (Docbook format) must retain the +.\" above copyright notice, this list of conditions and the following +.\" disclaimer. +.\" +.\" 2. Redistributions in compiled form (transformed to other DTDs, +.\" converted to PDF, PostScript, HTML, RTF, and other formats) must +.\" reproduce the above copyright notice, this list of conditions and +.\" the following disclaimer in the documentation and/or other +.\" materials provided with the distribution. +.\" +.\" 3. The name of the author may not be used to endorse or promote +.\" products derived from this documentation without specific prior +.\" written permission. +.\" +.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY +.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\".\".\" +.SH NAME +picket_fence \- Pickett fence geometry file generator +.SH SYNOPSIS +.B picket_fence +<filename> <prefix> <height> <spacing> <x0> <y0> <z0> ... <xn> <yn> <zn> [-r] +.SH DESCRIPTION +.I picket_fence\^ +creates a geometry file in +.I <filename>\^ +of a picket fence. All parameters for the fence are in mm. If more than two +points are specified it will generate a fence with multiple sections connecting +the points. Parts of the fence are created starting at the origin. The +two backing boards are created in the negative x halfspace. The pickets are +created in the positive x halfspace and translated down the y-axis to their +proper positions. The entire segment is then rotated and translated to the +position specified by the user. To create a box of fence with the +pickets on the outside, the points must be specified in a counter-clockwise +order. Parts of the model are named according to the format +.RS +<prefix><partname><sec_num>[-<part_num>].<obj_type> +.RE +The +.I <prefix>\^ +above is the second argument to the program. The +.I spacing\^ +parameter specifies the amount of space (in mm) between pickets. The +.I -r\^ +option specifies round fronts for the pickets. +.SH EXAMPLE +The following will create a picket fence two meters high and six meters long +with fifteen millimeter spaces between the pickets. It will start at +the origin and extend to the point (100, 6000, 0). +.RS +$ \|\fIpicket_fence \|fence.g \Imy\|2000 \|15 \|0 \|0 \|0 \|100 \|6000 \|0 \fP +.RE +.SH "SEE ALSO" +.I +.I mged\^(1) +.SH DIAGNOSTICS +Error messages are intended to be self-explanatory. +.SH "BUG REPORTS" +Reports of bugs or problems should be submitted via electronic +mail to <de...@br...>. Copied: brlcad/trunk/src/shapes/picket_fence.c (from rev 33512, brlcad/trunk/src/proc-db/picket_fence.c) =================================================================== --- brlcad/trunk/src/shapes/picket_fence.c (rev 0) +++ brlcad/trunk/src/shapes/picket_fence.c 2009-01-09 23:44:55 UTC (rev 33513) @@ -0,0 +1,288 @@ +/* P I C K E T _ F E N C E . C + * BRL-CAD + * + * Copyright (c) 2004-2008 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file picket_fence.c + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <string.h> + +#include "vmath.h" +#include "raytrace.h" +#include "wdb.h" + + +int main(int argc, char *argv[]) +{ + long i, j, k, l; + struct rt_wdb *fp_db = NULL; + + char name[256] = {}; + char pname[256] = {}; + char w1name[256] = {}; + char w2name[256] = {}; + char firstname[256] = {}; + char prefix[256] = {}; + + struct wmember wm; + struct wmember wm2; + struct wmember fwm; + struct wmember swm; + struct wmember *nwm; + + fastf_t first_mat[16]; + + fastf_t s0[24] = {0, 0, 0, + 0, 0, 0, + 15, 0, 0, + 15, 0, 0, + 0, 0, 0, + 0, 0, 0, + 15, 0, 0, + 15, 0, 0}; + point_t c0 = {15, 0, 0}; + point_t w0 = {0, 0, 0}; + point_t w1 = {25, 0, 0}; + fastf_t s1[24] = {-0.001, 0, 0, + -0.001, 0, 0, + -12.6, 0, 0, + -12.6, 0, 0, + -0.001, 0, 0, + -0.001, 0, 0, + -12.6, 0, 0, + -12.6, 0, 0}; + fastf_t xlen = .0001; + fastf_t ylen = -26; + fastf_t zlen; + fastf_t xt, yt; + fastf_t x_top_len = 20; + vect_t w0x = {0, 1, 0}; + vect_t w0z = {0, 0, -1}; + vect_t w1x = {0, -1, 0}; + vect_t w1z = {0, 0, -1}; + vect_t c0a = {4, 0, 0}; + vect_t c0b = {0, 0, 0}; + vect_t c0c = {4, 0, 0}; + vect_t c0d = {0, 0, 0}; + vect_t c0h = {0, 0, 0}; + fastf_t x0, y0, z0, x1, y1, z1; + fastf_t height; + fastf_t width; + fastf_t pwidth; + fastf_t ps; + long numposts; + fastf_t zstep; + unsigned char matcolor[3] = {0, 0, 0}; + + int round = 0; + + if (argc < 11) { + bu_exit(1, "Usage: picket_fence <filename> <prefix> <height_in_mm> <spacing> [-r] <x0> <y0> <z0> ... <xn> <yn> <zn>\n"); + } + bu_strlcpy(prefix, argv[2], sizeof(prefix)); + + height = (fastf_t)atof(argv[3]); + if (height <= 0) { + bu_exit(1, "Invalid argument, height must be a positive value\n"); + } + + ps = atof(argv[4]); + if (ps < 0) { + bu_exit(1, "Invalid argument, spacing must be non-negative\n"); + } + + if (strcmp(argv[5], "-r") == 0) { + round = 1; + argc--; argv++; + } + + fp_db = wdb_fopen(argv[1]); + if (fp_db == NULL) { + perror(argv[1]); + bu_exit(2, NULL); + } + mk_id(fp_db, "Picket Fence"); + + argc-=5; argv+=5; /* chomp, leave just the waypoints */ + + BU_LIST_INIT(&wm.l); + BU_LIST_INIT(&wm2.l); + BU_LIST_INIT(&fwm.l); + BU_LIST_INIT(&swm.l); + + for (j = 0; j < (argc / 3) - 1; j++) { + x0 = (fastf_t)atof(argv[0 + (3 * j)]); + y0 = (fastf_t)atof(argv[1 + (3 * j)]); + z0 = (fastf_t)atof(argv[2 + (3 * j)]); + x1 = (fastf_t)atof(argv[3 + (3 * j)]); + y1 = (fastf_t)atof(argv[4 + (3 * j)]); + z1 = (fastf_t)atof(argv[5 + (3 * j)]); + if (isnan(x0) || isnan(y0) || isnan(z0) || isnan(x1) || isnan(y1) || isnan(z1)) { + bu_exit(1, "Invalid argument, position is not a valid coordiate\n"); + } + + width = sqrt(((x1 - x0) * (x1 - x0)) + ((y1 - y0) * (y1 - y0))); + pwidth = ((fastf_t)width / + (fastf_t)(((int)(width / (51+ps))) * (51+ps))) * (51+ps); + numposts = (width / pwidth); + zstep = (z1 - z0) / numposts; + zlen = -.076001 * height; + s0[4] = s0[7] = s0[16] = s0[19] = pwidth - ps; + s0[14] = s0[17] = s0[20] = s0[23] = height; + c0[1] = (pwidth - ps) / 2.0; + w0[2] = w1[2] = .924 * height; + w1[1] = pwidth - ps; + s1[2] = s1[11] = z0 + (height / 3); + s1[5] = s1[8] = z1 + (height / 3); + s1[14] = s1[23] = z0 + ((height / 3) + 102); + s1[17] = s1[20] = z1 + ((height / 3) + 102); + s1[4] = s1[7] = s1[16] = s1[19] = width; + c0b[1] = (pwidth - ps) / 2.0; + c0d[1] = (pwidth - ps) / 2.0; + c0h[2] = height; + + snprintf(w1name, sizeof(w1name), "%swedge1-%ld.s", prefix, j); + mk_wedge(fp_db, w1name, w0, w0x, w0z, xlen, ylen, zlen, x_top_len); + + snprintf(w2name, sizeof(w2name), "%swedge2-%ld.s", prefix, j); + mk_wedge(fp_db, w2name, w1, w1x, w1z, xlen, ylen, zlen, x_top_len); + + snprintf(name, sizeof(name), "%spost-%ld.s", prefix, j); + mk_arb8(fp_db, name, s0); + mk_addmember(name, &wm.l, NULL, WMOP_UNION); + mk_addmember(w1name, &wm.l, NULL, WMOP_SUBTRACT); + mk_addmember(w2name, &wm.l, NULL, WMOP_SUBTRACT); + + if (round) { + snprintf(name, sizeof(name), "%spost_c.s", prefix); + mk_tgc(fp_db, name, c0, c0h, c0a, c0b, c0c, c0d); + mk_addmember(name, &wm.l, NULL, WMOP_UNION); + mk_addmember(w1name, &wm.l, NULL, WMOP_SUBTRACT); + mk_addmember(w2name, &wm.l, NULL, WMOP_SUBTRACT); + } + + snprintf(name, sizeof(name), "%sls%ld.s", prefix, j); + mk_arb8(fp_db, name, s1); + mk_addmember(name, &swm.l, NULL, WMOP_UNION); + + for (k = 0; k < 8; k++) + s1[(3 * k) + 2] += (height / 3); + + snprintf(name, sizeof(name), "%shs%ld.s", prefix, j); + mk_arb8(fp_db, name, s1); + mk_addmember(name, &swm.l, NULL, WMOP_UNION); + + snprintf(pname, sizeof(pname), "%sp-%ld.c", prefix, j); + matcolor[0] = 50; + matcolor[1] = 30; + matcolor[2] = 10; + mk_lcomb(fp_db, pname, &wm, 0, "plastic", "", matcolor, 0); + + for (i = 0; i < numposts; i++) { + snprintf(name, sizeof(name), "%sp%ld-%ld.r", prefix, j, i); + mk_addmember(pname, &wm2.l, NULL, WMOP_UNION); + + matcolor[0] = 50; + matcolor[1] = 50; + matcolor[2] = 20; + mk_lcomb(fp_db, name, &wm2, 0, "plastic", "", matcolor, 0); + + nwm = mk_addmember(name, &swm.l, NULL, WMOP_UNION); + for (k = 0; k < 16; k++) + nwm->wm_mat[k] = 0; + nwm->wm_mat[0] = 1; + nwm->wm_mat[5] = 1; + nwm->wm_mat[7] = i * pwidth; + nwm->wm_mat[10] = 1; + nwm->wm_mat[11] = i * zstep; + nwm->wm_mat[15] = 1; + } + + snprintf(name, sizeof(name), "%ssec%ld.c", prefix, j); + matcolor[0] = 50; + matcolor[1] = 50; + matcolor[2] = 20; + mk_lcomb(fp_db, name, &swm, 0, "plastic", "", matcolor, 0); + + nwm = mk_addmember(name, &fwm.l, NULL, WMOP_SUBTRACT); + xt = x1 - x0; + yt = y1 - y0; + xt /= sqrt((xt * xt) + (yt * yt)); + yt /= sqrt((xt * xt) + (yt * yt)); + nwm->wm_mat[0] = nwm->wm_mat[5] = cos(atan2(-xt, yt)); + nwm->wm_mat[1] = -sin(atan2(-xt, yt)); + nwm->wm_mat[3] = x0; + nwm->wm_mat[4] = -(nwm->wm_mat[1]); + nwm->wm_mat[5] = nwm->wm_mat[0]; + nwm->wm_mat[7] = y0; + nwm->wm_mat[10] = 1; + nwm->wm_mat[11] = z0; + nwm->wm_mat[15] = 1; + + nwm = mk_addmember(name, &fwm.l, NULL, WMOP_UNION); + xt = x1 - x0; + yt = y1 - y0; + xt /= sqrt((xt * xt) + (yt * yt)); + yt /= sqrt((xt * xt) + (yt * yt)); + nwm->wm_mat[0] = nwm->wm_mat[5] = cos(atan2(-xt, yt)); + nwm->wm_mat[1] = -sin(atan2(-xt, yt)); + nwm->wm_mat[3] = x0; + nwm->wm_mat[4] = -(nwm->wm_mat[1]); + nwm->wm_mat[5] = nwm->wm_mat[0]; + nwm->wm_mat[7] = y0; + nwm->wm_mat[10] = 1; + nwm->wm_mat[11] = z0; + nwm->wm_mat[15] = 1; + + if (j == 0) { + bu_strlcpy(firstname, name, sizeof(firstname)); + for (l = 0; l < 16; l++) + first_mat[l] = nwm->wm_mat[l]; + } + } + + nwm = mk_addmember(firstname, &fwm.l, NULL, WMOP_SUBTRACT); + for (l = 0; l < 16; l++) + nwm->wm_mat[l] = first_mat[l]; + + snprintf(name, sizeof(name), "%sfence.c", prefix); + matcolor[0] = 50; + matcolor[1] = 50; + matcolor[2] = 20; + mk_lcomb(fp_db, name, &fwm, 0, "plastic", "", matcolor, 0); + + wdb_close(fp_db); + + return 0; +} + +/* + * Local Variables: + * mode: C + * tab-width: 8 + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-01-12 07:02:48
|
Revision: 33530 http://brlcad.svn.sourceforge.net/brlcad/?rev=33530&view=rev Author: brlcad Date: 2009-01-12 07:02:44 +0000 (Mon, 12 Jan 2009) Log Message: ----------- Itcl_Init() leaves initialization in a bad state if it fails causing a failure the second time through during initialization (we try once as-is, then once again after setting up auto_path and friends via tclcad_auto_path(). this gets rid of the failure and associated failure message. Modified Paths: -------------- brlcad/trunk/src/bwish/main.c brlcad/trunk/src/mged/setup.c Modified: brlcad/trunk/src/bwish/main.c =================================================================== --- brlcad/trunk/src/bwish/main.c 2009-01-11 18:53:08 UTC (rev 33529) +++ brlcad/trunk/src/bwish/main.c 2009-01-12 07:02:44 UTC (rev 33530) @@ -123,6 +123,8 @@ if (init_itcl && Itcl_Init(interp) == TCL_ERROR) { if (!try_auto_path) { try_auto_path=1; + Tcl_DeleteCommand(interp, "::itcl::class"); + Tcl_DeleteNamespace(Tcl_FindNamespace(interp, "::itcl", NULL, 0)); continue; } bu_log("Itcl_Init ERROR:\n%s\n", Tcl_GetStringResult(interp)); Modified: brlcad/trunk/src/mged/setup.c =================================================================== --- brlcad/trunk/src/mged/setup.c 2009-01-11 18:53:08 UTC (rev 33529) +++ brlcad/trunk/src/mged/setup.c 2009-01-12 07:02:44 UTC (rev 33530) @@ -503,6 +503,8 @@ if (init_itcl && Itcl_Init(interp) == TCL_ERROR) { if (!try_auto_path) { try_auto_path=1; + Tcl_DeleteCommand(interp, "::itcl::class"); + Tcl_DeleteNamespace(Tcl_FindNamespace(interp, "::itcl", NULL, 0)); continue; } bu_log("Itcl_Init ERROR:\n%s\n", Tcl_GetStringResult(interp)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-01-12 07:06:23
|
Revision: 33531 http://brlcad.svn.sourceforge.net/brlcad/?rev=33531&view=rev Author: brlcad Date: 2009-01-12 07:06:12 +0000 (Mon, 12 Jan 2009) Log Message: ----------- comment on the stupid Itcl_Init() behavior for comprehending down the road. Modified Paths: -------------- brlcad/trunk/src/bwish/main.c brlcad/trunk/src/mged/setup.c Modified: brlcad/trunk/src/bwish/main.c =================================================================== --- brlcad/trunk/src/bwish/main.c 2009-01-12 07:02:44 UTC (rev 33530) +++ brlcad/trunk/src/bwish/main.c 2009-01-12 07:06:12 UTC (rev 33531) @@ -123,6 +123,9 @@ if (init_itcl && Itcl_Init(interp) == TCL_ERROR) { if (!try_auto_path) { try_auto_path=1; + /* Itcl_Init() leaves initialization in a bad state + * and can cause retry failures. cleanup manually. + */ Tcl_DeleteCommand(interp, "::itcl::class"); Tcl_DeleteNamespace(Tcl_FindNamespace(interp, "::itcl", NULL, 0)); continue; Modified: brlcad/trunk/src/mged/setup.c =================================================================== --- brlcad/trunk/src/mged/setup.c 2009-01-12 07:02:44 UTC (rev 33530) +++ brlcad/trunk/src/mged/setup.c 2009-01-12 07:06:12 UTC (rev 33531) @@ -503,6 +503,9 @@ if (init_itcl && Itcl_Init(interp) == TCL_ERROR) { if (!try_auto_path) { try_auto_path=1; + /* Itcl_Init() leaves initialization in a bad state + * and can cause retry failures. cleanup manually. + */ Tcl_DeleteCommand(interp, "::itcl::class"); Tcl_DeleteNamespace(Tcl_FindNamespace(interp, "::itcl", NULL, 0)); continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-01-14 21:30:10
|
Revision: 33558 http://brlcad.svn.sourceforge.net/brlcad/?rev=33558&view=rev Author: bob1961 Date: 2009-01-14 21:29:56 +0000 (Wed, 14 Jan 2009) Log Message: ----------- Added "more args" behavior to libged's ged_3ptarb and modified MGED to use it. Modified Paths: -------------- brlcad/trunk/src/libged/3ptarb.c brlcad/trunk/src/mged/cmd.c brlcad/trunk/src/mged/cmd.h brlcad/trunk/src/mged/setup.c Modified: brlcad/trunk/src/libged/3ptarb.c =================================================================== --- brlcad/trunk/src/libged/3ptarb.c 2009-01-14 18:28:50 UTC (rev 33557) +++ brlcad/trunk/src/libged/3ptarb.c 2009-01-14 21:29:56 UTC (rev 33558) @@ -33,6 +33,18 @@ #include "rtgeom.h" #include "ged_private.h" +static char *p_arb3pt[] = { + "Enter X, Y, Z for point 1: ", + "Enter Y, Z: ", + "Enter Z: ", + "Enter X, Y, Z for point 2: ", + "Enter Y, Z: ", + "Enter Z: ", + "Enter X, Y, Z for point 3: ", + "Enter Y, Z: ", + "Enter Z: " +}; + int ged_3ptarb(struct ged *gedp, int argc, const char *argv[]) { @@ -42,6 +54,7 @@ fastf_t pt4[2], length, thick; vect_t norm; fastf_t ndotv; + char **prompts; struct directory *dp; struct rt_db_internal internal; struct rt_arb_internal *aip; @@ -54,22 +67,36 @@ /* initialize result */ bu_vls_trunc(&gedp->ged_result_str, 0); +#if 0 /* must be wanting help */ if (argc == 1) { bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); return BRLCAD_HELP; } +#endif - if (argc != 15) { + if (argc > 15) { bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); return BRLCAD_ERROR; } + if (argc < 2) { + bu_vls_printf(&gedp->ged_result_str, "Enter name for this arb: "); + return BRLCAD_MORE_ARGS; + } + if ( db_lookup( gedp->ged_wdbp->dbip, argv[1], LOOKUP_QUIET) != DIR_NULL ) { bu_vls_printf(&gedp->ged_result_str, "%s: %s already exists\n", argv[0], argv[1]); return BRLCAD_ERROR; } + /* read the three points */ + prompts = &p_arb3pt[0]; + if (argc < 11) { + bu_vls_printf(&gedp->ged_result_str, prompts[argc-2]); + return BRLCAD_MORE_ARGS; + } + /* preliminary calculations to check input so far */ for (i=0; i<3; i++) { vec1[i] = atof(argv[i+2]) - atof(argv[i+5]); @@ -83,6 +110,11 @@ } VSCALE(norm, norm, 1.0/length); + if (argc < 12) { + bu_vls_printf(&gedp->ged_result_str, "Enter coordinate to solve for (x, y, or z): "); + return BRLCAD_MORE_ARGS; + } + switch (argv[11][0]) { case 'x': if (norm[0] == 0.0) { @@ -91,6 +123,15 @@ } solve = X; + if (argc < 13) { + bu_vls_printf(&gedp->ged_result_str, "Enter the Y, Z coordinate values: "); + return BRLCAD_MORE_ARGS; + } + if (argc < 14) { + bu_vls_printf(&gedp->ged_result_str, "Enter the Z coordinate value: "); + return BRLCAD_MORE_ARGS; + } + pt4[0] = atof( argv[12] ) * gedp->ged_wdbp->dbip->dbi_local2base; pt4[1] = atof( argv[13] ) * gedp->ged_wdbp->dbip->dbi_local2base; break; @@ -102,6 +143,15 @@ } solve = Y; + if (argc < 13) { + bu_vls_printf(&gedp->ged_result_str, "Enter the X, Z coordinate values: "); + return BRLCAD_MORE_ARGS; + } + if (argc < 14) { + bu_vls_printf(&gedp->ged_result_str, "Enter the Z coordinate value: "); + return BRLCAD_MORE_ARGS; + } + pt4[0] = atof( argv[12] ) * gedp->ged_wdbp->dbip->dbi_local2base; pt4[1] = atof( argv[13] ) * gedp->ged_wdbp->dbip->dbi_local2base; break; @@ -113,6 +163,15 @@ } solve = Z; + if (argc < 13) { + bu_vls_printf(&gedp->ged_result_str, "Enter the X, Y coordinate values: "); + return BRLCAD_MORE_ARGS; + } + if (argc < 14) { + bu_vls_printf(&gedp->ged_result_str, "Enter the Y coordinate value: "); + return BRLCAD_MORE_ARGS; + } + pt4[0] = atof( argv[12] ) * gedp->ged_wdbp->dbip->dbi_local2base; pt4[1] = atof( argv[13] ) * gedp->ged_wdbp->dbip->dbi_local2base; break; @@ -122,6 +181,11 @@ return BRLCAD_ERROR; } + if (argc < 15) { + bu_vls_printf(&gedp->ged_result_str, "Enter thickness for this arb: "); + return BRLCAD_MORE_ARGS; + } + if ((thick = (atof( argv[14] ))) == 0.0) { bu_vls_printf(&gedp->ged_result_str, "%s: thickness = 0.0\n", argv[0]); return BRLCAD_ERROR; Modified: brlcad/trunk/src/mged/cmd.c =================================================================== --- brlcad/trunk/src/mged/cmd.c 2009-01-14 18:28:50 UTC (rev 33557) +++ brlcad/trunk/src/mged/cmd.c 2009-01-14 21:29:56 UTC (rev 33558) @@ -294,7 +294,7 @@ } int -cmd_ged_inside(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]) +cmd_ged_more_wrapper(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]) { int ret; Tcl_DString ds; @@ -324,7 +324,15 @@ /* draw the "inside" solid */ new_cmd[0] = "draw"; - new_cmd[1] = argv[2]; + if (ctp->ged_func == ged_3ptarb) + new_cmd[1] = argv[1]; + else if (ctp->ged_func == ged_inside) + new_cmd[1] = argv[2]; + else { + (void)signal(SIGINT, SIG_IGN); + return TCL_OK; + } + new_cmd[2] = (char *)NULL; (void)cmd_draw( clientData, interp, 2, new_cmd ); Modified: brlcad/trunk/src/mged/cmd.h =================================================================== --- brlcad/trunk/src/mged/cmd.h 2009-01-14 18:28:50 UTC (rev 33557) +++ brlcad/trunk/src/mged/cmd.h 2009-01-14 21:29:56 UTC (rev 33558) @@ -43,7 +43,7 @@ BU_EXTERN(int cmd_ged_edit_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); BU_EXTERN(int cmd_ged_erase_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); BU_EXTERN(int cmd_ged_in, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); -BU_EXTERN(int cmd_ged_inside, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); +BU_EXTERN(int cmd_ged_more_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); BU_EXTERN(int cmd_ged_plain_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); BU_EXTERN(int cmd_ged_view_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); Modified: brlcad/trunk/src/mged/setup.c =================================================================== --- brlcad/trunk/src/mged/setup.c 2009-01-14 18:28:50 UTC (rev 33557) +++ brlcad/trunk/src/mged/setup.c 2009-01-14 21:29:56 UTC (rev 33558) @@ -50,7 +50,7 @@ struct cmdtab mged_cmdtab[] = { {"%", f_comm, GED_FUNC_PTR_NULL}, {"35, 25", bv_35_25, GED_FUNC_PTR_NULL}, - {"3ptarb", f_3ptarb, GED_FUNC_PTR_NULL}, + {"3ptarb", cmd_ged_more_wrapper, ged_3ptarb}, {"45, 45", bv_45_45, GED_FUNC_PTR_NULL}, {"B", cmd_blast, GED_FUNC_PTR_NULL}, {"accept", be_accept, GED_FUNC_PTR_NULL}, @@ -165,7 +165,7 @@ {"idents", cmd_ged_plain_wrapper, ged_tables}, {"ill", f_ill, GED_FUNC_PTR_NULL}, {"in", cmd_ged_in, ged_in}, - {"inside", cmd_ged_inside, ged_inside}, + {"inside", cmd_ged_more_wrapper, ged_inside}, {"item", cmd_ged_plain_wrapper, ged_item}, {"joint", f_joint, GED_FUNC_PTR_NULL}, {"journal", f_journal, GED_FUNC_PTR_NULL}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-01-16 06:37:40
|
Revision: 33560 http://brlcad.svn.sourceforge.net/brlcad/?rev=33560&view=rev Author: brlcad Date: 2009-01-16 06:37:23 +0000 (Fri, 16 Jan 2009) Log Message: ----------- rename bu_tcl.c and bn_tcl.c to just tcl.c for consistency with the other half-dozen+ libs that already use that name. Modified Paths: -------------- brlcad/trunk/src/libbn/CMakeLists.txt brlcad/trunk/src/libbn/Makefile.am brlcad/trunk/src/libbu/CMakeLists.txt brlcad/trunk/src/libbu/Makefile.am Added Paths: ----------- brlcad/trunk/src/libbn/tcl.c brlcad/trunk/src/libbu/tcl.c Removed Paths: ------------- brlcad/trunk/src/libbn/bn_tcl.c brlcad/trunk/src/libbu/bu_tcl.c Modified: brlcad/trunk/src/libbn/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libbn/CMakeLists.txt 2009-01-16 00:35:02 UTC (rev 33559) +++ brlcad/trunk/src/libbn/CMakeLists.txt 2009-01-16 06:37:23 UTC (rev 33560) @@ -1,7 +1,6 @@ set(LIBBN_SOURCES anim.c axis.c - bn_tcl.c complex.c font.c fortran.c @@ -20,6 +19,7 @@ sphmap.c symbol.c tabdata.c + tcl.c tplot.c vectfont.c vector.c Modified: brlcad/trunk/src/libbn/Makefile.am =================================================================== --- brlcad/trunk/src/libbn/Makefile.am 2009-01-16 00:35:02 UTC (rev 33559) +++ brlcad/trunk/src/libbn/Makefile.am 2009-01-16 06:37:23 UTC (rev 33560) @@ -7,7 +7,6 @@ libbn_nil_la_SOURCES = \ anim.c \ axis.c \ - bn_tcl.c \ complex.c \ font.c \ fortran.c \ @@ -26,6 +25,7 @@ sphmap.c \ symbol.c \ tabdata.c \ + tcl.c \ tplot.c \ vectfont.c \ vector.c \ Deleted: brlcad/trunk/src/libbn/bn_tcl.c =================================================================== --- brlcad/trunk/src/libbn/bn_tcl.c 2009-01-16 00:35:02 UTC (rev 33559) +++ brlcad/trunk/src/libbn/bn_tcl.c 2009-01-16 06:37:23 UTC (rev 33560) @@ -1,953 +0,0 @@ -/* B N _ T C L . C - * BRL-CAD - * - * Copyright (c) 1995-2009 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @addtogroup bntcl */ -/** @{ */ -/** @file bn_tcl.c - * - * @brief - * Tcl interfaces to all the LIBBN math routines. - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <string.h> - -#include "tcl.h" - -#include "bu.h" -#include "vmath.h" -#include "bn.h" - -/* Support routines for the math functions */ - -/* XXX Really need a decode_array function that uses atof(), - * XXX so that junk like leading { and commas between inputs - * XXX don't spoil the conversion. - */ - -int -bn_decode_mat(fastf_t *m, const char *str) -{ - if ( strcmp( str, "I" ) == 0 ) { - MAT_IDN( m ); - return 16; - } - if ( *str == '{' ) str++; - - return sscanf(str, - "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", - &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6], &m[7], - &m[8], &m[9], &m[10], &m[11], &m[12], &m[13], &m[14], &m[15]); -} - -int -bn_decode_quat(fastf_t *q, const char *str) -{ - if ( *str == '{' ) str++; - return sscanf(str, "%lf %lf %lf %lf", &q[0], &q[1], &q[2], &q[3]); -} - -int -bn_decode_vect(fastf_t *v, const char *str) -{ - if ( *str == '{' ) str++; - return sscanf(str, "%lf %lf %lf", &v[0], &v[1], &v[2]); -} - -int -bn_decode_hvect(fastf_t *v, const char *str) -{ - if ( *str == '{' ) str++; - return sscanf(str, "%lf %lf %lf %lf", &v[0], &v[1], &v[2], &v[3]); -} - -void -bn_encode_mat(struct bu_vls *vp, const mat_t m) -{ - if ( m == NULL ) { - bu_vls_putc(vp, 'I'); - return; - } - - bu_vls_printf(vp, "%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g", - m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], - m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]); -} - -void -bn_encode_quat(struct bu_vls *vp, const mat_t q) -{ - bu_vls_printf(vp, "%g %g %g %g", V4ARGS(q)); -} - -void -bn_encode_vect(struct bu_vls *vp, const mat_t v) -{ - bu_vls_printf(vp, "%g %g %g", V3ARGS(v)); -} - -void -bn_encode_hvect(struct bu_vls *vp, const mat_t v) -{ - bu_vls_printf(vp, "%g %g %g %g", V4ARGS(v)); -} - -void -bn_quat_distance_wrapper(double *dp, mat_t q1, mat_t q2) -{ - *dp = quat_distance(q1, q2); -} - -void -bn_mat_scale_about_pt_wrapper(int *statusp, mat_t mat, const point_t pt, const double scale) -{ - *statusp = bn_mat_scale_about_pt(mat, pt, scale); -} - -static void -bn_mat4x3pnt(fastf_t *o, mat_t m, point_t i) -{ - MAT4X3PNT(o, m, i); -} - -static void -bn_mat4x3vec(fastf_t *o, mat_t m, vect_t i) -{ - MAT4X3VEC(o, m, i); -} - -static void -bn_hdivide(fastf_t *o, const mat_t i) -{ - HDIVIDE(o, i); -} - -static void -bn_vjoin1(fastf_t *o, const point_t pnt, double scale, const vect_t dir) -{ - VJOIN1( o, pnt, scale, dir ); -} - - -static void bn_vblend(mat_t a, fastf_t b, mat_t c, fastf_t d, mat_t e) -{ - VBLEND2( a, b, c, d, e ); -} - -/** - * B N _ M A T H _ C M D - *@brief - * Tcl wrappers for the math functions. - * - * This is where you should put clauses, in the below "if" statement, to add - * Tcl support for the LIBBN math routines. - */ - -int -bn_math_cmd(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) -{ - void (*math_func)(); - struct bu_vls result; - - math_func = (void (*)())clientData; /* object-to-function cast */ - bu_vls_init(&result); - - if (math_func == bn_mat_mul) { - mat_t o, a, b; - if (argc < 3 || bn_decode_mat(a, argv[1]) < 16 || - bn_decode_mat(b, argv[2]) < 16) { - bu_vls_printf(&result, "usage: %s matA matB", argv[0]); - goto error; - } - bn_mat_mul(o, a, b); - bn_encode_mat(&result, o); - } else if (math_func == bn_mat_inv || math_func == bn_mat_trn) { - mat_t o, a; - - if (argc < 2 || bn_decode_mat(a, argv[1]) < 16) { - bu_vls_printf(&result, "usage: %s mat", argv[0]); - goto error; - } - (*math_func)(o, a); - bn_encode_mat(&result, o); - } else if (math_func == bn_matXvec) { - mat_t m; - hvect_t i, o; - if (argc < 3 || bn_decode_mat(m, argv[1]) < 16 || - bn_decode_hvect(i, argv[2]) < 4) { - bu_vls_printf(&result, "usage: %s mat hvect", argv[0]); - goto error; - } - bn_matXvec(o, m, i); - bn_encode_hvect(&result, o); - } else if (math_func == bn_mat4x3pnt) { - mat_t m; - point_t i, o; - if (argc < 3 || bn_decode_mat(m, argv[1]) < 16 || - bn_decode_vect(i, argv[2]) < 3) { - bu_vls_printf(&result, "usage: %s mat point", argv[0]); - goto error; - } - bn_mat4x3pnt(o, m, i); - bn_encode_vect(&result, o); - } else if (math_func == bn_mat4x3vec) { - mat_t m; - vect_t i, o; - if (argc < 3 || bn_decode_mat(m, argv[1]) < 16 || - bn_decode_vect(i, argv[2]) < 3) { - bu_vls_printf(&result, "usage: %s mat vect", argv[0]); - goto error; - } - bn_mat4x3vec(o, m, i); - bn_encode_vect(&result, o); - } else if (math_func == bn_hdivide) { - hvect_t i; - vect_t o; - if (argc < 2 || bn_decode_hvect(i, argv[1]) < 4) { - bu_vls_printf(&result, "usage: %s hvect", argv[0]); - goto error; - } - bn_hdivide(o, i); - bn_encode_vect(&result, o); - } else if (math_func == bn_vjoin1) { - point_t o; - point_t b, d; - fastf_t c; - - if (argc < 4) { - bu_vls_printf(&result, "usage: %s pnt scale dir", argv[0]); - goto error; - } - if ( bn_decode_vect(b, argv[1]) < 3) goto error; - if (Tcl_GetDouble(interp, argv[2], &c) != TCL_OK) goto error; - if ( bn_decode_vect(d, argv[3]) < 3) goto error; - - VJOIN1( o, b, c, d ); /* bn_vjoin1( o, b, c, d ) */ - bn_encode_vect(&result, o); - - } else if ( math_func == bn_vblend) { - point_t a, c, e; - fastf_t b, d; - - if ( argc < 5 ) { - bu_vls_printf(&result, "usage: %s scale pnt scale pnt", argv[0]); - goto error; - } - - if ( Tcl_GetDouble(interp, argv[1], &b) != TCL_OK) goto error; - if ( bn_decode_vect( c, argv[2] ) < 3) goto error; - if ( Tcl_GetDouble(interp, argv[3], &d) != TCL_OK) goto error; - if ( bn_decode_vect( e, argv[4] ) < 3) goto error; - - VBLEND2( a, b, c, d, e ) - bn_encode_vect( &result, a ); - - } else if (math_func == bn_mat_ae) { - mat_t o; - double az, el; - - if (argc < 3) { - bu_vls_printf(&result, "usage: %s azimuth elevation", argv[0]); - goto error; - } - if (Tcl_GetDouble(interp, argv[1], &az) != TCL_OK) goto error; - if (Tcl_GetDouble(interp, argv[2], &el) != TCL_OK) goto error; - - bn_mat_ae(o, (fastf_t)az, (fastf_t)el); - bn_encode_mat(&result, o); - } else if (math_func == bn_ae_vec) { - fastf_t az, el; - vect_t v; - - if (argc < 2 || bn_decode_vect(v, argv[1]) < 3) { - bu_vls_printf(&result, "usage: %s vect", argv[0]); - goto error; - } - - bn_ae_vec(&az, &el, v); - bu_vls_printf(&result, "%g %g", az, el); - } else if (math_func == bn_aet_vec) { - fastf_t az, el, twist, accuracy; - vect_t vec_ae, vec_twist; - - if (argc < 4 || bn_decode_vect(vec_ae, argv[1]) < 3 || - bn_decode_vect(vec_twist, argv[2]) < 3 || - sscanf(argv[3], "%lf", &accuracy) < 1) { - bu_vls_printf(&result, "usage: %s vec_ae vec_twist accuracy", - argv[0]); - goto error; - } - - bn_aet_vec(&az, &el, &twist, vec_ae, vec_twist, accuracy); - bu_vls_printf(&result, "%g %g %g", az, el, twist); - } else if (math_func == bn_mat_angles) { - mat_t o; - double alpha, beta, ggamma; - - if (argc < 4) { - bu_vls_printf(&result, "usage: %s alpha beta gamma", argv[0]); - goto error; - } - if (Tcl_GetDouble(interp, argv[1], &alpha) != TCL_OK) goto error; - if (Tcl_GetDouble(interp, argv[2], &beta) != TCL_OK) goto error; - if (Tcl_GetDouble(interp, argv[3], &ggamma) != TCL_OK) goto error; - - bn_mat_angles(o, alpha, beta, ggamma); - bn_encode_mat(&result, o); - } else if (math_func == bn_eigen2x2) { - fastf_t val1, val2; - vect_t vec1, vec2; - double a, b, c; - - if (argc < 4) { - bu_vls_printf(&result, "usage: %s a b c", argv[0]); - goto error; - } - if (Tcl_GetDouble(interp, argv[1], &a) != TCL_OK) goto error; - if (Tcl_GetDouble(interp, argv[2], &c) != TCL_OK) goto error; - if (Tcl_GetDouble(interp, argv[3], &b) != TCL_OK) goto error; - - bn_eigen2x2(&val1, &val2, vec1, vec2, (fastf_t)a, (fastf_t)b, - (fastf_t)c); - bu_vls_printf(&result, "%g %g {%g %g %g} {%g %g %g}", val1, val2, - V3ARGS(vec1), V3ARGS(vec2)); - } else if (math_func == bn_mat_fromto) { - mat_t o; - vect_t from, to; - - if (argc < 3 || bn_decode_vect(from, argv[1]) < 3 || - bn_decode_vect(to, argv[2]) < 3) { - bu_vls_printf(&result, "usage: %s vecFrom vecTo", argv[0]); - goto error; - } - bn_mat_fromto(o, from, to); - bn_encode_mat(&result, o); - } else if (math_func == bn_mat_xrot || math_func == bn_mat_yrot || - math_func == bn_mat_zrot) { - mat_t o; - double s, c; - if (argc < 3) { - bu_vls_printf(&result, "usage: %s sinAngle cosAngle", argv[0]); - goto error; - } - if (Tcl_GetDouble(interp, argv[1], &s) != TCL_OK) goto error; - if (Tcl_GetDouble(interp, argv[2], &c) != TCL_OK) goto error; - - (*math_func)(o, s, c); - bn_encode_mat(&result, o); - } else if (math_func == bn_mat_lookat) { - mat_t o; - vect_t dir; - int yflip; - if (argc < 3 || bn_decode_vect(dir, argv[1]) < 3) { - bu_vls_printf(&result, "usage: %s dir yflip", argv[0]); - goto error; - } - if (Tcl_GetBoolean(interp, argv[2], &yflip) != TCL_OK) goto error; - - bn_mat_lookat(o, dir, yflip); - bn_encode_mat(&result, o); - } else if (math_func == bn_vec_ortho || math_func == bn_vec_perp) { - vect_t ov, vec; - - if (argc < 2 || bn_decode_vect(vec, argv[1]) < 3) { - bu_vls_printf(&result, "usage: %s vec", argv[0]); - goto error; - } - - (*math_func)(ov, vec); - bn_encode_vect(&result, ov); - } else if (math_func == bn_mat_scale_about_pt_wrapper) { - mat_t o; - vect_t v; - double scale; - int status; - - if (argc < 3 || bn_decode_vect(v, argv[1]) < 3) { - bu_vls_printf(&result, "usage: %s pt scale", argv[0]); - goto error; - } - if (Tcl_GetDouble(interp, argv[2], &scale) != TCL_OK) goto error; - - bn_mat_scale_about_pt_wrapper(&status, o, v, scale); - if (status != 0) { - bu_vls_printf(&result, "error performing calculation"); - goto error; - } - bn_encode_mat(&result, o); - } else if (math_func == bn_mat_xform_about_pt) { - mat_t o, xform; - vect_t v; - - if (argc < 3 || bn_decode_mat(xform, argv[1]) < 16 || - bn_decode_vect(v, argv[2]) < 3) { - bu_vls_printf(&result, "usage: %s xform pt", argv[0]); - goto error; - } - - bn_mat_xform_about_pt(o, xform, v); - bn_encode_mat(&result, o); - } else if (math_func == bn_mat_arb_rot) { - mat_t o; - point_t pt; - vect_t dir; - double angle; - - if (argc < 4 || bn_decode_vect(pt, argv[1]) < 3 || - bn_decode_vect(dir, argv[2]) < 3) { - bu_vls_printf(&result, "usage: %s pt dir angle", argv[0]); - goto error; - } - if (Tcl_GetDouble(interp, argv[3], &angle) != TCL_OK) - return TCL_ERROR; - - bn_mat_arb_rot(o, pt, dir, (fastf_t)angle); - bn_encode_mat(&result, o); - } else if (math_func == quat_mat2quat) { - mat_t mat; - quat_t quat; - - if (argc < 2 || bn_decode_mat(mat, argv[1]) < 16) { - bu_vls_printf(&result, "usage: %s mat", argv[0]); - goto error; - } - - quat_mat2quat(quat, mat); - bn_encode_quat(&result, quat); - } else if (math_func == quat_quat2mat) { - mat_t mat; - quat_t quat; - - if (argc < 2 || bn_decode_quat(quat, argv[1]) < 4) { - bu_vls_printf(&result, "usage: %s quat", argv[0]); - goto error; - } - - quat_quat2mat(mat, quat); - bn_encode_mat(&result, mat); - } else if (math_func == bn_quat_distance_wrapper) { - quat_t q1, q2; - double d; - - if (argc < 3 || bn_decode_quat(q1, argv[1]) < 4 || - bn_decode_quat(q2, argv[2]) < 4) { - bu_vls_printf(&result, "usage: %s quatA quatB", argv[0]); - goto error; - } - - bn_quat_distance_wrapper(&d, q1, q2); - bu_vls_printf(&result, "%g", d); - } else if (math_func == quat_double || math_func == quat_bisect || - math_func == quat_make_nearest) { - quat_t oqot, q1, q2; - - if (argc < 3 || bn_decode_quat(q1, argv[1]) < 4 || - bn_decode_quat(q2, argv[2]) < 4) { - bu_vls_printf(&result, "usage: %s quatA quatB", argv[0]); - goto error; - } - - (*math_func)(oqot, q1, q2); - bn_encode_quat(&result, oqot); - } else if (math_func == quat_slerp) { - quat_t oq, q1, q2; - double d; - - if (argc < 4 || bn_decode_quat(q1, argv[1]) < 4 || - bn_decode_quat(q2, argv[2]) < 4) { - bu_vls_printf(&result, "usage: %s quat1 quat2 factor", argv[0]); - goto error; - } - if (Tcl_GetDouble(interp, argv[3], &d) != TCL_OK) goto error; - - quat_slerp(oq, q1, q2, d); - bn_encode_quat(&result, oq); - } else if (math_func == quat_sberp) { - quat_t oq, q1, qa, qb, q2; - double d; - - if (argc < 6 || bn_decode_quat(q1, argv[1]) < 4 || - bn_decode_quat(qa, argv[2]) < 4 || bn_decode_quat(qb, argv[3]) < 4 || - bn_decode_quat(q2, argv[4]) < 4) { - bu_vls_printf(&result, "usage: %s quat1 quatA quatB quat2 factor", - argv[0]); - goto error; - } - if (Tcl_GetDouble(interp, argv[5], &d) != TCL_OK) goto error; - - quat_sberp(oq, q1, qa, qb, q2, d); - bn_encode_quat(&result, oq); - } else if (math_func == quat_exp || math_func == quat_log) { - quat_t qout, qin; - - if (argc < 2 || bn_decode_quat(qin, argv[1]) < 4) { - bu_vls_printf(&result, "usage: %s quat", argv[0]); - goto error; - } - - (*math_func)(qout, qin); - bn_encode_quat(&result, qout); - } else if (math_func == (void (*)())bn_isect_line3_line3) { - double t, u; - point_t pt, a; - vect_t dir, c; - int i; - static const struct bn_tol tol = { - BN_TOL_MAGIC, 0.005, 0.005*0.005, 1e-6, 1-1e-6 - }; - if (argc != 5) { - bu_vls_printf(&result, - "Usage: bn_isect_line3_line3 pt dir pt dir (%d args specified)", - argc-1); - goto error; - } - - if (bn_decode_vect(pt, argv[1]) < 3) { - bu_vls_printf(&result, "bn_isect_line3_line3 no pt: %s\n", argv[0]); - goto error; - } - if (bn_decode_vect(dir, argv[2]) < 3) { - bu_vls_printf(&result, "bn_isect_line3_line3 no dir: %s\n", argv[0]); - goto error; - } - if (bn_decode_vect(a, argv[3]) < 3) { - bu_vls_printf(&result, "bn_isect_line3_line3 no a pt: %s\n", argv[0]); - goto error; - } - if (bn_decode_vect(c, argv[4]) < 3) { - bu_vls_printf(&result, "bn_isect_line3_line3 no c dir: %s\n", argv[0]); - goto error; - } - i = bn_isect_line3_line3(&t, &u, pt, dir, a, c, &tol); - if (i != 1) { - bu_vls_printf(&result, "bn_isect_line3_line3 no intersection: %s\n", argv[0]); - goto error; - } - - VJOIN1(a, pt, t, dir); - bn_encode_vect(&result, a); - - } else if (math_func == (void (*)())bn_isect_line2_line2) { - double dist[2]; - point_t pt, a; - vect_t dir, c; - int i; - static const struct bn_tol tol = { - BN_TOL_MAGIC, 0.005, 0.005*0.005, 1e-6, 1-1e-6 - }; - - if (argc != 5) { - bu_vls_printf(&result, - "Usage: bn_isect_line2_line2 pt dir pt dir (%d args specified)", - argc-1); - goto error; - } - - /* i = bn_isect_line2_line2 {0 0} {1 0} {1 1} {0 -1} */ - - VSETALL(pt, 0.0); - VSETALL(dir, 0.0); - VSETALL(a, 0.0); - VSETALL(c, 0.0); - - if (bn_decode_vect(pt, argv[1]) < 2) { - bu_vls_printf(&result, "bn_isect_line2_line2 no pt: %s\n", argv[0]); - goto error; - } - if (bn_decode_vect(dir, argv[2]) < 2) { - bu_vls_printf(&result, "bn_isect_line2_line2 no dir: %s\n", argv[0]); - goto error; - } - if (bn_decode_vect(a, argv[3]) < 2) { - bu_vls_printf(&result, "bn_isect_line2_line2 no a pt: %s\n", argv[0]); - goto error; - } - if (bn_decode_vect(c, argv[4]) < 2) { - bu_vls_printf(&result, "bn_isect_line2_line2 no c dir: %s\n", argv[0]); - goto error; - } - i = bn_isect_line2_line2(dist, pt, dir, a, c, &tol); - if (i != 1) { - bu_vls_printf(&result, "bn_isect_line2_line2 no intersection: %s\n", argv[0]); - goto error; - } - - VJOIN1(a, pt, dist[0], dir); - bu_vls_printf(&result, "%g %g", a[0], a[1]); - - } else { - bu_vls_printf(&result, "libbn/bn_tcl.c: math function %s not supported yet\n", argv[0]); - goto error; - } - - Tcl_AppendResult(interp, bu_vls_addr(&result), (char *)NULL); - bu_vls_free(&result); - return TCL_OK; - - error: - Tcl_AppendResult(interp, bu_vls_addr(&result), (char *)NULL); - bu_vls_free(&result); - return TCL_ERROR; -} - -static struct math_func_link { - char *name; - void (*func)(); -} math_funcs[] = { - {"bn_isect_line2_line2", (void (*)())bn_isect_line2_line2}, - {"bn_isect_line3_line3", (void (*)())bn_isect_line3_line3}, - {"mat_mul", bn_mat_mul}, - {"mat_inv", bn_mat_inv}, - {"mat_trn", bn_mat_trn}, - {"matXvec", bn_matXvec}, - {"mat4x3vec", bn_mat4x3vec}, - {"mat4x3pnt", bn_mat4x3pnt}, - {"hdivide", bn_hdivide}, - {"vjoin1", bn_vjoin1}, - {"vblend", bn_vblend}, - {"mat_ae", bn_mat_ae}, - {"mat_ae_vec", bn_ae_vec}, - {"mat_aet_vec", bn_aet_vec}, - {"mat_angles", bn_mat_angles}, - {"mat_eigen2x2", bn_eigen2x2}, - {"mat_fromto", bn_mat_fromto}, - {"mat_xrot", bn_mat_xrot}, - {"mat_yrot", bn_mat_yrot}, - {"mat_zrot", bn_mat_zrot}, - {"mat_lookat", bn_mat_lookat}, - {"mat_vec_ortho", bn_vec_ortho}, - {"mat_vec_perp", bn_vec_perp}, - {"mat_scale_about_pt", bn_mat_scale_about_pt_wrapper}, - {"mat_xform_about_pt", bn_mat_xform_about_pt}, - {"mat_arb_rot", bn_mat_arb_rot}, - {"quat_mat2quat", quat_mat2quat}, - {"quat_quat2mat", quat_quat2mat}, - {"quat_distance", bn_quat_distance_wrapper}, - {"quat_double", quat_double}, - {"quat_bisect", quat_bisect}, - {"quat_slerp", quat_slerp}, - {"quat_sberp", quat_sberp}, - {"quat_make_nearest", quat_make_nearest}, - {"quat_exp", quat_exp}, - {"quat_log", quat_log}, - {0, 0} -}; - -int -bn_cmd_noise_perlin(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ - point_t pt; - double v; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " X Y Z \"", - NULL); - return TCL_ERROR; - } - - pt[X] = atof(argv[1]); - pt[Y] = atof(argv[2]); - pt[Z] = atof(argv[3]); - - v = bn_noise_perlin( pt ); - Tcl_SetObjResult( interp, Tcl_NewDoubleObj(v) ); - - return TCL_OK; -} - -/* - * usage: bn_noise_fbm X Y Z h_val lacunarity octaves - * - */ -int -bn_cmd_noise(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ - point_t pt; - double h_val; - double lacunarity; - double octaves; - double val; - - if (argc != 7) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " X Y Z h_val lacunarity octaves\"", - NULL); - return TCL_ERROR; - } - - pt[0] = atof(argv[1]); - pt[1] = atof(argv[2]); - pt[2] = atof(argv[3]); - - h_val = atof(argv[4]); - lacunarity = atof(argv[5]); - octaves = atof(argv[6]); - - - if (!strcmp("bn_noise_turb", argv[0])) { - val = bn_noise_turb(pt, h_val, lacunarity, octaves); - - Tcl_SetObjResult( interp, Tcl_NewDoubleObj(val) ); - } else if (!strcmp("bn_noise_fbm", argv[0])) { - val = bn_noise_fbm(pt, h_val, lacunarity, octaves); - Tcl_SetObjResult( interp, Tcl_NewDoubleObj(val) ); - } else { - Tcl_AppendResult(interp, "Unknown noise type \"", - argv[0], "\"", NULL); - return TCL_ERROR; - } - return TCL_OK; -} - - -/** - * @brief - * usage: noise_slice xdim ydim inv h_val lac octaves dX dY dZ sX [sY sZ] - * - * The idea here is to get a whole slice of noise at once, thereby - * avoiding the overhead of doing this in Tcl. - */ -int -bn_cmd_noise_slice(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ - double h_val; - double lacunarity; - double octaves; - - vect_t delta; /* translation to noise space */ - vect_t scale; /* scale to noise space */ - unsigned xdim; /* # samples X direction */ - unsigned ydim; /* # samples Y direction */ - unsigned xval, yval; -#define NOISE_FBM 0 -#define NOISE_TURB 1 - - int noise_type = NOISE_FBM; - double val; - point_t pt; - - if (argc != 7) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " Xdim Ydim Zval h_val lacunarity octaves\"", - NULL); - return TCL_ERROR; - } - - xdim = atoi(argv[0]); - ydim = atoi(argv[1]); - VSETALL(delta, 0.0); - VSETALL(scale, 1.); - pt[Z] = delta[Z] = atof(argv[2]); - h_val = atof(argv[3]); - lacunarity = atof(argv[4]); - octaves = atof(argv[5]); - - switch (noise_type) { - case NOISE_FBM: - for (yval = 0; yval < ydim; yval++) { - - pt[Y] = yval * scale[Y] + delta[Y]; - - for (xval = 0; xval < xdim; xval++) { - pt[X] = xval * scale[X] + delta[X]; - - val = bn_noise_fbm(pt, h_val, lacunarity, octaves); - - } - } - break; - case NOISE_TURB: - for (yval = 0; yval < ydim; yval++) { - - pt[Y] = yval * scale[Y] + delta[Y]; - - for (xval = 0; xval < xdim; xval++) { - pt[X] = xval * scale[X] + delta[X]; - - val = bn_noise_turb(pt, h_val, lacunarity, octaves); - - } - } - break; - } - - - pt[0] = atof(argv[1]); - pt[1] = atof(argv[2]); - pt[2] = atof(argv[3]); - - h_val = atof(argv[4]); - lacunarity = atof(argv[5]); - octaves = atof(argv[6]); - - - if (!strcmp("bn_noise_turb", argv[0])) { - val = bn_noise_turb(pt, h_val, lacunarity, octaves); - Tcl_SetObjResult( interp, Tcl_NewDoubleObj(val) ); - } else if (!strcmp("bn_noise_fbm", argv[0])) { - val = bn_noise_fbm(pt, h_val, lacunarity, octaves); - Tcl_SetObjResult( interp, Tcl_NewDoubleObj(val) ); - } else { - Tcl_AppendResult(interp, "Unknown noise type \"", - argv[0], "\"", NULL); - return TCL_ERROR; - } - return TCL_OK; -} - - -int -bn_cmd_random(ClientData clientData, - Tcl_Interp *interp, - int argc, - char **argv) -{ - int val; - const char *str; - double rnd; - char buf[32]; - - if (argc != 2) { - Tcl_AppendResult(interp, "Wrong # args: Should be \"", - argv[0], " varname\"", NULL); - return TCL_ERROR; - } - - if (! (str=Tcl_GetVar(interp, argv[1], 0))) { - Tcl_AppendResult(interp, "Error getting variable ", - argv[1], NULL); - return TCL_ERROR; - } - val = atoi(str); - - if (val < 0) val = 0; - - rnd = BN_RANDOM(val); - - snprintf(buf, 32, "%d", val); - - if (!Tcl_SetVar(interp, argv[1], buf, 0)) { - Tcl_AppendResult(interp, "Error setting variable ", - argv[1], NULL); - return TCL_ERROR; - } - - snprintf(buf, 32, "%g", rnd); - Tcl_AppendResult(interp, buf, NULL); - return TCL_OK; -} - -/** - * B N _ M A T _ P R I N T - */ -void -bn_tcl_mat_print(Tcl_Interp *interp, - const char *title, - const mat_t m) -{ - char obuf[1024]; /* sprintf may be non-PARALLEL */ - - bn_mat_print_guts(title, m, obuf, 1024); - Tcl_AppendResult(interp, obuf, "\n", (char *)NULL); -} - - -/** - * B N _ T C L _ S E T U P - *@brief - * Add all the supported Tcl interfaces to LIBBN routines to - * the list of commands known by the given interpreter. - */ -void -bn_tcl_setup(Tcl_Interp *interp) -{ - struct math_func_link *mp; - - for (mp = math_funcs; mp->name != NULL; mp++) { - (void)Tcl_CreateCommand(interp, mp->name, - (Tcl_CmdProc *)bn_math_cmd, - (ClientData)mp->func, /* Function-to-Object pointer cast */ - (Tcl_CmdDeleteProc *)NULL); - } - - (void)Tcl_CreateCommand(interp, "bn_noise_perlin", - (Tcl_CmdProc *)bn_cmd_noise_perlin, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); - - (void)Tcl_CreateCommand(interp, "bn_noise_turb", - (Tcl_CmdProc *)bn_cmd_noise, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); - - (void)Tcl_CreateCommand(interp, "bn_noise_fbm", - (Tcl_CmdProc *)bn_cmd_noise, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); - - (void)Tcl_CreateCommand(interp, "bn_noise_slice", - (Tcl_CmdProc *)bn_cmd_noise_slice, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); - - (void)Tcl_CreateCommand(interp, "bn_random", - (Tcl_CmdProc *)bn_cmd_random, (ClientData)NULL, - (Tcl_CmdDeleteProc *)NULL); -} - - -/** - * B N _ I N I T - *@brief - * Allows LIBBN to be dynamically loade to a vanilla tclsh/wish with - * "load /usr/brlcad/lib/libbn.so" - * - * The name of this function is specified by TCL. - */ -int -Bn_Init(Tcl_Interp *interp) -{ - bn_tcl_setup(interp); - return TCL_OK; -} - - -double bn_noise_fbm(point_t point, double h_val, double lacunarity, double octaves); -double bn_noise_turb(point_t point, double h_val, double lacunarity, double octaves); -/** @} */ -/* - * Local Variables: - * mode: C - * tab-width: 8 - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Copied: brlcad/trunk/src/libbn/tcl.c (from rev 33559, brlcad/trunk/src/libbn/bn_tcl.c) =================================================================== --- brlcad/trunk/src/libbn/tcl.c (rev 0) +++ brlcad/trunk/src/libbn/tcl.c 2009-01-16 06:37:23 UTC (rev 33560) @@ -0,0 +1,953 @@ +/* B N _ T C L . C + * BRL-CAD + * + * Copyright (c) 1995-2009 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @addtogroup bntcl */ +/** @{ */ +/** @file bn_tcl.c + * + * @brief + * Tcl interfaces to all the LIBBN math routines. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <string.h> + +#include "tcl.h" + +#include "bu.h" +#include "vmath.h" +#include "bn.h" + +/* Support routines for the math functions */ + +/* XXX Really need a decode_array function that uses atof(), + * XXX so that junk like leading { and commas between inputs + * XXX don't spoil the conversion. + */ + +int +bn_decode_mat(fastf_t *m, const char *str) +{ + if ( strcmp( str, "I" ) == 0 ) { + MAT_IDN( m ); + return 16; + } + if ( *str == '{' ) str++; + + return sscanf(str, + "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", + &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6], &m[7], + &m[8], &m[9], &m[10], &m[11], &m[12], &m[13], &m[14], &m[15]); +} + +int +bn_decode_quat(fastf_t *q, const char *str) +{ + if ( *str == '{' ) str++; + return sscanf(str, "%lf %lf %lf %lf", &q[0], &q[1], &q[2], &q[3]); +} + +int +bn_decode_vect(fastf_t *v, const char *str) +{ + if ( *str == '{' ) str++; + return sscanf(str, "%lf %lf %lf", &v[0], &v[1], &v[2]); +} + +int +bn_decode_hvect(fastf_t *v, const char *str) +{ + if ( *str == '{' ) str++; + return sscanf(str, "%lf %lf %lf %lf", &v[0], &v[1], &v[2], &v[3]); +} + +void +bn_encode_mat(struct bu_vls *vp, const mat_t m) +{ + if ( m == NULL ) { + bu_vls_putc(vp, 'I'); + return; + } + + bu_vls_printf(vp, "%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g", + m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], + m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]); +} + +void +bn_encode_quat(struct bu_vls *vp, const mat_t q) +{ + bu_vls_printf(vp, "%g %g %g %g", V4ARGS(q)); +} + +void +bn_encode_vect(struct bu_vls *vp, const mat_t v) +{ + bu_vls_printf(vp, "%g %g %g", V3ARGS(v)); +} + +void +bn_encode_hvect(struct bu_vls *vp, const mat_t v) +{ + bu_vls_printf(vp, "%g %g %g %g", V4ARGS(v)); +} + +void +bn_quat_distance_wrapper(double *dp, mat_t q1, mat_t q2) +{ + *dp = quat_distance(q1, q2); +} + +void +bn_mat_scale_about_pt_wrapper(int *statusp, mat_t mat, const point_t pt, const double scale) +{ + *statusp = bn_mat_scale_about_pt(mat, pt, scale); +} + +static void +bn_mat4x3pnt(fastf_t *o, mat_t m, point_t i) +{ + MAT4X3PNT(o, m, i); +} + +static void +bn_mat4x3vec(fastf_t *o, mat_t m, vect_t i) +{ + MAT4X3VEC(o, m, i); +} + +static void +bn_hdivide(fastf_t *o, const mat_t i) +{ + HDIVIDE(o, i); +} + +static void +bn_vjoin1(fastf_t *o, const point_t pnt, double scale, const vect_t dir) +{ + VJOIN1( o, pnt, scale, dir ); +} + + +static void bn_vblend(mat_t a, fastf_t b, mat_t c, fastf_t d, mat_t e) +{ + VBLEND2( a, b, c, d, e ); +} + +/** + * B N _ M A T H _ C M D + *@brief + * Tcl wrappers for the math functions. + * + * This is where you should put clauses, in the below "if" statement, to add + * Tcl support for the LIBBN math routines. + */ + +int +bn_math_cmd(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) +{ + void (*math_func)(); + struct bu_vls result; + + math_func = (void (*)())clientData; /* object-to-function cast */ + bu_vls_init(&result); + + if (math_func == bn_mat_mul) { + mat_t o, a, b; + if (argc < 3 || bn_decode_mat(a, argv[1]) < 16 || + bn_decode_mat(b, argv[2]) < 16) { + bu_vls_printf(&result, "usage: %s matA matB", argv[0]); + goto error; + } + bn_mat_mul(o, a, b); + bn_encode_mat(&result, o); + } else if (math_func == bn_mat_inv || math_func == bn_mat_trn) { + mat_t o, a; + + if (argc < 2 || bn_decode_mat(a, argv[1]) < 16) { + bu_vls_printf(&result, "usage: %s mat", argv[0]); + goto error; + } + (*math_func)(o, a); + bn_encode_mat(&result, o); + } else if (math_func == bn_matXvec) { + mat_t m; + hvect_t i, o; + if (argc < 3 || bn_decode_mat(m, argv[1]) < 16 || + bn_decode_hvect(i, argv[2]) < 4) { + bu_vls_printf(&result, "usage: %s mat hvect", argv[0]); + goto error; + } + bn_matXvec(o, m, i); + bn_encode_hvect(&result, o); + } else if (math_func == bn_mat4x3pnt) { + mat_t m; + point_t i, o; + if (argc < 3 || bn_decode_mat(m, argv[1]) < 16 || + bn_decode_vect(i, argv[2]) < 3) { + bu_vls_printf(&result, "usage: %s mat point", argv[0]); + goto error; + } + bn_mat4x3pnt(o, m, i); + bn_encode_vect(&result, o); + } else if (math_func == bn_mat4x3vec) { + mat_t m; + vect_t i, o; + if (argc < 3 || bn_decode_mat(m, argv[1]) < 16 || + bn_decode_vect(i, argv[2]) < 3) { + bu_vls_printf(&result, "usage: %s mat vect", argv[0]); + goto error; + } + bn_mat4x3vec(o, m, i); + bn_encode_vect(&result, o); + } else if (math_func == bn_hdivide) { + hvect_t i; + vect_t o; + if (argc < 2 || bn_decode_hvect(i, argv[1]) < 4) { + bu_vls_printf(&result, "usage: %s hvect", argv[0]); + goto error; + } + bn_hdivide(o, i); + bn_encode_vect(&result, o); + } else if (math_func == bn_vjoin1) { + point_t o; + point_t b, d; + fastf_t c; + + if (argc < 4) { + bu_vls_printf(&result, "usage: %s pnt scale dir", argv[0]); + goto error; + } + if ( bn_decode_vect(b, argv[1]) < 3) goto error; + if (Tcl_GetDouble(interp, argv[2], &c) != TCL_OK) goto error; + if ( bn_decode_vect(d, argv[3]) < 3) goto error; + + VJOIN1( o, b, c, d ); /* bn_vjoin1( o, b, c, d ) */ + bn_encode_vect(&result, o); + + } else if ( math_func == bn_vblend) { + point_t a, c, e; + fastf_t b, d; + + if ( argc < 5 ) { + bu_vls_printf(&result, "usage: %s scale pnt scale pnt", argv[0]); + goto error; + } + + if ( Tcl_GetDouble(interp, argv[1], &b) != TCL_OK) goto error; + if ( bn_decode_vect( c, argv[2] ) < 3) goto error; + if ( Tcl_GetDouble(interp, argv[3], &d) != TCL_OK) goto error; + if ( bn_decode_vect( e, argv[4] ) < 3) goto error; + + VBLEND2( a, b, c, d, e ) + bn_encode_vect( &result, a ); + + } else if (math_func == bn_mat_ae) { + mat_t o; + double az, el; + + if (argc < 3) { + bu_vls_printf(&result, "usage: %s azimuth elevation", argv[0]); + goto error; + } + if (Tcl_GetDouble(interp, argv[1], &az) != TCL_OK) goto error; + if (Tcl_GetDouble(interp, argv[2], &el) != TCL_OK) goto error; + + bn_mat_ae(o, (fastf_t)az, (fastf_t)el); + bn_encode_mat(&result, o); + } else if (math_func == bn_ae_vec) { + fastf_t az, el; + vect_t v; + + if (argc < 2 || bn_decode_vect(v, argv[1]) < 3) { + bu_vls_printf(&result, "usage: %s vect", argv[0]); + goto error; + } + + bn_ae_vec(&az, &el, v); + bu_vls_printf(&result, "%g %g", az, el); + } else if (math_func == bn_aet_vec) { + fastf_t az, el, twist, accuracy; + vect_t vec_ae, vec_twist; + + if (argc < 4 || bn_decode_vect(vec_ae, argv[1]) < 3 || + bn_decode_vect(vec_twist, argv[2]) < 3 || + sscanf(argv[3], "%lf", &accuracy) < 1) { + bu_vls_printf(&result, "usage: %s vec_ae vec_twist accuracy", + argv[0]); + goto error; + } + + bn_aet_vec(&az, &el, &twist, vec_ae, vec_twist, accuracy); + bu_vls_printf(&result, "%g %g %g", az, el, twist); + } else if (math_func == bn_mat_angles) { + mat_t o; + double alpha, beta, ggamma; + + if (argc < 4) { + bu_vls_printf(&result, "usage: %s alpha beta gamma", argv[0]); + goto error; + } + if (Tcl_GetDouble(interp, argv[1], &alpha) != TCL_OK) goto error; + if (Tcl_GetDouble(interp, argv[2], &beta) != TCL_OK) goto error; + if (Tcl_GetDouble(interp, argv[3], &ggamma) != TCL_OK) goto error; + + bn_mat_angles(o, alpha, beta, ggamma); + bn_encode_mat(&result, o); + } else if (math_func == bn_eigen2x2) { + fastf_t val1, val2; + vect_t vec1, vec2; + double a, b, c; + + if (argc < 4) { + bu_vls_printf(&result, "usage: %s a b c", argv[0]); + goto error; + } + if (Tcl_GetDouble(interp, argv[1], &a) != TCL_OK) goto error; + if (Tcl_GetDouble(interp, argv[2], &c) != TCL_OK) goto error; + if (Tcl_GetDouble(interp, argv[3], &b) != TCL_OK) goto error; + + bn_eigen2x2(&val1, &val2, vec1, vec2, (fastf_t)a, (fastf_t)b, + (fastf_t)c); + bu_vls_printf(&result, "%g %g {%g %g %g} {%g %g %g}", val1, val2, + V3ARGS(vec1), V3ARGS(vec2)); + } else if (math_func == bn_mat_fromto) { + mat_t o; + vect_t from, to; + + if (argc < 3 || bn_decode_vect(from, argv[1]) < 3 || + bn_decode_vect(to, argv[2]) < 3) { + bu_vls_printf(&result, "usage: %s vecFrom vecTo", argv[0]); + goto error; + } + bn_mat_fromto(o, from, to); + bn_encode_mat(&result, o); + } else if (math_func == bn_mat_xrot || math_func == bn_mat_yrot || + math_func == bn_mat_zrot) { + mat_t o; + double s, c; + if (argc < 3) { + bu_vls_printf(&result, "usage: %s sinAngle cosAngle", argv[0]); + goto error; + } + if (Tcl_GetDouble(interp, argv[1], &s) != TCL_OK) goto error; + if (Tcl_GetDouble(interp, argv[2], &c) != TCL_OK) goto error; + + (*math_func)(o, s, c); + bn_encode_mat(&result, o); + } else if (math_func == bn_mat_lookat) { + mat_t o; + vect_t dir; + int yflip; + if (argc < 3 || bn_decode_vect(dir, argv[1]) < 3) { + bu_vls_printf(&result, "usage: %s dir yflip", argv[0]); + goto error; + } + if (Tcl_GetBoolean(interp, argv[2], &yflip) != TCL_OK) goto error; + + bn_mat_lookat(o, dir, yflip); + bn_encode_mat(&result, o); + } else if (math_func == bn_vec_ortho || math_func == bn_vec_perp) { + vect_t ov, vec; + + if (argc < 2 || bn_decode_vect(vec, argv[1]) < 3) { + bu_vls_printf(&result, "usage: %s vec", argv[0]); + goto error; + } + + (*math_func)(ov, vec); + bn_encode_vect(&result, ov); + } else if (math_func == bn_mat_scale_about_pt_wrapper) { + mat_t o; + vect_t v; + double scale; + int status; + + if (argc < 3 || bn_decode_vect(v, argv[1]) < 3) { + bu_vls_printf(&result, "usage: %s pt scale", argv[0]); + goto error; + } + if (Tcl_GetDouble(interp, argv[2], &scale) != TCL_OK) goto error; + + bn_mat_scale_about_pt_wrapper(&status, o, v, scale); + if (status != 0) { + bu_vls_printf(&result, "error performing calculation"); + goto error; + } + bn_encode_mat(&result, o); + } else if (math_func == bn_mat_xform_about_pt) { + mat_t o, xform; + vect_t v; + + if (argc < 3 || bn_decode_mat(xform, argv[1]) < 16 || + bn_decode_vect(v, argv[2]) < 3) { + bu_vls_printf(&result, "usage: %s xform pt", argv[0]); + goto error; + } + + bn_mat_xform_about_pt(o, xform, v); + bn_encode_mat(&result, o); + } else if (math_func == bn_mat_arb_rot) { + mat_t o; + point_t pt; + vect_t dir; + double angle; + + if (argc < 4 || bn_decode_vect(pt, argv[1]) < 3 || + bn_decode_vect(dir, argv[2]) < 3) { + bu_vls_printf(&result, "usage: %s pt dir angle", argv[0]); + goto error; + } + if (Tcl_GetDouble(interp, argv[3], &angle) != TCL_OK) + return TCL_ERROR; + + bn_mat_arb_rot(o, pt, dir, (fastf_t)angle); + bn_encode_mat(&result, o); + } else if (math_func == quat_mat2quat) { + mat_t mat; + quat_t quat; + + if (argc < 2 || bn_decode_mat(mat, argv[1]) < 16) { + bu_vls_printf(&result, "usage: %s mat", argv[0]); + goto error; + } + + quat_mat2quat(quat, mat); + bn_encode_quat(&result, quat); + } else if (math_func == quat_quat2mat) { + mat_t mat; + quat_t quat; + + if (argc < 2 || bn_decode_quat(quat, argv[1]) < 4) { + bu_vls_printf(&result, "usage: %s quat", argv[0]); + goto error; + } + + quat_quat2mat(mat, quat); + bn_encode_mat(&result, mat); + } else if (math_func == bn_quat_distance_wrapper) { + quat_t q1, q2; + double d; + + if (argc < 3 || bn_decode_quat(q1, argv[1]) < 4 || + bn_decode_quat(q2, argv[2]) < 4) { + bu_vls_printf(&result, "usage: %s quatA quatB", argv[0]); + goto error; + } + + bn_quat_distance_wrapper(&d, q1, q2); + bu_vls_printf(&result, "%g", d); + } else if (math_func == quat_double || math_func == quat_bisect || + math_func == quat_make_nearest) { + quat_t oqot, q1, q2; + + if (argc < 3 || bn_decode_quat(q1, argv[1]) < 4 || + bn_decode_quat(q2, argv[2]) < 4) { + bu_vls_printf(&result, "usage: %s quatA quatB", argv[0]); + goto error; + } + + (*math_func)(oqot, q1, q2); + bn_encode_quat(&result, oqot); + } else if (math_func == quat_slerp) { + quat_t oq, q1, q2; + double d; + + if (argc < 4 || bn_decode_quat(q1, argv[1]) < 4 || + bn_decode_quat(q2, argv[2]) < 4) { + bu_vls_printf(&result, "usage: %s quat1 quat2 factor", argv[0]); + goto error; + } + if (Tcl_GetDouble(interp, argv[3], &d) != TCL_OK) goto error; + + quat_slerp(oq, q1, q2, d); + bn_encode_quat(&result, oq); + } else if (math_func == quat_sberp) { + quat_t oq, q1, qa, qb, q2; + double d; + + if (argc < 6 || bn_decode_quat(q1, argv[1]) < 4 || + bn_decode_quat(qa, argv[2]) < 4 || bn_decode_quat(qb, argv[3]) < 4 || + bn_decode_quat(q2, argv[4]) < 4) { + bu_vls_printf(&result, "usage: %s quat1 quatA quatB quat2 factor", + argv[0]); + goto error; + } + if (Tcl_GetDouble(interp, argv[5], &d) != TCL_OK) goto error; + + quat_sberp(oq, q1, qa, qb, q2, d); + bn_encode_quat(&result, oq); + } else if (math_func == quat_exp || math_func == quat_log) { + quat_t qout, qin; + + if (argc < 2 || bn_decode_quat(qin, argv[1]) < 4) { + bu_vls_printf(&result, "usage: %s quat", argv[0]); + goto error; + } + + (*math_func)(qout, qin); + bn_encode_quat(&result, qout); + } else if (math_func == (void (*)())bn_isect_line3_line3) { + double t, u; + point_t pt, a; + vect_t dir, c; + int i; + static const struct bn_tol tol = { + BN_TOL_MAGIC, 0.005, 0.005*0.005, 1e-6, 1-1e-6 + }; + if (argc != 5) { + bu_vls_printf(&result, + "Usage: bn_isect_line3_line3 pt dir pt dir (%d args specified)", + argc-1); + goto error; + } + + if (bn_decode_vect(pt, argv[1]) < 3) { + bu_vls_printf(&result, "bn_isect_line3_line3 no pt: %s\n", argv[0]); + goto error; + } + if (bn_decode_vect(dir, argv[2]) < 3) { + bu_vls_printf(&result, "bn_isect_line3_line3 no dir: %s\n", argv[0]); + goto error; + } + if (bn_decode_vect(a, argv[3]) < 3) { + bu_vls_printf(&result, "bn_isect_line3_line3 no a pt: %s\n", argv[0]); + goto error; + } + if (bn_decode_vect(c, argv[4]) < 3) { + bu_vls_printf(&result, "bn_isect_line3_line3 no c dir: %s\n", argv[0]); + goto error; + } + i = bn_isect_line3_line3(&t, &u, pt, dir, a, c, &tol); + if (i != 1) { + bu_vls_printf(&result, "bn_isect_line3_line3 no intersection: %s\n", argv[0]); + goto error; + } + + VJOIN1(a, pt, t, dir); + bn_encode_vect(&result, a); + + } else if (math_func == (void (*)())bn_isect_line2_line2) { + double dist[2]; + point_t pt, a; + vect_t dir, c; + int i; + static const struct bn_tol tol = { + BN_TOL_MAGIC, 0.005, 0.005*0.005, 1e-6, 1-1e-6 + }; + + if (argc != 5) { + bu_vls_printf(&result, + "Usage: bn_isect_line2_line2 pt dir pt dir (%d args specified)", + argc-1); + goto error; + } + + /* i = bn_isect_line2_line2 {0 0} {1 0} {1 1} {0 -1} */ + + VSETALL(pt, 0.0); + VSETALL(dir, 0.0); + VSETALL(a, 0.0); + VSETALL(c, 0.0); + + if (bn_decode_vect(pt, argv[1]) < 2) { + bu_vls_printf(&result, "bn_isect_line2_line2 no pt: %s\n", argv[0]); + goto error; + } + if (bn_decode_vect(dir, argv[2]) < 2) { + bu_vls_printf(&result, "bn_isect_line2_line2 no dir: %s\n", argv[0]); + goto error; + } + if (bn_decode_vect(a, argv[3]) < 2) { + bu_vls_printf(&result, "bn_isect_line2_line2 no a pt: %s\n", argv[0]); + goto error; + } + if (bn_decode_vect(c, argv[4]) < 2) { + bu_vls_printf(&result, "bn_isect_line2_line2 no c dir: %s\n", argv[0]); + goto error; + } + i = bn_isect_line2_line2(dist, pt, dir, a, c, &tol); + if (i != 1) { + bu_vls_printf(&result, "bn_isect_line2_line2 no intersection: %s\n", argv[0]); + goto error; + } + + VJOIN1(a, pt, dist[0], dir); + bu_vls_printf(&result, "%g %g", a[0], a[1]); + + } else { + bu_vls_printf(&result, "libbn/bn_tcl.c: math function %s not supported yet\n", argv[0]); + goto error; + } + + Tcl_AppendResult(interp, bu_vls_addr(&result), (char *)NULL); + bu_vls_free(&result); + return TCL_OK; + + error: + Tcl_AppendResult(interp, bu_vls_addr(&result), (char *)NULL); + bu_vls_free(&result); + return TCL_ERROR; +} + +static struct math_func_link { + char *name; + void (*func)(); +} math_funcs[] = { + {"bn_isect_line2_line2", (void (*)())bn_isect_line2_line2}, + {"bn_isect_line3_line3", (void (*)())bn_isect_line3_line3}, + {"mat_mul", bn_mat_mul}, + {"mat_inv", bn_mat_inv}, + {"mat_trn", bn_mat_trn}, + {"matXvec", bn_matXvec}, + {"mat4x3vec", bn_mat4x3vec}, + {"mat4x3pnt", bn_mat4x3pnt}, + {"hdivide", bn_hdivide}, + {"vjoin1", bn_vjoin1}, + {"vblend", bn_vblend}, + {"mat_ae", bn_mat_ae}, + {"mat_ae_vec", bn_ae_vec}, + {"mat_aet_vec", bn_aet_vec}, + {"mat_angles", bn_mat_angles}, + {"mat_eigen2x2", bn_eigen2x2}, + {"mat_fromto", bn_mat_fromto}, + {"mat_xrot", bn_mat_xrot}, + {"mat_yrot", bn_mat_yrot}, + {"mat_zrot", bn_mat_zrot}, + {"mat_lookat", bn_mat_lookat}, + {"mat_vec_ortho", bn_vec_ortho}, + {"mat_vec_perp", bn_vec_perp}, + {"mat_scale_about_pt", bn_mat_scale_about_pt_wrapper}, + {"mat_xform_about_pt", bn_mat_xform_about_pt}, + {"mat_arb_rot", bn_mat_arb_rot}, + {"quat_mat2quat", quat_mat2quat}, + {"quat_quat2mat", quat_quat2mat}, + {"quat_distance", bn_quat_distance_wrapper}, + {"quat_double", quat_double}, + {"quat_bisect", quat_bisect}, + {"quat_slerp", quat_slerp}, + {"quat_sberp", quat_sberp}, + {"quat_make_nearest", quat_make_nearest}, + {"quat_exp", quat_exp}, + {"quat_log", quat_log}, + {0, 0} +}; + +int +bn_cmd_noise_perlin(ClientData clientData, + Tcl_Interp *interp, + int argc, + char **argv) +{ + point_t pt; + double v; + + if (argc != 4) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " X Y Z \"", + NULL); + return TCL_ERROR; + } + + pt[X] = atof(argv[1]); + pt[Y] = atof(argv[2]); + pt[Z] = atof(argv[3]); + + v = bn_noise_perlin( pt ); + Tcl_SetObjResult( interp, Tcl_NewDoubleObj(v) ); + + return TCL_OK; +} + +/* + * usage: bn_noise_fbm X Y Z h_val lacunarity octaves + * + */ +int +bn_cmd_noise(ClientData clientData, + Tcl_Interp *interp, + int argc, + char **argv) +{ + point_t pt; + double h_val; + double lacunarity; + double octaves; + double val; + + if (argc != 7) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " X Y Z h_val lacunarity octaves\"", + NULL); + return TCL_ERROR; + } + + pt[0] = atof(argv[1]); + pt[1] = atof(argv[2]); + pt[2] = atof(argv[3]); + + h_val = atof(argv[4]); + lacunarity = atof(argv[5]); + octaves = atof(argv[6]); + + + if (!strcmp("bn_noise_turb", argv[0])) { + val = bn_noise_turb(pt, h_val, lacunarity, octaves); + + Tcl_SetObjResult( interp, Tcl_NewDoubleObj(val) ); + } else if (!strcmp("bn_noise_fbm", argv[0])) { + val = bn_noise_fbm(pt, h_val, lacunarity, octaves); + Tcl_SetObjResult( interp, Tcl_NewDoubleObj(val) ); + } else { + Tcl_AppendResult(interp, "Unknown noise type \"", + argv[0], "\"", NULL); + return TCL_ERROR; + } + return TCL_OK; +} + + +/** + * @brief + * usage: noise_slice xdim ydim inv h_val lac octaves dX dY dZ sX [sY sZ] + * + * The idea here is to get a whole slice of noise at once, thereby + * avoiding the overhead of doing this in Tcl. + */ +int +bn_cmd_noise_slice(ClientData clientData, + Tcl_Interp *interp, + int argc, + char **argv) +{ + double h_val; + double lacunarity; + double octaves; + + vect_t delta; /* translation to noise space */ + vect_t scale; /* scale to noise space */ + unsigned xdim; /* # samples X direction */ + unsigned ydim; /* # samples Y direction */ + unsigned xval, yval; +#define NOISE_FBM 0 +#define NOISE_TURB 1 + + int noise_type = NOISE_FBM; + double val; + point_t pt; + + if (argc != 7) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " Xdim Ydim Zval h_val lacunarity octaves\"", + NULL); + return TCL_ERROR; + } + + xdim = atoi(argv[0]); + ydim = atoi(argv[1]); + VSETALL(delta, 0.0); + VSETALL(scale, 1.); + pt[Z] = delta[Z] = atof(argv[2]); + h_val = atof(argv[3]); + lacunarity = atof(argv[4]); + octaves = atof(argv[5]); + + switch (noise_type) { + case NOISE_FBM: + for (yval = 0; yval < ydim; yval++) { + + pt[Y] = yval * scale[Y] + delta[Y]; + + for (xval = 0; xval < xdim; xval++) { + pt[X] = xval * scale[X] + delta[X]; + + val = bn_noise_fbm(pt, h_val, lacunarity, octaves); + + } + } + break; + case NOISE_TURB: + for (yval = 0; yval < ydim; yval++) { + + pt[Y] = yval * scale[Y] + delta[Y]; + + for (xval = 0; xval < xdim; xval++) { + pt[X] = xval * scale[X] + delta[X]; + + val = bn_noise_turb(pt, h_val, lacunarity, octaves); + + } + } + break; + } + + + pt[0] = atof(argv[1]); + pt[1] = atof(argv[2]); + pt[2] = atof(argv[3]); + + h_val = atof(argv[4]); + lacunarity = atof(argv[5]); + octaves = atof(argv[6]); + + + if (!strcmp("bn_noise_turb", argv[0])) { + val = bn_noise_turb(pt, h_val, lacunarity, octaves); + Tcl_SetObjResult( interp, Tcl_NewDoubleObj(val) ); + } else if (!strcmp("bn_noise_fbm", argv[0])) { + val = bn_noise_fbm(pt, h_val, lacunarity, octaves); + Tcl_SetObjResult( interp, Tcl_NewDoubleObj(val) ); + } else { + Tcl_AppendResult(interp, "Unknown noise type \"", + argv[0], "\"", NULL); + return TCL_ERROR; + } + return TCL_OK; +} + + +int +bn_cmd_random(ClientData clientData, + Tcl_Interp *interp, + int argc, + char **argv) +{ + int val; + const char *str; + double rnd; + char buf[32]; + + if (argc != 2) { + Tcl_AppendResult(interp, "Wrong # args: Should be \"", + argv[0], " varname\"", NULL); + return TCL_ERROR; + } + + if (! (str=Tcl_GetVar(interp, argv[1], 0))) { + Tcl_AppendResult(interp, "Error getting variable ", + argv[1], NULL); + return TCL_ERROR; + } + val = atoi(str); + + if (val < 0) val = 0; + + rnd = BN_RANDOM(val); + + snprintf(buf, 32, "%d", val); + + if (!Tcl_SetVar(interp, argv[1], buf, 0)) { + Tcl_AppendResult(interp, "Error setting variable ", + argv[1], NULL); + return TCL_ERROR; + } + + snprintf(buf, 32, "%g", rnd); + Tcl_AppendResult(interp, buf, NULL); + return TCL_OK; +} + +/** + * B N _ M A T _ P R I N T + */ +void +bn_tcl_mat_print(Tcl_Interp *interp, + const char *title, + const mat_t m) +{ + char obuf[1024]; /* sprintf may be non-PARALLEL */ + + bn_mat_print_guts(title, m, obuf, 1024); + Tcl_AppendResult(interp, obuf, "\n", (char *)NULL); +} + + +/** + * B N _ T C L _ S E T U P + *@brief + * Add all the supported Tcl interfaces to LIBBN routines to + * the list of commands known by the given interpreter. + */ +void +bn_tcl_setup(Tcl_Interp *interp) +{ + struct math_func_link *mp; + + for (mp = math_funcs; mp->name != NULL; mp++) { + (void)Tcl_CreateCommand(interp, mp->name, + (Tcl_CmdProc *)bn_math_cmd, + (ClientData)mp->func, /* Function-to-Object pointer cast */ + (Tcl_CmdDeleteProc *)NULL); + } + + (void)Tcl_CreateCommand(interp, "bn_noise_perlin", + (Tcl_CmdProc *)bn_cmd_noise_perlin, (ClientData)NULL, + (Tcl_CmdDeleteProc *)NULL); + + (void)Tcl_CreateCommand(interp, "bn_noise_turb", + (Tcl_CmdProc *)bn_cmd_noise, (ClientData)NULL, + (Tcl_CmdDeleteProc *)NULL); + + (void)Tcl_CreateCommand(interp, "bn_noise_fbm", + (Tcl_CmdProc *)bn_cmd_noise, (ClientData)NULL, + (Tcl_CmdDeleteProc *)NULL); + + (void)Tcl_CreateCommand(interp, "bn_noise_slice", + (Tcl_CmdProc *)bn_cmd_noise_slice, (ClientData)NULL, + (Tcl_CmdDeleteProc *)NULL); + + (void)Tcl_CreateCommand(interp, "bn_random", + (Tcl_CmdProc *)bn_cmd_random, (ClientData)NULL, + (Tcl_CmdDeleteProc *)NULL); +} + + +/** + * B N _ I N I T + *@brief + * Allows LIBBN to be dynamically loade to a vanilla tclsh/wish with + * "load /usr/brlcad/lib/libbn.so" + * + * The name of this function is specified by TCL. + */ +int +Bn_Init(Tcl_Interp *interp) +{ + bn_tcl_setup(interp); + return TCL_OK; +} + + +double bn_noise_fbm(point_t point, double h_val, double lacunarity, double octaves); +double bn_noise_turb(point_t point, double h_val, double lacunarity, double octaves); +/** @} */ +/* + * Local Variables: + * mode: C + * tab-width: 8 + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Modified: brlcad/trunk/src/libbu/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libbu/CMakeLists.txt 2009-01-16 00:35:02 UTC (rev 33559) +++ brlcad/trunk/src/libbu/CMakeLists.txt 2009-01-16 06:37:23 UTC (rev 33560) @@ -7,7 +7,6 @@ bitv.c bomb.c brlcad_path.c - bu_tcl.c cmd.c cmdhist.c cmdhist_obj.c @@ -59,6 +58,7 @@ semaphore.c stat.c str.c + tcl.c temp.c units.c vers.c Modified: brlcad/trunk/src/libbu/Makefile.am =================================================================== --- brlcad/trunk/src/libbu/Makefile.am 2009-01-16 00:35:02 UTC (rev 33559) +++ brlcad/trunk/src/libbu/Makefile.am 2009-01-16 06:37:23 UTC (rev 33560) @@ -13,7 +13,6 @@ bitv.c \ bomb.c \ brlcad_path.c \ - bu_tcl.c \ cmd.c \ cmdhist.c \ cmdhist_obj.c \ @@ -65,6 +64,7 @@ semaphore.c \ stat.c \ str.c \ + tcl.c \ temp.c \ units.c \ vers.c \ Deleted: brlcad/trunk/src/libbu/bu_tcl.c =================================================================== --- brlcad/trunk/src/libbu/bu_tcl.c 2009-01-16 00:35:02 UTC (rev 33559) +++ brlcad/trunk/src/libbu/bu_tcl.c 2009-01-16 06:37:23 UTC (rev 33560) @@ -1,1483 +0,0 @@ -/* B U _ T C L . C - * BRL-CAD - * - * Copyright (c) 1998-2009 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ -/** @addtogroup butcl */ -/** @{ */ -/** @file bu_tcl.c - * - * Tcl interfaces to all the LIBBU Basic BRL-CAD Utility routines. - * - * Remember that in MGED you need to say "set glob_compat_mode 0" to - * get [] to work with TCL semantics rather than MGED glob semantics. - * - */ - -#include "common.h" - -#include <stdlib.h> -#include <math.h> -#include <string.h> -#include <ctype.h> -#include "bio.h" - -#include "tcl.h" -#include "cmd.h" /* this includes bu.h */ -#include "bu.h" - -/*XXX Temporary global interp */ -Tcl_Interp *brlcad_interp = (Tcl_Interp *)0; - -#define TINYBUFSIZ 32 -#define SMALLBUFSIZ 256 - -/* defined in libbu/cmdhist_obj.c */ -extern int Cho_Init(Tcl_Interp *interp); - -static struct bu_cmdtab bu_cmds[] = { - {"bu_units_conversion", bu_tcl_units_conversion}, - {"bu_brlcad_data", bu_tcl_brlcad_data}, - {"bu_brlcad_root", bu_tcl_brlcad_root}, - {"bu_mem_barriercheck", bu_tcl_mem_barriercheck}, - {"bu_ck_malloc_ptr", bu_tcl_ck_malloc_ptr}, - {"bu_malloc_len_roundup", bu_tcl_malloc_len_roundup}, - {"bu_prmem", bu_tcl_prmem}, - {"bu_printb", bu_tcl_printb}, - {"bu_get_all_keyword_values", bu_tcl_get_all_keyword_values}, - {"bu_get_value_by_keyword", bu_tcl_get_value_by_keyword}, - {"bu_rgb_to_hsv", bu_tcl_rgb_to_hsv}, - {"bu_hsv_to_rgb", bu_tcl_hsv_to_rgb}, - {"bu_key_eq_to_key_val", bu_tcl_key_eq_to_key_val}, - {"bu_shader_to_tcl_list", bu_tcl_shader_to_key_val}, - {"bu_key_val_to_key_eq", bu_tcl_key_val_to_key_eq}, - {"bu_shader_to_key_eq", bu_tcl_shader_to_key_eq}, - {(char *)NULL, NULL } -}; - - -/** - * b u _ b a d m a g i c _ t c l - * - * Support routine for BU_CKMAG_TCL macro. As used by BU_CKMAG_TCL, - * this routine is not called unless there is trouble with the - * pointer. When called, an appropriate message is added to interp - * indicating the problem. - * - * @param interp - tcl interpreter where result is stored - * @param ptr - pointer to a data structure - * @param magic - the correct/desired magic number - * @param str - usually indicates the data structure name - * @param file - file where this routine was called - * @param line - line number in the above file - * - * @return - * void - */ -void -bu_badmagic_tcl(Tcl_Interp *interp, - const unsigned long *ptr, - unsigned long magic, - const char *str, - const char *file, - int line) -{ - char buf[SMALLBUFSIZ]; - - if (!(ptr)) { - snprintf(buf, SMALLBUFSIZ, "ERROR: NULL %s pointer in TCL interface, file %s, line %d\n", - str, file, line); - Tcl_AppendResult(interp, buf, NULL); - return; - } - if (*((unsigned long *)(ptr)) != (magic)) { - snprintf(buf, SMALLBUFSIZ, "ERROR: bad pointer in TCL interface x%lx: s/b %s(x%lx), was %s(x%lx), file %s, line %d\n", - (unsigned long)ptr, - str, magic, - bu_identify_magic((unsigned long)*(ptr)), *(ptr), - file, line); - Tcl_AppendResult(interp, buf, NULL); - return; - } - Tcl_AppendResult(interp, "bu_badmagic_tcl() mysterious error condition, ", str, " pointer, ", file, "\n", NULL); -} - - -/** - * b u _ t c l _ s t r u c t p a r s e _ g e t _ t e r s e _ f o r m - * - * Convert the "form" of a bu_structparse table into a TCL result string, - * with parameter-name data-type pairs: - * - * V {%f %f %f} A {%f %f %f} - * - * A different routine should build a more general 'form', along the - * lines of {V {%f %f %f} default {help}} {A {%f %f %f} default# {help}} - * - * @param interp - tcl interpreter - * @param sp - structparse table - * - * @return - * void - */ -void -bu_tcl_structparse_get_terse_form(Tcl_Interp *interp, - const struct bu_structparse *sp) -{ -#if 1 - struct bu_vls log; - - bu_vls_init(&log); - bu_structparse_get_terse_form(&log, sp); - Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)NULL); - bu_vls_free(&log); -#else - struct bu_vls str; - int i; - - bu_vls_init(&str); - - while (sp->sp_name != NULL) { - Tcl_AppendElement(interp, sp->sp_name); - bu_vls_trunc(&str, 0); - /* These types are specified by lengths, e.g. %80s */ - if (strcmp(sp->sp_fmt, "%c") == 0 || - strcmp(sp->sp_fmt, "%s") == 0 || - strcmp(sp->sp_fmt, "%S") == 0 || /* XXX - DEPRECATED [7.14] */ - strcmp(sp->sp_fmt, "%V") == 0) { - if (sp->sp_count > 1) { - /* Make them all look like %###s */ - bu_vls_printf(&str, "%%%lds", sp->sp_count); - } else { - /* Singletons are specified by their actual character */ - bu_vls_printf(&str, "%%c"); - } - } else { - /* Vectors are specified by repetition, e.g. {%f %f %f} */ - bu_vls_printf(&str, "%s", sp->sp_fmt); - for (i = 1; i < sp->sp_count; i++) - bu_vls_printf(&str, " %s", sp->sp_fmt); - } - Tcl_AppendElement(interp, bu_vls_addr(&str)); - ++sp; - } - bu_vls_free(&str); -#endif -} - -#if 0 -/** - * b u _ s p _ s k i p _ s e p - * - * Skip the separator(s) (i.e. whitespace and open-braces) - * - * @param _cp - character pointer - */ -#define BU_SP_SKIP_SEP(_cp) \ - { while (*(_cp) && (*(_cp) == ' ' || *(_cp) == '\n' || \ - *(_cp) == '\t' || *(_cp) == '{')) ++(_cp); ... [truncated message content] |
From: <bo...@us...> - 2009-02-03 21:06:31
|
Revision: 33649 http://brlcad.svn.sourceforge.net/brlcad/?rev=33649&view=rev Author: bob1961 Date: 2009-02-03 21:06:17 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Tweak the usage message and the message complaining about the missing density data. Modified Paths: -------------- brlcad/trunk/src/gtools/g_qa.c brlcad/trunk/src/libged/gqa.c Modified: brlcad/trunk/src/gtools/g_qa.c =================================================================== --- brlcad/trunk/src/gtools/g_qa.c 2009-02-03 20:38:14 UTC (rev 33648) +++ brlcad/trunk/src/gtools/g_qa.c 2009-02-03 21:06:17 UTC (rev 33649) @@ -36,7 +36,7 @@ #include "cmd.h" #include "ged.h" -static char usage[] = "Usage: %s [options] model object [object...]\n"; +static char usage[] = "Usage: %s [-A A|a|b|e|g|o|v|w] [-a az] [-d] [-e el] [-f densityFile] [-g spacing|upper,lower|upper-lower] [-G] [-n nhits] [-N nviews] [-p] [-P ncpus] [-r] [-S nsamples] [-t overlap_tol] [-U useair] [-u len_units vol_units wt_units] [-v] [-V volume_tol] [-W weight_tol] model object [object...]\n"; /* * M A I N Modified: brlcad/trunk/src/libged/gqa.c =================================================================== --- brlcad/trunk/src/libged/gqa.c 2009-02-03 20:38:14 UTC (rev 33648) +++ brlcad/trunk/src/libged/gqa.c 2009-02-03 21:06:17 UTC (rev 33649) @@ -56,6 +56,7 @@ /* bu_getopt() options */ char *options = "A:a:de:f:g:Gn:N:pP:rS:s:t:U:u:vV:W:"; +char *options_str = "[-A A|a|b|e|g|o|v|w] [-a az] [-d] [-e el] [-f densityFile] [-g spacing|upper,lower|upper-lower] [-G] [-n nhits] [-N nviews] [-p] [-P ncpus] [-r] [-S nsamples] [-t overlap_tol] [-U useair] [-u len_units vol_units wt_units] [-v] [-V volume_tol] [-W weight_tol]"; #define ANALYSIS_VOLUME 1 #define ANALYSIS_WEIGHT 2 @@ -813,7 +814,8 @@ dp = db_lookup(rtip->rti_dbip, "_DENSITIES", LOOKUP_QUIET); if (dp == (struct directory *)NULL) { - bu_vls_printf(&ged_current_gedp->ged_result_str, "No \"_DENSITIES\" density table object in database\n"); + bu_vls_printf(&ged_current_gedp->ged_result_str, "No \"_DENSITIES\" density table object in database."); + bu_vls_printf(&ged_current_gedp->ged_result_str, " If you do not have density data you can still get adjacent air, bounding box, exposed air, gaps, volume or overlaps by using the -Aa, -Ab, -Ae, -Ag, -Av or -Ao options, respectively.\n"); return BRLCAD_ERROR; } @@ -2069,7 +2071,7 @@ struct cstate state; int start_objs; /* index in command line args where geom object list starts */ struct region_pair *rp; - static const char *usage = "[options] object [object ...]"; + static const char *usage = "object [object ...]"; GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); GED_CHECK_ARGC_GT_0(gedp, argc, BRLCAD_ERROR); @@ -2079,7 +2081,7 @@ /* must be wanting help */ if (argc == 1) { - bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s %s", argv[0], options_str, usage); return BRLCAD_HELP; } @@ -2119,7 +2121,7 @@ arg_count = parse_args(argc, (char **)argv); if (arg_count < 0 || (argc-arg_count) < 1) { - bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s %s", argv[0], options_str, usage); return BRLCAD_ERROR; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-02-14 07:34:44
|
Revision: 33774 http://brlcad.svn.sourceforge.net/brlcad/?rev=33774&view=rev Author: brlcad Date: 2009-02-14 07:34:35 +0000 (Sat, 14 Feb 2009) Log Message: ----------- fix some of the initialization and shutdown problems including the qray vls one. the problem was a set of pointers in the gedp that were getting freed/closed but weren't being set to null so the second use of that gedp erroneously would try to use the old pointer (and crash). Modified Paths: -------------- brlcad/trunk/src/libged/ged.c brlcad/trunk/src/libged/qray.c brlcad/trunk/src/mged/mged.c Modified: brlcad/trunk/src/libged/ged.c =================================================================== --- brlcad/trunk/src/libged/ged.c 2009-02-14 07:05:42 UTC (rev 33773) +++ brlcad/trunk/src/libged/ged.c 2009-02-14 07:34:35 UTC (rev 33774) @@ -58,7 +58,11 @@ return; wdb_close(gedp->ged_wdbp); + gedp->ged_wdbp = RT_WDB_NULL; + ged_drawable_close(gedp->ged_gdp); + gedp->ged_gdp = GED_DRAWABLE_NULL; + ged_free(gedp); } Modified: brlcad/trunk/src/libged/qray.c =================================================================== --- brlcad/trunk/src/libged/qray.c 2009-02-14 07:05:42 UTC (rev 33773) +++ brlcad/trunk/src/libged/qray.c 2009-02-14 07:34:35 UTC (rev 33774) @@ -437,7 +437,7 @@ for (qfdp = def_qray_fmt_data; qfdp->fmt != (char *)NULL; ++qfdp) ++n; - gdp->gd_qray_fmts = (struct ged_qray_fmt *)bu_malloc(sizeof(struct ged_qray_fmt) * n + 1, "qray_fmts"); + gdp->gd_qray_fmts = (struct ged_qray_fmt *)bu_calloc(n+1, sizeof(struct ged_qray_fmt), "qray_fmts"); for (i = 0; i < n; ++i) { gdp->gd_qray_fmts[i].type = def_qray_fmt_data[i].type; Modified: brlcad/trunk/src/mged/mged.c =================================================================== --- brlcad/trunk/src/mged/mged.c 2009-02-14 07:05:42 UTC (rev 33773) +++ brlcad/trunk/src/mged/mged.c 2009-02-14 07:34:35 UTC (rev 33774) @@ -2234,8 +2234,10 @@ db_close(dbip); #endif - if (gedp->ged_gdp) + if (gedp->ged_gdp) { ged_drawable_close(gedp->ged_gdp); + gedp->ged_gdp = GED_DRAWABLE_NULL; + } ged_free(gedp); gedp = GED_NULL; @@ -2830,6 +2832,8 @@ #endif ged_drawable_close(gedp->ged_gdp); + gedp->ged_gdp = NULL; + gedp->ged_wdbp = RT_WDB_NULL; /* wipe out the global pointers */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-02-20 19:14:42
|
Revision: 33850 http://brlcad.svn.sourceforge.net/brlcad/?rev=33850&view=rev Author: bob1961 Date: 2009-02-20 19:14:27 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Added a -Ap option to libged's ged_gqa function for creating psuedo-solid wireframe of overlaps. Added a cmd_ged_gqa wrapper to MGED for using the currently displayed objects if no objects were specified on the command line. Modified Paths: -------------- brlcad/trunk/src/libged/gqa.c brlcad/trunk/src/mged/cmd.c brlcad/trunk/src/mged/cmd.h brlcad/trunk/src/mged/setup.c Modified: brlcad/trunk/src/libged/gqa.c =================================================================== --- brlcad/trunk/src/libged/gqa.c 2009-02-20 19:10:11 UTC (rev 33849) +++ brlcad/trunk/src/libged/gqa.c 2009-02-20 19:14:27 UTC (rev 33850) @@ -56,7 +56,7 @@ /* bu_getopt() options */ char *options = "A:a:de:f:g:Gn:N:pP:rS:s:t:U:u:vV:W:"; -char *options_str = "[-A A|a|b|c|e|g|m|o|v|w] [-a az] [-d] [-e el] [-f densityFile] [-g spacing|upper,lower|upper-lower] [-G] [-n nhits] [-N nviews] [-p] [-P ncpus] [-r] [-S nsamples] [-t overlap_tol] [-U useair] [-u len_units vol_units wt_units] [-v] [-V volume_tol] [-W weight_tol]"; +char *options_str = "[-A A|a|b|c|e|g|m|o|p|v|w] [-a az] [-d] [-e el] [-f densityFile] [-g spacing|upper,lower|upper-lower] [-G] [-n nhits] [-N nviews] [-p] [-P ncpus] [-r] [-S nsamples] [-t overlap_tol] [-U useair] [-u len_units vol_units wt_units] [-v] [-V volume_tol] [-W weight_tol]"; #define ANALYSIS_VOLUME 1 #define ANALYSIS_WEIGHT 2 @@ -68,6 +68,7 @@ #define ANALYSIS_INTERFACES 128 #define ANALYSIS_CENTROIDS 256 #define ANALYSIS_MOMENTS 512 +#define ANALYSIS_PLOT_OVERLAPS 1024 #ifndef HUGE # ifdef MAXFLT @@ -162,6 +163,11 @@ fastf_t *m_poi; /* one vector per view for collecting the partial products of inertia calculation */ }; +struct ged_gqa_plot { + struct bn_vlblock *vbp; + struct bu_list *vhead; +} ged_gqa_plot; + /* the entries in the density table */ struct density_entry { long magic; @@ -525,6 +531,13 @@ analysis_flags |= ANALYSIS_OVERLAPS; break; + case 'p' : + if (analysis_flags) + multiple_analyses = 1; + + analysis_flags |= ANALYSIS_OVERLAPS; + analysis_flags |= ANALYSIS_PLOT_OVERLAPS; + break; case 'v' : if (analysis_flags) multiple_analyses = 1; @@ -971,6 +984,13 @@ bu_semaphore_release(BU_SEM_SYSCALL); } + if (analysis_flags & ANALYSIS_PLOT_OVERLAPS) { + bu_semaphore_acquire(GED_SEM_WORKER); + BN_ADD_VLIST(ged_gqa_plot.vbp->free_vlist_hd, ged_gqa_plot.vhead, ihit, BN_VLIST_LINE_MOVE); + BN_ADD_VLIST(ged_gqa_plot.vbp->free_vlist_hd, ged_gqa_plot.vhead, ohit, BN_VLIST_LINE_DRAW); + bu_semaphore_release(GED_SEM_WORKER); + } + if (analysis_flags & ANALYSIS_OVERLAPS) { #if 0 struct region_pair *rp = @@ -2425,6 +2445,11 @@ bu_semaphore_reinit(GED_SEM_LAST); + if (analysis_flags & ANALYSIS_PLOT_OVERLAPS) { + ged_gqa_plot.vbp = rt_vlblock_init(); + ged_gqa_plot.vhead = rt_vlblock_find(ged_gqa_plot.vbp, 0xFF, 0xFF, 0x00); + } + rtip = rt_new_rti(gedp->ged_wdbp->dbip); rtip->useair = use_air; @@ -2561,11 +2586,17 @@ if (verbose) bu_vls_printf(&gedp->ged_result_str, "Computation Done\n"); - if (!aborted) + if (!aborted) { summary_reports(&state, start_objs, argc, argv); - else + + if (analysis_flags & ANALYSIS_PLOT_OVERLAPS) + ged_cvt_vlblock_to_solids(gedp, ged_gqa_plot.vbp, "OVERLAPS", 0); + } else aborted = 0; /* reset flag */ + if (analysis_flags & ANALYSIS_PLOT_OVERLAPS) + rt_vlblock_free(ged_gqa_plot.vbp); + /* Clear out the lists */ while (BU_LIST_WHILE(rp, region_pair, &overlapList.l)) { BU_LIST_DEQUEUE(&rp->l); Modified: brlcad/trunk/src/mged/cmd.c =================================================================== --- brlcad/trunk/src/mged/cmd.c 2009-02-20 19:10:11 UTC (rev 33849) +++ brlcad/trunk/src/mged/cmd.c 2009-02-20 19:14:27 UTC (rev 33850) @@ -217,6 +217,72 @@ } int +cmd_ged_gqa(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]) +{ + register char **vp; + register int i; + int ret; + Tcl_DString ds; + struct cmdtab *ctp = (struct cmdtab *)clientData; + + if (gedp == GED_NULL) + return TCL_OK; + + vp = &gedp->ged_gdp->gd_rt_cmd[0]; + + /* Grab command name and any options */ + *vp++ = argv[0]; + for (i=1; i < argc; i++) { + if (argv[i][0] != '-') + break; + + if (argv[i][0] == '-' && + argv[i][1] == '-' && + argv[i][2] == '\0') { + ++i; + break; + } + + *vp++ = (char *)argv[i]; + } + + /* + * Append remaining args, if any. Otherwise, append currently displayed objects. + */ + if (i < argc) { + while (i < argc) + *vp++ = (char *)argv[i++]; + gedp->ged_gdp->gd_rt_cmd_len = vp - gedp->ged_gdp->gd_rt_cmd; + *vp = 0; + vp = &gedp->ged_gdp->gd_rt_cmd[0]; + while (*vp) + bu_vls_printf(&gedp->ged_result_str, "%s ", *vp++); + + bu_vls_printf(&gedp->ged_result_str, "\n"); + } else { + gedp->ged_gdp->gd_rt_cmd_len = vp - gedp->ged_gdp->gd_rt_cmd; + gedp->ged_gdp->gd_rt_cmd_len += ged_build_tops(gedp, + vp, + &gedp->ged_gdp->gd_rt_cmd[MAXARGS]); + } + + ret = (*ctp->ged_func)(gedp, gedp->ged_gdp->gd_rt_cmd_len, gedp->ged_gdp->gd_rt_cmd); + Tcl_DStringInit(&ds); + Tcl_DStringAppend(&ds, bu_vls_addr(&gedp->ged_result_str), -1); + Tcl_DStringResult(interp, &ds); + + if (ret == BRLCAD_HELP) + return TCL_OK; + + if (ret != BRLCAD_OK) + return TCL_ERROR; + + update_views = 1; + + return TCL_OK; +} + +int cmd_ged_in(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]) { int ret; Modified: brlcad/trunk/src/mged/cmd.h =================================================================== --- brlcad/trunk/src/mged/cmd.h 2009-02-20 19:10:11 UTC (rev 33849) +++ brlcad/trunk/src/mged/cmd.h 2009-02-20 19:14:27 UTC (rev 33850) @@ -42,6 +42,7 @@ BU_EXTERN(int cmd_ged_edit_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); BU_EXTERN(int cmd_ged_erase_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); +BU_EXTERN(int cmd_ged_gqa, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); BU_EXTERN(int cmd_ged_in, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); BU_EXTERN(int cmd_ged_more_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); BU_EXTERN(int cmd_ged_plain_wrapper, (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])); Modified: brlcad/trunk/src/mged/setup.c =================================================================== --- brlcad/trunk/src/mged/setup.c 2009-02-20 19:10:11 UTC (rev 33849) +++ brlcad/trunk/src/mged/setup.c 2009-02-20 19:14:27 UTC (rev 33850) @@ -151,7 +151,7 @@ {"get_sed", f_get_sedit, GED_FUNC_PTR_NULL}, {"get_sed_menus", f_get_sedit_menus, GED_FUNC_PTR_NULL}, {"get_solid_keypoint", f_get_solid_keypoint, GED_FUNC_PTR_NULL}, - {"gqa", cmd_ged_plain_wrapper, ged_gqa}, + {"gqa", cmd_ged_gqa, ged_gqa}, {"grid2model_lu", cmd_ged_plain_wrapper, ged_grid2model_lu}, {"grid2view_lu", cmd_ged_plain_wrapper, ged_grid2view_lu}, #ifdef HIDELINE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-02-27 19:31:15
|
Revision: 33914 http://brlcad.svn.sourceforge.net/brlcad/?rev=33914&view=rev Author: bob1961 Date: 2009-02-27 19:30:55 +0000 (Fri, 27 Feb 2009) Log Message: ----------- Update CAD_VERSION. Modified Paths: -------------- brlcad/trunk/src/archer/archer.bat brlcad/trunk/src/mged/mged.bat brlcad/trunk/src/util/rtwizard.bat Modified: brlcad/trunk/src/archer/archer.bat =================================================================== --- brlcad/trunk/src/archer/archer.bat 2009-02-27 18:58:51 UTC (rev 33913) +++ brlcad/trunk/src/archer/archer.bat 2009-02-27 19:30:55 UTC (rev 33914) @@ -24,7 +24,7 @@ REM Company: Survice Engineering SETLOCAL -SET CAD_VERSION=7.13.0 +SET CAD_VERSION=7.14.3 SET SAVE_CD=%CD% SET PATH=%~dp0 SET ARCHER=%~dp0archer Modified: brlcad/trunk/src/mged/mged.bat =================================================================== --- brlcad/trunk/src/mged/mged.bat 2009-02-27 18:58:51 UTC (rev 33913) +++ brlcad/trunk/src/mged/mged.bat 2009-02-27 19:30:55 UTC (rev 33914) @@ -24,7 +24,7 @@ REM Company: Survice Engineering SETLOCAL -SET CAD_VERSION=7.13.0 +SET CAD_VERSION=7.14.3 SET SAVE_CD=%CD% SET PATH=%~dp0 CD %PATH%\.. Modified: brlcad/trunk/src/util/rtwizard.bat =================================================================== --- brlcad/trunk/src/util/rtwizard.bat 2009-02-27 18:58:51 UTC (rev 33913) +++ brlcad/trunk/src/util/rtwizard.bat 2009-02-27 19:30:55 UTC (rev 33914) @@ -24,7 +24,7 @@ REM Company: Survice Engineering SETLOCAL -SET CAD_VERSION=7.13.0 +SET CAD_VERSION=7.14.3 SET SAVE_CD=%CD% SET PATH=%~dp0 CD %PATH%\.. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2009-02-27 23:49:11
|
Revision: 33919 http://brlcad.svn.sourceforge.net/brlcad/?rev=33919&view=rev Author: starseeker Date: 2009-02-27 23:49:10 +0000 (Fri, 27 Feb 2009) Log Message: ----------- Move coil into shapes Modified Paths: -------------- brlcad/trunk/src/proc-db/Makefile.am brlcad/trunk/src/shapes/Makefile.am Added Paths: ----------- brlcad/trunk/src/shapes/coil.c Removed Paths: ------------- brlcad/trunk/src/proc-db/coil.c Modified: brlcad/trunk/src/proc-db/Makefile.am =================================================================== --- brlcad/trunk/src/proc-db/Makefile.am 2009-02-27 23:48:53 UTC (rev 33918) +++ brlcad/trunk/src/proc-db/Makefile.am 2009-02-27 23:49:10 UTC (rev 33919) @@ -29,7 +29,6 @@ sketch \ sphflake \ spltest \ - coil \ tea \ tea_nmg \ terrain \ @@ -79,7 +78,6 @@ sketch_SOURCES = sketch.c sphflake_SOURCES = sphflake.c spltest_SOURCES = spltest.c -coil_SOURCES = coil.c tea_SOURCES = tea.c tea_nmg_SOURCES = tea_nmg.c terrain_SOURCES = terrain.c @@ -125,7 +123,6 @@ $(sketch_OBJECTS) \ $(sphflake_OBJECTS) \ $(spltest_OBJECTS) \ - $(coil_OBJECTS) \ $(tea_OBJECTS) \ $(tea_nmg_OBJECTS) \ $(terrain_OBJECTS) \ Deleted: brlcad/trunk/src/proc-db/coil.c =================================================================== --- brlcad/trunk/src/proc-db/coil.c 2009-02-27 23:48:53 UTC (rev 33918) +++ brlcad/trunk/src/proc-db/coil.c 2009-02-27 23:49:10 UTC (rev 33919) @@ -1,505 +0,0 @@ -/* C O I L . C - * BRL-CAD - * - * Copyright (c) 2009 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ - -/** @file coil.c - * - * Coil Generator - * - * Program to create coils using the pipe primitive. - * - */ - -#include "common.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include "bu.h" -#include "vmath.h" -#include "bn.h" -#include "raytrace.h" -#include "wdb.h" - - -#define D2R(x) (x * DEG2RAD) -#define DEFAULT_COIL_FILENAME "coil.g" - -struct coil_data_t { - struct bu_list l; - int nt; /*Number of Turns*/ - fastf_t od; /*Outer Diameter*/ - fastf_t wd; /*Wire Diameter*/ - fastf_t ha; /*Helix Angle*/ - fastf_t p; /*Pitch*/ -}; - -fastf_t cap_squared(struct rt_wdb *file, struct bu_list *head, char *prefix, struct wmember *coil_subtractions, fastf_t mean_outer_diameter, fastf_t wire_diameter, fastf_t helix_angle, fastf_t pitch, fastf_t starting_pitch, int is_start, int *need_subtraction) -{ - fastf_t pipe_bend, coil_radius; - point_t pnt1, pnt2, pnt4, pnt6, pnt8; - - coil_radius = mean_outer_diameter/2 - wire_diameter/2; - pipe_bend = coil_radius; - - *need_subtraction += 0; - - if (is_start == 1) { - VSET(pnt1, 0, -coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt2, coil_radius , -coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt4, coil_radius , coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt6, -coil_radius , coil_radius, pitch/2+starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt8, -coil_radius , -coil_radius, pitch+starting_pitch - sin(D2R(helix_angle))*coil_radius); - mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); - return pitch + starting_pitch; - } else { - VSET(pnt2, coil_radius, -coil_radius, starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt4, coil_radius , coil_radius, pitch/2 + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt6, -coil_radius , coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt8, -coil_radius , -coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt1, 0 , -coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); - mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); - return pitch + starting_pitch; - } - - return 0; -} - -fastf_t cap_squared_ground(struct rt_wdb *file, struct bu_list *head, char *prefix, struct wmember *coil_subtractions, fastf_t mean_outer_diameter, fastf_t wire_diameter, fastf_t helix_angle, fastf_t pitch, fastf_t starting_pitch, int is_start, int *need_subtraction) -{ - fastf_t pipe_bend, coil_radius; - point_t origin, height, pnt1, pnt2, pnt4, pnt6, pnt8, pnt10; - struct bu_vls str; - - bu_vls_init(&str); - - coil_radius = mean_outer_diameter/2 - wire_diameter/2; - pipe_bend = coil_radius; - - *need_subtraction += 1; - - if (is_start == 1) { - VSET(pnt1, -coil_radius, 0, starting_pitch - sin(D2R(helix_angle))*coil_radius - pitch/4); - VSET(pnt10, -coil_radius, -coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt2, coil_radius , -coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt4, coil_radius , coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt6, -coil_radius , coil_radius, pitch/2+starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt8, -coil_radius , -coil_radius, pitch+starting_pitch - sin(D2R(helix_angle))*coil_radius); - mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt10, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); - VSET(origin, 0, 0, starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(height, 0, 0, -wire_diameter); - bu_vls_trunc(&str, 0); - bu_vls_printf(&str, "%s-startcap.s", prefix); - mk_rcc(file, bu_vls_addr(&str), origin, height, coil_radius+wire_diameter+.1*wire_diameter); - (void)mk_addmember(bu_vls_addr(&str), &(*coil_subtractions).l, NULL, WMOP_UNION); - bu_vls_free(&str); - return pitch + starting_pitch; - } else { - VSET(pnt2, coil_radius, -coil_radius, starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt4, coil_radius , coil_radius, pitch/2 + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt6, -coil_radius , coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt8, -coil_radius , -coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt10, coil_radius , -coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt1, coil_radius , 0, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius + pitch/4); - mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt10, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); - VSET(origin, 0, 0, starting_pitch + pitch + sin(D2R(helix_angle))*coil_radius); - VSET(height, 0, 0, wire_diameter); - bu_vls_trunc(&str, 0); - bu_vls_printf(&str, "%s-endcap.s", prefix); - mk_rcc(file, bu_vls_addr(&str), origin, height, coil_radius+wire_diameter+.1*wire_diameter); - (void)mk_addmember(bu_vls_addr(&str), &(*coil_subtractions).l, NULL, WMOP_UNION); - bu_vls_free(&str); - return pitch + starting_pitch; - } - bu_vls_free(&str); - return 0; -} - -fastf_t cap_ground(struct rt_wdb *file, struct bu_list *head, char *prefix, struct wmember *coil_subtractions, fastf_t mean_outer_diameter, fastf_t wire_diameter, fastf_t helix_angle, fastf_t pitch, fastf_t starting_pitch, int is_start, int *need_subtraction) -{ - fastf_t coil_radius, pipe_bend; - point_t origin, height, pnt1, pnt2, pnt4, pnt6, pnt8; - - coil_radius = mean_outer_diameter/2 - wire_diameter/2; - pipe_bend = coil_radius; - - struct bu_vls str; - bu_vls_init(&str); - - *need_subtraction += 1; - - if (is_start == 1) { - VSET(pnt1, 0, -coil_radius, starting_pitch); - VSET(pnt2, coil_radius , -coil_radius, pitch/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt4, coil_radius , coil_radius, pitch*3/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt6, -coil_radius , coil_radius, pitch*5/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt8, -coil_radius , -coil_radius, pitch*7/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); - mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); - VSET(origin, 0, 0, starting_pitch); - VSET(height, 0, 0, -wire_diameter - sin(D2R(helix_angle))*coil_radius); - bu_vls_trunc(&str, 0); - bu_vls_printf(&str, "%s-startcap.s", prefix); - mk_rcc(file, bu_vls_addr(&str), origin, height, coil_radius+wire_diameter+.1*wire_diameter); - (void)mk_addmember(bu_vls_addr(&str), &(*coil_subtractions).l, NULL, WMOP_UNION); - bu_vls_free(&str); - return pitch + starting_pitch; - } else { - VSET(pnt2, coil_radius , -coil_radius, pitch/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt4, coil_radius , coil_radius, pitch*3/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt6, -coil_radius , coil_radius, pitch*5/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt8, -coil_radius , -coil_radius, pitch*7/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt1, 0 , -coil_radius, pitch+starting_pitch); - mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); - VSET(origin, 0, 0, starting_pitch + pitch); - VSET(height, 0, 0, wire_diameter + sin(D2R(helix_angle))*coil_radius); - bu_vls_trunc(&str, 0); - bu_vls_printf(&str, "%s-endcap.s", prefix); - mk_rcc(file, bu_vls_addr(&str), origin, height, coil_radius+wire_diameter+.1*wire_diameter); - (void)mk_addmember(bu_vls_addr(&str), &(*coil_subtractions).l, NULL, WMOP_UNION); - bu_vls_free(&str); - return pitch+starting_pitch; - } - bu_vls_free(&str); - return 0; -} - - - -fastf_t helical_coil_plain(struct bu_list *head, struct wmember *coil, fastf_t mean_outer_diameter, fastf_t wire_diameter, fastf_t helix_angle, fastf_t pitch, fastf_t starting_pitch, int nt) -{ - int i; - fastf_t coil_radius, pipe_bend; - point_t pnt1, pnt2, pnt4, pnt6, pnt8; - - coil_radius = mean_outer_diameter/2 - wire_diameter/2; - pipe_bend = coil_radius; - - for (i = 0; i < nt; i++) { - VSET(pnt2, coil_radius , -coil_radius, i*pitch + pitch/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt4, coil_radius , coil_radius, i*pitch + pitch*3/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); - VSET(pnt6, -coil_radius , coil_radius, i*pitch + pitch*5/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); - VSET(pnt8, -coil_radius , -coil_radius, i*pitch + pitch*7/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); - mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); - mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); - } - - return (nt-1)*pitch + pitch*7/8 + starting_pitch; - -} - -void make_coil(struct rt_wdb (*file), char *prefix, struct bu_list *sections, int start_cap_type, int end_cap_type) -{ - struct bu_list head; - mk_pipe_init(&head); - fastf_t last_pitch_pt; - point_t pnt1; - int need_subtractions = 0; - struct wmember coil; - BU_LIST_INIT(&coil.l); - struct wmember coil_subtractions; - BU_LIST_INIT(&coil_subtractions.l); - - struct coil_data_t *s_data; - struct coil_data_t *e_data; - struct coil_data_t *cd; - - s_data = BU_LIST_FIRST(coil_data_t,&(*sections)); - e_data = BU_LIST_LAST(coil_data_t,&(*sections)); - - struct bu_vls str; - bu_vls_init(&str); - - last_pitch_pt = 0; - - switch (start_cap_type) { - case 0: - VSET(pnt1, 0, -1*(s_data->od/2-s_data->wd/2), last_pitch_pt); - mk_add_pipe_pt(&head, pnt1, s_data->wd, 0.0, (s_data->od/2-s_data->wd/2)); - break; - case 1: - last_pitch_pt = cap_squared(file, &head, prefix, &coil_subtractions, s_data->od, s_data->wd, s_data->ha, s_data->p, 0, 1, &need_subtractions); - break; - case 2: - last_pitch_pt = cap_ground(file, &head, prefix, &coil_subtractions, s_data->od, s_data->wd, s_data->ha, s_data->p, 0, 1, &need_subtractions); - break; - case 3: - last_pitch_pt = cap_squared_ground(file, &head, prefix, &coil_subtractions, s_data->od, s_data->wd, s_data->ha, s_data->p, 0, 1, &need_subtractions); - break; - default: - break; - } - - for (BU_LIST_FOR(cd, coil_data_t, &(*sections))) { - last_pitch_pt = helical_coil_plain(&head, &coil_subtractions, cd->od, cd->wd, cd->ha, cd->p, last_pitch_pt, cd->nt); - } - - switch (end_cap_type) { - case 0: - VSET(pnt1, 0 , -1*(e_data->od/2-e_data->wd/2), 1/8*e_data->p+last_pitch_pt); - mk_add_pipe_pt(&head, pnt1, e_data->wd, 0.0, (e_data->od/2-e_data->wd/2)); - break; - case 1: - last_pitch_pt = cap_squared(file, &head, prefix, &coil_subtractions, e_data->od, e_data->wd, e_data->ha, e_data->p, last_pitch_pt, 0, &need_subtractions); - break; - case 2: - last_pitch_pt = cap_ground(file, &head, prefix, &coil_subtractions, e_data->od, e_data->wd, e_data->ha, e_data->p, last_pitch_pt, 0, &need_subtractions); - break; - case 3: - last_pitch_pt = cap_squared_ground(file, &head, prefix, &coil_subtractions, e_data->od, e_data->wd, e_data->ha, e_data->p, last_pitch_pt, 0, &need_subtractions); - break; - default: - break; - } - - bu_vls_trunc(&str,0); - bu_vls_printf(&str, "%s_core.s", prefix); - mk_pipe(file, bu_vls_addr(&str), &head); - - (void)mk_addmember(bu_vls_addr(&str), &coil.l, NULL, WMOP_UNION); - - if (need_subtractions > 0) { - bu_vls_trunc(&str,0); - bu_vls_printf(&str, "%s_subtractions.c", prefix); - mk_lcomb(file, bu_vls_addr(&str), &coil_subtractions, 0, NULL, NULL, NULL, 0); - (void)mk_addmember(bu_vls_addr(&str), &coil.l, NULL, WMOP_SUBTRACT); - } - - mk_lcomb(file, prefix, &coil, 0, NULL, NULL, NULL, 0); - - bu_vls_free(&str); - mk_pipe_free(&head); -} - - - -/* Process command line arguments */ -int ReadArgs(int argc, char **argv, struct bu_list *sections, fastf_t *mean_outer_diameter, fastf_t *wire_diameter, fastf_t *helix_angle, fastf_t *pitch, int *nt, int *start_cap_type, int *end_cap_type) -{ - int c = 0; - char *options="d:w:h:p:n:s:e:S:"; - int numturns, stype, etype; - float mean_od, wired, h_angle, ptch; - int d1; - float d2, d3, d4, d5; - char s1, s2, s3, s4; - - struct coil_data_t *coil_data; - - bu_opterr = 0; - - while ((c=bu_getopt(argc, argv, options)) != -1) { - switch (c) { - case 'd' : - sscanf(bu_optarg, "%f", &mean_od); - *mean_outer_diameter = mean_od; - break; - case 'w': - sscanf(bu_optarg, "%f", &wired); - *wire_diameter = wired; - break; - case 'h': - sscanf(bu_optarg, "%f", &h_angle); - *helix_angle = h_angle; - break; - case 'p': - sscanf(bu_optarg, "%f", &ptch); - *pitch = ptch; - break; - case 'n': - sscanf(bu_optarg, "%d", &numturns); - *nt = numturns; - break; - case 's': - sscanf(bu_optarg, "%d", &stype); - *start_cap_type = stype; - break; - case 'e': - sscanf(bu_optarg, "%d", &etype); - *end_cap_type = etype; - break; - case 'S': - coil_data = (struct coil_data_t *) - bu_malloc( sizeof(struct coil_data_t), "coil data structure"); - sscanf(bu_optarg, "%d%c%f%c%f%c%f%c%f", &d1,&s1,&d2,&s2,&d3,&s3,&d4,&s4,&d5); - coil_data->nt = d1; - coil_data->od = d2; - coil_data->wd = d3; - coil_data->ha = d4; - coil_data->p = d5; - BU_LIST_INSERT(&(*sections),&((*coil_data).l)); - break; - default: - bu_log("%s: illegal option -- %c\n", bu_getprogname(), c); - bu_exit(EXIT_SUCCESS, NULL); - } - } - return(bu_optind); -} - - -int main(int ac, char *av[]) -{ - struct rt_wdb *db_fp; - struct bu_vls coil_type; - struct bu_vls name; - struct bu_vls str; - fastf_t mean_outer_diameter, wire_diameter; - fastf_t helix_angle, pitch; - - struct coil_data_t *coil_data; - struct bu_list sections; - - int nt; /* Number of turns */ - int start_cap_type, end_cap_type; - - - bu_vls_init(&str); - bu_vls_init(&coil_type); - bu_vls_init(&name); - bu_vls_trunc(&coil_type, 0); - bu_vls_trunc(&name, 0); - - BU_LIST_INIT( §ions ); - - mean_outer_diameter = 0; - wire_diameter = 0; - helix_angle = 0; - pitch = 0; - nt = 0; - start_cap_type = 0; - end_cap_type = 0; - - - /* Process arguments */ - ReadArgs(ac, av, §ions, &mean_outer_diameter, &wire_diameter, &helix_angle, &pitch, &nt, &start_cap_type, &end_cap_type); - - /* Handle various potential errors in args and set defaults if nothing supplied */ - - if (BU_LIST_IS_EMPTY(§ions)) { - - if (mean_outer_diameter < 0 || wire_diameter < 0 || helix_angle < 0 || pitch < 0 || nt < 0 || start_cap_type < 0 || end_cap_type < 0) - bu_exit(-1," Error - negative value in one or more arguments supplied to coil"); - - if (wire_diameter == 0 && mean_outer_diameter == 0) { - mean_outer_diameter = 1000; - wire_diameter = 100; - } - - if (wire_diameter == 0 && mean_outer_diameter > 0) { - wire_diameter = mean_outer_diameter/10; - } - - if (mean_outer_diameter == 0 && wire_diameter > 0) { - mean_outer_diameter = wire_diameter * 10; - } - - if (pitch == 0) { - pitch = wire_diameter; - } - - if (pitch < wire_diameter) { - bu_log("Warning - pitch less than wire diameter. Setting pitch to wire diameter: %f mm\n", wire_diameter); - pitch = wire_diameter; - } - - if (nt == 0) nt = 30; - - coil_data = (struct coil_data_t *) bu_malloc( sizeof(struct coil_data_t), "coil data structure"); - coil_data->nt = nt; - coil_data->od = mean_outer_diameter; - coil_data->wd = wire_diameter; - coil_data->ha = helix_angle; - coil_data->p = pitch; - BU_LIST_APPEND(&(sections),&((*coil_data).l)); - } - - bu_log("Outer Diameter: %f\n",mean_outer_diameter); - bu_log("Wire Diameter: %f\n",wire_diameter); - - /* Generate Name - this needs some thought for multiple section coils*/ - bu_vls_printf(&name, "coil"); - - - /* Create file name if supplied, else use "string.g" */ - if (av[bu_optind]) { - if (!bu_file_exists(av[bu_optind])) { - db_fp = wdb_fopen( av[bu_optind] ); - } else { - bu_exit(-1,"Error - refusing to overwrite pre-existing file %s",av[bu_optind]); - } - } - if (!av[bu_optind]) { - if (!bu_file_exists(DEFAULT_COIL_FILENAME)) { - db_fp = wdb_fopen(DEFAULT_COIL_FILENAME); - } else { - bu_exit(-1,"Error - no filename supplied and coil.g exists."); - } - } - - bu_log("Making coil...\n"); - make_coil(db_fp, bu_vls_addr(&name), §ions, start_cap_type, end_cap_type); - - bu_vls_free(&str); - bu_vls_free(&name); - - /* Close database */ - wdb_close(db_fp); - - return 0; -} - - -/* - * Local Variables: - * mode: C - * tab-width: 8 - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ Modified: brlcad/trunk/src/shapes/Makefile.am =================================================================== --- brlcad/trunk/src/shapes/Makefile.am 2009-02-27 23:48:53 UTC (rev 33918) +++ brlcad/trunk/src/shapes/Makefile.am 2009-02-27 23:49:10 UTC (rev 33919) @@ -1,6 +1,7 @@ bin_PROGRAMS = \ bolt \ + coil \ fence \ gastank \ handle \ @@ -14,6 +15,7 @@ LDADD = ${WDB} bolt_SOURCES = bolt.c +coil_SOURCES = coil.c fence_SOURCES = fence.c gastank_SOURCES = gastank.c handle_SOURCES = handle.c @@ -45,6 +47,7 @@ FAST_OBJECTS = \ $(bolt_OBJECTS) \ + $(coil_OBJECTS) \ $(fence_OBJECTS) \ $(gastank_OBJECTS) \ $(handle_OBJECTS) \ Added: brlcad/trunk/src/shapes/coil.c =================================================================== --- brlcad/trunk/src/shapes/coil.c (rev 0) +++ brlcad/trunk/src/shapes/coil.c 2009-02-27 23:49:10 UTC (rev 33919) @@ -0,0 +1,505 @@ +/* C O I L . C + * BRL-CAD + * + * Copyright (c) 2009 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + +/** @file coil.c + * + * Coil Generator + * + * Program to create coils using the pipe primitive. + * + */ + +#include "common.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include "bu.h" +#include "vmath.h" +#include "bn.h" +#include "raytrace.h" +#include "wdb.h" + + +#define D2R(x) (x * DEG2RAD) +#define DEFAULT_COIL_FILENAME "coil.g" + +struct coil_data_t { + struct bu_list l; + int nt; /*Number of Turns*/ + fastf_t od; /*Outer Diameter*/ + fastf_t wd; /*Wire Diameter*/ + fastf_t ha; /*Helix Angle*/ + fastf_t p; /*Pitch*/ +}; + +fastf_t cap_squared(struct rt_wdb *file, struct bu_list *head, char *prefix, struct wmember *coil_subtractions, fastf_t mean_outer_diameter, fastf_t wire_diameter, fastf_t helix_angle, fastf_t pitch, fastf_t starting_pitch, int is_start, int *need_subtraction) +{ + fastf_t pipe_bend, coil_radius; + point_t pnt1, pnt2, pnt4, pnt6, pnt8; + + coil_radius = mean_outer_diameter/2 - wire_diameter/2; + pipe_bend = coil_radius; + + *need_subtraction += 0; + + if (is_start == 1) { + VSET(pnt1, 0, -coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt2, coil_radius , -coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt4, coil_radius , coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt6, -coil_radius , coil_radius, pitch/2+starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt8, -coil_radius , -coil_radius, pitch+starting_pitch - sin(D2R(helix_angle))*coil_radius); + mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); + return pitch + starting_pitch; + } else { + VSET(pnt2, coil_radius, -coil_radius, starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt4, coil_radius , coil_radius, pitch/2 + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt6, -coil_radius , coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt8, -coil_radius , -coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt1, 0 , -coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); + mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); + return pitch + starting_pitch; + } + + return 0; +} + +fastf_t cap_squared_ground(struct rt_wdb *file, struct bu_list *head, char *prefix, struct wmember *coil_subtractions, fastf_t mean_outer_diameter, fastf_t wire_diameter, fastf_t helix_angle, fastf_t pitch, fastf_t starting_pitch, int is_start, int *need_subtraction) +{ + fastf_t pipe_bend, coil_radius; + point_t origin, height, pnt1, pnt2, pnt4, pnt6, pnt8, pnt10; + struct bu_vls str; + + bu_vls_init(&str); + + coil_radius = mean_outer_diameter/2 - wire_diameter/2; + pipe_bend = coil_radius; + + *need_subtraction += 1; + + if (is_start == 1) { + VSET(pnt1, -coil_radius, 0, starting_pitch - sin(D2R(helix_angle))*coil_radius - pitch/4); + VSET(pnt10, -coil_radius, -coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt2, coil_radius , -coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt4, coil_radius , coil_radius, starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt6, -coil_radius , coil_radius, pitch/2+starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt8, -coil_radius , -coil_radius, pitch+starting_pitch - sin(D2R(helix_angle))*coil_radius); + mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt10, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); + VSET(origin, 0, 0, starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(height, 0, 0, -wire_diameter); + bu_vls_trunc(&str, 0); + bu_vls_printf(&str, "%s-startcap.s", prefix); + mk_rcc(file, bu_vls_addr(&str), origin, height, coil_radius+wire_diameter+.1*wire_diameter); + (void)mk_addmember(bu_vls_addr(&str), &(*coil_subtractions).l, NULL, WMOP_UNION); + bu_vls_free(&str); + return pitch + starting_pitch; + } else { + VSET(pnt2, coil_radius, -coil_radius, starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt4, coil_radius , coil_radius, pitch/2 + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt6, -coil_radius , coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt8, -coil_radius , -coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt10, coil_radius , -coil_radius, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt1, coil_radius , 0, pitch + starting_pitch + sin(D2R(helix_angle))*coil_radius + pitch/4); + mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt10, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); + VSET(origin, 0, 0, starting_pitch + pitch + sin(D2R(helix_angle))*coil_radius); + VSET(height, 0, 0, wire_diameter); + bu_vls_trunc(&str, 0); + bu_vls_printf(&str, "%s-endcap.s", prefix); + mk_rcc(file, bu_vls_addr(&str), origin, height, coil_radius+wire_diameter+.1*wire_diameter); + (void)mk_addmember(bu_vls_addr(&str), &(*coil_subtractions).l, NULL, WMOP_UNION); + bu_vls_free(&str); + return pitch + starting_pitch; + } + bu_vls_free(&str); + return 0; +} + +fastf_t cap_ground(struct rt_wdb *file, struct bu_list *head, char *prefix, struct wmember *coil_subtractions, fastf_t mean_outer_diameter, fastf_t wire_diameter, fastf_t helix_angle, fastf_t pitch, fastf_t starting_pitch, int is_start, int *need_subtraction) +{ + fastf_t coil_radius, pipe_bend; + point_t origin, height, pnt1, pnt2, pnt4, pnt6, pnt8; + + coil_radius = mean_outer_diameter/2 - wire_diameter/2; + pipe_bend = coil_radius; + + struct bu_vls str; + bu_vls_init(&str); + + *need_subtraction += 1; + + if (is_start == 1) { + VSET(pnt1, 0, -coil_radius, starting_pitch); + VSET(pnt2, coil_radius , -coil_radius, pitch/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt4, coil_radius , coil_radius, pitch*3/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt6, -coil_radius , coil_radius, pitch*5/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt8, -coil_radius , -coil_radius, pitch*7/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); + mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); + VSET(origin, 0, 0, starting_pitch); + VSET(height, 0, 0, -wire_diameter - sin(D2R(helix_angle))*coil_radius); + bu_vls_trunc(&str, 0); + bu_vls_printf(&str, "%s-startcap.s", prefix); + mk_rcc(file, bu_vls_addr(&str), origin, height, coil_radius+wire_diameter+.1*wire_diameter); + (void)mk_addmember(bu_vls_addr(&str), &(*coil_subtractions).l, NULL, WMOP_UNION); + bu_vls_free(&str); + return pitch + starting_pitch; + } else { + VSET(pnt2, coil_radius , -coil_radius, pitch/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt4, coil_radius , coil_radius, pitch*3/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt6, -coil_radius , coil_radius, pitch*5/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt8, -coil_radius , -coil_radius, pitch*7/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt1, 0 , -coil_radius, pitch+starting_pitch); + mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt1, wire_diameter, 0.0, pipe_bend); + VSET(origin, 0, 0, starting_pitch + pitch); + VSET(height, 0, 0, wire_diameter + sin(D2R(helix_angle))*coil_radius); + bu_vls_trunc(&str, 0); + bu_vls_printf(&str, "%s-endcap.s", prefix); + mk_rcc(file, bu_vls_addr(&str), origin, height, coil_radius+wire_diameter+.1*wire_diameter); + (void)mk_addmember(bu_vls_addr(&str), &(*coil_subtractions).l, NULL, WMOP_UNION); + bu_vls_free(&str); + return pitch+starting_pitch; + } + bu_vls_free(&str); + return 0; +} + + + +fastf_t helical_coil_plain(struct bu_list *head, struct wmember *coil, fastf_t mean_outer_diameter, fastf_t wire_diameter, fastf_t helix_angle, fastf_t pitch, fastf_t starting_pitch, int nt) +{ + int i; + fastf_t coil_radius, pipe_bend; + point_t pnt1, pnt2, pnt4, pnt6, pnt8; + + coil_radius = mean_outer_diameter/2 - wire_diameter/2; + pipe_bend = coil_radius; + + for (i = 0; i < nt; i++) { + VSET(pnt2, coil_radius , -coil_radius, i*pitch + pitch/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt4, coil_radius , coil_radius, i*pitch + pitch*3/8 + starting_pitch + sin(D2R(helix_angle))*coil_radius); + VSET(pnt6, -coil_radius , coil_radius, i*pitch + pitch*5/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); + VSET(pnt8, -coil_radius , -coil_radius, i*pitch + pitch*7/8 + starting_pitch - sin(D2R(helix_angle))*coil_radius); + mk_add_pipe_pt(head, pnt2, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt4, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt6, wire_diameter, 0.0, pipe_bend); + mk_add_pipe_pt(head, pnt8, wire_diameter, 0.0, pipe_bend); + } + + return (nt-1)*pitch + pitch*7/8 + starting_pitch; + +} + +void make_coil(struct rt_wdb (*file), char *prefix, struct bu_list *sections, int start_cap_type, int end_cap_type) +{ + struct bu_list head; + mk_pipe_init(&head); + fastf_t last_pitch_pt; + point_t pnt1; + int need_subtractions = 0; + struct wmember coil; + BU_LIST_INIT(&coil.l); + struct wmember coil_subtractions; + BU_LIST_INIT(&coil_subtractions.l); + + struct coil_data_t *s_data; + struct coil_data_t *e_data; + struct coil_data_t *cd; + + s_data = BU_LIST_FIRST(coil_data_t,&(*sections)); + e_data = BU_LIST_LAST(coil_data_t,&(*sections)); + + struct bu_vls str; + bu_vls_init(&str); + + last_pitch_pt = 0; + + switch (start_cap_type) { + case 0: + VSET(pnt1, 0, -1*(s_data->od/2-s_data->wd/2), last_pitch_pt); + mk_add_pipe_pt(&head, pnt1, s_data->wd, 0.0, (s_data->od/2-s_data->wd/2)); + break; + case 1: + last_pitch_pt = cap_squared(file, &head, prefix, &coil_subtractions, s_data->od, s_data->wd, s_data->ha, s_data->p, 0, 1, &need_subtractions); + break; + case 2: + last_pitch_pt = cap_ground(file, &head, prefix, &coil_subtractions, s_data->od, s_data->wd, s_data->ha, s_data->p, 0, 1, &need_subtractions); + break; + case 3: + last_pitch_pt = cap_squared_ground(file, &head, prefix, &coil_subtractions, s_data->od, s_data->wd, s_data->ha, s_data->p, 0, 1, &need_subtractions); + break; + default: + break; + } + + for (BU_LIST_FOR(cd, coil_data_t, &(*sections))) { + last_pitch_pt = helical_coil_plain(&head, &coil_subtractions, cd->od, cd->wd, cd->ha, cd->p, last_pitch_pt, cd->nt); + } + + switch (end_cap_type) { + case 0: + VSET(pnt1, 0 , -1*(e_data->od/2-e_data->wd/2), 1/8*e_data->p+last_pitch_pt); + mk_add_pipe_pt(&head, pnt1, e_data->wd, 0.0, (e_data->od/2-e_data->wd/2)); + break; + case 1: + last_pitch_pt = cap_squared(file, &head, prefix, &coil_subtractions, e_data->od, e_data->wd, e_data->ha, e_data->p, last_pitch_pt, 0, &need_subtractions); + break; + case 2: + last_pitch_pt = cap_ground(file, &head, prefix, &coil_subtractions, e_data->od, e_data->wd, e_data->ha, e_data->p, last_pitch_pt, 0, &need_subtractions); + break; + case 3: + last_pitch_pt = cap_squared_ground(file, &head, prefix, &coil_subtractions, e_data->od, e_data->wd, e_data->ha, e_data->p, last_pitch_pt, 0, &need_subtractions); + break; + default: + break; + } + + bu_vls_trunc(&str,0); + bu_vls_printf(&str, "%s_core.s", prefix); + mk_pipe(file, bu_vls_addr(&str), &head); + + (void)mk_addmember(bu_vls_addr(&str), &coil.l, NULL, WMOP_UNION); + + if (need_subtractions > 0) { + bu_vls_trunc(&str,0); + bu_vls_printf(&str, "%s_subtractions.c", prefix); + mk_lcomb(file, bu_vls_addr(&str), &coil_subtractions, 0, NULL, NULL, NULL, 0); + (void)mk_addmember(bu_vls_addr(&str), &coil.l, NULL, WMOP_SUBTRACT); + } + + mk_lcomb(file, prefix, &coil, 0, NULL, NULL, NULL, 0); + + bu_vls_free(&str); + mk_pipe_free(&head); +} + + + +/* Process command line arguments */ +int ReadArgs(int argc, char **argv, struct bu_list *sections, fastf_t *mean_outer_diameter, fastf_t *wire_diameter, fastf_t *helix_angle, fastf_t *pitch, int *nt, int *start_cap_type, int *end_cap_type) +{ + int c = 0; + char *options="d:w:h:p:n:s:e:S:"; + int numturns, stype, etype; + float mean_od, wired, h_angle, ptch; + int d1; + float d2, d3, d4, d5; + char s1, s2, s3, s4; + + struct coil_data_t *coil_data; + + bu_opterr = 0; + + while ((c=bu_getopt(argc, argv, options)) != -1) { + switch (c) { + case 'd' : + sscanf(bu_optarg, "%f", &mean_od); + *mean_outer_diameter = mean_od; + break; + case 'w': + sscanf(bu_optarg, "%f", &wired); + *wire_diameter = wired; + break; + case 'h': + sscanf(bu_optarg, "%f", &h_angle); + *helix_angle = h_angle; + break; + case 'p': + sscanf(bu_optarg, "%f", &ptch); + *pitch = ptch; + break; + case 'n': + sscanf(bu_optarg, "%d", &numturns); + *nt = numturns; + break; + case 's': + sscanf(bu_optarg, "%d", &stype); + *start_cap_type = stype; + break; + case 'e': + sscanf(bu_optarg, "%d", &etype); + *end_cap_type = etype; + break; + case 'S': + coil_data = (struct coil_data_t *) + bu_malloc( sizeof(struct coil_data_t), "coil data structure"); + sscanf(bu_optarg, "%d%c%f%c%f%c%f%c%f", &d1,&s1,&d2,&s2,&d3,&s3,&d4,&s4,&d5); + coil_data->nt = d1; + coil_data->od = d2; + coil_data->wd = d3; + coil_data->ha = d4; + coil_data->p = d5; + BU_LIST_INSERT(&(*sections),&((*coil_data).l)); + break; + default: + bu_log("%s: illegal option -- %c\n", bu_getprogname(), c); + bu_exit(EXIT_SUCCESS, NULL); + } + } + return(bu_optind); +} + + +int main(int ac, char *av[]) +{ + struct rt_wdb *db_fp; + struct bu_vls coil_type; + struct bu_vls name; + struct bu_vls str; + fastf_t mean_outer_diameter, wire_diameter; + fastf_t helix_angle, pitch; + + struct coil_data_t *coil_data; + struct bu_list sections; + + int nt; /* Number of turns */ + int start_cap_type, end_cap_type; + + + bu_vls_init(&str); + bu_vls_init(&coil_type); + bu_vls_init(&name); + bu_vls_trunc(&coil_type, 0); + bu_vls_trunc(&name, 0); + + BU_LIST_INIT( §ions ); + + mean_outer_diameter = 0; + wire_diameter = 0; + helix_angle = 0; + pitch = 0; + nt = 0; + start_cap_type = 0; + end_cap_type = 0; + + + /* Process arguments */ + ReadArgs(ac, av, §ions, &mean_outer_diameter, &wire_diameter, &helix_angle, &pitch, &nt, &start_cap_type, &end_cap_type); + + /* Handle various potential errors in args and set defaults if nothing supplied */ + + if (BU_LIST_IS_EMPTY(§ions)) { + + if (mean_outer_diameter < 0 || wire_diameter < 0 || helix_angle < 0 || pitch < 0 || nt < 0 || start_cap_type < 0 || end_cap_type < 0) + bu_exit(-1," Error - negative value in one or more arguments supplied to coil"); + + if (wire_diameter == 0 && mean_outer_diameter == 0) { + mean_outer_diameter = 1000; + wire_diameter = 100; + } + + if (wire_diameter == 0 && mean_outer_diameter > 0) { + wire_diameter = mean_outer_diameter/10; + } + + if (mean_outer_diameter == 0 && wire_diameter > 0) { + mean_outer_diameter = wire_diameter * 10; + } + + if (pitch == 0) { + pitch = wire_diameter; + } + + if (pitch < wire_diameter) { + bu_log("Warning - pitch less than wire diameter. Setting pitch to wire diameter: %f mm\n", wire_diameter); + pitch = wire_diameter; + } + + if (nt == 0) nt = 30; + + coil_data = (struct coil_data_t *) bu_malloc( sizeof(struct coil_data_t), "coil data structure"); + coil_data->nt = nt; + coil_data->od = mean_outer_diameter; + coil_data->wd = wire_diameter; + coil_data->ha = helix_angle; + coil_data->p = pitch; + BU_LIST_APPEND(&(sections),&((*coil_data).l)); + } + + bu_log("Outer Diameter: %f\n",mean_outer_diameter); + bu_log("Wire Diameter: %f\n",wire_diameter); + + /* Generate Name - this needs some thought for multiple section coils*/ + bu_vls_printf(&name, "coil"); + + + /* Create file name if supplied, else use "string.g" */ + if (av[bu_optind]) { + if (!bu_file_exists(av[bu_optind])) { + db_fp = wdb_fopen( av[bu_optind] ); + } else { + bu_exit(-1,"Error - refusing to overwrite pre-existing file %s",av[bu_optind]); + } + } + if (!av[bu_optind]) { + if (!bu_file_exists(DEFAULT_COIL_FILENAME)) { + db_fp = wdb_fopen(DEFAULT_COIL_FILENAME); + } else { + bu_exit(-1,"Error - no filename supplied and coil.g exists."); + } + } + + bu_log("Making coil...\n"); + make_coil(db_fp, bu_vls_addr(&name), §ions, start_cap_type, end_cap_type); + + bu_vls_free(&str); + bu_vls_free(&name); + + /* Close database */ + wdb_close(db_fp); + + return 0; +} + + +/* + * Local Variables: + * mode: C + * tab-width: 8 + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/shapes/coil.c ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-03 02:41:26
|
Revision: 33933 http://brlcad.svn.sourceforge.net/brlcad/?rev=33933&view=rev Author: brlcad Date: 2009-03-03 02:41:20 +0000 (Tue, 03 Mar 2009) Log Message: ----------- var doesn't need to be global, make it static Modified Paths: -------------- brlcad/trunk/src/libged/clone.c brlcad/trunk/src/mged/clone.c Modified: brlcad/trunk/src/libged/clone.c =================================================================== --- brlcad/trunk/src/libged/clone.c 2009-03-02 20:41:01 UTC (rev 33932) +++ brlcad/trunk/src/libged/clone.c 2009-03-03 02:41:20 UTC (rev 33933) @@ -102,7 +102,7 @@ int names_used; }; -struct nametbl obj_list; +static struct nametbl obj_list; /** * a polynamial value for representing knots Modified: brlcad/trunk/src/mged/clone.c =================================================================== --- brlcad/trunk/src/mged/clone.c 2009-03-02 20:41:01 UTC (rev 33932) +++ brlcad/trunk/src/mged/clone.c 2009-03-03 02:41:20 UTC (rev 33933) @@ -113,7 +113,7 @@ int names_used; }; -struct nametbl obj_list; +static struct nametbl obj_list; /** * a polynamial value for representing knots This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-03 02:41:48
|
Revision: 33934 http://brlcad.svn.sourceforge.net/brlcad/?rev=33934&view=rev Author: brlcad Date: 2009-03-03 02:41:43 +0000 (Tue, 03 Mar 2009) Log Message: ----------- these commands that run external tools weren't migrated to libged correctly so that they identify their run-time path correctly. the bu_brlcad_root lookups need to happen on the final argv that is exec'd. Modified Paths: -------------- brlcad/trunk/src/libged/nirt.c brlcad/trunk/src/libged/rt.c brlcad/trunk/src/libged/rtcheck.c brlcad/trunk/src/mged/rtif.c Modified: brlcad/trunk/src/libged/nirt.c =================================================================== --- brlcad/trunk/src/libged/nirt.c 2009-03-03 02:41:20 UTC (rev 33933) +++ brlcad/trunk/src/libged/nirt.c 2009-03-03 02:41:43 UTC (rev 33934) @@ -105,6 +105,9 @@ struct ged_qray_dataList *ndlp; struct ged_qray_dataList HeadQRayData; + const char *bin; + char nirt[256]; + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); GED_CHECK_DRAWABLE(gedp, BRLCAD_ERROR); GED_CHECK_VIEW(gedp, BRLCAD_ERROR); @@ -113,8 +116,17 @@ /* initialize result */ bu_vls_trunc(&gedp->ged_result_str, 0); + bin = bu_brlcad_root("bin", 1); + if (bin) { +#ifdef _WIN32 + snprintf(nirt, 256, "\"%s/%s\"", bin, argv[0]); +#else + snprintf(nirt, 256, "%s/%s", bin, argv[0]); +#endif + } + vp = &gedp->ged_gdp->gd_rt_cmd[0]; - *vp++ = "nirt"; + *vp++ = nirt; /* swipe x, y, z off the end if present */ if (argc > 3) { @@ -624,7 +636,7 @@ bu_vls_printf(&y_vls, "%lf", center_model[Y]); bu_vls_printf(&z_vls, "%lf", center_model[Z]); - /* pass remaining arguments to nirt */ + /* pass remaining arguments to ged nirt command */ av[0] = "nirt"; for (i = 1; i < argc; ++i) av[i] = (char *)argv[i]; Modified: brlcad/trunk/src/libged/rt.c =================================================================== --- brlcad/trunk/src/libged/rt.c 2009-03-03 02:41:20 UTC (rev 33933) +++ brlcad/trunk/src/libged/rt.c 2009-03-03 02:41:43 UTC (rev 33934) @@ -42,6 +42,9 @@ char pstring[32]; static const char *usage = "options"; + const char *bin; + char rt[256] = {0}; + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); GED_CHECK_DRAWABLE(gedp, BRLCAD_ERROR); GED_CHECK_VIEW(gedp, BRLCAD_ERROR); @@ -55,8 +58,17 @@ return BRLCAD_ERROR; } + bin = bu_brlcad_root("bin", 1); + if (bin) { +#ifdef _WIN32 + snprintf(rt, 256, "\"%s/%s\"", bin, argv[0]); +#else + snprintf(rt, 256, "%s/%s", bin, argv[0]); +#endif + } + vp = &gedp->ged_gdp->gd_rt_cmd[0]; - *vp++ = (char *)argv[0]; + *vp++ = rt; *vp++ = "-M"; if (gedp->ged_gvp->gv_perspective > 0) { Modified: brlcad/trunk/src/libged/rtcheck.c =================================================================== --- brlcad/trunk/src/libged/rtcheck.c 2009-03-03 02:41:20 UTC (rev 33933) +++ brlcad/trunk/src/libged/rtcheck.c 2009-03-03 02:41:43 UTC (rev 33934) @@ -105,6 +105,9 @@ vect_t eye_model; static const char *usage = "options"; + const char *bin; + char rtcheck[256] = {0}; + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); GED_CHECK_DRAWABLE(gedp, BRLCAD_ERROR); GED_CHECK_VIEW(gedp, BRLCAD_ERROR); @@ -113,9 +116,18 @@ /* initialize result */ bu_vls_trunc(&gedp->ged_result_str, 0); + bin = bu_brlcad_root("bin", 1); + if (bin) { +#ifdef _WIN32 + snprintf(rtcheck, 256, "\"%s/%s\"", bin, argv[0]); +#else + snprintf(rtcheck, 256, "%s/%s", bin, argv[0]); +#endif + } + #ifndef _WIN32 vp = &gedp->ged_gdp->gd_rt_cmd[0]; - *vp++ = (char *)argv[0]; + *vp++ = rtcheck; *vp++ = "-M"; for (i=1; i < argc; i++) *vp++ = (char *)argv[i]; @@ -212,7 +224,7 @@ #else /* _WIN32 */ vp = &gedp->ged_gdp->gd_rt_cmd[0]; - *vp++ = "rtcheck"; + *vp++ = rtcheck; *vp++ = "-M"; for (i=1; i < argc; i++) *vp++ = (char *)argv[i]; Modified: brlcad/trunk/src/mged/rtif.c =================================================================== --- brlcad/trunk/src/mged/rtif.c 2009-03-03 02:41:20 UTC (rev 33933) +++ brlcad/trunk/src/mged/rtif.c 2009-03-03 02:41:43 UTC (rev 33934) @@ -67,8 +67,6 @@ int argc, char **argv) { - const char *ptr; - char buf[256] = {0}; int doRtcheck; int ret; Tcl_DString ds; @@ -85,16 +83,6 @@ else doRtcheck = 0; - ptr = bu_brlcad_root("bin", 1); - if (ptr) { -#ifdef _WIN32 - snprintf(buf, 256, "\"%s/%s\"", ptr, argv[0]); -#else - snprintf(buf, 256, "%s/%s", ptr, argv[0]); -#endif - argv[0] = buf; - } - Tcl_DStringInit(&ds); if (doRtcheck) @@ -367,21 +355,9 @@ { int ret; Tcl_DString ds; - const char *ptr; - char buf[256]; CHECK_DBI_NULL; - ptr = bu_brlcad_root("bin", 1); - if (ptr) { -#ifdef _WIN32 - snprintf(buf, 256, "\"%s/%s\"", ptr, argv[0]); -#else - snprintf(buf, 256, "%s/%s", ptr, argv[0]); -#endif - argv[0] = buf; - } - Tcl_DStringInit(&ds); if (mged_variables->mv_use_air) { @@ -416,21 +392,9 @@ { int ret; Tcl_DString ds; - const char *ptr; - char buf[256]; CHECK_DBI_NULL; - ptr = bu_brlcad_root("bin", 1); - if (ptr) { -# ifdef _WIN32 - snprintf(buf, 256, "\"%s/%s\"", ptr, argv[0]); -# else - snprintf(buf, 256, "%s/%s", ptr, argv[0]); -# endif - argv[0] = buf; - } - Tcl_DStringInit(&ds); ret = ged_vnirt(gedp, argc, (const char **)argv); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-03-06 17:57:11
|
Revision: 33964 http://brlcad.svn.sourceforge.net/brlcad/?rev=33964&view=rev Author: bob1961 Date: 2009-03-06 17:57:07 +0000 (Fri, 06 Mar 2009) Log Message: ----------- This fixes the "Pick Edit-Primitive" mode in MGED. Modified Paths: -------------- brlcad/trunk/src/mged/setup.c brlcad/trunk/src/tclscripts/mged/ray.tcl Modified: brlcad/trunk/src/mged/setup.c =================================================================== --- brlcad/trunk/src/mged/setup.c 2009-03-06 17:52:49 UTC (rev 33963) +++ brlcad/trunk/src/mged/setup.c 2009-03-06 17:57:07 UTC (rev 33964) @@ -188,6 +188,7 @@ {"lookat", cmd_ged_view_wrapper, ged_lookat}, {"ls", cmd_ged_plain_wrapper, ged_ls}, {"M", f_mouse, GED_FUNC_PTR_NULL}, + {"m2v_point", cmd_ged_plain_wrapper, ged_m2v_point}, {"make", f_make, GED_FUNC_PTR_NULL}, {"make_bb", cmd_ged_plain_wrapper, ged_make_bb}, {"make_name", cmd_ged_plain_wrapper, ged_make_name}, @@ -331,6 +332,7 @@ {"tree", cmd_ged_plain_wrapper, ged_tree}, {"unhide", cmd_ged_plain_wrapper, ged_unhide}, {"units", cmd_units, GED_FUNC_PTR_NULL}, + {"v2m_point", cmd_ged_plain_wrapper, ged_v2m_point}, {"vars", f_set, GED_FUNC_PTR_NULL}, {"vdraw", cmd_ged_plain_wrapper, ged_vdraw}, {"view", cmd_ged_view_wrapper, ged_view}, Modified: brlcad/trunk/src/tclscripts/mged/ray.tcl =================================================================== --- brlcad/trunk/src/tclscripts/mged/ray.tcl 2009-03-06 17:52:49 UTC (rev 33963) +++ brlcad/trunk/src/tclscripts/mged/ray.tcl 2009-03-06 17:57:07 UTC (rev 33964) @@ -40,9 +40,9 @@ ray no_bool 1 set xx [expr $x / 2048.0] set yy [expr $y / 2048.0] - set target [view2model $xx $yy 0] + set target [v2m_point $xx $yy 0] if {$perspective_mode} { - set start [view2model 0 0 1] + set start [v2m_point 0 0 1] } elseif {!$zclip} { # calculate a view Z that's in front of all geometry @@ -50,14 +50,14 @@ set center_size [get_autoview] # extract view Z from center of geometry, then back the rest of the way out of the geometry - set Z [expr [lindex [eval model2view [lindex $center_size 1]] 2] + [expr [lindex $center_size 3] / [size]]] + set Z [expr [lindex [eval m2v_point [lindex $center_size 1]] 2] + [expr [lindex $center_size 3] / [size]]] if {$Z < 1} { set Z 1 } - set start [view2model $xx $yy $Z] + set start [v2m_point $xx $yy $Z] } else { - set start [view2model $xx $yy 1] + set start [v2m_point $xx $yy 1] } return [ray shootray $start at $target] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ind...@us...> - 2009-03-12 14:42:30
|
Revision: 34012 http://brlcad.svn.sourceforge.net/brlcad/?rev=34012&view=rev Author: indianlarry Date: 2009-03-12 14:41:57 +0000 (Thu, 12 Mar 2009) Log Message: ----------- Added 'clone' to mged_help_data table and added print_usage() when to few args Modified Paths: -------------- brlcad/trunk/src/libged/clone.c brlcad/trunk/src/tclscripts/mged/help.tcl Modified: brlcad/trunk/src/libged/clone.c =================================================================== --- brlcad/trunk/src/libged/clone.c 2009-03-12 13:01:27 UTC (rev 34011) +++ brlcad/trunk/src/libged/clone.c 2009-03-12 14:41:57 UTC (rev 34012) @@ -945,7 +945,7 @@ /* must be wanting help */ if (argc == 1) { - bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + print_usage(gedp); return BRLCAD_HELP; } Modified: brlcad/trunk/src/tclscripts/mged/help.tcl =================================================================== --- brlcad/trunk/src/tclscripts/mged/help.tcl 2009-03-12 13:01:27 UTC (rev 34011) +++ brlcad/trunk/src/tclscripts/mged/help.tcl 2009-03-12 14:41:57 UTC (rev 34012) @@ -83,6 +83,22 @@ set mged_help_data(cat) $helplib_data(wdb_cat) set mged_help_data(center) $helplib_data(vo_center) set mged_help_data(closedb) {{} {close any open database}} +set mged_help_data(clone) {{[-abhimnprtv] <object>} {clone allows user to quickly create copies of objects + -a <n> <x> <y> <z> - Specifies a translation split between n copies. + -b <n> <x> <y> <z> - Specifies a rotation around x, y, and z axes + split between n copies. + -c - Increment the second number in object names. + -f - Don't draw the new object. + -g - Don't resize the view after drawing new objects. + -h - Prints this message. + -i <n> - Specifies the increment between each copy. + -m <axis> <pos> - Specifies the axis and point to mirror the group. + -n <# copies> - Specifies the number of copies to make. + -p <x> <y> <z> - Specifies point to rotate around for -r. + (Default is 0 0 0). + -r <x> <y> <z> - Specifies the rotation around x, y, and z axes. + -t <x> <y> <z> - Specifies translation between each copy. + -v - Prints version info.}} set mged_help_data(color) $helplib_data(wdb_color) set mged_help_data(comb) $helplib_data(wdb_comb) set mged_help_data(comb_color) {{comb R G B} {assign a color to a combination (like 'mater')}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2009-03-17 00:21:10
|
Revision: 34049 http://brlcad.svn.sourceforge.net/brlcad/?rev=34049&view=rev Author: brlcad Date: 2009-03-17 00:21:06 +0000 (Tue, 17 Mar 2009) Log Message: ----------- bah, these weren't updated for release. *really* should not have version numbers in these files, nor should it be necessary to set BRLCAD_DATA even on Windows. Modified Paths: -------------- brlcad/trunk/src/archer/archer.bat brlcad/trunk/src/mged/mged.bat brlcad/trunk/src/util/rtwizard.bat Modified: brlcad/trunk/src/archer/archer.bat =================================================================== --- brlcad/trunk/src/archer/archer.bat 2009-03-17 00:04:39 UTC (rev 34048) +++ brlcad/trunk/src/archer/archer.bat 2009-03-17 00:21:06 UTC (rev 34049) @@ -24,7 +24,10 @@ REM Company: Survice Engineering SETLOCAL + +REM XXX FIXME: SHOULD NOT NEED TO SET BRLCAD_DATA OR CAD_VERSION XXX SET CAD_VERSION=7.14.3 + SET SAVE_CD=%CD% SET PATH=%~dp0 SET ARCHER=%~dp0archer Modified: brlcad/trunk/src/mged/mged.bat =================================================================== --- brlcad/trunk/src/mged/mged.bat 2009-03-17 00:04:39 UTC (rev 34048) +++ brlcad/trunk/src/mged/mged.bat 2009-03-17 00:21:06 UTC (rev 34049) @@ -24,7 +24,10 @@ REM Company: Survice Engineering SETLOCAL + +REM XXX FIXME: SHOULD NOT NEED TO SET BRLCAD_DATA OR CAD_VERSION XXX SET CAD_VERSION=7.14.3 + SET SAVE_CD=%CD% SET PATH=%~dp0 CD %PATH%\.. Modified: brlcad/trunk/src/util/rtwizard.bat =================================================================== --- brlcad/trunk/src/util/rtwizard.bat 2009-03-17 00:04:39 UTC (rev 34048) +++ brlcad/trunk/src/util/rtwizard.bat 2009-03-17 00:21:06 UTC (rev 34049) @@ -24,7 +24,10 @@ REM Company: Survice Engineering SETLOCAL + +REM XXX FIXME: SHOULD NOT NEED TO SET BRLCAD_DATA OR CAD_VERSION XXX SET CAD_VERSION=7.14.3 + SET SAVE_CD=%CD% SET PATH=%~dp0 CD %PATH%\.. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-03-26 13:45:01
|
Revision: 34081 http://brlcad.svn.sourceforge.net/brlcad/?rev=34081&view=rev Author: bob1961 Date: 2009-03-26 13:44:39 +0000 (Thu, 26 Mar 2009) Log Message: ----------- Modify bwish and archer to NOT use BLT. Modified Paths: -------------- brlcad/trunk/src/archer/archer brlcad/trunk/src/bwish/Makefile.am brlcad/trunk/src/bwish/cadAppInit.c brlcad/trunk/src/bwish/main.c brlcad/trunk/src/tclscripts/archer/Archer.tcl brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl brlcad/trunk/src/tclscripts/archer/CombEditFrame.tcl brlcad/trunk/src/tclscripts/archer/bgerror.tcl brlcad/trunk/src/tclscripts/archer/cursor.tcl Modified: brlcad/trunk/src/archer/archer =================================================================== --- brlcad/trunk/src/archer/archer 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/archer/archer 2009-03-26 13:44:39 UTC (rev 34081) @@ -77,16 +77,6 @@ # } #} -# stupid blt needs blt_library to be set (must be done AFTER loading BLT...) -set blt_library [file normalize [file join [bu_brlcad_root "lib"] blt2.4]] -if {![file exists $blt_library]} { - set blt_library [file normalize [file join [bu_brlcad_data "src"] other blt library]] -} -if {![file exists $blt_library]} { - puts "ERROR: Unable to initialize Archer resources" - exit 1 -} - # load archer guts if { [catch {package require Archer 1.0} _initialized] } { puts "$_initialized" Modified: brlcad/trunk/src/bwish/Makefile.am =================================================================== --- brlcad/trunk/src/bwish/Makefile.am 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/bwish/Makefile.am 2009-03-26 13:44:39 UTC (rev 34081) @@ -29,7 +29,6 @@ blib_LIBS = \ ${TCLCAD} \ ${DM} \ - ${BLT} \ ${ITK} \ ${ITCL} \ ${TK} \ Modified: brlcad/trunk/src/bwish/cadAppInit.c =================================================================== --- brlcad/trunk/src/bwish/cadAppInit.c 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/bwish/cadAppInit.c 2009-03-26 13:44:39 UTC (rev 34081) @@ -37,7 +37,6 @@ # include "itk.h" # include "dm.h" # include "fb.h" -# include "blt.h" #endif #include "bu.h" @@ -71,12 +70,6 @@ bu_log("Itk_Init ERROR:\n%s\n", Tcl_GetStringResult(interp)); return TCL_ERROR; } - -/* Initialize BLT */ - if (Blt_Init(interp) == TCL_ERROR) { - bu_log("Blt_Init ERROR:\n%s\n", Tcl_GetStringResult(interp)); - return TCL_ERROR; - } #endif #ifdef IMPORT_ITCL Modified: brlcad/trunk/src/bwish/main.c =================================================================== --- brlcad/trunk/src/bwish/main.c 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/bwish/main.c 2009-03-26 13:44:39 UTC (rev 34081) @@ -72,7 +72,6 @@ int init_tk = 1; int init_itcl = 1; int init_itk = 1; - int init_blt = 1; /* a two-pass init loop. the first pass just tries default init * routines while the second calls tclcad_auto_path() to help it @@ -149,19 +148,6 @@ } Tcl_StaticPackage(interp, "Itk", Itk_Init, (Tcl_PackageInitProc *) NULL); init_itk=0; - - /* Initialize BLT */ - Tcl_ResetResult(interp); - if (init_blt && Blt_Init(interp) == TCL_ERROR) { - if (!try_auto_path) { - try_auto_path=1; - continue; - } - bu_log("Blt_Init ERROR:\n%s\n", Tcl_GetStringResult(interp)); - return TCL_ERROR; - } - Tcl_StaticPackage(interp, "BLT", Blt_Init, (Tcl_PackageInitProc *) NULL); - init_blt=0; #endif /* don't actually want to loop forever */ Modified: brlcad/trunk/src/tclscripts/archer/Archer.tcl =================================================================== --- brlcad/trunk/src/tclscripts/archer/Archer.tcl 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/tclscripts/archer/Archer.tcl 2009-03-26 13:44:39 UTC (rev 34081) @@ -843,9 +843,9 @@ wm geometry $dialog 400x400 # Event bindings - bind $dialog <Enter> "raise $dialog" - bind $dialog <Configure> "raise $dialog" - bind $dialog <FocusOut> "raise $dialog" +# bind $dialog <Enter> "raise $dialog" +# bind $dialog <Configure> "raise $dialog" +# bind $dialog <FocusOut> "raise $dialog" $dialog center $w $dialog activate @@ -961,7 +961,7 @@ } if {[info exists itk_component(ged)]} { - SetWaitCursor + SetWaitCursor $this set savedUnits [$itk_component(ged) units -s] $itk_component(ged) units in $itk_component(ged) configure -autoViewEnable 0 @@ -1097,7 +1097,7 @@ $itk_component(ged) attachObservers $itk_component(ged) refreshAll $itk_component(ged) configure -autoViewEnable 1 - SetNormalCursor + SetNormalCursor $this } } @@ -1126,6 +1126,7 @@ } ::itcl::body Archer::Load {_target} { + SetWaitCursor $this if {$mNeedSave} { $itk_component(saveDialog) center [namespace tail $this] if {[$itk_component(saveDialog) activate]} { @@ -1208,9 +1209,7 @@ showGroundPlane # refresh tree contents - SetWaitCursor refreshTree 0 - SetNormalCursor } else { applyPreferences doLighting @@ -1220,6 +1219,7 @@ set mDefaultBindingMode $ROTATE_MODE beginViewRotate } + SetNormalCursor $this } ::itcl::body Archer::updateTheme {} { @@ -1688,7 +1688,7 @@ ################################### Miscellaneous Section ################################### ::itcl::body Archer::archerWrapper {cmd eflag hflag sflag tflag args} { - SetWaitCursor + SetWaitCursor $this if {$eflag} { set optionsAndArgs [eval dbExpand $args] @@ -1714,7 +1714,7 @@ } if {[catch {eval gedCmd $cmd $options $expandedArgs} ret]} { - SetNormalCursor + SetNormalCursor $this return $ret } @@ -1727,7 +1727,7 @@ if {$tflag} { catch {refreshTree} } - SetNormalCursor + SetNormalCursor $this return $ret } @@ -1760,75 +1760,22 @@ set parent [$itk_component(aboutDialog) childsite] itk_component add aboutDialogTabs { - blt::tabnotebook $parent.tabs \ - -side bottom \ - -relief flat \ - -tiers 99 \ - -tearoff 0 \ - -gap 3 \ - -width 0 \ - -height 0 \ - -outerpad 0 \ - -highlightthickness 1 \ - -selectforeground black + ttk::notebook $parent.tabs } {} - $itk_component(aboutDialogTabs) configure \ - -highlightcolor [$itk_component(aboutDialogTabs) cget -background] \ - -borderwidth 0 \ - -font $mFontText - $itk_component(aboutDialogTabs) insert end -text "About" -stipple gray25 - $itk_component(aboutDialogTabs) insert end -text "License" -stipple gray25 - $itk_component(aboutDialogTabs) insert end -text "Acknowledgements" -stipple gray25 - # About Info - # set aboutImg [image create photo -file [file join $env(ARCHER_HOME) $brlcadDataPath tclscripts archer images aboutArcher.png]] set aboutImg [image create photo -file [file join $brlcadDataPath tclscripts archer images aboutArcher.png]] itk_component add aboutInfo { ::label $itk_component(aboutDialogTabs).aboutInfo \ -image $aboutImg } {} - set aboutTabIndex 0 - $itk_component(aboutDialogTabs) tab configure $aboutTabIndex \ - -window $itk_component(aboutInfo) \ - -fill both - - - # License Info - itk_component add licenseDialogTabs { - blt::tabnotebook $itk_component(aboutDialogTabs).tabs \ - -side top \ - -relief flat \ - -tiers 99 \ - -tearoff 0 \ - -gap 3 \ - -width 0 \ - -height 0 \ - -outerpad 0 \ - -highlightthickness 1 \ - -selectforeground black - } {} - $itk_component(licenseDialogTabs) configure \ - -highlightcolor [$itk_component(licenseDialogTabs) cget -background] \ - -borderwidth 0 \ - -font $mFontText - $itk_component(licenseDialogTabs) insert end -text "BRL-CAD" -stipple gray25 - - incr aboutTabIndex - $itk_component(aboutDialogTabs) tab configure $aboutTabIndex \ - -window $itk_component(licenseDialogTabs) \ - -fill both - - set licenseTabIndex -1 - # BRL-CAD License Info - # set fd [open [file join $env(ARCHER_HOME) $brlcadDataPath COPYING] r] set fd [open [file join $brlcadDataPath COPYING] r] set mBrlcadLicenseInfo [read $fd] close $fd itk_component add brlcadLicenseInfo { - ::iwidgets::scrolledtext $itk_component(licenseDialogTabs).brlcadLicenseInfo \ + ::iwidgets::scrolledtext $itk_component(aboutDialogTabs).brlcadLicenseInfo \ -wrap word \ -hscrollmode dynamic \ -vscrollmode dynamic \ @@ -1839,12 +1786,6 @@ $itk_component(brlcadLicenseInfo) insert 0.0 $mBrlcadLicenseInfo $itk_component(brlcadLicenseInfo) configure -state disabled - incr licenseTabIndex - $itk_component(licenseDialogTabs) tab configure $licenseTabIndex \ - -window $itk_component(brlcadLicenseInfo) \ - -fill both - - # Acknowledgement Info # set fd [open [file join $env(ARCHER_HOME) $brlcadDataPath doc archer_ack.txt] r] set fd [open [file join $brlcadDataPath doc archer_ack.txt] r] @@ -1862,10 +1803,9 @@ $itk_component(ackInfo) insert 0.0 $mAckInfo $itk_component(ackInfo) configure -state disabled - incr aboutTabIndex - $itk_component(aboutDialogTabs) tab configure $aboutTabIndex \ - -window $itk_component(ackInfo) \ - -fill both + $itk_component(aboutDialogTabs) add $itk_component(aboutInfo) -text "About" + $itk_component(aboutDialogTabs) add $itk_component(brlcadLicenseInfo) -text "License" + $itk_component(aboutDialogTabs) add $itk_component(ackInfo) -text "Acknowledgements" # Version Info itk_component add versionInfo { @@ -2024,6 +1964,8 @@ grid rowconfigure $oglParent 0 -weight 1 grid columnconfigure $oglParent 0 -weight 1 + + $itk_component(preferenceTabs) add $itk_component(displayLF) -text "Display" } @@ -2417,31 +2359,33 @@ grid rowconfigure $parent 0 -weight 1 grid columnconfigure $parent 0 -weight 1 + + $itk_component(preferenceTabs) add $itk_component(generalLF) -text "General" } ::itcl::body Archer::buildGroundPlanePreferences {} { - itk_component add groundPlaneF { - ::iwidgets::Labeledframe $itk_component(preferenceTabs).groundPlaneF \ + itk_component add groundPlaneLF { + ::iwidgets::Labeledframe $itk_component(preferenceTabs).groundPlaneLF \ -labeltext "Ground Plane Settings" \ -labelpos nw \ -borderwidth 2 \ -relief groove } - set parent [$itk_component(groundPlaneF) childsite] - itk_component add groundPlaneF2 { + set parent [$itk_component(groundPlaneLF) childsite] + itk_component add groundPlaneF { ::frame $parent.groundPlaneF } {} itk_component add groundPlaneSizeL { - ::label $itk_component(groundPlaneF2).sizeL \ + ::label $itk_component(groundPlaneF).sizeL \ -anchor e \ -text "Square Size:" } {} set hbc [$itk_component(groundPlaneSizeL) cget -background] itk_component add groundPlaneSizeE { - ::entry $itk_component(groundPlaneF2).sizeE \ + ::entry $itk_component(groundPlaneF).sizeE \ -width 12 \ -background $SystemWindow \ -highlightbackground $hbc \ @@ -2450,19 +2394,19 @@ -vcmd [::itcl::code $this validateDouble %P] } {} itk_component add groundPlaneSizeUnitsL { - ::label $itk_component(groundPlaneF2).sizeUnitsL \ + ::label $itk_component(groundPlaneF).sizeUnitsL \ -anchor e \ -text "mm" } {} itk_component add groundPlaneIntervalL { - ::label $itk_component(groundPlaneF2).intervalL \ + ::label $itk_component(groundPlaneF).intervalL \ -anchor e \ -text "Line Interval:" } {} set hbc [$itk_component(groundPlaneIntervalL) cget -background] itk_component add groundPlaneIntervalE { - ::entry $itk_component(groundPlaneF2).intervalE \ + ::entry $itk_component(groundPlaneF).intervalE \ -width 12 \ -background $SystemWindow \ -highlightbackground $hbc \ @@ -2471,19 +2415,19 @@ -vcmd [::itcl::code $this validateDouble %P] } {} itk_component add groundPlaneIntervalUnitsL { - ::label $itk_component(groundPlaneF2).intervalUnitsL \ + ::label $itk_component(groundPlaneF).intervalUnitsL \ -anchor e \ -text "mm" } {} - buildComboBox $itk_component(groundPlaneF2) \ + buildComboBox $itk_component(groundPlaneF) \ groundPlaneMajorColor \ majorColor \ mGroundPlaneMajorColorPref \ "Major Color:" \ $mColorListNoTriple - buildComboBox $itk_component(groundPlaneF2) \ + buildComboBox $itk_component(groundPlaneF) \ groundPlaneMinorColor \ minorColor \ mGroundPlaneMinorColorPref \ @@ -2506,10 +2450,12 @@ grid $itk_component(groundPlaneMinorColorF) -column 1 -row $i -sticky ew set i 0 - grid $itk_component(groundPlaneF2) -column 0 -row $i -sticky nw + grid $itk_component(groundPlaneF) -column 0 -row $i -sticky nw grid rowconfigure $parent 0 -weight 1 grid columnconfigure $parent 0 -weight 1 + + $itk_component(preferenceTabs) add $itk_component(groundPlaneLF) -text "Ground Plane" } @@ -2599,20 +2545,20 @@ ::itcl::body Archer::buildModelAxesPreferences {} { - itk_component add modelAxesF { - ::iwidgets::Labeledframe $itk_component(preferenceTabs).modelAxesF \ + itk_component add modelAxesLF { + ::iwidgets::Labeledframe $itk_component(preferenceTabs).modelAxesLF \ -labeltext "Model Axes Settings" \ -labelpos nw \ -borderwidth 2 \ -relief groove } - set parent [$itk_component(modelAxesF) childsite] - itk_component add modelAxesF2 { + set parent [$itk_component(modelAxesLF) childsite] + itk_component add modelAxesF { ::frame $parent.modelAxesF } {} - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesSize \ size \ mModelAxesSizePref \ @@ -2621,30 +2567,30 @@ "View (1x)" "View (2x)" "View (4x)" "View (8x)"} # itk_component add modelAxesPositionL { - # ::label $itk_component(modelAxesF2).positionL \ + # ::label $itk_component(modelAxesF).positionL \ # -text "Position:" # } # itk_component add modelAxesPositionF { - # ::frame $itk_component(modelAxesF2).positionF + # ::frame $itk_component(modelAxesF).positionF # } {} # _build_model_axes_position $itk_component(modelAxesPositionF) - buildModelAxesPosition $itk_component(modelAxesF2) + buildModelAxesPosition $itk_component(modelAxesF) - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesLineWidth \ lineWidth \ mModelAxesLineWidthPref \ "Line Width:" \ {1 2 3} - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesColor \ color \ mModelAxesColorPref \ "Axes Color:" \ $mColorList - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesLabelColor \ labelColor \ mModelAxesLabelColorPref \ @@ -2652,12 +2598,12 @@ $mColorListNoTriple itk_component add modelAxesTickIntervalL { - ::label $itk_component(modelAxesF2).tickIntervalL \ + ::label $itk_component(modelAxesF).tickIntervalL \ -text "Tick Interval:" } {} set hbc [$itk_component(modelAxesTickIntervalL) cget -background] itk_component add modelAxesTickIntervalE { - ::entry $itk_component(modelAxesF2).tickIntervalE \ + ::entry $itk_component(modelAxesF).tickIntervalE \ -textvariable [::itcl::scope mModelAxesTickIntervalPref] \ -validate key \ -validatecommand [::itcl::code $this validateTickInterval %P] \ @@ -2665,42 +2611,42 @@ -highlightbackground $hbc } {} - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesTicksPerMajor \ ticksPerMajor \ mModelAxesTicksPerMajorPref \ "Ticks Per Major:" \ {2 3 4 5 6 8 10 12} - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesTickThreshold \ tickThreshold \ mModelAxesTickThresholdPref \ "Tick Threshold:" \ {4 8 16 32 64} - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesTickLength \ tickLength \ mModelAxesTickLengthPref \ "Tick Length:" \ {2 4 8 16} - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesTickMajorLength \ tickMajorLength \ mModelAxesTickMajorLengthPref \ "Major Tick Length:" \ {2 4 8 16} - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesTickColor \ tickColor \ mModelAxesTickColorPref \ "Tick Color:" \ $mColorListNoTriple - buildComboBox $itk_component(modelAxesF2) \ + buildComboBox $itk_component(modelAxesF) \ modelAxesTickMajorColor \ tickMajorColor \ mModelAxesTickMajorColorPref \ @@ -2754,10 +2700,12 @@ grid $itk_component(modelAxesTickMajorColorF) -column 1 -row $i -sticky ew set i 0 - grid $itk_component(modelAxesF2) -column 0 -row $i -sticky nw + grid $itk_component(modelAxesF) -column 0 -row $i -sticky nw grid rowconfigure $parent 0 -weight 1 grid columnconfigure $parent 0 -weight 1 + + $itk_component(preferenceTabs) add $itk_component(modelAxesLF) -text "Model Axes" } @@ -2907,47 +2855,14 @@ set parent [$itk_component(preferencesDialog) childsite] itk_component add preferenceTabs { - blt::tabnotebook $parent.tabs \ - -side left \ - -relief flat \ - -tiers 99 \ - -tearoff 0 \ - -gap 3 \ - -width 0 \ - -height 0 \ - -selectforeground black + ttk::notebook $parent.tabs } {} - $itk_component(preferenceTabs) insert end -text "General" -stipple gray25 - $itk_component(preferenceTabs) insert end -text "Model Axes" -stipple gray25 - $itk_component(preferenceTabs) insert end -text "View Axes" -stipple gray25 - $itk_component(preferenceTabs) insert end -text "Ground Plane" -stipple gray25 - $itk_component(preferenceTabs) insert end -text "Display" -stipple gray25 - - set i 0 buildGeneralPreferences - $itk_component(preferenceTabs) tab configure $i \ - -window $itk_component(generalLF) -fill both - - incr i buildModelAxesPreferences - $itk_component(preferenceTabs) tab configure $i \ - -window $itk_component(modelAxesF) -fill both - - incr i buildViewAxesPreferences - $itk_component(preferenceTabs) tab configure $i \ - -window $itk_component(viewAxesF) -fill both - - incr i buildGroundPlanePreferences - $itk_component(preferenceTabs) tab configure $i \ - -window $itk_component(groundPlaneF) -fill both - - incr i buildDisplayPreferences - $itk_component(preferenceTabs) tab configure $i \ - -window $itk_component(displayLF) -fill both pack $itk_component(preferenceTabs) -expand yes -fill both @@ -3239,48 +3154,48 @@ ::itcl::body Archer::buildViewAxesPreferences {} { - itk_component add viewAxesF { - ::iwidgets::Labeledframe $itk_component(preferenceTabs).viewAxesF \ + itk_component add viewAxesLF { + ::iwidgets::Labeledframe $itk_component(preferenceTabs).viewAxesLF \ -labeltext "View Axes Settings" \ -labelpos nw \ -borderwidth 2 \ -relief groove } - set parent [$itk_component(viewAxesF) childsite] - itk_component add viewAxesF2 { + set parent [$itk_component(viewAxesLF) childsite] + itk_component add viewAxesF { ::frame $parent.viewAxesF } {} - buildComboBox $itk_component(viewAxesF2) \ + buildComboBox $itk_component(viewAxesF) \ viewAxesSize \ size \ mViewAxesSizePref \ "Size:" \ {Small Medium Large X-Large} - buildComboBox $itk_component(viewAxesF2) \ + buildComboBox $itk_component(viewAxesF) \ viewAxesPosition \ position \ mViewAxesPositionPref \ "Position:" \ {Center "Upper Left" "Upper Right" "Lower Left" "Lower Right"} - buildComboBox $itk_component(viewAxesF2) \ + buildComboBox $itk_component(viewAxesF) \ viewAxesLineWidth \ lineWidth \ mViewAxesLineWidthPref \ "Line Width:" \ {1 2 3} - buildComboBox $itk_component(viewAxesF2) \ + buildComboBox $itk_component(viewAxesF) \ viewAxesColor \ color \ mViewAxesColorPref \ "Axes Color:" \ $mColorList - buildComboBox $itk_component(viewAxesF2) \ + buildComboBox $itk_component(viewAxesF) \ viewAxesLabelColor \ labelColor \ mViewAxesLabelColorPref \ @@ -3304,17 +3219,19 @@ grid $itk_component(viewAxesLabelColorF) -column 1 -row $i -sticky ew set i 0 - grid $itk_component(viewAxesF2) -column 0 -row $i -sticky nw + grid $itk_component(viewAxesF) -column 0 -row $i -sticky nw grid rowconfigure $parent 0 -weight 1 grid columnconfigure $parent 0 -weight 1 + + $itk_component(preferenceTabs) add $itk_component(viewAxesLF) -text "View Axes" } ::itcl::body Archer::doAboutArcher {} { - bind $itk_component(aboutDialog) <Enter> "raise $itk_component(aboutDialog)" - bind $itk_component(aboutDialog) <Configure> "raise $itk_component(aboutDialog)" - bind $itk_component(aboutDialog) <FocusOut> "raise $itk_component(aboutDialog)" +# bind $itk_component(aboutDialog) <Enter> "raise $itk_component(aboutDialog)" +# bind $itk_component(aboutDialog) <Configure> "raise $itk_component(aboutDialog)" +# bind $itk_component(aboutDialog) <FocusOut> "raise $itk_component(aboutDialog)" $itk_component(aboutDialog) center [namespace tail $this] $itk_component(aboutDialog) activate @@ -6012,9 +5929,9 @@ # wm geometry $dialog "500x500" # Event bindings - bind $dialog <Enter> "raise $dialog" - bind $dialog <Configure> "raise $dialog" - bind $dialog <FocusOut> "raise $dialog" +# bind $dialog <Enter> "raise $dialog" +# bind $dialog <Configure> "raise $dialog" +# bind $dialog <FocusOut> "raise $dialog" $dialog center $w $dialog activate Modified: brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl =================================================================== --- brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl 2009-03-26 13:44:39 UTC (rev 34081) @@ -40,6 +40,7 @@ if {![info exists parentClass]} { set parentClass itk::Toplevel set inheritFromToplevel 1 + set cursorWaitCount 0 # if {$tcl_platform(platform) == "windows"} { # set parentClass itk::Toplevel @@ -635,23 +636,8 @@ set parent [$itk_component(hpane) childsite bottomView] itk_component add advancedTabs { - blt::tabnotebook $parent.tabs \ - -relief flat \ - -tiers 99 \ - -tearoff 1 \ - -gap 3 \ - -width 0 \ - -height 0 \ - -outerpad 0 \ - -highlightthickness 1 \ - -selectforeground black + ttk::notebook $parent.tabs } {} - $itk_component(advancedTabs) configure \ - -highlightcolor [$itk_component(advancedTabs) cget -background] \ - -borderwidth 0 \ - -font $mFontText - $itk_component(advancedTabs) insert end -text "Command" -stipple gray25 - $itk_component(advancedTabs) insert end -text "History" -stipple gray25 itk_component add cmd { Command $itk_component(advancedTabs).cmd \ @@ -662,12 +648,6 @@ -prompt2 "% " -result_color black -cmd_color red } {} - set i 0 - $itk_component(advancedTabs) tab configure $i \ - -window $itk_component(cmd) \ - -fill both - incr i - itk_component add history { ::iwidgets::scrolledtext $itk_component(advancedTabs).history \ -relief sunken -borderwidth 2 \ @@ -675,10 +655,10 @@ -scrollmargin 2 -visibleitems 80x15 \ -textbackground $SystemWindow } {} - $itk_component(advancedTabs) tab configure $i \ - -window $itk_component(history) \ - -fill both [$itk_component(history) component text] configure -state disabled + + $itk_component(advancedTabs) add $itk_component(cmd) -text "Command" + $itk_component(advancedTabs) add $itk_component(history) -text "History" } # vertical panes @@ -1046,7 +1026,7 @@ return } - SetWaitCursor + SetWaitCursor $this if {$eflag} { set optionsAndArgs [eval dbExpand $args] @@ -1072,7 +1052,7 @@ } if {[catch {eval gedCmd $cmd $options $expandedArgs} ret]} { - SetNormalCursor + SetNormalCursor $this return $ret } @@ -1085,7 +1065,7 @@ if {$tflag} { catch {refreshTree} } - SetNormalCursor + SetNormalCursor $this return $ret } @@ -1542,6 +1522,7 @@ set mLastSelectedDir [file dirname $target] } + ::update Load $target } @@ -1673,7 +1654,7 @@ set mNeedSave 1 updateSaveMode - SetWaitCursor + SetWaitCursor $this gedCmd kill $comp set select [$itk_component(tree) selection get] @@ -1702,18 +1683,18 @@ set parent [$itk_component(tree) query -parent $element] $itk_component(tree) remove $element $parent refreshTree - SetNormalCursor + SetNormalCursor $this } ::itcl::body ArcherCore::doCopyOrMove {top comp cmd} { set mNeedSave 1 updateSaveMode - SetWaitCursor + SetWaitCursor $this set comp2 [string trim [$top.entry get]] wm withdraw $top gedCmd $cmd $comp refreshTree - SetNormalCursor + SetNormalCursor $this destroy $top } @@ -2194,7 +2175,7 @@ ::itcl::body ArcherCore::render {node state trans updateTree {wflag 1}} { if {$wflag} { - SetWaitCursor + SetWaitCursor $this } set savePwd "" @@ -2275,7 +2256,7 @@ } if {$wflag} { - SetNormalCursor + SetNormalCursor $this } } @@ -2384,7 +2365,7 @@ } ::itcl::body ArcherCore::doLighting {} { - SetWaitCursor + SetWaitCursor $this if {$mZClipMode != $ZCLIP_NONE} { gedCmd zclip_all $mLighting @@ -2393,7 +2374,7 @@ gedCmd zbuffer_all $mLighting gedCmd light_all $mLighting - SetNormalCursor + SetNormalCursor $this } ::itcl::body ArcherCore::doViewReset {} { @@ -2853,6 +2834,7 @@ # GENERAL # ------------------------------------------------------------ ::itcl::body ArcherCore::Load {target} { + SetWaitCursor $this if {$mNeedSave} { $itk_component(saveDialog) center [namespace tail $this] if {[$itk_component(saveDialog) activate]} { @@ -2933,9 +2915,7 @@ deleteTargetOldCopy # refresh tree contents - SetWaitCursor refreshTree 0 - SetNormalCursor } else { doLighting } @@ -2945,6 +2925,7 @@ set mDefaultBindingMode $ROTATE_MODE beginViewRotate } + SetNormalCursor $this } ::itcl::body ArcherCore::GetUserCmds {} { @@ -3799,7 +3780,7 @@ } if {$wflag} { - SetWaitCursor + SetWaitCursor $this } set optionsAndArgs [eval dbExpand $args] @@ -3815,7 +3796,7 @@ if {[catch {eval gedCmd draw $options $tobjects} ret]} { gedCmd configure -primitiveLabels {} refreshTree - SetNormalCursor + SetNormalCursor $this return $ret } @@ -3823,7 +3804,7 @@ gedCmd configure -primitiveLabels {} refreshTree if {$wflag} { - SetNormalCursor + SetNormalCursor $this } return $ret @@ -3850,7 +3831,7 @@ return } - SetWaitCursor + SetWaitCursor $this set optionsAndArgs [eval dbExpand $args] set options [lindex $optionsAndArgs 0] @@ -3864,14 +3845,14 @@ if {[catch {eval gedCmd erase $tobjects} ret]} { gedCmd configure -primitiveLabels {} refreshTree - SetNormalCursor + SetNormalCursor $this return $ret } gedCmd configure -primitiveLabels {} refreshTree - SetNormalCursor + SetNormalCursor $this } ::itcl::body ArcherCore::erase_all {args} { Modified: brlcad/trunk/src/tclscripts/archer/CombEditFrame.tcl =================================================================== --- brlcad/trunk/src/tclscripts/archer/CombEditFrame.tcl 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/tclscripts/archer/CombEditFrame.tcl 2009-03-26 13:44:39 UTC (rev 34081) @@ -51,9 +51,9 @@ # variable mMaterial "" variable mInherit "" - method buildGeneralGUI {parent tabs ti} - method buildShaderGUI {parent tabs ti} - method buildTreeGUI {parent tabs ti} + method buildGeneralGUI {} + method buildShaderGUI {} + method buildTreeGUI {} # Override what's in GeometryEditFrame method updateGeometryIfMod {} @@ -71,32 +71,12 @@ set parent [childsite upper] itk_component add tabs { - blt::tabnotebook $parent.tabs \ - -relief flat \ - -tiers 99 \ - -tearoff 0 \ - -gap 3 \ - -width 0 \ - -height 0 \ - -outerpad 2 \ - -highlightthickness 1 \ - -selectforeground black + ttk::notebook $parent.tabs } {} - $itk_component(tabs) configure \ - -highlightcolor [$itk_component(tabs) cget -background] \ - -borderwidth 0 \ - -font [list $ArcherCore::SystemWindowFont 8] - $itk_component(tabs) insert end -text "General" -stipple gray25 - $itk_component(tabs) insert end -text "Shader" -stipple gray25 - $itk_component(tabs) insert end -text "Tree" -stipple gray25 - set parent $itk_component(tabs) - set ti 0 - buildGeneralGUI $parent $itk_component(tabs) $ti - incr ti - buildShaderGUI $parent $itk_component(tabs) $ti - incr ti - buildTreeGUI $parent $itk_component(tabs) $ti + buildGeneralGUI + buildShaderGUI + buildTreeGUI pack $itk_component(tabs) -expand yes -fill both @@ -264,9 +244,9 @@ # PROTECTED METHODS # ------------------------------------------------------------ -::itcl::body CombEditFrame::buildGeneralGUI {parent tabs tabIndex} { +::itcl::body CombEditFrame::buildGeneralGUI {} { itk_component add combGeneralF { - ::frame $parent.combgeneralf + ::frame $itk_component(tabs).combgeneralf } {} set parent $itk_component(combGeneralF) @@ -446,16 +426,11 @@ -row $row \ -sticky nsew grid columnconfigure $parent 1 -weight 1 - pack $itk_component(combGeneralF) -expand yes -fill x -anchor n + # pack $itk_component(combGeneralF) -expand yes -fill both # pack $parent -expand yes -fill x -anchor n # grid columnconfigure [namespace tail $this] 1 -weight 1 - $tabs tab configure $tabIndex \ - -window $itk_component(combGeneralF) \ - -fill x \ - -anchor n - # Set up bindings bind $itk_component(combIdE) <Return> [::itcl::code $this updateGeometryIfMod] bind $itk_component(combAirE) <Return> [::itcl::code $this updateGeometryIfMod] @@ -471,24 +446,24 @@ # bind $itk_component(combMaterialE) <Return> [::itcl::code $this updateGeometryIfMod] # bind $itk_component(combInheritE) <Return> [::itcl::code $this updateGeometryIfMod] + + $itk_component(tabs) add $itk_component(combGeneralF) -text "General" } -::itcl::body CombEditFrame::buildShaderGUI {parent tabs ti} { +::itcl::body CombEditFrame::buildShaderGUI {} { itk_component add combShader { - ::ShaderEdit $parent.shader \ + ::ShaderEdit $itk_component(tabs).shader \ -shaderChangedCallback [::itcl::code $this updateGeometryIfMod] } {} - $tabs tab configure $ti \ - -window $itk_component(combShader) \ - -fill both - # bind $itk_component(combShaderE) <Return> [::itcl::code $this updateGeometryIfMod] + + $itk_component(tabs) add $itk_component(combShader) -text "Shader" } -::itcl::body CombEditFrame::buildTreeGUI {parent tabs ti} { +::itcl::body CombEditFrame::buildTreeGUI {} { itk_component add combTreeF { - ::frame $parent.treef + ::frame $itk_component(tabs).treef } {} set parent $itk_component(combTreeF) @@ -502,17 +477,13 @@ grid $itk_component(combTreeT) \ -row 0 \ -sticky nsew - # pack $itk_component(combTreeT) -expand yes -fill both - pack $itk_component(combTreeF) -expand yes -fill both - $tabs tab configure $ti \ - -window $itk_component(combTreeF) \ - -fill both - # bind $itk_component(combTreeT) <Leave> [::itcl::code $this updateGeometryIfMod] # bind $itk_component(combTreeT) <Return> [::itcl::code $this updateGeometryIfMod] # bind $itk_component(combTreeT) <FocusOut> [::itcl::code $this updateGeometryIfMod] bind $itk_component(combTreeT) <KeyRelease> [::itcl::code $this updateGeometryIfMod] + + $itk_component(tabs) add $itk_component(combTreeF) -text "Tree" } ::itcl::body CombEditFrame::updateGeometryIfMod {} { Modified: brlcad/trunk/src/tclscripts/archer/bgerror.tcl =================================================================== --- brlcad/trunk/src/tclscripts/archer/bgerror.tcl 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/tclscripts/archer/bgerror.tcl 2009-03-26 13:44:39 UTC (rev 34081) @@ -487,8 +487,8 @@ # Make sure the wait cursor is unlocked if [info exists App::gui] { $App::gui SetStatusString + SetNormalCursor $App::gui } - SetNormalCursor } SAVE { # already handled by bgerrorSave procedure Modified: brlcad/trunk/src/tclscripts/archer/cursor.tcl =================================================================== --- brlcad/trunk/src/tclscripts/archer/cursor.tcl 2009-03-26 06:37:24 UTC (rev 34080) +++ brlcad/trunk/src/tclscripts/archer/cursor.tcl 2009-03-26 13:44:39 UTC (rev 34081) @@ -29,22 +29,7 @@ #*** ############################################################## -if {$tcl_platform(os) == "Windows NT"} { - package require BLT -} else { - # For the moment, leave it this way for - # all other platforms. - #package require blt - package require BLT -} -# avoid a pkg_index error about ::blt:: being unknown -namespace eval blt {} - -if {![info exists ::blt::cursorWaitCount]} { - set ::blt::cursorWaitCount 0 -} - # PROCEDURE: SetWaitCursor # # Changes the cursor for all of the GUI's widgets to the wait cursor. @@ -55,25 +40,16 @@ # Results: # None # -proc SetWaitCursor {} { - incr ::blt::cursorWaitCount +proc SetWaitCursor {_w} { + incr ::ArcherCore::cursorWaitCount - if {1 < $::blt::cursorWaitCount} { + if {1 < $::ArcherCore::cursorWaitCount} { # Already in cursor wait mode return } - update idletasks - set children [winfo children .] - foreach kid $children { - if {![catch {$kid isa "::itk::Toplevel"} result]} { - switch -- $result { - "1" {catch {blt::busy $kid}} - } - } - } - blt::busy . - update + $_w configure -cursor watch + ::update idletasks } # PROCEDURE: SetNormalCursor @@ -86,29 +62,15 @@ # Results: # None # -proc SetNormalCursor {} { - incr ::blt::cursorWaitCount -1 - if {$::blt::cursorWaitCount < 0} { - # Already in cursor normal mode - set ::blt::cursorWaitCount 0 - return - } +proc SetNormalCursor {_w} { + incr ::ArcherCore::cursorWaitCount -1 - if {$::blt::cursorWaitCount != 0} { + if {$::ArcherCore::cursorWaitCount != 0} { return } - update idletasks - set children [winfo children .] - foreach kid $children { - if {![catch {$kid isa "::itk::Toplevel"} result]} { - switch -- $result { - "1" {catch {blt::busy release $kid}} - } - } - } - blt::busy release . - update + $_w configure -cursor {} + ::update idletasks } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sta...@us...> - 2009-04-06 19:21:35
|
Revision: 34163 http://brlcad.svn.sourceforge.net/brlcad/?rev=34163&view=rev Author: starseeker Date: 2009-04-06 19:21:25 +0000 (Mon, 06 Apr 2009) Log Message: ----------- Remove old man pages that have been incorporated into the docbook system. Modified Paths: -------------- brlcad/trunk/src/anim/Makefile.am brlcad/trunk/src/gtools/Makefile.am brlcad/trunk/src/irprep/Makefile.am brlcad/trunk/src/mged/Makefile.am brlcad/trunk/src/nirt/Makefile.am brlcad/trunk/src/rt/Makefile.am brlcad/trunk/src/util/Makefile.am Removed Paths: ------------- brlcad/trunk/src/anim/anim_cascade.1 brlcad/trunk/src/anim/anim_fly.1 brlcad/trunk/src/anim/anim_hardtrack.1 brlcad/trunk/src/anim/anim_keyread.1 brlcad/trunk/src/anim/anim_lookat.1 brlcad/trunk/src/anim/anim_offset.1 brlcad/trunk/src/anim/anim_orient.1 brlcad/trunk/src/gtools/g_qa.1 brlcad/trunk/src/irprep/all_sf.1 brlcad/trunk/src/mged/mged.1 brlcad/trunk/src/nirt/nirt.1 brlcad/trunk/src/rt/rt.1 brlcad/trunk/src/rt/rtarea.1 brlcad/trunk/src/rt/rtcheck.1 brlcad/trunk/src/rt/rtedge.1 brlcad/trunk/src/util/alias-pix.1 brlcad/trunk/src/util/bwscale.1 Modified: brlcad/trunk/src/anim/Makefile.am =================================================================== --- brlcad/trunk/src/anim/Makefile.am 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/anim/Makefile.am 2009-04-06 19:21:25 UTC (rev 34163) @@ -64,13 +64,6 @@ chan_permute_LDADD = ${BU} man_MANS = \ - anim_cascade.1 \ - anim_fly.1 \ - anim_hardtrack.1 \ - anim_keyread.1 \ - anim_lookat.1 \ - anim_offset.1 \ - anim_orient.1 \ anim_script.1 \ anim_sort.1 \ anim_time.1 \ Deleted: brlcad/trunk/src/anim/anim_cascade.1 =================================================================== --- brlcad/trunk/src/anim/anim_cascade.1 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/anim/anim_cascade.1 2009-04-06 19:21:25 UTC (rev 34163) @@ -1,228 +0,0 @@ -.TH ANIM_CASCADE 1 BRL-CAD -.\" A N I M _ C A S C A D E . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 1993-2009 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.SH NAME -anim_cascade - evaluate movement of an object relative to a moving frame of -reference -.SH SYNOPSIS -.B anim_cascade [-s][-o(f|r|a)] [-(f|r|a)(c|y) # # #] < -.B input.table > -.B output.table -.SH DESCRIPTION -.I Anim_cascade -is designed to enable the user to control the movement of objects relative to -other objects. In the normal mode of operation, the user supplies -the position and orientation of a (possibly moving) frame of reference and -the position -and orientation of an object relative to the frame of reference, -and -.I anim_cascade -produces the absolute position and orientation of the object at each -point in time. -All orientations are specified as yaw, pitch, and roll. -The columns of the input table are: -.sp -time fx fy fz fyaw fpitch froll rx ry rz ryaw rpitch rroll -.sp -and the columns of the output table are: -.sp -time ax ay az ayaw apitch aroll -.sp -Here "f" refers to the frame of reference, "r" refers to the position -and orientation of the object relative to the frame, and "a" -refers to the absolute position and orientation of the object. - -.SH OPTIONS -.TP -.B \-or -Output the relative position and orientation. -If this option is specified, -.I anim_cascade -will expect the absolute position and orientation of the frame of -reference and the object as input, -and will produce the position and orientation or the object relative to -the frame as output. The -input columns should be: -.sp -time fx fy fz fyaw fpitch froll ax ay az ayaw apitch aroll -.sp -and the output columns will be: -.sp -time rx ry rz ryaw rpitch rroll -.sp -.TP -.B \-of -Output the frame of reference. -If this option is specified, -.I anim_cascade -will expect the absolute and relative positions and orientations of the -object as input, -and will produce the corresponding frame of reference as output. -The input columns should be: -.sp -time ax ay az ayaw apitch aroll rx ry rz ryaw rpitch rroll -.sp -and the output columns will be: -.sp -time fx fy fz fyaw fpitch froll -.sp -.TP -.B \-fc # # # -Specify a constant position for the frame of reference. The -columns fx, fy, and fz should be omitted from the input table, and the -command-line arguments will be used instead. -This has no effect if used -in conjunction with -.B -of -.TP -.B \-fy # # # -Specify a constant orientation for the frame of reference. The -columns fyaw, fpitch, and froll should be omitted from the input table, -and the command-line arguments will be used instead. -This has no effect if used -in conjunction with -.BR -of . -.TP -.B \-rc # # # -Specify a constant position of the object relative to the frame -of reference. The -columns rx, ry, and rz should be omitted from the input table, and the -command-line arguments will be used instead. -This has no effect if used -in conjunction with -.BR -or . -.TP -.B \-ry # # # -Specify a constant orientation of the object relative to the -frame of reference. The -columns ryaw, rpitch, and rroll should be omitted from the input table, -and the command-line arguments will be used instead. -This has no effect if used -in conjunction with -.BR -or . -.TP -.B \-ac # # # -Specify a constant absolute position for the object. The -columns ax, ay, and az should be omitted from the input table, and the -command-line arguments will be used instead. -This has no effect unless used -in conjunction with -.B -or -or -.BR -of . -.TP -.B \-ay # # # -Specify a constant absolute orientation for the object. The -columns ayaw, apitch, and aroll should be omitted from the input table, -and the -command-line arguments will be used instead. -This has no effect unless used -in conjunction with -.B -or -or -.BR -of . -.TP -.B \-s -Suppress time column. No time column is read or written. -.sp -Note: When all of the input columns are specified with command-line arguments, -then standard input is not read and -only one line of output is produced. The time value will be set to zero, -unless it is suppressed. - -.SH EXAMPLES -1. Suppose that you want the virtual camera to pan in a circle around a -moving vehicle, always staying a fixed distance from the vehicle. -There should already exist an animation table with the time, position, -and orientation of the vehicle in each frame. This will be the moving -frame of reference. Next, you should create an animation table which -describes how the camera would need to move if the vehicle stood still -at the origin. The columns of the second animation table should be -appended to the columns of the first table -(using -.IR paste , -for example), to create the -input table. -.I Anim_cascade -will produce an absolute animation table for -the camera, suitable to use as input to -.IR anim_script : -.sp -anim_cascade < input.table | anim_script -v500 > view.script -.sp -2. Suppose that you have an animation path for an object and you want to -know when it crosses a given oblique plane. You can use the -.B -or -option to -find out what the position of the object is relative to the frame of -reference of the plane. Suppose that the plane is defined by the -equation: -.sp - x + z = 0 -.sp -In a frame of reference located at the origin with a pitch of 45 -degrees, the x-axis is perpendicular to the given plane. -To convert the absolute animation path into this frame of reference, the command -would be: -.sp -anim_cascade -or -fc 0 0 0 -fy 0 45 0 < absolute.table > relative.table -.sp -Wherever the x coordinate in the output table is positive, the object -lies above the plane. -.sp -3. Suppose that one object is situated at the point (1,2,3) with a yaw, -pitch, and roll of (45, 25, 10). Suppose further that you want to -position a camera so that to the camera, the first object seems to be 10 -units straight ahead, facing to the right. You could find the required -position and orientation of the camera with the following command: -.sp -anim_cascade -s -of -ac 1 2 3 -ay 45 25 10 -rc 10 0 0 -ry -90 0 0 -.sp - -.SH AUTHOR -Carl J. Nuzman -.SH COPYRIGHT - This software is Copyright (c) 1993-2009 by the United States Government -as represented by the U.S. Army Research Laboratory. - -in all countries except the USA. All rights reserved. -.SH "BUG REPORTS" -Reports of bugs or problems should be submitted via electronic -mail to <de...@br...>. Deleted: brlcad/trunk/src/anim/anim_fly.1 =================================================================== --- brlcad/trunk/src/anim/anim_fly.1 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/anim/anim_fly.1 2009-04-06 19:21:25 UTC (rev 34163) @@ -1,134 +0,0 @@ -.TH ANIM_FLY 1 BRL-CAD -.\" A N I M _ F L Y . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 1993-2009 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.SH NAME -anim_fly - make animation table to simulate flying motion -.SH SYNOPSIS -.B anim_fly -.B [-f factor] -.B [-r] -.B [-p integer] -.B [-b max_bank_angle] -.B [-s step] -.B < in.table -.B > out.table -.SH DESCRIPTION -This filter is designed to simulate the motion of an airplane. -Given a four-column table specifying the desired 3D position of the -airplane at each relevant time step, -.I anim_fly -produces a seven-column file -which also includes the orientation of the plane in terms of yaw, -pitch, and roll. The yaw and pitch are manipulated so that -the plane faces the direction of motion, while the roll is used to do -banking. -.SH OPTIONS -.TP -.B -f# -This option specifies a factor to control the severity of the banking. -The best factor is a subjective decision; a good starting point can best -be obtained by using the -b option. Animations representing aircraft -of different scales will need different factors. -If the -slightest curve throws the plane into a 90 degree bank, the factor is -too large; if it doesn't bank enough, the factor is too small. The size -of the best factor varies inversely with the size of the imagined -aircraft plane. -If a factor of 0 is used, there will -be no banking. This would be appropriate for animating a ground -vehicle. -.TP -.B -b# -This option is used to estimate a good value for the -f option. The -parameter is the maximum desired banking angle. Anim_fly then computes -the factor necessary to keep the banking below the specified angle. This -value is returned instead of anim_fly's usual output. -.TP -.B -r -Suppress vertical loop smoothing. -A special case occurs if the aircraft is to perform a vertical -loop. Normally, the algorithm likes to keep the aircraft right-side up. -This would cause the airplane to do an instantaneous 180 roll as it hits -the vertical portion of the loop. To counter this, a capability was -built in which prevents this sudden roll, allowing the aircraft to go -upside-down in a loop situation. This feature can be suppressed with the -.B -r -flag. -.TP -.B -p -Specify the ratio of input rows to output rows, which must be -an integer. The default, of course, is one. The accuracy of the output -depends on having a large number of input lines, which is not usually a -problem in animations, which require a large number of frames per -second, anyway. If a test animation with a small number of frames per -second is being created, the user should still use an input table -with a high number of input rows, reducing the frequency of the output -with the -.B -p -option. For example, if -.B in.table -contains 30 rows for each -second of the animation, then the command: -.sp -anim_fly -f0.001 -p10 < in.table > out.table -.sp -would produce an animation table containing 3 rows for each -second of the animation. -.TP -.B -s -Specify the minimum step size for the discrete-time differentiation. At any -given point on the flight path, the yaw, pitch, and roll are calculated based -on a past point, the current point, and a future point. Normally, -these are consecutive points from the input table. If the time -difference between the points falls below a certain threshold, -then non-consecutive points are used to avoid -numerical instability. The default time threshhold is 0.1 seconds - this -can be raised or lowered using the -s option. -Try raising the threshold if the output orientations experience random -jiter. -.SH AUTHOR -Carl J. Nuzman -.SH COPYRIGHT -This software is Copyright (c) 1993-2009 by the United States -Government as represented by U.S. Army Research Laboratory. - -.SH "BUG REPORTS" -Reports of bugs or problems should be submitted via electronic -mail to <de...@br...>. Deleted: brlcad/trunk/src/anim/anim_hardtrack.1 =================================================================== --- brlcad/trunk/src/anim/anim_hardtrack.1 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/anim/anim_hardtrack.1 2009-04-06 19:21:25 UTC (rev 34163) @@ -1,349 +0,0 @@ -.TH ANIM_HARDTRACK 1 BRL-CAD -.\" A N I M _ H A R D T R A C K . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 1993-2009 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.SH NAME -anim_hardtrack - make an animation script for the links and/or wheels of a -tracked vehicle with rigid axles. -.SH SYNOPSIS -.B -anim_hardtrack [-l num_links linkname] [-w wheelname] [options] wheelfile < in.table > out.script -.SH DESCRIPTION -.I Anim_hardtrack -is designed to produce an animation script for the -animation of a track and/or the wheels defining a track, where the wheels -are rigidly fixed in place with respect to the vehicle. The main -difference between -.I anim_hardtrack -and -.I anim_track -is that -.I anim_track -handles vehicles with dynamic axles. Both are designed to be use in -conjunction with -.I anim_script, -to achieve the final result. -.PP -.B in.table -is the file that will be used to animate the -vehicle itself. By default, it is assumed that it contains a time column, -three columns of translation information, and three columns specifying the -vehicle's yaw, pitch, and roll. If it is desired that the vehicle be steered -automatically, then the table should contain only time and position, and the -.B -s -option should be used. -.PP -The track's -geometry is defined by -.BR wheelfile , -a table which contains one row for each wheel defining the track. The -first three columns of the table specify the x, y, and z coordinates of -the wheel centers. The fourth column specifies the radius of each wheel. -.PP -The order in which the wheels are listed should be the order in which a -link of the track would move around the wheels when the vehicle is moving -forward. (clockwise, when looking from the right of the vehicle). -The wheel centers should all lie in a plane perpendicular to the vehicle's -left-right axis. If this is not the case, -.I anim_hardtrack -uses the first wheel as the standard and projects all the other wheels into -the same plane as the first wheel. By default, it is assumed that the -vehicle's left-right axis is the y-axis. If the modeled vehicle has some -other orientation, this must be specified with the -.B -b -option. -.PP -By default, it is -assumed that -all of the link objects are modeled at the model origin, -with the wheel-contacting surface centered on the origin and the -ground-contacting surface facing up. The sides of each link which -connect to other links should face the positive and negative x-axes. -.I Anim_hardtrack -prints the appropriate -commands to move the links from -the origin to the correct place around the wheels. -.PP -If the links are modeled in place around the wheels to begin with, the -the -.B -p -and -.B -i -options are needed. - -.SH OPTIONS: -.PP -One or both of the first two options should always be specified. -.TP -.B \-l num linkname -Print animation scripts to animate the links of the track. Animation -commands will be printed for -.I num -different links -named -.IR linkname .0, linkname .1, -up through -.IR linkname .( num -1). -A typical example of a linkname might -be "tank/righttrack/links/link". The full pathname must be specified, -because anim_hardtrack's method is to roll the links around within -the vehicle's tree structure so that when the whole vehicle "tank" is -animated, the complete combination of rolling around and translating is -achieved. -.TP -.B \-w wheelname -Print animation -scripts to rotate each wheel. The wheels are named wheelname.0, wheelname.1, -and so on, where wheelname.0 is the first wheel listed in -.BR wheelfile . -As with the links, the full pathname for the wheels should be specified. -.TP -.B \-b # # # -Specify the yaw, pitch, and roll of the vehicle's axes -with respect to the world axes. By default, the vehicle is assumed to -have a yaw, pitch, and roll of 0. -.TP -.B \-d # # # -Specify (in world coordinates) the centroid of the vehicle -of which the track is a part. By default, the vehicle is assumed -centered at the origin. -.\" Should this be .PP? It munges up the indentation. -.PP -When calling -.I anim_script -to handle the animation of the vehicle -itself, the parameters following the -.B -b -and -.B -d -options should be identical -to those used for -.IR anim_hardtrack . -.TP -.B \-r # -Specify the common radius of all wheels. In this case the fourth column -should be omitted from the -.BR wheelfile . -.TP -.B \-s -Automatic steering. In this case, -.B in.table -specifies only the time and position -of the vehicle. The orientation is calculated to always face the vehicle -in the direction of motion. -This should be used when the -.B \-s -option is used by -.I anim_script -to animate the vehicle. -.PP -.TP -.B \-f# -Specify the integer with which to begin numbering frames. -Default is zero. -.TP -.B \-p -Animate placed links, rather than links stored at the origin. -In order for placed links to be animated, they must be equally spaced -around the wheels defining the track. The track must be formed of arcs -around the wheels and straight lines between the wheels, and the links -must be numbered clockwise as seen from the right. -By default, it is assumed that the -center of the first link, linkname.0, is at the beginning of the -straight track segment between wheel.(n-1) and wheel.0 . If this is -not the case, the position of the first link must be identified with the -.B \-i# -option. -.TP -.B \-i# -Specify the initial offset of the first link. If this option is -not used, the initial position of linkname.0 is assumed to be the -beginning of the straight track segment between wheel.(n-1) and wheel.0. -If it is used, the argument specifies the distance clockwise around the -track from the default position to the actual desired offset. If the -links are modeled at the origin, the user can choose any offset. This -can be useful for lining up the links with gears of a drive wheel, for -example. -If the -.B -p -option is being used to animated pre-placed links, then it is essential -that the actual offset of the first pre-placed link be specified. -.TP -.B \-g# -Return "arced" for mged instead of "anim" for rt. -.TP -.B \-ml<string> -Use -.B <string> -for the link command. Defaults to "rarc". -.TP -.B \-mw<string> -Use -.B <string> -for the wheel command. Defaults to "lmul". -.TP -.B \-c -Only output the circumference of the track. -.SS Output: -.PP -The output is a script containing as many frames as there -are positions in -.BR in.table . -If there are -.I n -links and -.I k -wheels, each -frame contains up to -.IR n + k -anim commands, either: -.nf - -anim linkname.i matrix lmul -[... matrix ...] ; - or -anim wheelname.j matrix lmul -[... matrix ...] ; - -for 0<=i<n and 0<=j<k. - -.fi -.SH EXAMPLES -Suppose you want to make an animation of a tank rolling across -flat ground. A list of desired positions is created, perhaps by -interpolating between a few key positions; this information is placed -in a four column animation table, in.table. The model of the tank is stored in -model.g as a combination named "tank". Its centroid is at the -point (0,0,1000) and it faces the y-axis. An animation script for the -tank itself is created as follows: -.PP -anim_script -s -d 0 0 1000 -b 90 0 0 /tank < in.table > tank.script -.PP -Suppose that there are two -roadwheels and a drivewheel (tank/rwheel/wheel.i, 0<=i<3) which define -the shape of the right track. -A file called -.B rwheelfile -is created: -.nf - -1500 -2000 30 30 -1500 0 1000 35 -1500 2000 30 30 - -.fi -This -.B rwheelfile -lists the position and -radius of each of the three wheels. -.PP -There are eighty links which make up the right track -(tank/rtrack/link.i, 0<=i<80). -The links of the right track are all modeled -at the origin with the outer, ground-contacting surface -facing up and the inner, wheel-contacting surface centered at the -origin. -.PP -The appropriate call to -.I anim_hardtrack -is now: -.sp -anim_hardtrack -d 0 0 1000 -b 90 0 0 -w tank/rwheel -l 80 tank/rtrack/link - rwheelfile < in.table > rtrack.script -.sp -Suppose that the left track is similar to the right track, -except that all the wheels are of radius 30 units, and the links, rather -than being stored at the origin, are actually placed in position around -the left wheels to begin with. The -.B lwheelfile -would be: -.nf - --1500 -2000 30 --1500 0 1000 --1500 2000 30 - -.fi -and the call would be: -.sp -anim_hardtrack -p -r 30 -d 0 0 1000 -b 90 0 0 -w tank/lwheel - -l 80 tank/ltrack/link lwheelfile <in.table > ltrack.script -.sp -Here, it is assumed that tank/ltrack/link.0 is initially at the -beginning of the straight track segment between lwheel.2 and lwheel.0, -that is, at the point (2000,1500,-1000) in the vehicle's coordinates. -If, instead, the first link is initially centered halfway between the -two roadwheels, this must be specified with the -.B -i# -option. If the link's -actual position is 2000 units farther around the track than expected: -.sp -anim_hardtrack -i 2000 -p -r 30 -d 0 0 1000 -b 90 0 0 -w tank/lwheel - -l 80 tank/ltrack/link lwheelfile <in.table > ltrack.script -.sp -One final step may remain. The above procedure produces a script with rigid -naming conventions, in order to make input simple. This may mean that -the names in the script do not match the names in model.g. An editor -should then be used at the end to replace all instances of the -conventional name with the real name; for example, in this case it may -be necessary to replace "rwheel.1" with "r_drivewheel". -.PP -.BR Tank.script , -.BR rtrack.script , -and -.B ltrack.script -can be combined -with -.I anim_sort -to make the complete script. -.PP -.SH BUGS -Tracks must have at least two wheels, and they must be listed in clockwise -order, or the results are unpredictable. -.SH SEE ALSO -anim_script(1), anim_track(1) -.SH AUTHOR -Carl J. Nuzman -.SH COPYRIGHT - This software is Copyright (c) 1993-2009 by the United States -Government as represented by U.S. Army Research Laboratory. - -.SH "BUG REPORTS" -Reports of bugs or problems should be submitted via electronic -mail to <de...@br...>. Deleted: brlcad/trunk/src/anim/anim_keyread.1 =================================================================== --- brlcad/trunk/src/anim/anim_keyread.1 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/anim/anim_keyread.1 2009-04-06 19:21:25 UTC (rev 34163) @@ -1,153 +0,0 @@ -.TH ANIM_KEYREAD 1 BRL-CAD -.\" A N I M _ K E Y R E A D . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 1993-2009 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.SH NAME -anim_keyread - prepares key frames from the mged savekey command for interpolation -.SH SYNOPSIS -.B anim_keyread -.B [-y|z] -.B < key.file -.B > key.table -.SH DESCRIPTION -.I Anim_keyread -takes as input a file containing a series of keyframes -generated by the -.I mged -command `savekey', and produces a table containing -the same information, except that the view orientation matrix is -changed to a form that can be interpolated. The default form for the -orientation information is the quaternion. -For each such keyframe in the input file, -.I anim_keyread -will produce a -row in the output file containing the time, the viewsize, the position -of the camera, and the orientation of the camera, specified as a unit -quaternion in the order x, y, z, and w. -.SH OPTIONS -.TP -.B -y -Specify the orientation in terms of yaw, pitch, and roll. -.TP -.B -z -Specify the orientation as a rotation about the z-axis, y-axis, -and then x-axis, where the columns are in the order: x,y,z. -.SH EXAMPLES -The following is an example of a typical keyframe generated by the -`savekey' command. The time is 0, the viewsize is ten, the camera is at the -point (2.5,2.5,3.53) and the camera orientation is specified by a -matrix. -.nf - -0.000000 -1.000000000e+01 -2.500000000e+00 2.500000000e+00 3.535533906e+00 --7.071067812e-01 7.071067812e-01 0.000000000e+00 0.000000000e+00 --5.000000000e-01 -5.000000000e-01 7.071067812e-01 0.000000000e+00 -5.000000000e-01 5.000000000e-01 7.071067812e-01 0.000000000e+00 -0.000000000e+00 0.000000000e+00 0.000000000e+00 1.000000000e+00 - -.fi -For the key frame shown above, the output would -be: -.sp -0.000000 10.000000 2.500000 2.500000 3.535534 0.146447 0.353553 0.853553 0.353553 -.sp -The last four numbers define the desired orientation as a -quaternion. -.PP -With the -.B -y -option, the output would be: -.sp -0.000000 10.000000 2.500000 2.500000 3.535534 -135.000000 -45.000000 0.000000 -.sp -Here, the last three numbers are the yaw, pitch, and roll, -which can be interpreted as follows: Imagine a camera at the origin -originally facing the positive x-direction, with the z-axis going up -and the y-axis positive to the left. The camera should be rotated -+roll degrees about the x-axis, -pitch degrees about the y-axis, -and +yaw degrees about the z-axis. In this case, the camera ends up -pointing down and to the right of its original position. -.PP -With the -z option, the output would be: -.sp -0.000000 10.000000 2.500000 2.500000 3.535534 -35.264390 30.000000 144.735610 -.sp -The last three numbers are x, y, and z rotation angles. -The camera is considered to be originally on the z-axis, looking toward -the origin with the x-axis to the right and the y-axis going up. The -camera is rotated 144.7 degrees about the model's z-axis, then 30 -degrees about the model's y-axis, and finally -35.2 degrees about the -model x-axis. -.SH DIAGNOSTICS -Problems arise when using Eulers angles, because -certain orientations do not have a uniqe representation, and the program -must arbitrarily select among an infinite number of possibilities. For -example, when using yaw, pitch and roll, the yaw and roll -become indistinguishable when the pitch is 90 degrees. -.PP -When this happens, the roll is set to 0, and the following -messages appear on standard error: -.nf - -Warning: roll arbitrarily set to 0.0; yaw set to -0.585334 radians. -Warning: yaw and roll arbitrarily defined at time = 1.000000. - -.fi -A similar effect occurs in xyz format when the rotation about -the y-axis is 90 degrees. -.nf - -Warning: x arbitrarily set to 0.0; z set to 0.000000. -Warning: x and z rotations arbitrarily defined at time = 9.000000. - -.fi -One nice thing about quaternions is that you don't run into such -problems. -.SH SEE ALSO -mged(1), tabsub(1), anim_script(1), tabinterp(1) -.SH AUTHOR -Carl J. Nuzman -.SH COPYRIGHT - This software is Copyright (c) 1993-2009 by the United States -Government as represented by U.S. Army Research Laboratory. -.SH "BUG REPORTS" -Reports of bugs or problems should be submitted via electronic -mail to <de...@br...>. Deleted: brlcad/trunk/src/anim/anim_lookat.1 =================================================================== --- brlcad/trunk/src/anim/anim_lookat.1 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/anim/anim_lookat.1 2009-04-06 19:21:25 UTC (rev 34163) @@ -1,97 +0,0 @@ -.TH ANIM_LOOKAT 1 BRL-CAD -.\" A N I M _ L O O K A T . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 1993-2009 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.SH NAME -anim_lookat - create a view animation script or table which looks from an eye point to -a specified point. -.SH SYNOPSIS -.B anim_lookat -.B [\-f #] -.B \[-v] -.B < in.table -.B > out.script -.PP -.B anim_lookat -.B \-[y|q] -.B \[-v] -.B < in.table -.B > out.table - -.SH DESCRIPTION -This program takes as input a seven-column animation table -consisting of time, an eye point, and a "look-at point", and prints a -view animation script to control the virtual camera. -The camera always remains "right-side up"; that is, it yaws and pitches but -doesn't roll. In cases where the camera looks vertically up or down, the -yaw from the previous frame is retained. This avoids sudden jumps as much -as possible. -.PP -.SH OPTIONS -.TP -.B \-f# -Specify an integer with which to begin -numbering frames. The default is 0. -.TP -.B \-y -The output will be an animation table rather -than a view animation script. The output table has 7 columns: -a time column, three -columns representing position, and three columns representing yaw, -pitch, and roll. -.TP -.B \-q -The output will be an animation table rather than a view animation script. -The output table has eight columns: -a time column, three position columns, and four columns -representing the x,y,z, and w coordinates of an orientation quaternion. -.TP -.B \-v -Include the viewsize in the output script or table. The viewsize is -calculated in every frame as twice the distance from the eye point to -the lookat point. If the output is a table, then the viewsize is printed -in the second column. -.SH AUTHOR -Carl J. Nuzman -.SH COPYRIGHT - This software is Copyright (c) 1993-2009 by the United States -Government as represented by U.S. Army Research Laboratory. -.SH "BUG REPORTS" -Reports of bugs or problems should be submitted via electronic -mail to <de...@br...>. Deleted: brlcad/trunk/src/anim/anim_offset.1 =================================================================== --- brlcad/trunk/src/anim/anim_offset.1 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/anim/anim_offset.1 2009-04-06 19:21:25 UTC (rev 34163) @@ -1,136 +0,0 @@ -.TH ANIM_OFFSET 1 BRL-CAD -.\" A N I M _ O F F S E T . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 1993-2009 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.SH NAME -anim_offset - create an animation table for an object rigidly attached to -another object. -.SH SYNOPSIS -.B anim_offset -.B -o # # # -.B [-r] -.B < in.table -.B > out.table -.SH DESCRIPTION -This filter operates on animation tables of the type used by -.I tabsub -and -.I anim_script. -Given a table specifying the position and -orientation of one object at every applicable time, -.I anim_offset -calculates -the position of another object which is rigidly attached to it. -.PP -The columns of the input table should be time, three columns of -position, followed by yaw, pitch, and roll. The output will be -normally be a four-column file specifying time and position. If the -.B -r -option is used, the output is a seven-column file in which the last -three columns are copies of the orientation information from the input -file. -.PP -The position of the object relative to the rigid body should be -given on the command line in the order x, y, z, with the -.B -o # # # -option. These offset values -should be as measured from the centroid of the rigid body. -.SH EXAMPLES -This filter could be used, for example, to do an animation where -the camera is placed inside a moving vehicle. -.PP -Suppose that truck.table contains the desired position of the -center of the front axle of the truck as well as its orientation at each -time. One row of the table might look like this: -.nf - -35.2 12450 -140 600 90.0 0.0 0.0 - -.fi -Thus 35.2 seconds into the animation, the center of the front axle will -be at (12450, -140, 600), and the truck will be pointed in the positive -y direction. (yaw = 90). -.PP -Now, suppose we want the camera to ride along in the cab, above -and behind the front axle and somewhat to the left. To specify this -offset, we use the coordinate frame of the truck, with the origin at the -center of the front axle, the x-axis to the front, y to the left, and z -pointing up. Let the exact offset from the axle to the desired camera -position in this case be (-600, 900, 1200), in units of mm. Now we use -the routine: -.nf - -anim_offset -o -600 900 1200 < truck.table > camera.table - -.fi -The result is a four-column table giving the desired position of the -virtual camera at each time. The row corresponding to the sample row -above would be: -.nf - -35.2 11550 -740 1800 - -.fi -With the -.B -r -option, the output would have been: -.nf - -35.2 11550 -740 1800 90.0 0.0 0.0 - -.fi -Now -.I tabsub -and/or -.I anim_script -can be used to process these two animation -tables into an animation script. -.SH BUGS - The program will only use orientations specified as yaw, -pitch, and roll. You can get around this using -.IR anim_orient , -which converts between different orientation representations. -.SH AUTHOR -Carl J. Nuzman -.SH COPYRIGHT - This software is Copyright (c) 1993-2009 by the United States -Government as represented by U.S. Army Research Laboratory. -.SH "BUG REPORTS" -Reports of bugs or problems should be submitted via electronic -mail to <de...@br...>. Deleted: brlcad/trunk/src/anim/anim_orient.1 =================================================================== --- brlcad/trunk/src/anim/anim_orient.1 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/anim/anim_orient.1 2009-04-06 19:21:25 UTC (rev 34163) @@ -1,255 +0,0 @@ -.TH ANIM_ORIENT 1 BRL-CAD -.\" A N I M _ O R I E N T . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 1993-2009 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.SH NAME -anim_orient - convert between orientation formats -.SH SYNOPSIS -.B anim_orient -.B [q|y|a|z|m][vri] -.B [q|y|a|z|m][vriu] -.B < in.table -.B > out.table -.SH DESCRIPTION -.I Anim_orient -is a filter which translates a table of orientation -information from one format to another. The method used is to convert -the input format to a matrix, then convert the matrix to the desired -output format. The input format is specified in the first argument, and -the output format is specified in the second. -The orientation formats -must be one of the following: -.B q -(quaternion), -.B y -(yaw,pitch, and roll), -.B a -(azimuth, elevation, and twist), -.B z -(x-y-z angles), or -.B m -(rotation matrix). -In addition, the output format may be modified by the -.B u -option, and the input and output formats may be modified by the -.BR r , -.BR i , -and -.B v -options. The -.B r -option specifies that angles are read or written in radians, rather -than degrees. The -.BR i , v , -and -.B u -options are explained below. -.PP -To clearly understand the operation of anim_orient, it is important to -examine the difference between orientation and rotation. -The matrices, quaternions, and angles -used by anim_orient specify rotations. These are transformations -which, when applied to an object, preserve its shape but change its -orientation with respect to a fixed set of axes. Given the initial -orientation of an object, a rotation defines the final orientation, but -different initial orientations will yield different final orientations. -In order -to represent orientations with rotations, we -must define a default initial orientation for the object. -Then a given matrix, quaternion, or set of angles represents the orientation -resulting from applying the rotation to the initial object orientation. -.PP -If no modifying codes are specified, anim_orient assumes that the -default orientation of the object in question faces the positive -x-direction, with the world y-axis pointing to the object's left and the -z-axis pointing up. This is the orientation in which many -.I brlcad -objects -are modeled, and the default assumed by other animation routines such as -anim_script. If the -.B v -code is specified, then the default orientation -is taken to be facing the negative z-direction, with the world x-axis -pointing to the object's right and the y-axis pointing up. This is the -default orientation of the eye in -.I mged -and -.IR rt . -Some common uses of the v -option are demonstrated in the examples section. -.PP -The input and output format codes are: -.TP -.BR q : -Quaternions, in the order x,y,z,w. This is the default input and -output format. The output will -always be unit quaternions. For a unit quaternion, the -xyz-vector represents an axis of rotation and and w represents -cos(omega/2), where -omega is the angle to be rotated about the given axis. -.TP -.BR z : -x-y-z angles, in the order x, y, z. They represent a rotation -of z degrees around the z-axis, followed by y degrees around the y-axis, -followed by x degrees around the x-axis. If the code -.B zr -is used -then the angles will be read or written in radians -rather than degrees. -.TP -.BR y : -yaw-pitch-roll format, in that order. They represent -a rotation of +roll degrees about the x-axis, -pitch degrees about -the y-axis, followed by +yaw degrees about the z-axis. If the code -.B yr -is used, angles are in radians rather than degrees. -.TP -.BR a : -azimuth, elevation, twist, in that order. They represent a rotation of --twist degrees about the x-axis, +elevation degrees about the y-axis, -and +azimuth + 180 degrees about the z-axis. Alternatively, they can -be thought of as a 180 degree rotation about the z-axis followed by a -rotation of +twist degrees about the x-axis, -elevation degrees about -the y-axis, and +azimuth degrees about the z-axis. -.TP -.BR m : -pre-multiplication rotation matrix. Sixteen -numbers form a 4x4 matrix, although only the nine elements in the upper -left corner are actually used. This is the format used at the interior of -the conversion routine. It is a transformation from initial orientation to -a new orientation. -.PP -The input and ouput modification codes are: -.TP -.B i -This code is used in conjunction with any of the format codes to represent -the inverse transformation. Under the -.B i -code, a matrix, quaternion, or -set of angles represents the inverse of the rotation that it normally -represents. -For example, normally, the orientation -corresponding to a given matrix is the orientation that the default -object ends up in after the matrix is applied to it. With the -.B i -code, -a given matrix represents the orientation an object should be placed -in so that the applying the matrix puts it back in the default -orientation. - -One common use of the -.B i -option is for handling "Viewrot" matrices used -by -.I mged -and -.IR rt . -The viewrot matrix is a model-to-view matrix, which is -the transpose (inverse) of the matrix which would conceptually be -applied to an eye object to put it in the desired place in the model. -.TP -.B v -When this option is specified, the corresponding rotation is considered -applied to the default view orientation, rather than the default object -orientation, as explained above. -.TP -.B u -This option forces the output orientation to be upright, or "right-side -up", where the z-axis is the up direction. In terms of yaw, pitch, and -roll, this means that the roll is forced to zero. Because this is a -one-way operation, it can only be applied to the output orientation, not -the input. - -.SH EXAMPLES -.sp -Normalize a table of quaternions to unit magnitude. (quaternions are the -default format). -.sp - anim_orient < in.table > out.table -.sp -change xyz angles to a rotation matrix -.sp - anim_orient z m < in.table > out.table -.sp -change azimuth,elevation, and twist to a matrix suitable for the -.I rt -viewrot command -.sp - anim_orient a miv < in.table > out.table -.sp -transpose matrices -.sp - anim_orient m mi < in.table > out.table -.sp -change radian xyz angles to yaw-pitch-roll in degrees -.sp - anim_orient zr y < in.table > out.table -.sp -given a quaternion being applied to an object facing the x-axis, -find the quaternion needed -to turn the virtual camera in the same direction using -.IR rt 's -orientation command -.sp - anim_orient q qv < in.table > out.table -.sp -Given the yaw, pitch, and roll of an object, find the yaw, pitch, and -roll which would bring it back to the default position. -.sp - anim_orient y yi < in.table > out.table -.sp -Force a table of view quaternions to represent "right-side up" -orientations. -.sp - anim_orient qv qvu < in.table > out.table -.SH BUGS -There are built-in trouble spots which occur, in ypr, xyz, or aet -formats, when the pitch, y-rotation, or elevation is an odd multiple of 90 -degrees, because at this point the other two angles become -indistinguishable. The program makes the arbitrary assumption that the -roll is zero or that the x-rotation is zero, depending on the format, -and gives a warning to that effect on standard error. -.SH AUTHOR -Carl J. Nuzman -.SH COPYRIGHT - This software is Copyright (c) 1993-2009 by the United States -Government as represented by U.S. Army Research Laboratory. -.SH "BUG REPORTS" -Reports of bugs or problems should be submitted via electronic -mail to <de...@br...>. Modified: brlcad/trunk/src/gtools/Makefile.am =================================================================== --- brlcad/trunk/src/gtools/Makefile.am 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/gtools/Makefile.am 2009-04-06 19:21:25 UTC (rev 34163) @@ -24,8 +24,7 @@ man_MANS = \ g_diff.1 \ - g_lint.1 \ - g_qa.1 + g_lint.1 EXTRA_DIST = $(man_MANS) Deleted: brlcad/trunk/src/gtools/g_qa.1 =================================================================== --- brlcad/trunk/src/gtools/g_qa.1 2009-04-06 18:36:32 UTC (rev 34162) +++ brlcad/trunk/src/gtools/g_qa.1 2009-04-06 19:21:25 UTC (rev 34163) @@ -1,523 +0,0 @@ -.TH G_QA 1 -.\" G _ Q A . 1 -.\" BRL-CAD -.\" -.\" Copyright (c) 2005-2009 United States Government as represented by -.\" the U.S. Army Research Laboratory. -.\" -.\" Redistribution and use in source (Docbook format) and 'compiled' -.\" forms (PDF, PostScript, HTML, RTF, etc), with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code (Docbook format) must retain the -.\" above copyright notice, this list of conditions and the following -.\" disclaimer. -.\" -.\" 2. Redistributions in compiled form (transformed to other DTDs, -.\" converted to PDF, PostScript, HTML, RTF, and other formats) must -.\" reproduce the above copyright notice, this list of conditions and -.\" the following disclaimer in the documentation and/or other -.\" materials provided with the distribution. -.\" -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this documentation without specific prior -.\" written permission. -.\" -.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -.\" USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\".\".\" -.\" Set the interparagraph spacing to 1 (default is 0.4) -.PD 1v -.\" -.\" The man page begins... -.SH NAME -g_qa \- a BRL-CAD quantitative geometry analysis tool -.SH SYNOPSIS -.BR "g_qa " "[options] model.g objects" -.SH DESCRIPTION -The -.I g_qa -program computes and reports a variety of characteristics of the -.I objects -specified from the given -.I model.g -geometric description. -The characteristics which can be computed include -.B weight, volume, overlaps, exposed air, gaps/voids, -and -.B adjacent air. -.\"and -.\".B interfaces. -Only the -.I objects -from the database specified on the command line are analyzed. -.P -It works by shooting grids of rays from the three axis-aligned directions (sometimes called -\fIviews\fR). - - -For Volume/Weight calculations the resulting calculations for each view are compared to each other. -The grid of rays is progressively refined until the results from all three views -agree within a user-specifiable tolerance, or a limit on grid refinement is reached. -.P -For error and interface calculations, the grid is refined until an error is found or the grid refinement -limit is reached. -.P -When multiple calculations are performed, the most extensive path is taken. -For example, if weight and overlap calculations are performed, then the grid -will be refined until the refinement limit is reached, or an overlap is -detected. - -.SH VOLUME AND WEIGHT CALCULATION -If volume or weight calculation is selected a value is calculated and reported -For each -.I object -specified on the command line. -.B Note that if there are overlaps or other errors in the geometry the values reported will be invalid. - -.P -For weight computation, the density of every region must be specified. -Densities are specified as an index in a table of density values. -This index is stored in the -.I GIFTmater -attribute of each region (typically set with the -.I edcodes -or -.I adjust -commands in MGED). -.P -The density table consists of three columns: -.IP -.B An integer index value. -This is the value the to which the \fIGIFTmater\fR attribute will be set to select this material for the region. -.IP -.B A floating point density value. -This is the density for the material, and is specified in \fBgrams/cc\fR. -.IP -.B A name string -This is a name or description the material. -.in -5 -.P -An example file might look like the following: -.IP -2 7.82 Carbon Tool Steel -.br -3 2.7 Aluminum, 6061-T6 -.br -4 2.74 Aluminum, 7079-T6 -.br -5 8.9 Copper, pure -.br -6 19.32 Gold, pure -.br -7 8.03 Stainless, 18Cr-8Ni -.br -8 7.47 Stainless 27Cr -.br -9 7.715 Steel, tool -.br -10 7.84 Carbon Steel -.P -The table is typically created in an external file using a text editor. - -The geometry editor MGED automatically assigns an index value of -.B 1 -to a newly created region. -While this default can be handy when a vast majority of objects are made from the same -material, it can lead to surprising errors when objects which are supposed to have a -certain weight are computed to have different weight because one or two regions -were not set to the correct, non-default index value. As a result, it is advised that the index value -.B 1 -never be used. If this practice is followed, then an error message will be generated for any -regions which have not had their material index set to something other than the default. -.P -The user will typically want to run g_qa and verify the results using the -.I \-f -option (see below) -before importing the table into the database. -For example, if a material index is left out of the table, -it is easier to rectify the situation using the external file. -Once the table has been verified as correct and complete, it is imported to the database as the binary object -\fB_DENSITIES\fR. -To import the text file into the database, the following command is used: -.IP -mged> -.B bo \-i u c _DENSITIES -.I filename - -.SH GEOMETRY ERROR DETECTION -.P -All of these calculations run until an error is detected, or until the grid -refinement limit is reached. -.SH OVERLAP DETECTION -For each pair of regions that overlap, the tool reports the two regions that -overlap, -the maximum line-of-sight thickness of the overlap, and the in-hit location -of the ray that caused that maximum overlap thickness. -.P -Other analysis in the error detection category behave in a similar manner. -.SH OPTIONS -.TP -.B \-A \fR\fIanalysis_flags\fR -\fRSpecifies which computations are to be performed and reported. -The -.I analysis_flags -parameter is one or more of the following: -.in +5 -.sp -\fBvalue report generated\fR -.br -A all -.br -a Adjacent different air -.br -b Bounding box dimensions -.br -e Exposed air -.br -g Gaps/voids -.br -o Overlaps -.br -v Volume -.br -w Weight -.sp -.in -5 -Only those reports requested w... [truncated message content] |