From 375e48775c5c6f60426392d2cc06b0f0c1ebb908 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 10 Jan 2011 20:27:43 +0000 Subject: [PATCH] geometry tcl-files --- ng/csgeom.tcl | 700 +++++++++++++++++++++++++++++++++++++++++++++++++ ng/occgeom.tcl | 433 ++++++++++++++++++++++++++++++ ng/stlgeom.tcl | 20 ++ 3 files changed, 1153 insertions(+) create mode 100644 ng/csgeom.tcl create mode 100644 ng/occgeom.tcl create mode 100644 ng/stlgeom.tcl diff --git a/ng/csgeom.tcl b/ng/csgeom.tcl new file mode 100644 index 00000000..64b29bfa --- /dev/null +++ b/ng/csgeom.tcl @@ -0,0 +1,700 @@ +.ngmenu.geometry add command -label "Scan CSG Geometry" -command { Ng_ParseGeometry } +.ngmenu.geometry add command -label "CSG Options..." -command geometryoptionsdialog + +# only intern version ! +# .ngmenu.geometry add separator +# .ngmenu.geometry add command -label "New Primitive" \ +# -command newprimitivedialog -accelerator "

" +# .ngmenu.geometry add command -label "Edit Primitive" \ +# -command editprimitivedialog -accelerator "

" +# .ngmenu.geometry add command -label "Edit Solid" \ +# -command newsoliddialog -accelerator "" +# .ngmenu.geometry add command -label "Choose Top Level " \ +# -command topleveldialog +# .ngmenu.geometry add command -label "Identify" \ +# -command identifydialog +.ngmenu.geometry add command -label "CSG Properties..." \ + -command topleveldialog2 + +.ngmenu.geometry add separator + + + + + + + + + + + + + + +proc geometryoptionsdialog { } { + + + set w .geometry_dlg + + if {[winfo exists .geometry_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + + toplevel $w + + global geooptions + + Ng_GeometryOptions get + + checkbutton $w.drawcsg -text "Draw Geometry" \ + -variable geooptions.drawcsg + pack $w.drawcsg + + frame $w.fac + pack $w.fac -pady 5 + label $w.fac.lab -text "Facets:"; + entry $w.fac.ent -width 8 -relief sunken \ + -textvariable geooptions.facets + pack $w.fac.lab $w.fac.ent -side left + + + frame $w.det + pack $w.det -pady 5 + label $w.det.lab -text "Detail:"; + entry $w.det.ent -width 8 -relief sunken \ + -textvariable geooptions.detail + pack $w.det.lab $w.det.ent -side left + + frame $w.cox + pack $w.cox -pady 5 + label $w.cox.lab -text "min/max x:"; + entry $w.cox.ent1 -width 8 -relief sunken \ + -textvariable geooptions.minx + entry $w.cox.ent2 -width 8 -relief sunken \ + -textvariable geooptions.maxx + pack $w.cox.lab $w.cox.ent1 \ + $w.cox.ent2 -side left + + frame $w.coy + pack $w.coy -pady 5 + label $w.coy.lab -text "min/max y:"; + entry $w.coy.ent1 -width 8 -relief sunken \ + -textvariable geooptions.miny + entry $w.coy.ent2 -width 8 -relief sunken \ + -textvariable geooptions.maxy + pack $w.coy.lab $w.coy.ent1 \ + $w.coy.ent2 -side left + + frame $w.coz + pack $w.coz -pady 5 + label $w.coz.lab -text "min/max z:"; + entry $w.coz.ent1 -width 8 -relief sunken \ + -textvariable geooptions.minz + entry $w.coz.ent2 -width 8 -relief sunken \ + -textvariable geooptions.maxz + pack $w.coz.lab $w.coz.ent1 \ + $w.coz.ent2 -side left + + + +# tixButtonBox $w.bbox -orientation horizontal +# $w.bbox add ok -text Apply -underline 0 -width 5 \ +# -command { Ng_GeometryOptions set } + +# $w.bbox add close -text Done -underline 0 -width 5 \ +# -command { +# Ng_GeometryOptions set +# destroy .geometry_dlg +# } +# pack $w.bbox -side bottom -fill x + + + frame $w.bu + pack $w.bu -fill x -ipady 3 + + + button $w.bu.app -text "Apply" -command { + Ng_GeometryOptions set + } + button $w.bu.ok -text "Done" -command { + Ng_GeometryOptions set + destroy .geometry_dlg + } + pack $w.bu.app $w.bu.ok -side left -expand yes + + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Geometry options" + focus $w + } +} + + + + + + + + + + + + + + + + + +# +# +# Edit primitive +# +# +proc editprimitivedialog2 { name } { + + global w classname + + set w .ep_dlg + toplevel .$w + + Ng_GetPrimitiveData $name classname valuelist + + + label $w.lab1 -text "Primitive Name: $name"; + label $w.lab2 -text "Primitive Class: $classname"; + pack $w.lab1 $w.lab2 -fill x -pady 1m -padx 5m + + frame $w.specific -relief groove + + global spec + set spec(sphere) { cx cy cz rad } + set spec(cylinder) { ax ay az bx by bz rad } + set spec(plane) { px py pz nx ny nz } + set spec(cone) { ax ay az bx by bz ra rb } + set spec(brick) { p1x p1y p1z p2x p2y p2z p3x p3y p3z p4x p4y p4z } + + set cnt 0 + foreach field $spec($classname) { + + frame $w.specific.f$cnt + pack $w.specific.f$cnt -side top -anchor ne + + label $w.specific.f$cnt.lab -text "$field" + entry $w.specific.f$cnt.ent -textvariable dataval($cnt) \ + -width 6 -relief sunken + pack $w.specific.f$cnt.ent $w.specific.f$cnt.lab -side right + $w.specific.f$cnt.ent delete 0 end + $w.specific.f$cnt.ent insert 0 [lindex $valuelist $cnt] + set cnt [expr $cnt + 1] + } + pack $w.specific + + + button $w.cancel -text "cancel" -command { + destroy $w + } + + button $w.ok -text "ok" -command { + + set valuelist "" + set cnt 0 + foreach field $spec($classname) { + lappend valuelist $dataval($cnt) + set cnt [expr $cnt + 1] + } + Ng_SetPrimitiveData $name $valuelist + destroy $w + } + pack $w.cancel $w.ok -side left -expand yes + + bind $w { $w.ok invoke} + bind $w { $w.cancel invoke} + + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + +# grab $w + focus $w.specific.f0.ent +} + + + +# +# +# Select primitve to edit +# +# + +proc editprimitivedialog { } { + global w + + set w .ep_dlg + toplevel $w + + frame $w.frame -borderwidth 5m + pack $w.frame -side top -expand yes -fill y + + listbox $w.frame.list -yscroll "$w.frame.scroll set" -setgrid 1 -height 12 + scrollbar $w.frame.scroll -command "$w.frame.list yview" + pack $w.frame.scroll -side right -fill y + pack $w.frame.list -side left -expand 1 -fill both + + + Ng_GetPrimitiveList primlist + foreach el $primlist { + $w.frame.list insert end $el } + + button $w.cancel -text "cancel" -command { destroy $w } + button $w.ok -text "ok" -command { + set name [.ep_dlg.frame.list get active] + puts "name=($name)" + destroy $w + if { $name != "" } { editprimitivedialog2 $name } + } + + bind $w { $w.cancel invoke } + bind $w { $w.ok invoke } + + + pack $w.cancel $w.ok -side left -expand yes + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + +# grab $w + focus $w.frame.list +} + + + +# +# +# Create new primitive +# +# +proc newprimitivedialog { } { + + global w name + + set w .ap_dlg + + toplevel $w + + set name "" + frame $w.f1 + pack $w.f1 -pady 2m + label $w.f1.lab -text "Primitive Name: "; + entry $w.f1.ent -width 5 -relief sunken \ + -textvariable name + pack $w.f1.lab $w.f1.ent -side left + + frame $w.frame -borderwidth .5c + pack $w.frame -side top -expand yes -fill y + + listbox $w.frame.list -yscroll "$w.frame.scroll set" -setgrid 1 -height 8 + scrollbar $w.frame.scroll -command "$w.frame.list yview" + pack $w.frame.scroll -side right -fill y + pack $w.frame.list -side left -expand 1 -fill both + + $w.frame.list insert 0 sphere cylinder plane cone brick + $w.frame.list activate 0 + + button $w.ok -text "ok" -command { + Ng_CreatePrimitive [$w.frame.list get active] $name + destroy $w + editprimitivedialog2 $name + } + + button $w.cancel -text "cancel" -command { + destroy $w + } + + pack $w.cancel $w.ok -side left -expand yes -pady 2m + + + bind $w { $w.cancel invoke } + bind $w { $w.ok invoke } + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + +# grab $w + focus $w.f1.ent +} + + + + + + +proc newsoliddialog { } { + + global w name val sollist + + set w .ns_dlg + toplevel $w + + set name "" + frame $w.f1 + label $w.f1.lab -text "Solid Name: "; + entry $w.f1.ent -width 5 -relief sunken \ + -textvariable name + $w.f1.ent delete 0 end + button $w.f1.getsel -text "Get Selected" -command { + $w.f1.ent delete 0 end + $w.f1.ent insert 0 [$w.f3.list get active] + $w.bu.get invoke + } + pack $w.f1.getsel -side bottom + pack $w.f1.ent $w.f1.lab -side right + + + frame $w.f3 -borderwidth .5c + listbox $w.f3.list -yscroll "$w.f3.scroll set" -setgrid 1 -height 12 + scrollbar $w.f3.scroll -command "$w.f3.list yview" + pack $w.f3.scroll -side right -fill y + pack $w.f3.list -side left -expand 1 -fill both + + Ng_GetSolidList sollist + foreach el $sollist { + $w.f3.list insert end $el } + + frame $w.f2 + label $w.f2.lab -text "Solid Description: "; + pack $w.f2.lab + + + entry $w.f2.ent -width 100 -relief sunken \ + -textvariable val -xscrollcommand "$w.f2.scr set" + scrollbar $w.f2.scr -relief sunken -orient horiz -command \ + "$w.f2.ent xview" + $w.f2.ent delete 0 end + pack $w.f2.ent $w.f2.scr -fill x + + + + frame $w.bu + button $w.bu.close -text "close" -command { + destroy $w + } + + button $w.bu.get -text "get data" -command { + Ng_GetSolidData $name val + } + + button $w.bu.set -text "set data" -command { + Ng_SetSolidData $name $val + } + + pack $w.bu.get $w.bu.set $w.bu.close -side left + + + pack $w.bu -pady 5 -side bottom ;# buttons + pack $w.f2 -pady 5 -side bottom ;# edit field + pack $w.f1 -pady 5 -side left ;# name + pack $w.f3 -side left -expand yes -fill y ;# listbox + + + + bind $w { $w.bu.close invoke } + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + +# grab $w + focus $w +} + + + + + + + +# +# Edit top level objects +# +# + + +proc toplevelproperties { w solname surfname } { + + global properties + + Ng_TopLevel getprop $solname $surfname properties + + + set w .tlprop_dlg + + if {[winfo exists $w] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + toplevel $w + + label $w.lab1 -text "Red" + scale $w.scale1 -orient horizontal -length 300 -from 0 -to 1 \ + -resolution 0.01 -tickinterval 0.2 \ + -command { Ng_TopLevel setprop $solname $surfname properties; redraw } -variable properties(red) + + label $w.lab2 -text "Green" + scale $w.scale2 -orient horizontal -length 300 -from 0 -to 1 \ + -resolution 0.01 -tickinterval 0.2 \ + -command { Ng_TopLevel setprop $solname $surfname properties; redraw } -variable properties(green) + + label $w.lab3 -text "Blue" + scale $w.scale3 -orient horizontal -length 300 -from 0 -to 1 \ + -resolution 0.01 -tickinterval 0.2 \ + -command { Ng_TopLevel setprop $solname $surfname properties; redraw } -variable properties(blue) + + + pack $w.lab1 $w.scale1 $w.lab2 $w.scale2 $w.lab3 $w.scale3 + + checkbutton $w.cb4 -text "Visible" \ + -command { Ng_TopLevel setprop $solname $surfname properties; redraw } \ + -variable properties(visible) + + checkbutton $w.cb5 -text "Transparent" \ + -command { Ng_TopLevel setprop $solname $surfname properties; redraw } \ + -variable properties(transp) + + + pack $w.cb4 $w.cb5 + + + frame $w.bu + pack $w.bu -fill x + button $w.bu.ok -text "Ok" -command "destroy .tlprop_dlg" + pack $w.bu.ok -expand yes + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + focus $w + } + wm title $w "Properties $solname $surfname" +} + + + + + + +proc topleveldialog { } { + + global w name val sollist + + set w .tl_dlg + toplevel $w + + + + frame $w.sol -borderwidth .5c + listbox $w.sol.list -yscroll "$w.sol.scroll set" -setgrid 1 -height 12 + scrollbar $w.sol.scroll -command "$w.sol.list yview" + pack $w.sol.scroll -side right -fill y + pack $w.sol.list -side left -expand 1 -fill both + + Ng_GetSolidList sollist + foreach el $sollist { + $w.sol.list insert end $el } + Ng_GetPrimitiveList sollist + foreach el $sollist { + $w.sol.list insert end $el } + + + + + frame $w.sul -borderwidth .5c + listbox $w.sul.list -yscroll "$w.sul.scroll set" -setgrid 1 -height 12 + scrollbar $w.sul.scroll -command "$w.sul.list yview" + pack $w.sul.scroll -side right -fill y + pack $w.sul.list -side left -expand 1 -fill both + + Ng_GetSurfaceList sollist + foreach el $sollist { + $w.sul.list insert end $el } + + + + + + frame $w.topl -borderwidth .5c + listbox $w.topl.list -yscroll "$w.topl.scroll set" -setgrid 1 -height 12 \ + -command { puts hi } + scrollbar $w.topl.scroll -command "$w.topl.list yview" + pack $w.topl.scroll -side right -fill y + pack $w.topl.list -side left -expand 1 -fill both + + Ng_TopLevel getlist sollist + puts $sollist + foreach el $sollist { + set hel "[ lindex $el 0 ]" + if { [ llength $el ] == 2 } { + set hel "[ lindex $el 1 ] on [ lindex $el 0 ]" + } + $w.topl.list insert end $hel + } + + + frame $w.bu + + button $w.bu.close -text "close" -command { + destroy $w + } + button $w.bu.addsol -text "Add Solid" -command { + set solname [$w.sol.list get active] + Ng_TopLevel set $solname "" + Ng_ParseGeometry + $w.topl.list insert end $solname + } + + button $w.bu.addsurf -text "Add Surface" -command { + set solname [$w.sol.list get active] + set surfname [$w.sul.list get active] + Ng_TopLevel set $solname $surfname + Ng_ParseGeometry + puts "$solname on $surfname" + $w.topl.list insert end "$surfname on $solname" + } + + button $w.bu.remsol -text "Remove" -command { + set solname [$w.topl.list get active] + set surfname "" + if { [llength $solname] == 3 } { + set surfname [lindex $solname 0] + set solname [lindex $solname 2] + } + Ng_TopLevel remove $solname $surfname + Ng_ParseGeometry + $w.topl.list delete active + } + + button $w.bu.prop -text "Properties" -command { + set solname [$w.topl.list get active] + set surfname "" + if { [llength $solname] == 3 } { + set surfname [lindex $solname 0] + set solname [lindex $solname 2] + } + toplevelproperties tlp $solname $surfname + } + + + + + pack $w.bu.close $w.bu.addsol $w.bu.addsurf $w.bu.remsol $w.bu.prop -side left + + + pack $w.bu -side bottom + pack $w.sol -side left -expand yes -fill y ;# listbox + pack $w.sul -side left -expand yes -fill y ;# listbox + pack $w.topl -side left -expand yes -fill y ;# listbox + + + bind $w { $w.bu.close invoke } + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + +# grab $w + focus $w +} + + + + + + +proc topleveldialog2 { } { + set w .tl2_dlg + + if {[winfo exists .tl2_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + toplevel $w + + global name val sollist + + frame $w.topl -borderwidth .5c + listbox $w.topl.list -yscroll "$w.topl.scroll set" -setgrid 1 -height 12 + scrollbar $w.topl.scroll -command "$w.topl.list yview" + pack $w.topl.scroll -side right -fill y + pack $w.topl.list -side left -expand 1 -fill both + + Ng_TopLevel getlist sollist + puts $sollist + set i 1 + foreach el $sollist { + set hel "$i: [ lindex $el 0 ]" + if { [ llength $el ] == 2 } { + set hel "$i: [ lindex $el 1 ] on [ lindex $el 0 ]" + } + incr i + $w.topl.list insert end $hel } + + + frame $w.bu + + button $w.bu.close -text "close" -command { + destroy .tl2_dlg + } + + + button $w.bu.prop -text "Properties" -command { + set solname [.tl2_dlg.topl.list get active] + set surfname "" + if { [llength $solname] == 2 } { + set solname [lindex $solname 1] + } + if { [llength $solname] == 4 } { + set surfname [lindex $solname 1] + set solname [lindex $solname 3] + } + toplevelproperties tlp $solname $surfname + } + + pack $w.bu.close $w.bu.prop -side left + pack $w.bu -side bottom + pack $w.topl -side left -expand yes -fill y ;# listbox + + bind .tl2_dlg.topl.list { + set solname [.tl2_dlg.topl.list get @%x,%y] + set surfname "" + if { [llength $solname] == 2 } { + set solname [lindex $solname 1] + } + if { [llength $solname] == 4 } { + set surfname [lindex $solname 1] + set solname [lindex $solname 3] + } + toplevelproperties tlp $solname $surfname + } + + bind .tl2_dlg { .tl2_dlg.bu.close invoke } + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Top-Level Options" + focus $w + } +} + + + + + diff --git a/ng/occgeom.tcl b/ng/occgeom.tcl new file mode 100644 index 00000000..9061aadc --- /dev/null +++ b/ng/occgeom.tcl @@ -0,0 +1,433 @@ +.ngmenu.geometry add command -label "IGES/STEP Topology Explorer/Doctor..." \ + -command { occdialog; } + + + +# Philippose - 30/01/2009 +# Add menu item for local face mesh size definition in the +# TCL Gui +.ngmenu.geometry add command -label "Edit Face Mesh Size..." \ + -command { surfacemeshsizedialog } + + +# .ngmenu.geometry add command -label "OCC Construction" \ + # -command { Ng_OCCConstruction; } + + + + + + + + + + + + + +set entities [ ] + + +proc occdialogbuildtree {} { + global entities + + set w .occ_dlg + set hlist [$w.mtre subwidget hlist] + + set entities [Ng_GetOCCData getentities] + set nrentities [expr [llength $entities]] + + + if {$nrentities != 0} { + + $hlist add Topology -itemtype text -text "Topology" + + $hlist add Topology/CompSolids -itemtype text -text "Composite Solids" -data "Composite Solids" + $hlist add Topology/FreeSolids -itemtype text -text "Free Solids" -data "Free Solids" + $hlist add Topology/FreeShells -itemtype text -text "Free Shells" -data "Free Shells" + $hlist add Topology/FreeFaces -itemtype text -text "Free Faces" -data "Free Faces" + $hlist add Topology/FreeWires -itemtype text -text "Free Wires" -data "Free Wires" + $hlist add Topology/FreeEdges -itemtype text -text "Free Edges" -data "Free Edges" + $hlist add Topology/FreeVertices -itemtype text -text "Free Vertices" -data "Free Vertices" + + # $hlist add SingularEntities -itemtype text -text "Entities marked as singular" + + set i [expr 0] + while {$i < $nrentities} { + set entity [lindex $entities [expr $i]] + incr i 1 + set entityname [lindex $entities [expr $i]] + $hlist add Topology/$entity -text $entityname -data $entityname + incr i 1 + $w.mtre close Topology/$entity + } + + $w.mtre autosetmode + + $w.mtre open Topology + $w.mtre close Topology/CompSolids + $w.mtre close Topology/FreeSolids + $w.mtre close Topology/FreeShells + $w.mtre close Topology/FreeFaces + $w.mtre close Topology/FreeWires + $w.mtre close Topology/FreeEdges + $w.mtre close Topology/FreeVertices + + set i [expr 0] + while {$i < $nrentities} { + set entity [lindex $entities [expr $i]] + $w.mtre close Topology/$entity + incr i 2 + } + + set faces [Ng_OCCCommand getunmeshedfaceinfo] + set nrfaces [expr [llength $faces]] + if {$nrfaces >= 2} { + $hlist add ErrorFaces -itemtype text -text "Faces with surface meshing error" + $w.mtre open ErrorFaces + set i [expr 0] + while {$i < $nrfaces} { + set entity [lindex $faces [expr $i]] + incr i 1 + set entityname [lindex $faces [expr $i]] + $hlist add ErrorFaces/$entity -text $entityname -data $entityname + incr i 1 + } + } + + + set faces [Ng_OCCCommand getnotdrawablefaces] + set nrfaces [expr [llength $faces]] + if {$nrfaces >= 2} { + $hlist add NotDrawableFaces -itemtype text -text "Faces impossible to visualize" + $w.mtre open NotDrawableFaces + set i [expr 0] + while {$i < $nrfaces} { + set entity [lindex $faces [expr $i]] + incr i 1 + set entityname [lindex $faces [expr $i]] + $hlist add NotDrawableFaces/$entity -text $entityname -data $entityname + incr i 1 + } + } + + + $w.mtre autosetmode + + puts "done" + } +} + + +proc rebuildoccdialog {} { + if {[winfo exists .occ_dlg] == 1} { + [.occ_dlg.mtre subwidget hlist] delete all + occdialogbuildtree + } +} + +proc checkoccloaded { } { + set isoccgeometryloaded [Ng_OCCCommand isoccgeometryloaded] + if {$isoccgeometryloaded == 0} { + puts "no IGES/STEP geometry loaded" + destroy .occ_dlg + } +} + +#proc setocctolerance { } { +# set w .setocctolerance +#} + + +proc selectentity { entityname } { + global entities + set nrentities [expr [llength $entities]] + set i [expr 0] + while {$i < $nrentities} { + set entitylength [] + + set entity2 [lindex $entities [expr $i]] + incr i 1 + set entityname2 [lindex $entities [expr $i]] + incr i 1 + set entityname2 [string range $entityname2 0 [expr [string length $entityname]-1]] + + if {$entityname == $entityname2} { + set hlist [.occ_dlg.mtre subwidget hlist] + .occ_dlg.mtre open Topology + set slashpos [string last "/" $entity2] + set entity3 [string range $entity2 0 [expr $slashpos-1]] + while {$slashpos != -1} { + .occ_dlg.mtre open Topology/$entity3 + + set slashpos [string last "/" $entity3] + set entity3 [string range $entity3 0 [expr $slashpos-1]] + } + $hlist selection clear + $hlist see Topology/$entity2 + $hlist selection set Topology/$entity2 + } + } +} + + + +proc occdialog { } { + + uplevel 1 { + + global entities + set selectvisual geometry + Ng_SetVisParameters + redraw + + set w .occ_dlg + + if {[winfo exists .occ_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + toplevel $w + + tixTree $w.mtre -options { separator "/" } + pack $w.mtre -fill both -expand yes + + occdialogbuildtree + + set hlist [$w.mtre subwidget hlist] + + + set solname {""} + + + bind $hlist { + set oldsolname {$solname} + set solname [[.occ_dlg.mtre subwidget hlist] info selection] + if {$solname != "" && $oldsolname != $solname } { + set seppos [string first "/" $solname] + set rootname [string range $solname 0 [expr $seppos-1]] + + set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname] + set spacepos [string first " " $entityname] + set entitytype [string range $entityname 0 [expr $spacepos-1]] + set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]] + set spacepos2 [string first " " $helpstring] + set entitynumber [string range $helpstring 0 [expr $spacepos2-1]] + if {$rootname == "Topology"} { + Ng_OCCCommand highlightentity $entitytype $entitynumber + set selectvisual geometry + redraw + } { + set brackpos [string first " (" $entityname] + if {$brackpos != -1} { + set entityname [string range $entityname 0 $brackpos] + } + + selectentity $entityname + } + } + } + + button $w.cl -text "Close" -command { + destroy .occ_dlg + } + + button $w.show -text "Show" -command { + set solname [[.occ_dlg.mtre subwidget hlist] info selection] + set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname] + set spacepos [string first " " $entityname] + set entitytype [string range $entityname 0 [expr $spacepos-1]] + set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]] + set spacepos2 [string first " " $helpstring] + set entitynumber [string range $helpstring 0 [expr $spacepos2-1]] + + Ng_OCCCommand show $entitytype $entitynumber + set selectvisual geometry + # Ng_SetVisParameters + redraw + } + button $w.hide -text "Hide" -command { + set solname [[.occ_dlg.mtre subwidget hlist] info selection] + set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname] + set spacepos [string first " " $entityname] + set entitytype [string range $entityname 0 [expr $spacepos-1]] + set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]] + set spacepos2 [string first " " $helpstring] + set entitynumber [string range $helpstring 0 [expr $spacepos2-1]] + + Ng_OCCCommand hide $entitytype $entitynumber + set selectvisual geometry + # Ng_SetVisParameters + redraw + } + + button $w.swaporientation -text "Swap orientation" -command { + set solname [[.occ_dlg.mtre subwidget hlist] info selection] + set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname] + set spacepos [string first " " $entityname] + set entitytype [string range $entityname 0 [expr $spacepos-1]] + set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]] + set spacepos2 [string first " " $helpstring] + set entitynumber [string range $helpstring 0 [expr $spacepos2-1]] + + Ng_OCCCommand swaporientation $entitytype $entitynumber + set selectvisual geometry + # Ng_SetVisParameters + redraw + + [.occ_dlg.mtre subwidget hlist] delete all + occdialogbuildtree + } + + button $w.marksingular -text "Mark/Unmark as singular" -command { + set solname [[.occ_dlg.mtre subwidget hlist] info selection] + set entityname [[.occ_dlg.mtre subwidget hlist] info data $solname] + set spacepos [string first " " $entityname] + if { $spacepos != 0 } { + set entitytype [string range $entityname 0 [expr $spacepos-1]] + set helpstring [string range $entityname [expr $spacepos+1] [expr [string length $entityname]-1]] + set spacepos2 [string first " " $helpstring] + if { $spacepos2 != 0 } { + set entitynumber [string range $helpstring 0 [expr $spacepos2-1]] + + global ismarkedsingular + Ng_OCCCommand marksingular $entitytype $entitynumber + + set hlist [$w.mtre subwidget hlist] + + # $hlist entryconfigure $solname -text "hallo" + # set style1 [tixDisplayStyle imagetext -font 8x13] + set style1 [tixDisplayStyle imagetext -foreground black -background white -selectforeground white -selectbackground blue] + set style2 [tixDisplayStyle imagetext -foreground red -background white -selectforeground red -selectbackground blue] + + if { $ismarkedsingular == 0 } { + $hlist entryconfigure $solname -style $style1 + } { + $hlist entryconfigure $solname -style $style2 + } + + # set hlist [$w.mtre subwidget hlist] + # foreach solname2 $hlist { + # if { $ismarkedsingular == 0 } { + # $hlist entryconfigure $solname2 -style $style1 + # } { + # $hlist entryconfigure $solname2 -style $style2 + # } + # } + } + } + # $hlist add test -after $solname + + # $hlist add SingularEntities/$entityname -text $entityname + # set selectvisual geometry + # Ng_SetVisParameters + # redraw + + # [.occ_dlg.mtre subwidget hlist] delete all + # occdialogbuildtree + } + + + checkbutton $w.zoomtohighlightedentity -text "Zoom to highlighted entity" \ + -variable occoptions.zoomtohighlightedentity \ + -command { + Ng_SetOCCVisParameters + if { ${occoptions.zoomtohighlightedentity} == 1} { + set selectvisual geometry + # Ng_SetVisParameters + Ng_OCCCommand redrawstatus 1 + redraw + } { + Ng_OCCCommand redrawstatus 0 + } + } + + + + frame $w.healing -relief groove -borderwidth 3 + + button $w.healing.checkentities -text "Analyze geometry" -command { + set irregent [Ng_OCCCommand findsmallentities] + + set w .occ_dlg + set hlist [$w.mtre subwidget hlist] + + $hlist add ProblematicEntities -text "Problematic Entities" + $hlist delete offsprings ProblematicEntities + + set nritems [expr [llength $irregent]] + set i [expr 0] + while {$i < $nritems} { + set entity [lindex $irregent [expr $i]] + incr i 1 + set entityname [lindex $irregent [expr $i]] + $hlist add ProblematicEntities/$entity -text $entityname -data $entityname + incr i 1 + } + $w.mtre open ProblematicEntities + $w.mtre autosetmode + } + + tixControl $w.healing.tolerance -label "Healing tolerance: " -integer false \ + -variable occoptions.tolerance -min 1e-9 -max 1e6 \ + -options { + entry.width 6 + label.width 25 + label.anchor e + } + + checkbutton $w.healing.fixsmalledges -text "Fix small edges" \ + -variable occoptions.fixsmalledges + + checkbutton $w.healing.fixspotstripfaces -text "Fix spot/strip faces" \ + -variable occoptions.fixspotstripfaces + + checkbutton $w.healing.sewfaces -text "Sew faces" \ + -variable occoptions.sewfaces + + checkbutton $w.healing.makesolids -text "Make solids" \ + -variable occoptions.makesolids + + checkbutton $w.healing.splitpartitions -text "Split partitions" \ + -variable occoptions.splitpartitions + + button $w.healing.heal -text "Heal geometry" -command { + .occ_dlg.healing.tolerance invoke + Ng_OCCCommand shapehealing + redraw + [.occ_dlg.mtre subwidget hlist] delete all + occdialogbuildtree + } + + pack $w.healing.checkentities + + pack $w.healing.tolerance $w.healing.fixsmalledges \ + $w.healing.fixspotstripfaces $w.healing.sewfaces \ + $w.healing.makesolids $w.healing.splitpartitions -anchor w + + pack $w.healing.heal + + + + + pack $w.show $w.hide + + pack $w.zoomtohighlightedentity -anchor w + # pack $w.checkentities + pack $w.swaporientation + pack $w.marksingular + pack $w.healing -fill x + pack $w.cl + + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "IGES/STEP Topology Explorer/Doctor" + focus .occ_dlg + } + } +} + + diff --git a/ng/stlgeom.tcl b/ng/stlgeom.tcl new file mode 100644 index 00000000..df47e21e --- /dev/null +++ b/ng/stlgeom.tcl @@ -0,0 +1,20 @@ +.ngmenu.geometry add command -label "STL Doctor..." \ + -command { stldoctordialog; } + +.ngmenu.geometry add command -label "STL Info" \ + -command { + set notriangles 0 + set minx 0 + set maxx 0 + set miny 0 + set maxy 0 + set minz 0 + set maxz 0 + set trigscons 0 + Ng_STLInfo notriangles minx maxx miny maxy minz maxz trigscons + set msgtext "NO STL-Triangles : $notriangles\nGeometry:\nX = $minx - $maxx\nY = $miny - $maxy\nZ = $minz - $maxz\nConsistency Check = $trigscons\n" + set msgtext "$msgtext Status: [Ng_STLInfo status]" + tk_messageBox -title "STL Info" -message $msgtext -type ok + } + +.ngmenu.geometry add separator