diff --git a/ng/dialog.tcl b/ng/dialog.tcl new file mode 100644 index 00000000..b29d9fa5 --- /dev/null +++ b/ng/dialog.tcl @@ -0,0 +1,3532 @@ + + + +proc meshingoptionsdialog { } { + + set w .options_dlg + + if {[winfo exists .options_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + + toplevel $w + +# global options.meshsize + + tixNoteBook $w.nb -ipadx 6 -ipady 6 + + $w.nb add general -label "General" -underline 0 + $w.nb add meshsize -label "Mesh Size" -underline 0 + $w.nb add chartopt -label "STL Charts" -underline 0 + $w.nb add optimizer -label "Optimizer" -underline 0 + $w.nb add insider -label "Insider" -underline 0 + $w.nb add debug -label "Debug" -underline 0 + + + pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top + + + # General meshing options + + set f [$w.nb subwidget general] + + set finevals { 1 2 3 4 5 6 } + set finelabs(1) "very coarse" + set finelabs(2) "coarse" + set finelabs(3) "moderate" + set finelabs(4) "fine" + set finelabs(5) "very fine" + set finelabs(6) "user defined" + + tixOptionMenu $f.fine -label "Mesh granularity : " \ + -options { + label.width 19 + label.anchor e + menubutton.width 15 + } + + + foreach finev $finevals { + $f.fine add command $finev -label $finelabs($finev) + } + $f.fine config -variable meshoptions.fineness + $f.fine config -command { setgranularity } + global meshoptions.fineness +# setgranularity ${meshoptions.fineness} + pack $f.fine + + + + + + set mgsteps { ag me ms os mv ov } + set mgsteplabel(ag) "Analyze Geometry" + set mgsteplabel(me) "Mesh Edges" + set mgsteplabel(ms) "Mesh Surface" + set mgsteplabel(os) "Optimize Surface" + set mgsteplabel(mv) "Mesh Volume" + set mgsteplabel(ov) "Optimize Volume" + + + tixOptionMenu $f.first -label "First Step : " \ + -options { + label.width 19 + label.anchor e + menubutton.width 15 + } + + tixOptionMenu $f.last -label "Last Step : " \ + -options { + label.width 19 + label.anchor e + menubutton.width 15 + } + + foreach step $mgsteps { + $f.first add command $step -label $mgsteplabel($step) + $f.last add command $step -label $mgsteplabel($step) + } + + $f.first config -variable meshoptions.firststep + $f.last config -variable meshoptions.laststep + + pack $f.first $f.last + + + + + + set msg(0) "None" + set msg(1) "Least" + set msg(2) "Little" + set msg(3) "Moderate" + set msg(4) "Much" + set msg(5) "Most" + + tixOptionMenu $f.msg -label "Print Messages : " \ + -options { + label.width 19 + label.anchor e + menubutton.width 15 + } + + foreach step {0 1 2 3 4 5 } { + $f.msg add command $step -label $msg($step) + } + + $f.msg config -variable options.printmsg + pack $f.msg + + + + + + + + + checkbutton $f.parthread -text "Parallel meshing thread" \ + -variable options.parthread + checkbutton $f.second -text "Second order elements" \ + -variable options.secondorder + checkbutton $f.quad -text "Quad dominated" \ + -variable options.quad -command { + if { ${options.quad} } { + set meshoptions.laststep os + } + } + checkbutton $f.invtets -text "Invert volume elements" \ + -variable options.inverttets + checkbutton $f.invtrigs -text "Invert surface elements" \ + -variable options.inverttrigs + checkbutton $f.azref -text "Automatic Z-refinement" \ + -variable options.autozrefine + + pack $f.parthread $f.second $f.quad $f.invtets $f.invtrigs $f.azref + + + + tixControl $f.elementorder -label "Element order: " -integer true \ + -variable options.elementorder -min 1 -max 20 \ + -options { + entry.width 2 + label.width 20 + label.anchor e + } + + pack $f.elementorder + + + tixControl $f.memory -label "Large Memory \[MB\]: " -integer true \ + -variable options.memory -min 0 -max 2000 \ + -options { + entry.width 5 + label.width 20 + label.anchor e + } + + global userlevel + if { $userlevel >= 3} { pack $f.memory } + + + # Mesh - Size options + set f [$w.nb subwidget meshsize] + + tixControl $f.meshsize -label "max mesh-size: " -integer false \ + -variable options.meshsize -min 1e-9 -max 1e6 \ + -options { + entry.width 6 + label.width 25 + label.anchor e + } + + tixControl $f.minmeshsize -label "min mesh-size: " -integer false \ + -variable options.minmeshsize -min 0 -max 1e6 \ + -options { + entry.width 6 + label.width 25 + label.anchor e + } + + tixControl $f.grading -label "mesh-size grading: " -integer false \ + -variable options.grading -min 0.1 -max 1 -step 0.1 \ + -options { + entry.width 6 + label.width 25 + label.anchor e + } + + pack $f.meshsize $f.minmeshsize $f.grading + + + + frame $f.msf + pack $f.msf + + tixLabelEntry $f.msf.ent -label "mesh-size file: " \ + -labelside top \ + -options { + entry.textVariable options.meshsizefilename + entry.width 35 + label.width 25 + label.anchor w + } + button $f.msf.btn -text "Browse" -command { + global options.meshsizefilename + set types { + {"Meshsize file" {.msz} } } + set options.meshsizefilename [tk_getOpenFile -filetypes $types -initialfile ${options.meshsizefilename}] + } + + pack $f.msf.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4 + pack $f.msf.btn -side left -anchor s -padx 4 -pady 4 + + + label $f.lab -text "Additional mesh size restrictions:" + + #csg-meshsize options + + frame $f.csg -relief groove -borderwidth 3 + pack $f.csg -fill x + + + frame $f.csg.curv + pack $f.csg.curv -anchor w + + scale $f.csg.curv.sc -orient horizontal -length 200 -from 0.2 -to 5 \ + -resolution 0.1 -variable options.curvaturesafety + label $f.csg.curv.la -text "Elements per curvature radius" + pack $f.csg.curv.sc $f.csg.curv.la -side left + + frame $f.csg.elen + pack $f.csg.elen -anchor w + scale $f.csg.elen.sc -orient horizontal -length 200 -from 0.2 -to 5 \ + -resolution 0.1 -variable options.segmentsperedge + label $f.csg.elen.la -text "Elements per edge" + pack $f.csg.elen.sc $f.csg.elen.la -side left + + + #stl-meshsize options + + frame $f.stl -relief groove -borderwidth 3 + pack $f.stl -fill x + + frame $f.stl.r2 + pack $f.stl.r2 -anchor w + scale $f.stl.r2.sc -orient horizontal -length 200 -from 0.2 -to 5 \ + -resolution 0.1 -variable stloptions.resthchartdistfac + checkbutton $f.stl.r2.bu -text "STL - chart distance" \ + -variable stloptions.resthchartdistenable + pack $f.stl.r2.sc $f.stl.r2.bu -side left + + frame $f.stl.r6 + pack $f.stl.r6 -anchor w + scale $f.stl.r6.sc -orient horizontal -length 200 -from 0.2 -to 5 \ + -resolution 0.1 -variable stloptions.resthlinelengthfac + checkbutton $f.stl.r6.bu -text "STL - line length" \ + -variable stloptions.resthlinelengthenable + pack $f.stl.r6.sc $f.stl.r6.bu -side left + + frame $f.stl.r3 + pack $f.stl.r3 -anchor w + scale $f.stl.r3.sc -orient horizontal -length 200 -from 0.2 -to 8 \ + -resolution 0.1 -variable stloptions.resthcloseedgefac + checkbutton $f.stl.r3.bu -text "STL/IGES/STEP - close edges" \ + -variable stloptions.resthcloseedgeenable + pack $f.stl.r3.sc $f.stl.r3.bu -side left + + frame $f.stl.r1 + pack $f.stl.r1 -anchor w + scale $f.stl.r1.sc -orient horizontal -length 200 -from 0.2 -to 5 \ + -resolution 0.1 -variable stloptions.resthsurfcurvfac + checkbutton $f.stl.r1.bu -text "STL - surface curvature" \ + -variable stloptions.resthsurfcurvenable + pack $f.stl.r1.sc $f.stl.r1.bu -side left + + frame $f.stl.r3b + pack $f.stl.r3b -anchor w + scale $f.stl.r3b.sc -orient horizontal -length 200 -from 0.2 -to 5 \ + -resolution 0.1 -variable stloptions.resthedgeanglefac + checkbutton $f.stl.r3b.bu -text "STL - edge angle" \ + -variable stloptions.resthedgeangleenable + pack $f.stl.r3b.sc $f.stl.r3b.bu -side left + + frame $f.stl.r5 + pack $f.stl.r5 -anchor w + scale $f.stl.r5.sc -orient horizontal -length 200 -from 0.2 -to 5 \ + -resolution 0.1 -variable stloptions.resthsurfmeshcurvfac + checkbutton $f.stl.r5.bu -text "STL - surface mesh curv" \ + -variable stloptions.resthsurfmeshcurvenable + pack $f.stl.r5.sc $f.stl.r5.bu -side left + + + checkbutton $f.stl.recalch -text "STL - Recalc mesh size for surface optimization" \ + -variable stloptions.recalchopt + pack $f.stl.recalch + + button $f.stl.calch -text "Calc New H" -command { redraw; Ng_STLCalcLocalH } + pack $f.stl.calch + + + + + + + set f [$w.nb subwidget chartopt] + + + label $f.lab1 -text "Yellow Edges Angle ()" + scale $f.scale1 -orient horizontal -length 300 \ + -from 0 -to 90 -resolution 1 -tickinterval 10 \ + -variable stloptions.yangle + + pack $f.lab1 $f.scale1 + + label $f.lab2e -text "Edge Corner Angle ()" + scale $f.scale2e -orient horizontal -length 360 -from 0 -to 180 \ + -resolution 1 -tickinterval 20 \ + -variable stloptions.edgecornerangle + pack $f.lab2e $f.scale2e + + label $f.lab2 -text "Chart Angle ()" + scale $f.scale2 -orient horizontal -length 360 -from 0 -to 180 \ + -resolution 1 -tickinterval 20 \ + -variable stloptions.chartangle + pack $f.lab2 $f.scale2 + + label $f.lab2b -text "Outer Chart Angle ()" + scale $f.scale2b -orient horizontal -length 360 -from 0 -to 180 \ + -resolution 1 -tickinterval 20 \ + -variable stloptions.outerchartangle + pack $f.lab2b $f.scale2b + + + + + # Optimization options + + set f [$w.nb subwidget optimizer] + + + + + tixControl $f.os2d -label "Surface opt steps: " -integer true \ + -variable options.optsteps2d -min 0 -max 99 -step 1 \ + -options { + entry.width 3 + label.width 25 + label.anchor e + } + + tixControl $f.os3d -label "Volume opt steps: " -integer true \ + -variable options.optsteps3d -min 0 -max 99 -step 1 \ + -options { + entry.width 3 + label.width 25 + label.anchor e + } + + tixControl $f.elw -label "Element size weight: " -integer false \ + -variable options.elsizeweight -min 0 -max 1 -step 0.1 \ + -options { + entry.width 3 + label.width 25 + label.anchor e + } + + tixControl $f.wem -label "Worst element measure: " -integer false \ + -variable options.opterrpow -min 1 -max 10 -step 1 \ + -options { + entry.width 3 + label.width 25 + label.anchor e + } + + pack $f.os2d $f.os3d $f.elw $f.wem + + frame $f.badellimit + pack $f.badellimit -fill x + label $f.badellimit.lab -text "bad element criterion"; + scale $f.badellimit.scale -orient horizontal -length 150 \ + -from 160 -to 180 -resolution 1 \ + -variable options.badellimit + pack $f.badellimit.scale $f.badellimit.lab -side right -anchor s + + + # insider options + set f [$w.nb subwidget insider] + + + + checkbutton $f.localh -text "Use Local Meshsize" \ + -variable options.localh + checkbutton $f.delauney -text "Use Delaunay" \ + -variable options.delaunay + checkbutton $f.checkoverlap -text "Check Overlapping" \ + -variable options.checkoverlap + checkbutton $f.checkcb -text "Check Chart Boundary" \ + -variable options.checkchartboundary + checkbutton $f.blockfill -text "Do Blockfilling" \ + -variable options.blockfill + + pack $f.localh $f.delauney $f.checkoverlap $f.blockfill $f.checkcb -anchor w + + + + + # debugging options + set f [$w.nb subwidget debug] + + frame $f.cb + pack $f.cb -side top + + + + checkbutton $f.cb.slowchecks -text "Slow checks" \ + -variable debug.slowchecks -command { Ng_SetDebugParameters } + checkbutton $f.cb.debugoutput -text "Debugging outout" \ + -variable debug.debugoutput -command { Ng_SetDebugParameters } + checkbutton $f.cb.haltexline -text "Halt on exising line" \ + -variable debug.haltexistingline -command { Ng_SetDebugParameters } + checkbutton $f.cb.haltoverlap -text "Halt on Overlap" \ + -variable debug.haltoverlap -command { Ng_SetDebugParameters } + checkbutton $f.cb.haltsuc -text "Halt on success" \ + -variable debug.haltsuccess -command { Ng_SetDebugParameters } + checkbutton $f.cb.haltnosuc -text "Halt on no success" \ + -variable debug.haltnosuccess -command { Ng_SetDebugParameters } + checkbutton $f.cb.haltlargequal -text "Halt on large quality class" \ + -variable debug.haltlargequalclass -command { Ng_SetDebugParameters } + checkbutton $f.cb.haltseg -text "Halt on Segment:" \ + -variable debug.haltsegment -command { Ng_SetDebugParameters } + checkbutton $f.cb.haltnode -text "Halt on Node:" \ + -variable debug.haltnode -command { Ng_SetDebugParameters } + + + pack $f.cb.slowchecks $f.cb.debugoutput $f.cb.haltexline $f.cb.haltoverlap $f.cb.haltsuc $f.cb.haltnosuc $f.cb.haltlargequal $f.cb.haltseg $f.cb.haltnode + + frame $f.cb.hf + pack $f.cb.hf -pady 5 + checkbutton $f.cb.hf.cb -text "Halt on Face:" \ + -variable debug.haltface -command { Ng_SetDebugParameters } + entry $f.cb.hf.ent -textvariable debug.haltfacenr -width 5 + pack $f.cb.hf.cb $f.cb.hf.ent -side left + + checkbutton $f.cb.showactivechart -text "Show Active Meshing-Chart" \ + -variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw } + + + + + pack $f.cb.showactivechart + + + frame $f.segs + pack $f.segs -pady 5 + label $f.segs.lab1 -text "P1:"; + entry $f.segs.ent1 -width 8 -relief sunken \ + -textvariable debug.haltsegmentp1 + label $f.segs.lab2 -text "P2:"; + entry $f.segs.ent2 -width 8 -relief sunken \ + -textvariable debug.haltsegmentp2 + pack $f.segs.lab1 $f.segs.ent1 $f.segs.lab2 $f.segs.ent2 -side left + + + + frame $f.cont -relief groove -borderwidth 3 + pack $f.cont + #-fill x + + checkbutton $f.cont.multidrawing -text "Draw Meshing" \ + -variable multithread_drawing + pack $f.cont.multidrawing + + checkbutton $f.cont.multitestmode -text "Meshing Testmode" \ + -variable multithread_testmode + pack $f.cont.multitestmode + + button $f.cont.goon -text "Go On" -command { set multithread_pause 0 } + pack $f.cont.multidrawing $f.cont.multitestmode $f.cont.goon -side left -expand yes + + + + + global userlevel + if { $userlevel < 3} { + $w.nb delete insider + $w.nb delete debug + } + + + +# tixButtonBox $w.bbox -orientation horizontal +# $w.bbox add ok -text Apply -underline 0 -width 5 \ +# -command { +# [.options_dlg.nb subwidget meshsize].meshsize invoke +# [.options_dlg.nb subwidget meshsize].grading invoke +# [.options_dlg.nb subwidget optimizer].os2d invoke +# [.options_dlg.nb subwidget optimizer].os3d invoke +# [.options_dlg.nb subwidget optimizer].elw invoke +# [.options_dlg.nb subwidget optimizer].wem invoke + +# Ng_SetMeshingParameters +# } + +# $w.bbox add close -text Done -underline 0 -width 5 \ +# -command { +# [.options_dlg.nb subwidget meshsize].meshsize invoke +# [.options_dlg.nb subwidget meshsize].grading invoke +# [.options_dlg.nb subwidget optimizer].os2d invoke +# [.options_dlg.nb subwidget optimizer].os3d invoke +# [.options_dlg.nb subwidget optimizer].elw invoke +# [.options_dlg.nb subwidget optimizer].wem invoke + +# Ng_SetMeshingParameters +# destroy .options_dlg +# } + +# pack $w.bbox -side bottom -fill x + + + frame $w.bu + pack $w.bu -fill x -ipady 3 + + button $w.bu.apl -text "Apply" -command { + [.options_dlg.nb subwidget meshsize].meshsize invoke + [.options_dlg.nb subwidget meshsize].grading invoke + [.options_dlg.nb subwidget optimizer].os2d invoke + [.options_dlg.nb subwidget optimizer].os3d invoke + [.options_dlg.nb subwidget optimizer].elw invoke + [.options_dlg.nb subwidget optimizer].wem invoke + + Ng_SetMeshingParameters + Ng_SetDebugParameters + } + + button $w.bu.ok -text "Done" -command { + [.options_dlg.nb subwidget meshsize].meshsize invoke + [.options_dlg.nb subwidget meshsize].grading invoke + [.options_dlg.nb subwidget optimizer].os2d invoke + [.options_dlg.nb subwidget optimizer].os3d invoke + [.options_dlg.nb subwidget optimizer].elw invoke + [.options_dlg.nb subwidget optimizer].wem invoke + + Ng_SetMeshingParameters + Ng_SetDebugParameters + wm withdraw .options_dlg +# destroy .options_dlg + } + + pack $w.bu.apl $w.bu.ok -side left -expand yes + + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Meshing Options" + focus .options_dlg + } +} + + +meshingoptionsdialog +wm withdraw .options_dlg + + + + + + + + + + + + +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 + } +} + +# +# +# Viewing dialog +# +# +proc viewingoptionsdialog { } { + + global userlevel + + set w .viewopts_dlg + + if {[winfo exists .viewopts_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + toplevel $w + + + + + tixNoteBook $w.nb -ipadx 6 -ipady 6 + + $w.nb add general -label "General" -underline 0 + $w.nb add stl -label "STL" -underline 0 + $w.nb add occ -label "IGES/STEP" -underline 0 + $w.nb add mesh -label "Mesh" -underline 0 + $w.nb add light -label "Light" -underline 0 + $w.nb add edges -label "Edges" -underline 0 + $w.nb add misc -label "Misc." -underline 3 + + + pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top + + + + + + # general + set f [$w.nb subwidget general] + + checkbutton $f.backcol -text "White Background" \ + -variable viewoptions.whitebackground \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $f.cross -text "Draw Coordinate Cross" \ + -variable viewoptions.drawcoordinatecross \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $f.color -text "Draw Color-bar" \ + -variable viewoptions.drawcolorbar \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $f.netgen -text "Draw Netgen-logo" \ + -variable viewoptions.drawnetgenlogo \ + -command { Ng_SetVisParameters; redraw } + + pack $f.backcol $f.cross $f.color $f.netgen + +# checkbutton $f.stereo -text "Stereo View" \ +# -variable viewoptions.stereo \ +# -command { Ng_SetVisParameters; redraw } +# pack $f.stereo + + # stl geometry + set f [$w.nb subwidget stl] + + frame $f.show -relief groove -borderwidth 3 + pack $f.show + checkbutton $f.show.showtrias -text "Show STL-Triangles" \ + -variable stloptions.showtrias -command { Ng_SetVisParameters; redraw } + pack $f.show.showtrias -anchor w + + checkbutton $f.show.showfilledtrias -text "Show Filled Triangles" \ + -variable stloptions.showfilledtrias -command { Ng_SetVisParameters; redraw } + pack $f.show.showfilledtrias -anchor w + + checkbutton $f.show.showactivechart -text "Show Active Meshing-Chart" \ + -variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw } + pack $f.show.showactivechart -anchor w + + checkbutton $f.show.showedges -text "Show Edges" \ + -variable stloptions.showedges -command { Ng_SetVisParameters; redraw } + pack $f.show.showedges -anchor w + + frame $f.special -relief groove -borderwidth 3 + pack $f.special + checkbutton $f.special.showmarktrias -text "Show Chart Triangles" \ + -variable stloptions.showmarktrias \ + -command {set stldoctor.showfaces 0; Ng_STLDoctor; Ng_SetVisParameters; redraw } + pack $f.special.showmarktrias -side left + + checkbutton $f.special.showfaces -text "Show Faces" \ + -variable stldoctor.showfaces \ + -command {set stloptions.showmarktrias 0; Ng_STLDoctor; Ng_SetVisParameters; redraw} + pack $f.special.showfaces -side left + + frame $f.fn -relief groove -borderwidth 3 + pack $f.fn + label $f.fn.lab3 -text "Chart/Face number:" + scale $f.fn.scale3 -orient horizontal -length 200 -from 0 -to 200 \ + -resolution 1 -tickinterval 50 \ + -command { Ng_SetVisParameters; redraw } -variable stloptions.chartnumber + pack $f.fn.lab3 $f.fn.scale3 -side left + + frame $f.fo -relief groove -borderwidth 3 + pack $f.fo + label $f.fo.lab -text "Chart/Face Offset:"; + entry $f.fo.ent -width 5 -relief sunken \ + -textvariable stloptions.chartnumberoffset + pack $f.fo.lab $f.fo.ent -side left + + frame $f.mt + pack $f.mt -fill x + checkbutton $f.mt.bu -text "Show Marked (Dirty) Triangles" \ + -variable stldoctor.showmarkedtrigs \ + -command {Ng_STLDoctor; redraw} + pack $f.mt.bu + + frame $f.ep + pack $f.ep -fill x + checkbutton $f.ep.bu -text "show edge corner points" \ + -variable stldoctor.showedgecornerpoints \ + -command {Ng_STLDoctor; redraw} + pack $f.ep.bu + + frame $f.stt + pack $f.stt -fill x + checkbutton $f.stt.bu -text "show touched triangle chart" \ + -variable stldoctor.showtouchedtrigchart \ + -command {set stldoctor.showfaces 0; set stloptions.showmarktrias 1; \ + Ng_STLDoctor; Ng_SetVisParameters; redraw} + pack $f.stt.bu + + frame $f.sml + pack $f.sml -fill x + checkbutton $f.sml.bu -text "draw meshed edges" \ + -variable stldoctor.drawmeshededges \ + -command {Ng_STLDoctor;} + pack $f.sml.bu + + + frame $f.sm + pack $f.sm -fill x + checkbutton $f.sm.bu -text "select with mouse" \ + -variable stldoctor.selectwithmouse + pack $f.sm.bu + + frame $f.st -relief groove -borderwidth 3 + pack $f.st -fill x + label $f.st.lab -text "Select triangle by number"; + entry $f.st.ent -width 5 -relief sunken \ + -textvariable stldoctor.selecttrig + pack $f.st.ent $f.st.lab -side left -expand yes + + frame $f.vc -relief groove -borderwidth 3 + pack $f.vc -fill x + checkbutton $f.vc.bu -text "show vicinity" \ + -variable stldoctor.showvicinity \ + -command {Ng_STLDoctor vicinity; redraw} + label $f.vc.lab -text "vicinity size"; + scale $f.vc.sc -orient horizontal -length 200 -from 0 -to 200 \ + -resolution 1 -variable stldoctor.vicinity \ + -command { Ng_STLDoctor vicinity; redraw } + pack $f.vc.bu $f.vc.lab $f.vc.sc -expand yes + + + + # IGES/STEP + set f [$w.nb subwidget occ] + + checkbutton $f.occshowsurfaces -text "Show surfaces " \ + -variable occoptions.showsurfaces \ + -command { Ng_SetOCCVisParameters; redraw } + + checkbutton $f.occshowedges -text "Show edges " \ + -variable occoptions.showedges \ + -command { Ng_SetOCCVisParameters; redraw } + + frame $f.deflection -relief groove -borderwidth 3 + pack $f.deflection -fill x + button $f.deflection.lab -text "Rebuild visualization data" \ + -command { + Ng_SetOCCVisParameters + Ng_OCCCommand buildvisualizationmesh + redraw + } + + tixControl $f.deflection.ent -label "Visualization smoothness" -integer false \ + -variable occoptions.deflection -min 0.1 -max 3 -step 0.1 \ + -options { entry.width 3 } \ + -command { Ng_SetOCCVisParameters } + + + + + + pack $f.deflection.ent $f.deflection.lab -side left -expand yes + pack $f.occshowsurfaces $f.occshowedges + + + # ACIS visualization / construction + + tixControl $f.showsolid -label "Show solid (0 for all)" -integer true \ + -variable occoptions.showsolidnr -min 0 -max 999 \ + -options { entry.width 3 } \ + -command { Ng_SetOCCVisParameters; redraw } + + tixControl $f.showsolid2 -label "Show solid 2" -integer true \ + -variable occoptions.showsolidnr2 -min 0 -max 999 \ + -options { entry.width 3 } \ + -command { Ng_SetOCCVisParameters; redraw } + + button $f.subtract -text "Subtract (2 minus 1)" \ + -command { + Ng_ACISCommand subtract ${occoptions.showsolidnr} ${occoptions.showsolidnr2} + redraw + } + + button $f.combine -text "Combine all" \ + -command { + Ng_ACISCommand combineall + redraw + } + + pack $f.showsolid $f.showsolid2 $f.subtract $f.combine + + + + + # mesh options + set f [$w.nb subwidget mesh] + + checkbutton $f.showcolor -text "Colored Meshsize Visualization" \ + -variable viewoptions.colormeshsize \ + -command { Ng_SetVisParameters; redraw } + + + checkbutton $f.showfilledtrigs -text "Show filled triangles" \ + -variable viewoptions.drawfilledtrigs \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $f.showedges -text "Show edges" \ + -variable viewoptions.drawedges \ + -command { Ng_SetVisParameters; redraw } + + + checkbutton $f.showoutline -text "Show Triangle Outline" \ + -variable viewoptions.drawoutline \ + -command { Ng_SetVisParameters; redraw } + + + tixControl $f.subdiv -label "Subdivision" -integer true \ + -variable visoptions.subdivisions -min 0 -max 8 \ + -options { entry.width 2 } \ + -command { puts "mesh-subdivision"; Ng_SetVisParameters; Ng_Vis_Set parameters; Ng_SetNextTimeStamp; redraw } + + + checkbutton $f.showbadels -text "Show bad elements" \ + -variable viewoptions.drawbadels \ + -command { Ng_SetVisParameters; redraw } + + + + checkbutton $f.showprisms -text "Show prisms" \ + -variable viewoptions.drawprisms \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $f.showpyramids -text "Show pyramids" \ + -variable viewoptions.drawpyramids \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $f.showhexes -text "Show hexes" \ + -variable viewoptions.drawhexes \ + -command { Ng_SetVisParameters; redraw } + + frame $f.fshrink + label $f.fshrink.lab -text "Shrink elements" + scale $f.fshrink.scale -orient horizontal -length 200 -from 0 -to 1.0001 \ + -resolution 0.01 -tickinterval 0.25 \ + -command { Ng_SetVisParameters; redraw } -variable viewoptions.shrink + + + checkbutton $f.showidentified -text "Show identified points" \ + -variable viewoptions.drawidentified \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $f.showmetispartition -text "Show METIS Partition" \ + -variable viewoptions.drawmetispartition \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $f.showpointnumbers -text "Show Point-numbers" \ + -variable viewoptions.drawpointnumbers \ + -command { Ng_SetVisParameters; redraw } + checkbutton $f.showedgenumbers -text "Show Edge-numbers" \ + -variable viewoptions.drawedgenumbers \ + -command { Ng_SetVisParameters; redraw } + checkbutton $f.showfacenumbers -text "Show Face-numbers" \ + -variable viewoptions.drawfacenumbers \ + -command { Ng_SetVisParameters; redraw } + checkbutton $f.showelementnumbers -text "Show Element-numbers" \ + -variable viewoptions.drawelementnumbers \ + -command { Ng_SetVisParameters; redraw } + + # label $f.showdomainlab -text "Domain Surface" +# scale $f.showdomain -orient horizontal -length 100 -from 0 -to 50 \ + -resolution 1 -variable viewoptions.drawdomainsurf \ + -command { Ng_SetVisParameters; redraw } \ + -label "Domain Surface" + + tixControl $f.showdomain -label "Show surface of domain" -integer true \ + -variable viewoptions.drawdomainsurf -min 0 -max 50 \ + -options { entry.width 2 } \ + -command { Ng_SetVisParameters; Ng_Vis_Set parameters; redraw } + + + + + frame $f.center -relief groove -borderwidth 3 + pack $f.center -fill x + button $f.center.lab -text "Set Center Point" \ + -command { Ng_SetVisParameters; Ng_Center; redraw } + entry $f.center.ent -width 5 -relief sunken \ + -textvariable viewoptions.centerpoint + pack $f.center.ent $f.center.lab -side left -expand yes + + frame $f.drawel -relief groove -borderwidth 3 + pack $f.drawel -fill x + button $f.drawel.lab -text "Draw Element" \ + -command { Ng_SetVisParameters; Ng_ZoomAll; redraw } + entry $f.drawel.ent -width 5 -relief sunken \ + -textvariable viewoptions.drawelement + pack $f.drawel.ent $f.drawel.lab -side left -expand yes + + pack $f.showfilledtrigs + pack $f.showoutline $f.subdiv $f.showedges $f.showbadels + # pack $f.showdomainlab + pack $f.showdomain + pack $f.showpointnumbers + pack $f.showedgenumbers $f.showfacenumbers $f.showelementnumbers + pack $f.showmetispartition + + + frame $f.frametets + checkbutton $f.frametets.showtets -text "Show Tets in domain " \ + -variable viewoptions.drawtets \ + -command { Ng_SetVisParameters; redraw } + tixControl $f.frametets.showtetsdomain -label "" -integer true \ + -variable viewoptions.drawtetsdomain -min 0 -max 500 \ + -options { entry.width 2 } \ + -command { Ng_SetVisParameters; redraw } + + pack $f.frametets + pack $f.frametets.showtets $f.frametets.showtetsdomain -side left + + + pack $f.showcolor $f.showpyramids $f.showprisms $f.showhexes $f.showidentified + + pack $f.fshrink + pack $f.fshrink.lab $f.fshrink.scale -side left + +# if {$userlevel == 3} { +# frame $f.framecurveproj +# checkbutton $f.framecurveproj.showcurveproj -text "Show curved edge projection " \ + -variable viewoptions.drawcurveproj \ + -command { Ng_SetVisParameters; redraw } + # tixControl $f.framecurveproj.showcurveprojedge -label "" -integer true \ + -variable viewoptions.drawcurveprojedge -min 1 -max 99999 \ + -options { entry.width 5 } \ + -command { Ng_SetVisParameters; redraw } + +# pack $f.framecurveproj +# pack $f.framecurveproj.showcurveproj $f.framecurveproj.showcurveprojedge -side left +# } + + + + + + + # light options + set f [$w.nb subwidget light] + + label $f.lab1 -text "Ambient Light" + scale $f.scale1 -orient horizontal -length 300 -from 0 -to 1 \ + -resolution 0.01 -tickinterval 0.2 \ + -command { Ng_SetVisParameters; redraw } -variable viewoptions.light.amb + label $f.lab2 -text "Diffuse Light" + scale $f.scale2 -orient horizontal -length 300 -from 0 -to 1 \ + -resolution 0.01 -tickinterval 0.2 \ + -command { Ng_SetVisParameters; redraw } -variable viewoptions.light.diff + label $f.lab3 -text "Specular Light" + scale $f.scale3 -orient horizontal -length 300 -from 0 -to 1 \ + -resolution 0.01 -tickinterval 0.2 \ + -command { Ng_SetVisParameters; redraw } -variable viewoptions.light.spec + label $f.lab4 -text "Material Shininess" + scale $f.scale4 -orient horizontal -length 300 -from 0 -to 128 \ + -resolution 1 -tickinterval 32 \ + -command { Ng_SetVisParameters; redraw } -variable viewoptions.mat.shininess + label $f.lab5 -text "Material Transparency" + scale $f.scale5 -orient horizontal -length 300 -from 0 -to 1 \ + -resolution 0.01 -tickinterval 0.2 \ + -command { Ng_SetVisParameters; redraw } -variable viewoptions.mat.transp + + pack $f.lab1 $f.scale1 $f.lab2 $f.scale2 $f.lab3 $f.scale3 $f.lab4 $f.scale4 $f.lab5 $f.scale5 + + + + + + # edges options + set f [$w.nb subwidget edges] + + checkbutton $f.showedges -text "Show Edges" \ + -variable viewoptions.drawededges \ + -command { Ng_SetVisParameters; redraw } + checkbutton $f.showpoints -text "Show Points" \ + -variable viewoptions.drawedpoints \ + -command { Ng_SetVisParameters; redraw } + checkbutton $f.showpointnrs -text "Show Points Nrs" \ + -variable viewoptions.drawedpointnrs \ + -command { Ng_SetVisParameters; redraw } + checkbutton $f.showtang -text "Show CP Tangents" \ + -variable viewoptions.drawedtangents \ + -command { Ng_SetVisParameters; redraw } + checkbutton $f.drawedgenrs -text "Show Edge Nrs" \ + -variable viewoptions.drawededgenrs \ + -command { Ng_SetVisParameters; redraw } + + pack $f.showedges $f.showpoints $f.showpointnrs $f.showtang $f.drawedgenrs + + frame $f.center -relief groove -borderwidth 3 + pack $f.center -fill x + button $f.center.lab -text "Set Center Point" \ + -command { Ng_SetVisParameters; Ng_Center; redraw } + entry $f.center.ent -width 5 -relief sunken \ + -textvariable viewoptions.centerpoint + pack $f.center.ent $f.center.lab -side left -expand yes + + + + frame $f.f1 + pack $f.f1 -pady 5 + label $f.f1.lab -text "SpecPoint Veclen" + entry $f.f1.ent -width 5 -relief sunken -textvariable viewoptions.specpointvlen + pack $f.f1.lab $f.f1.ent + + + + + # misc options + set f [$w.nb subwidget misc] + + frame $f.point -relief groove -borderwidth 3 + + frame $f.point.dp + + checkbutton $f.point.dp.drawpoint -text "Draw Point" \ + -variable viewoptions.drawspecpoint \ + -command { Ng_SetVisParameters; redraw } + + entry $f.point.dp.px -width 8 -relief sunken -textvariable viewoptions.specpointx + entry $f.point.dp.py -width 8 -relief sunken -textvariable viewoptions.specpointy + entry $f.point.dp.pz -width 8 -relief sunken -textvariable viewoptions.specpointz + + pack $f.point.dp.drawpoint $f.point.dp.px $f.point.dp.py $f.point.dp.pz -side left + + pack $f.point.dp + + checkbutton $f.point.center -text "Use as Center" \ + -variable viewoptions.usecentercoords \ + -command { + if { ${viewoptions.usecentercoords} } { + set viewoptions.centerx ${viewoptions.specpointx} + set viewoptions.centery ${viewoptions.specpointy} + set viewoptions.centerz ${viewoptions.specpointz} + Ng_SetVisParameters; Ng_Center + redraw + } { + Ng_SetVisParameters + } + + + } + + pack $f.point.center + + pack $f.point -fill x -ipady 3 + + + + frame $w.bu + pack $w.bu -fill x -ipady 3 + + + button $w.bu.done -text "Done" -command { + Ng_SetVisParameters; + redraw + destroy .viewopts_dlg + } + button $w.bu.apply -text "Apply" -command { + Ng_SetVisParameters; + redraw + } + pack $w.bu.apply $w.bu.done -expand yes -side left + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Viewing options" + focus $w + } +} + + + + + + + +set clippingdialog_pop1 0 +set clippingdialog_pop2 0 +set clippingdialog_pop3 0 +set clippingdialog_pop4 0 + + +# +# +# clipping dialog +# +# +proc clippingdialog { } { + + global clippingdialog_pop1 + global clippingdialog_pop2 + global clippingdialog_pop3 + global clippingdialog_pop4 + set clippingdialog_pop1 1 + set clippingdialog_pop2 1 + set clippingdialog_pop3 1 + set clippingdialog_pop4 1 + + set w .clipping_dlg + + if {[winfo exists .clipping_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + + toplevel $w + + label $w.lab1 -text "Normal x" + scale $w.scale1 -orient horizontal -length 300 -from -1 -to 1 \ + -resolution 0.01 -tickinterval 0.5 \ + -variable viewoptions.clipping.nx \ + -command { popupcheckredraw2 clippingdialog_pop1 ${viewoptions.clipping.enable} } + +# Ng_SetVisParameters; +# if { ${viewoptions.clipping.enable} == 1 } { redraw }; +# Ng_SetVisParameters + + label $w.lab2 -text "Normal y" + scale $w.scale2 -orient horizontal -length 300 -from -1 -to 1 \ + -resolution 0.01 -tickinterval 0.5 \ + -variable viewoptions.clipping.ny \ + -command { popupcheckredraw2 clippingdialog_pop2 ${viewoptions.clipping.enable} } + + label $w.lab3 -text "Normal z" + scale $w.scale3 -orient horizontal -length 300 -from -1 -to 1 \ + -resolution 0.01 -tickinterval 0.5 \ + -variable viewoptions.clipping.nz \ + -command { popupcheckredraw2 clippingdialog_pop3 ${viewoptions.clipping.enable} } + label $w.lab4 -text "Distance" + scale $w.scale4 -orient horizontal -length 300 -from -1 -to 1.001 \ + -resolution 0.0001 -tickinterval 0.5 \ + -variable viewoptions.clipping.dist \ + -command { popupcheckredraw2 clippingdialog_pop4 ${viewoptions.clipping.enable} } + + + tixControl $w.clipdomain -label "Clip only domain" -integer true \ + -variable viewoptions.clipping.onlydomain -min 0 -max 50 \ + -options { entry.width 2 } \ + -command { Ng_SetVisParameters; redraw } + tixControl $w.donotclipdomain -label "Do not clip domain" -integer true \ + -variable viewoptions.clipping.notdomain -min 0 -max 50 \ + -options { entry.width 2 } \ + -command { Ng_SetVisParameters; redraw } + + pack $w.lab1 $w.scale1 $w.lab2 $w.scale2 $w.lab3 $w.scale3 $w.lab4 $w.scale4 $w.clipdomain $w.donotclipdomain + + + checkbutton $w.cb1 -text "Enable clipping" \ + -variable viewoptions.clipping.enable \ + -command { Ng_SetVisParameters; redraw } + + pack $w.cb1 + + + + frame $w.bu +# pack $w.bu -fill x + pack $w.bu -fill x -ipady 3 + + button $w.bu.cancle -text "Done" -command "destroy $w" + pack $w.bu.cancle -expand yes + + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Clipping Plane" + # grab $w + focus $w + + +# $w.scale1 configure -command { puts "call1b"; Ng_SetVisParameters; redraw } +# puts "after" + + + } +} + + + + + +# +# refinement dialog +# +# +proc refinementdialog { } { + + set w .refinement_dlg + + if {[winfo exists .refinement_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + + toplevel $w + + + tixControl $w.meshsize -label "max mesh-size: " -integer false \ + -variable options.meshsize -min 1e-6 -max 1e6 \ + -options { + entry.width 6 + label.width 25 + label.anchor e + } + + pack $w.meshsize + + global localh + set localh 1 + tixControl $w.loch -label "local mesh-size: " -integer false \ + -variable localh -min 1e-6 -max 1e6 \ + -options { + entry.width 6 + label.width 25 + label.anchor e + } + + pack $w.loch + + + button $w.restface -text "Restrict H at face" \ + -command { + .refinement_dlg.meshsize invoke + .refinement_dlg.loch invoke + Ng_RestrictH face $localh + } + button $w.restedge -text "Restrict H at edge" \ + -command { + .refinement_dlg.meshsize invoke + .refinement_dlg.loch invoke + Ng_RestrictH edge $localh + } + button $w.restelement -text "Restrict H at element" \ + -command { + .refinement_dlg.meshsize invoke + .refinement_dlg.loch invoke + Ng_RestrictH element $localh + } + button $w.restpoint -text "Restrict H at point" \ + -command { + .refinement_dlg.meshsize invoke + .refinement_dlg.loch invoke + Ng_RestrictH point $localh + } + + + pack $w.restface $w.restedge $w.restelement $w.restpoint + + + + button $w.anisoedge -text "Declare Anisotropic edge" \ + -command { + Ng_Anisotropy edge + } + pack $w.anisoedge + + + frame $w.bu + pack $w.bu -fill x -ipady 3 + + + button $w.bu.cancle -text "Done" -command "destroy .refinement_dlg" + button $w.bu.refine -text "Refine" \ + -command { +# Ng_BisectCopyMesh; + set oldnp 0; set newnp $status_np; + while { $oldnp < $newnp } { + set level [expr $level+1] + Ng_Bisect; + Ng_HighOrder ${options.elementorder} + Ng_ReadStatus; + redraw; + set oldnp $newnp + set newnp $status_np + puts "oldnp $oldnp newnp $newnp" + } + } + button $w.bu.zrefine -text "Z-Refine" \ + -command { Ng_ZRefinement; Ng_ReadStatus; redraw; } + + pack $w.bu.zrefine $w.bu.refine $w.bu.cancle -expand yes -side left + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Select Refinement" + focus $w + } +} + + + + +# +# boundcondessing dialog +# +# +proc bcpropdialog { } { + + set w .bcprop_dlg + + if {[winfo exists .bcprop_dlg] == 1} { + wm withdraw $w + wm deiconify $w + } { + toplevel $w + + frame $w.face -borderwidth 3 + pack $w.face -fill x + label $w.face.lab -text "face index:" + label $w.face.ent -text 1 -padx 4 + button $w.face.next -text "next" -command { + set w .bcprop_dlg; + set facenr [$w.face.ent cget -text] + if {$facenr == [Ng_BCProp getnfd]} { + set facenr 1 + } { + set facenr [expr $facenr + 1] + } + $w.face.ent configure -text $facenr + Ng_BCProp setactive $facenr + set bcnr [Ng_BCProp getbc $facenr] + $w.bc.ent delete 0 end + $w.bc.ent insert 0 $bcnr + + redraw + } + button $w.face.prev -text "prev" -command { + set w .bcprop_dlg; + set facenr [$w.face.ent cget -text] + if {$facenr == 1} { + set facenr [Ng_BCProp getnfd] + } { + set facenr [expr $facenr - 1] + } + $w.face.ent configure -text $facenr + Ng_BCProp setactive $facenr + set bcnr [Ng_BCProp getbc $facenr] + $w.bc.ent delete 0 end + $w.bc.ent insert 0 $bcnr + + redraw + } + + + pack $w.face.lab $w.face.ent $w.face.prev $w.face.next -side left + + frame $w.bc -borderwidth 3 + pack $w.bc -fill x + label $w.bc.lab -text "bc property:" + entry $w.bc.ent -width 5 -relief sunken + button $w.bc.but -text "change" -command { + set w .bcprop_dlg; + Ng_BCProp setbc [$w.face.ent cget -text] [$w.bc.ent get]; + } + button $w.bc.but2 -text "all" -command { + set w .bcprop_dlg; + Ng_BCProp setall [$w.bc.ent get]; + } + pack $w.bc.lab $w.bc.ent $w.bc.but $w.bc.but2 -side left -expand yes + + frame $w.bcname -borderwidth 3 + pack $w.bcname -fill x + label $w.bcname.lab -text "bc name:" + label $w.bcname.ent -text "-" + pack $w.bcname.lab $w.bcname.ent -side left -expand yes + + + frame $w.bu + pack $w.bu -fill x -ipady 3 + + button $w.bu.close -text "Close" -command { destroy .bcprop_dlg } + + pack $w.bu.close -expand yes -side left + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Boundary Conditions" + } + + focus $w + + set facenr [Ng_BCProp getactive] + $w.face.ent configure -text $facenr + + set bcnr [Ng_BCProp getbc $facenr] + $w.bc.ent delete 0 end + $w.bc.ent insert 0 $bcnr + + set bcname [Ng_BCProp getbcname $facenr] + $w.bcname.ent configure -text $bcname + +} + + + + +# +# METIS dialog +# +# +proc METISdialog { } { + + set w .metis_dlg + set w.parts 64 + + if {[winfo exists .metis_dlg] == 1} { + wm withdraw $w + wm deiconify $w + } { + toplevel $w + + frame $w.a -borderwidth 0 + frame $w.b -borderwidth 0 + pack $w.a $w.b + + label $w.a.lab -text "Number of partitions:" + entry $w.a.ent -textvariable w.parts -width 4 -relief sunken + + button $w.b.start -text "Start METIS" -command { + Ng_Metis ${w.parts} + redraw + } + button $w.b.cancel -text "Cancel" -command { destroy .metis_dlg } + pack $w.a.lab $w.a.ent -side left -expand yes + pack $w.b.start $w.b.cancel -side left + + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "METIS Partitioning" + focus $w + + } +} + + + +# +# STL dialog +# +proc stloptionsdialog { } { + + set w .stlopts_dlg + + if {[winfo exists .stlopts_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + toplevel $w + + tixNoteBook $w.nb -ipadx 6 -ipady 6 + # $w config -bg gray + # $w.nb subwidget nbframe config -backpagecolor gray + + # Create the two tabs on the notebook. The -underline option + # puts a underline on the first character of the labels of the tabs. + # Keyboard accelerators will be defined automatically according + # to the underlined character. + # + +# $w.nb add chartopt -label "Chart Options" -underline 0 +# #$w.nb add meshsize -label "Mesh Size" -underline 0 +# pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top + + +# set f [$w.nb subwidget chartopt] + + +# label $f.lab1 -text "Yellow Edges Angle ()" +# scale $f.scale1 -orient horizontal -length 300 \ +# -from 0 -to 90 -resolution 1 -tickinterval 10 \ +# -variable stloptions.yangle + +# pack $f.lab1 $f.scale1 + +# label $f.lab2e -text "Edge Corner Angle ()" +# scale $f.scale2e -orient horizontal -length 360 -from 0 -to 180 \ +# -resolution 1 -tickinterval 20 \ +# -variable stloptions.edgecornerangle +# pack $f.lab2e $f.scale2e + +# label $f.lab2 -text "Chart Angle ()" +# scale $f.scale2 -orient horizontal -length 360 -from 0 -to 180 \ +# -resolution 1 -tickinterval 20 \ +# -variable stloptions.chartangle +# pack $f.lab2 $f.scale2 + +# label $f.lab2b -text "Outer Chart Angle ()" +# scale $f.scale2b -orient horizontal -length 360 -from 0 -to 180 \ +# -resolution 1 -tickinterval 20 \ +# -variable stloptions.outerchartangle +# pack $f.lab2b $f.scale2b + +# frame $f.r4 +# pack $f.r4 -anchor w +# scale $f.r4.sc -orient horizontal -length 200 -from 0.1 -to 10 \ +# -resolution 0.1 -variable stloptions.resthatlasfac +# checkbutton $f.r4.bu -text "Restrict h for Calc Atlas (Faster)" \ +# -variable stloptions.resthatlasenable +# pack $f.r4.sc $f.r4.bu -side left + + + #set f [$w.nb subwidget meshsize] + + + +# checkbutton $w.seat -text "Use Searchtrees" \ +# -variable stloptions.usesearchtree +# pack $w.seat + + + + + frame $w.bu +# pack $w.bu + pack $w.bu -fill x -ipady 3 + +# -fill x + + button $w.bu.apply -text "Apply" -command { redraw; Ng_GenerateMesh 1 2} + button $w.bu.cancle -text "Done" -command { destroy .stlopts_dlg } + pack $w.bu.cancle $w.bu.apply -side left -expand yes + + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "STL Options" +# grab $w + focus $w + } +} + +proc stldoctordialog { } { + + set wd .stldoctor_dlg + + if {[winfo exists .stldoctor_dlg] == 1} { + wm withdraw $wd + wm deiconify $wd + focus $wd + } { + + toplevel $wd + + tixNoteBook $wd.nb -ipadx 6 -ipady 6 + + $wd.nb add general -label "General" -underline 0 + $wd.nb add topology -label "Edit Topology" -underline 5 + $wd.nb add edges -label "Edit Edges" -underline 5 + $wd.nb add normals -label "Edit Normals" -underline 5 + $wd.nb add advanced -label "Advanced" -underline 0 + + + pack $wd.nb -expand yes -fill both -padx 5 -pady 5 -side top + + + # GENERAL ***************************** + + set f [$wd.nb subwidget general] + + + frame $f.show + pack $f.show -fill x + checkbutton $f.show.showtrias -text "Show STL-Triangles" \ + -variable stloptions.showtrias -command { Ng_SetVisParameters; redraw } + pack $f.show.showtrias -anchor w + + checkbutton $f.show.showfilledtrias -text "Show Filled Triangles" \ + -variable stloptions.showfilledtrias -command { Ng_SetVisParameters; redraw } + pack $f.show.showfilledtrias -anchor w + + set selmodevals { 0 1 2 3 4 } + set selmodelabs(0) "triangle" + set selmodelabs(1) "edge" + set selmodelabs(2) "point" + set selmodelabs(3) "line" + set selmodelabs(4) "line cluster" + + tixOptionMenu $f.selmode -label "Double Click selects :" \ + -options { + label.width 19 + label.anchor e + menubutton.width 15 + } + + foreach selmodev $selmodevals { + $f.selmode add command $selmodev -label $selmodelabs($selmodev) + } + $f.selmode config -variable stldoctor.selectmode + $f.selmode config -command { Ng_STLDoctor } + global stldoctor.selectmode + pack $f.selmode + + frame $f.sm + pack $f.sm -fill x + checkbutton $f.sm.bu -text "select with mouse" \ + -variable stldoctor.selectwithmouse + pack $f.sm.bu + + frame $f.st -relief groove -borderwidth 3 + pack $f.st -fill x + label $f.st.lab -text "Select triangle by number"; + entry $f.st.ent -width 5 -relief sunken \ + -textvariable stldoctor.selecttrig + pack $f.st.ent $f.st.lab -side left -expand yes + + frame $f.vc -relief groove -borderwidth 3 + pack $f.vc -fill x + checkbutton $f.vc.bu -text "show vicinity" \ + -variable stldoctor.showvicinity \ + -command {Ng_STLDoctor vicinity; redraw} + label $f.vc.lab -text "vicinity size"; + scale $f.vc.sc -orient horizontal -length 200 -from 0 -to 200 \ + -resolution 1 -variable stldoctor.vicinity \ + -command { Ng_STLDoctor vicinity; redraw } + pack $f.vc.bu $f.vc.lab $f.vc.sc -expand yes + + frame $f.ge -relief groove -borderwidth 3 + pack $f.ge -fill x + button $f.ge.neighbourangles -text "calc neighbourangles" -command {Ng_STLDoctor neighbourangles} + button $f.ge.showcoords -text "show coords of touched triangle" -command {Ng_STLDoctor showcoords} + button $f.ge.moveptm -text "move point to middle of trianglepoints" -command {Ng_STLDoctor movepointtomiddle; redraw} + button $f.ge.destroy0trigs -text "destroy 0-volume triangles" -command {Ng_STLDoctor destroy0trigs} + pack $f.ge.neighbourangles $f.ge.showcoords $f.ge.moveptm $f.ge.destroy0trigs -expand yes + + + button $f.ge.cancle -text "Done" -command {destroy .stldoctor_dlg } + pack $f.ge.cancle -expand yes + + # TOPOLOGY ******************** + set f [$wd.nb subwidget topology] + + frame $f.oc -relief groove -borderwidth 3 + pack $f.oc -fill x + button $f.oc.bu -text "invert orientation of selected trig" -command {Ng_STLDoctor invertselectedtrig; redraw } + button $f.oc.bu2 -text "orient after selected trig" -command {Ng_STLDoctor orientafterselectedtrig; redraw } + pack $f.oc.bu $f.oc.bu2 -side left -expand yes + + button $f.toperr -text "mark inconsistent triangles" -command {Ng_STLDoctor marktoperrortrigs; redraw } + + button $f.deltrig -text "delete selected triangle" -command {Ng_STLDoctor deleteselectedtrig; redraw } + button $f.geosmooth -text "geometric smoothing" -command {Ng_STLDoctor smoothgeometry; redraw } + + pack $f.toperr $f.deltrig $f.geosmooth + + + + + + # EDGES *********************** + set f [$wd.nb subwidget edges] + + + frame $f.be -relief groove -borderwidth 3 + pack $f.be -fill x + label $f.be.lab -text "build edges with yellow angle:"; + scale $f.be.sc -orient horizontal -length 200 -from 0 -to 100 \ + -resolution 0.5 + $f.be.sc config -variable stloptions.yangle + $f.be.sc config -command { Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw } + label $f.be.lab2 -text "continue edges with yellow angle:"; + scale $f.be.sc2 -orient horizontal -length 200 -from 0 -to 100 \ + -resolution 0.5 + $f.be.sc2 config -variable stloptions.contyangle + $f.be.sc2 config -command { Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw } + + + + button $f.be.buildedges -text "Build Edges" -command {Ng_STLDoctor buildedges; redraw} + pack $f.be.lab $f.be.sc $f.be.lab2 $f.be.sc2 $f.be.buildedges -expand yes + + frame $f.se + pack $f.se -fill x + checkbutton $f.se.bu -text "show excluded" \ + -variable stldoctor.showexcluded \ + -command {Ng_STLDoctor; redraw} + pack $f.se.bu + + # edgeselectmode ****** + + set edgeselmodevals { 0 1 2 3 4 } + set edgeselmodelabs(0) "no change" + set edgeselmodelabs(1) "undefined" + set edgeselmodelabs(2) "confirmed" + set edgeselmodelabs(3) "candidate" + set edgeselmodelabs(4) "excluded" + + tixOptionMenu $f.edgeselmode -label "Double Click sets edge :" \ + -options { + label.width 19 + label.anchor e + menubutton.width 15 + } + + foreach edgeselmodev $edgeselmodevals { + $f.edgeselmode add command $edgeselmodev -label $edgeselmodelabs($edgeselmodev) + } + $f.edgeselmode config -variable stldoctor.edgeselectmode + $f.edgeselmode config -command { Ng_STLDoctor } + global stldoctor.edgeselectmode + pack $f.edgeselmode + + # edge buttons + + frame $f.edg -relief groove -borderwidth 3 + pack $f.edg -fill x + +# checkbutton $f.edg.bu -text "use external edges" \ +# -variable stldoctor.useexternaledges \ +# -command {Ng_STLDoctor; redraw} +# pack $f.edg.bu -expand yes + + + frame $f.edg.f0 + pack $f.edg.f0 + button $f.edg.f0.confirmedge -text "confirm" -command {Ng_STLDoctor confirmedge; redraw} + button $f.edg.f0.candidateedge -text "candidate" -command {Ng_STLDoctor candidateedge; redraw} + button $f.edg.f0.excludeedge -text "exclude" -command {Ng_STLDoctor excludeedge; redraw} + button $f.edg.f0.undefinededge -text "undefined" -command {Ng_STLDoctor undefinededge; redraw} + pack $f.edg.f0.confirmedge $f.edg.f0.candidateedge $f.edg.f0.excludeedge $f.edg.f0.undefinededge -side left + + frame $f.edg.fa + pack $f.edg.fa + button $f.edg.fa.setallundefined -text "all undefined" -command {Ng_STLDoctor setallundefinededges; redraw} + button $f.edg.fa.erasecandidates -text "candidates to undefined" -command {Ng_STLDoctor erasecandidateedges; redraw} + pack $f.edg.fa.setallundefined $f.edg.fa.erasecandidates -side left + + + frame $f.edg.fb + pack $f.edg.fb + button $f.edg.fb.confirmcandidates -text "candidates to confirmed" -command {Ng_STLDoctor confirmcandidateedges; redraw} + button $f.edg.fb.confirmedtocandidates -text "confirmed to candidates" -command {Ng_STLDoctor confirmedtocandidateedges; redraw} + pack $f.edg.fb.confirmcandidates $f.edg.fb.confirmedtocandidates -side left + + frame $f.edg.f1 + frame $f.edg.f2 + frame $f.edg.f3 + frame $f.edg.f4 + pack $f.edg.f1 $f.edg.f2 $f.edg.f3 $f.edg.f4 + + button $f.edg.f1.exportedges -text "export edges" -command {Ng_STLDoctor exportedges} + button $f.edg.f1.importedges -text "import edges" -command {Ng_STLDoctor importedges; redraw} + button $f.edg.f1.saveedgedata -text "save edgedata" \ + -command { + set types { + {"Netgen Edgedata" {.ned} } + } + set file [tk_getSaveFile -filetypes $types -defaultextension ".ned"] + if {$file != ""} { + Ng_STLDoctor saveedgedata $file + } + } + + button $f.edg.f1.loadedgedata -text "load edgedata" \ + -command { + set types { + {"Netgen Edgedata" {.ned} } + } + set file [tk_getOpenFile -filetypes $types -defaultextension ".ned"] + if {$file != ""} { + Ng_STLDoctor loadedgedata $file + puts "loading done" + + redraw + +# wm title . [concat "NETGEN - " $file] + } + } + + button $f.edg.f1.importAVLedges -text "import AVL edges" \ + -command { + set types {{"Edge file" {.edg }}} + + set file [tk_getOpenFile -filetypes $types -defaultextension ".edg"] + if {$file != ""} { + Ng_STLDoctor importexternaledges $file; + } + } + + pack $f.edg.f1.importAVLedges $f.edg.f1.loadedgedata $f.edg.f1.saveedgedata -side left + +# button $f.edg.f1.buildedges -text "build external edges" -command {Ng_STLDoctor buildexternaledges; redraw} + frame $f.edg2 -relief groove -borderwidth 3 + pack $f.edg2 -fill x + + +# button $f.edg2.addlonglines -text "make long lines candidates (% of diam)" -command {Ng_STLDoctor addlonglines; redraw} + label $f.edg2.lab -text "length (%):" + scale $f.edg2.sc -orient horizontal -length 200 -from 0 -to 100 \ + -resolution 0.5 \ + -variable stldoctor.longlinefact + + # button $f.edg2.deletedirtyedges -text "make dirty edges candidates" -command {Ng_STLDoctor deletedirtyedges; redraw} + button $f.edg2.undoedge -text "undo last edge change" -command {Ng_STLDoctor undoedgechange; redraw} + + # pack $f.edg2.addlonglines $f.edg2.deletedirtyedges -expand yes + # pack $f.edg2.lab $f.edg2.sc -side left + pack $f.edg2.undoedge -expand yes + + + + # NORMALS *********************** + set f [$wd.nb subwidget normals] + + frame $f.dt -relief groove -borderwidth 3 + pack $f.dt -fill x + label $f.dt.lab -text "dirty triangle factor"; + entry $f.dt.ent -width 5 -relief sunken \ + -textvariable stldoctor.dirtytrigfact + pack $f.dt.ent $f.dt.lab -side left -expand yes + + frame $f.srt -relief groove -borderwidth 3 + pack $f.srt -fill x + button $f.srt.bu -text "smooth reverted triangles geometric" -command {Ng_STLDoctor smoothrevertedtrigs; redraw } + entry $f.srt.ent -width 5 -relief sunken \ + -textvariable stldoctor.smoothangle + pack $f.srt.ent $f.srt.bu -side left -expand yes + + frame $f.bdt -relief groove -borderwidth 3 + pack $f.bdt -fill x + button $f.bdt.bu -text "mark dirty triangles" -command {Ng_STLDoctor markdirtytrigs; redraw } + button $f.bdt.bu2 -text "smooth dirty triangles normal" -command {Ng_STLDoctor smoothdirtytrigs; redraw } + pack $f.bdt.bu $f.bdt.bu2 -side left -expand yes + + + frame $f.sno -relief groove -borderwidth 3 + pack $f.sno + + label $f.sno.labrough -text "rough" + scale $f.sno.scsmooth -orient horizontal -length 100 -from 0 -to 0.8 \ + -resolution 0.01 -variable stldoctor.smoothnormalsweight \ + -command { Ng_SetSTLParameters } + label $f.sno.labsmooth -text "smooth" + button $f.sno.smoothnormals -text "smooth normals" -command { Ng_STLDoctor smoothnormals; redraw} + + + + pack $f.sno.labrough $f.sno.scsmooth $f.sno.labsmooth $f.sno.smoothnormals -side left -padx 5 + + frame $f.no -relief groove -borderwidth 3 + pack $f.no -fill x + + button $f.no.marknonsmoothnormals -text "mark non-smooth triangles" -command {Ng_STLDoctor marknonsmoothnormals; redraw} + button $f.no.calcnormals -text "calculate normals from geometry" -command {Ng_STLDoctor calcnormals; redraw} + + pack $f.no.marknonsmoothnormals $f.no.calcnormals -expand yes + + + # ADVANCED ************************** + set f [$wd.nb subwidget advanced] + + + frame $f.sc + pack $f.sc -fill x + checkbutton $f.sc.bu -text "spiral check" \ + -variable stldoctor.spiralcheck \ + -command {Ng_STLDoctor;} + checkbutton $f.sc.bu2 -text "cone check" \ + -variable stldoctor.conecheck \ + -command {Ng_STLDoctor;} + pack $f.sc.bu $f.sc.bu2 + + + tixControl $f.gtol -label "load-geometry tolerance factor" -integer false \ + -variable stldoctor.geom_tol_fact \ + -options { + entry.width 8 + label.width 30 + label.anchor e + } + pack $f.gtol + + button $f.adap -text "Apply" -command { + [.stldoctor_dlg.nb subwidget advanced].gtol invoke + Ng_STLDoctor; + } + pack $f.adap -expand yes + +# frame $f.gtol -relief groove -borderwidth 3 +# pack $f.gtol -fill x +# label $f.gtol.lab -text "Geometry-Load-Tolerance-Factor"; +# entry $f.gtol.ent -width 5 -relief sunken \ +# -textvariable stldoctor.geom_tol_fact +# pack $f.gtol.lab $f.gtol.ent -side left -expand yes + + #******************************* + wm withdraw $wd + wm geom $wd +100+100 + wm deiconify $wd + wm title $wd "STL Doctor" + + focus $wd +} +} + + + + + +proc meshdoctordialog { } { + + set w .meshdoc_dlg + global meshdoctor.active + + if {[winfo exists .meshdoc_dlg] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + toplevel $w + + set meshdoctor.active 1 + Ng_MeshDoctor; + + + frame $w.vis -relief groove -borderwidth 3 + pack $w.vis + + checkbutton $w.vis.showfilledtrigs -text "Show filled triangles" \ + -variable viewoptions.drawfilledtrigs \ + -command { Ng_SetVisParameters; redraw } + + checkbutton $w.vis.showedges -text "Show edges" \ + -variable viewoptions.drawedges \ + -command { Ng_SetVisParameters; redraw } + + + checkbutton $w.vis.showoutline -text "Show Triangle Outline" \ + -variable viewoptions.drawoutline \ + -command { Ng_SetVisParameters; redraw } + + pack $w.vis.showfilledtrigs $w.vis.showoutline $w.vis.showedges + + tixControl $w.markedgedist -label "Mark edge dist: " -integer true \ + -min 0 -max 999 \ + -variable meshdoc.markedgedist \ + -options { + entry.width 3 + label.width 20 + label.anchor e + } \ + -command { + Ng_MeshDoctor markedgedist ${meshdoc.markedgedist} + redraw + } + pack $w.markedgedist + + button $w.deledge -text "Delete marked segments" -command { + Ng_MeshDoctor deletemarkedsegments + redraw + } + pack $w.deledge + + button $w.close -text "Close" -command { + set meshdoctor.active 0; + Ng_MeshDoctor; + destroy .meshdoc_dlg + } + pack $w.close -expand yes + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Mesh Doctor" + } +} + + + +# +# Quality viewer +# + +proc qualityviewdialog { show } { + + set w .qualityview_dlg + + if {[winfo exists .qualityview_dlg] == 1} { + + if { $show == 1 } { + wm withdraw .qualityview_dlg + wm deiconify $w + focus $w + } { + wm withdraw $w + } + } { + toplevel $w + + set c $w.c + + canvas $c -relief raised -width 450 -height 300 + pack $w.c -side top -fill x + + set plotFont {Helvetica 12} + set smallFont {Helvetica 12} + + $c create line 100 250 400 250 -width 2 + $c create line 100 250 100 50 -width 2 + + for {set i 0} {$i <= 10} {incr i} { + set x [expr {100 + ($i*30)}] + $c create line $x 250 $x 245 -width 2 + if { [expr {$i % 2}] == 0 } { + $c create text $x 254 -text [format %1.1f [expr 0.1*$i]] -anchor n -font $plotFont + } + } + + global qualbar + global qualbarnull + global qualbaraxis + + for {set i 0} {$i <= 5} {incr i} { + set y [expr {250 - ($i*40)}] + $c create line 100 $y 105 $y -width 2 + +# global qualbaraxis($i) + set qualbaraxis($i) \ + [$c create text 96 $y -text [expr $i*50].0 -anchor e -font $plotFont] + } + + for {set i 0} {$i < 20} {incr i} { + set x1 [expr {100 + ($i*15) + 2}] + set x2 [expr {$x1+10}] + set y [expr {250 - 10 * $i}] +# global qualbar($i) + set qualbar($i) [$c create rectangle $x1 250 $x2 245 -fill blue] + set qualbarnull($i) [$c create text [expr {($x1+$x2)/2}] 245 -text 0 -anchor s -font $smallFont -fill blue] + } + + frame $w.bu + pack $w.bu + # -fill x + + button $w.close -text "Close" \ + -command { + wm withdraw .qualityview_dlg + set viewqualityplot 0 + } + pack $w.close + + + if { $show == 1 } { + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Mesh Quality" + focus $w + } + } +} + + + + + + + + + + +# +# Quality viewer +# +proc memusedialog { show } { + + set w .memuse_dlg + + if {[winfo exists .memuse_dlg] == 1} { + + if { $show == 1 } { + wm withdraw .memuse_dlg + wm deiconify $w + focus $w + } { + wm withdraw $w + } + } { + toplevel $w + + set c $w.c + + canvas $c -relief raised -width 600 -height 300 + pack $w.c -side top -fill x + + set plotFont {Helvetica 18} + set smallFont {Helvetica 12} + + + global memmark + for {set i 0} {$i < 512} { incr i } { + set memmark($i) [$c create line [expr 50+$i] 50 [expr 50+$i] 70 -fill blue] + } + + + set plotFont {Helvetica 18} + set smallFont {Helvetica 12} + + $c create text 50 90 -text "0 GB" -anchor n -font $plotFont + $c create text 178 90 -text "1 GB" -anchor n -font $plotFont + $c create text 306 90 -text "2 GB" -anchor n -font $plotFont + $c create text 434 90 -text "3 GB" -anchor n -font $plotFont + $c create text 562 90 -text "4 GB" -anchor n -font $plotFont + + + frame $w.bu + pack $w.bu + # -fill x + + button $w.close -text "Close" \ + -command { + wm withdraw .memuse_dlg + set memuseplot 0 + } + pack $w.close + + if { $show == 1 } { + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Memory Usage" + focus $w + } + } +} + + + + + + + + + + + + + + + +# +# STL INFO dialog +# +proc STLinfodialog { show } { + + set w .STLinfo_dlg + + if {[winfo exists .STLinfo_dlg] == 1} { + + if { $show == 1 } { + wm withdraw .STLinfo_dlg + wm deiconify $w + focus $w + } { + wm withdraw $w + } + } { + toplevel $w + + set c $w.c + + canvas $c -relief raised -width 450 -height 300 + pack $w.c -side top -fill x + + set plotFont {Helvetica 18} + set smallFont {Helvetica 12} + + $c create line 100 250 400 250 -width 2 + $c create line 100 250 100 50 -width 2 + + frame $w.bu + pack $w.bu + # -fill x + + button $w.close -text "Close" \ + -command { + wm withdraw .STLinfo_dlg + #set STLinfoopen 0 + } + pack $w.close + + + if { $show == 1 } { + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "STL Geometry Info" + 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 + } +} + + + + + + +proc logwindow { } { + set w .logwindow + + if {[winfo exists .logwindow] == 1} { + wm withdraw $w + wm deiconify $w + focus $w + } { + toplevel $w + + text $w.edit -yscroll "$w.scrolly set" -setgrid 1 -height 12 + scrollbar $w.scrolly -command "$w.edit yview" + pack $w.edit -side left -fill both -expand 1 + pack $w.scrolly -side left -fill both -expand 0 + + .logwindow.edit insert end "Netgen Log Window\n" + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Netgen Log" + focus $w + } +} +# logwindow + + +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 + } +} +} + + + +# Opens a window with a table. tablevar is a list, the first entry is the title, the second the number of rows, the third the number of columns, +# then the entries follow. + +proc printtable { tablevar } { + set w newtcltable + while {[winfo exists .$w] == 1} {set w 1$w} + set w .$w + toplevel $w + for {set i 0} {$i < [lindex $tablevar 2]} { incr i } { + frame $w.col$i + for {set j 0} {$j < [lindex $tablevar 1]} { incr j } { + frame $w.col$i.row$j + message $w.col$i.row$j.txt -aspect 10000000 -text [lindex $tablevar [expr 3+[lindex $tablevar 2]*$j+$i]] + pack $w.col$i.row$j.txt + pack $w.col$i.row$j -side top + } + pack $w.col$i -side left + } + wm withdraw $w + wm geom $w +200+100; wm deiconify $w + wm title $w [lindex $tablevar 0] + focus $w +} + + +set latestwarning 0 + + +proc printwarning { textvar } { + global latestwarning + set latestwarning $textvar + set w warning + while {[winfo exists .$w] == 1} {set w 1$w} + set w .$w + toplevel $w + message $w.mes -aspect 2000 -text "WARNING:\n$textvar" + button $w.done -text "Done" -command "destroy $w" + pack $w.mes + pack $w.done + wm withdraw $w + wm deiconify $w + wm title $w "Warning" + focus $w +} + + +proc printlatestwarning { } { + global latestwarning + if {$latestwarning != 0} {printwarning $latestwarning} +} + + +# for parallel visualization, overlapping meshes... +proc paralleldialog { } { + + set w .parallel_dlg + + if {[winfo exists .parallel_dlg] == 1} { + wm withdraw $w + wm deiconify $w + wm geometry $w =270x100 + + focus $w + } { + + toplevel $w + wm geometry $w =270x100 + +# frame $w.buttons -relief groove -borderwidth 3 -width 300 +# pack $w.buttons + set ww $w + + button $ww.visallb -text "View All" -width 20 -command\ + { Ng_VisualizeAll; } + pack $ww.visallb + + button $ww.visoneb -text "View One" -width 20 -command \ + { Ng_VisualizeOne; } + pack $ww.visoneb + + button $ww.overlap -text "overlap++" -width 20 -command \ + { Ng_IncrOverlap; } + + pack $ww.overlap + + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Parallel Netgen" + focus .parallel_dlg + } +} + + +# paralleldialog +#wm withdraw $w + +proc runtestdialog { } { + source $::ngdir/ngtcltk/ngshell.tcl + set w .runtest_dlg + + if {[winfo exists .runtest_dlg] == 1} { + wm withdraw $w + wm deiconify $w +# wm geometry $w =270x100 + + focus $w + } { + toplevel $w +# wm geometry $w =270x100 + +# in2d testing # + frame $w.in2dframe + pack $w.in2dframe + + set in2dlogfile "" + tixLabelEntry $w.in2dframe.ent -label "in2d log-file: console if empty" \ + -labelside top \ + -options { + entry.textVariable in2dlogfile + entry.width 35 + label.width 25 + label.anchor w + } + button $w.in2dframe.btn -text "Browse" -command { + set types { { "Log file" {.log} } } + set in2dlogfile [tk_getOpenFile -filetypes $types -initialfile $in2dlogfile] + } + button $w.in2dframe.test -text "Test in2d meshing" -command { ngtest in2d $in2dlogfile } + + + pack $w.in2dframe.test -side left -anchor s -padx 4 -pady 4 + pack $w.in2dframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4 + pack $w.in2dframe.btn -side left -anchor s -padx 4 -pady 4 + + +# geo testing # + frame $w.geoframe + pack $w.geoframe + + set geologfile "" + tixLabelEntry $w.geoframe.ent -label "geo log-file: console if empty" \ + -labelside top \ + -options { + entry.textVariable geologfile + entry.width 35 + label.width 25 + label.anchor w + } + button $w.geoframe.btn -text "Browse" -command { + set types { { "Log file" {.log} } } + set geologfile [tk_getOpenFile -filetypes $types -initialfile $geologfile] + } + button $w.geoframe.test -text "Test geo meshing" -command { ngtest geo $geologfile } + + + pack $w.geoframe.test -side left -anchor s -padx 4 -pady 4 + pack $w.geoframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4 + pack $w.geoframe.btn -side left -anchor s -padx 4 -pady 4 + +# stl testing # + frame $w.stlframe + pack $w.stlframe + + set stllogfile "" + tixLabelEntry $w.stlframe.ent -label "stl log-file: console if empty" \ + -labelside top \ + -options { + entry.textVariable stllogfile + entry.width 35 + label.width 25 + label.anchor w + } + button $w.stlframe.btn -text "Browse" -command { + set types { { "Log file" {.log} } } + set stllogfile [tk_getOpenFile -filetypes $types -initialfile $stllogfile] + } + button $w.stlframe.test -text "Test stl meshing" -command { ngtest stl $stllogfile } + + + pack $w.stlframe.test -side left -anchor s -padx 4 -pady 4 + pack $w.stlframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4 + pack $w.stlframe.btn -side left -anchor s -padx 4 -pady 4 + +# pde testing # + frame $w.pdeframe + pack $w.pdeframe + + set pdelogfile "" + tixLabelEntry $w.pdeframe.ent -label "pde log-file: console if empty" \ + -labelside top \ + -options { + entry.textVariable pdelogfile + entry.width 35 + label.width 25 + label.anchor w + } + button $w.pdeframe.btn -text "Browse" -command { + set types { { "Log file" {.log} } } + set pdelogfile [tk_getOpenFile -filetypes $types -initialfile $pdelogfile] + } + button $w.pdeframe.test -text "Test ngsolve pde's" -command { ngtest pde $pdelogfile } + + + pack $w.pdeframe.test -side left -anchor s -padx 4 -pady 4 + pack $w.pdeframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4 + pack $w.pdeframe.btn -side left -anchor s -padx 4 -pady 4 + + wm title $w "Testing" + focus .runtest_dlg + } +} + diff --git a/ng/drawing.tcl b/ng/drawing.tcl new file mode 100644 index 00000000..6913a934 --- /dev/null +++ b/ng/drawing.tcl @@ -0,0 +1,106 @@ +# +# Creates a drawing frame, and binds mouse events +# +set oldmousex 0 +set oldmousey 0 +# +# if { 1 } { +if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } { + puts "no OpenGL" +} { + # + pack .ndraw -expand true -fill both -padx 10 -pady 10 + # + bind .ndraw { + set oldmousex %x; set oldmousey %y; + } + bind .ndraw { + set oldmousex %x; set oldmousey %y; + } + bind .ndraw { + set oldmousex %x; set oldmousey %y; + } + bind .ndraw { + Ng_MouseMove $oldmousex $oldmousey %x %y $drawmode + .ndraw render + set oldmousex %x; set oldmousey %y; + } + + bind .ndraw { + Ng_MouseDblClick %x %y + .ndraw render + if { [winfo exists .bcprop_dlg] } { bcpropdialog } + if { [winfo exists .fieldlines_dlg] } { fieldlinesdialog } + } + + bind .ndraw { + Ng_MouseMove $oldmousex $oldmousey %x %y move + .ndraw render + set oldmousex %x; set oldmousey %y; + } + + bind .ndraw { + Ng_MouseMove $oldmousex $oldmousey %x %y zoom + .ndraw render + set oldmousex %x; set oldmousey %y; + } +} + + +proc popupcheckredraw { vari { x 0 } } { + upvar $vari varname + if { $varname == 1 } { + set varname 0 + } { + # puts "popup-redraw $vari" + Ng_Vis_Set parameters + redraw + } +} +proc popupcheckredraw2 { vari boolvar { x 0 } } { + upvar $vari varname + if { $varname == 1 } { + set varname 0 + } { + Ng_SetVisParameters + if { $boolvar == 1 } { redraw } + Ng_SetVisParameters + } +} +proc popupcheckredraw3 { vari { x 0 } } { + upvar $vari varname + if { $varname == 1 } { + set varname 0 + } { + Ng_Vis_Set parameters + } +} + + + + +proc redraw { {x 0} } { + if {[winfo exists .ndraw]} { .ndraw render } +} + + + +bind . { Ng_MouseMove 0 0 -10 0 rotate; redraw } +bind . { Ng_MouseMove 0 0 10 0 rotate; redraw } +bind . { Ng_MouseMove 0 0 0 -10 rotate; redraw } +bind . { Ng_MouseMove 0 0 0 10 rotate; redraw } +bind . { Ng_MouseMove 0 0 -10 0 move; redraw } +bind . { Ng_MouseMove 0 0 10 0 move; redraw } +bind . { Ng_MouseMove 0 0 0 -10 move; redraw } +bind . { Ng_MouseMove 0 0 0 10 move; redraw } +bind . { Ng_MouseMove 0 0 0 -10 zoom; redraw } +bind . { Ng_MouseMove 0 0 0 10 zoom; redraw } + +bind all \ + {event generate [focus -displayof %W] -delta 120} + + bind all \ + {event generate [focus -displayof %W] -delta -120} + +bind all { Ng_MouseMove 0 0 0 [expr {%D/-5}] zoom; redraw } + diff --git a/ng/menustat.tcl b/ng/menustat.tcl new file mode 100644 index 00000000..d54031bd --- /dev/null +++ b/ng/menustat.tcl @@ -0,0 +1,1137 @@ + +# netgen menus: + +menu .ngmenu -tearoff 0 -relief raised -bd 2 +. configure -menu .ngmenu + +.ngmenu add cascade -label "File" -menu .ngmenu.file -underline 0 +.ngmenu add cascade -label "Geometry" -menu .ngmenu.geometry -underline 0 +.ngmenu add cascade -label "Mesh" -menu .ngmenu.mesh -underline 0 +.ngmenu add cascade -label "View" -menu .ngmenu.view -underline 0 +.ngmenu add cascade -label "Refinement" -menu .ngmenu.meshsize -underline 5 + +if { $userlevel == 3} { + .ngmenu add cascade -label "Special" -menu .ngmenu.special -underline 3 +} + +.ngmenu add cascade -label "Help" -menu .ngmenu.help -underline 0 + + +##################################################### +# # +# Menu File # +# # +##################################################### + +menu .ngmenu.file + +.ngmenu.file add command -label "Load Geometry..." -accelerator "" \ + -command { + set types { + {"All Geometry types" { .stl .stlb .step .stp .geo .in2d .igs .iges .brep .in2dnew .sat} } + {"IGES Geometry" {.igs .iges} } + {"BREP OpenCascade Geometry" {.brep} } + {"STL Geometry" {.stl} } + {"Binary STL Geometry" {.stlb} } + {"STEP Geometry" {.step .stp} } + {"Geometry file" {.geo} } + {"2D Geometry" {.in2d } } + {"2D Geometry New" {.in2dnew } } + } + + set ACISavailable [Ng_ACISCommand isACISavailable] + if {$ACISavailable == "yes" } { + lappend types {"ACIS Geometry" {.sat} } + } + +# {"All Geometry types" {.stl .stlb .step .stp .geo .in2d .igs .iges .brep .in2dnew} } + +# {"Naomi Geometry" {.nao} } +# {"New Geometry file" {.ngg} } + + + set file [tk_getOpenFile -filetypes $types] + if {$file != ""} { + AddRecentFile $file + Ng_LoadGeometry $file + Ng_ParseGeometry +# if { [Ng_STLInfo status]=="ERROR" } { +# tk_messageBox -message "STL ERROR: \n [Ng_STLInfo statustext]" -type ok +# } + set selectvisual geometry + Ng_SetVisParameters + redraw + wm title . [concat "$progname - " $file] + set dirname [file dirname $file] + set basefilename [file tail [file rootname $file]] + + rebuildoccdialog + } + } + + + +.ngmenu.file add command -label "Save Geometry..." \ + -command { + set occgeometryloaded [Ng_OCCCommand isoccgeometryloaded] + puts $occgeometryloaded + if {$occgeometryloaded == 1 } { + set types { + {"IGES Geometry file" {.igs} } + {"STEP Geometry file" {.stp} } + {"STL Geometry file" {.stl} } + {"STL BIN Geometry file" {.stlb} } + } + } { + set types { + {"STL Geometry file" {.stl} } + {"STL BIN Geometry file" {.stlb} } + } + } + + set ACISavailable [Ng_ACISCommand isACISavailable] + puts $ACISavailable + if {$ACISavailable == "yes" } { + lappend types {"ACIS Geometry" {.sat} } + } + + + +# set file [tk_getSaveFile -filetypes $types -defaultextension ".stl" -initialdir $dirname -initialfile $basefilename ] + set file [tk_getSaveFile -filetypes $types -initialdir $dirname -initialfile $basefilename ] + if {$file != ""} { + Ng_SaveGeometry $file + } + } + + + +.ngmenu.file add cascade -label "Recent Files" -menu .ngmenu.file.recent +menu .ngmenu.file.recent + + +proc AddRecentFile { filename } { + global progname + global dirname + catch { [.ngmenu.file.recent delete $filename] } + .ngmenu.file.recent insert 0 command -label $filename \ + -command "AddRecentFile {$filename}; + Ng_LoadGeometry {$filename}; + Ng_ParseGeometry; + set selectvisual geometry; + Ng_SetVisParameters; + redraw; + wm title . [concat \" $progname - $filename \"]; + set dirname {[file dirname $filename]}; + set basefilename {[file tail [file rootname $filename]]}; + rebuildoccdialog;" + + if { [.ngmenu.file.recent index last] >= 6 } { + .ngmenu.file.recent delete last } + + saveinifile; + } +loadinifile; + + +.ngmenu.file add separator + + +.ngmenu.file add command -label "Load Mesh..." -accelerator "" \ + -command { + set types { + {"Mesh file" {.vol} } } + set file [tk_getOpenFile -filetypes $types -defaultextension ".vol"] + if {$file != ""} { + AddRecentMeshFile $file; + Ng_LoadMesh $file; + set selectvisual mesh + Ng_SetVisParameters + redraw + Ng_ReadStatus; +# Ng_MeshSizeFromSurfaceMesh + set dirname [file dirname $file] + set basefilename [file tail [file rootname $file]] + } + } + + + +# astrid +.ngmenu.file add cascade -label "Recent Meshes" -menu .ngmenu.file.recentmesh +menu .ngmenu.file.recentmesh + + +proc AddRecentMeshFile { filename } { + global progname + global dirname + catch { [.ngmenu.file.recentmesh delete $filename] } + .ngmenu.file.recentmesh insert 0 command -label $filename \ + -command "AddRecentMeshFile {$filename}; + Ng_LoadMesh {$filename}; + set selectvisual mesh; + Ng_SetVisParameters; + redraw; + wm title . [concat \" $progname - $filename \"]; + set dirname {[file dirname $filename]}; + set basefilename {[file tail [file rootname $filename]]}; + rebuildoccdialog;" + + if { [.ngmenu.file.recentmesh index last] >= 6 } { + .ngmenu.file.recentmesh delete last } + + savemeshinifile; + } +loadmeshinifile; + +# astrid ende + + +.ngmenu.file add command -label "Save Mesh..." -accelerator "" \ + -command { + set types { + {"Mesh file" {.vol} } } + + set file [tk_getSaveFile -filetypes $types -defaultextension ".vol" -initialfile $basefilename -initialdir $dirname ] + if {$file != ""} { + Ng_SaveMesh $file } + AddRecentMeshFile $file; + + } + +.ngmenu.file add command -label "Merge Mesh..." \ + -command { + set types { + {"Mesh file" {.vol} } } + set file [tk_getOpenFile -filetypes $types -defaultextension ".vol"] + if {$file != ""} { + Ng_MergeMesh $file; + set selectvisual mesh + Ng_SetVisParameters + redraw + Ng_ReadStatus; + } + } + + + + + +.ngmenu.file add command -label "Import Mesh..." \ + -command { + set types { + {"Neutral format" {.mesh .emt} } + {"Surface mesh format" {.surf} } + {"Universal format" {.unv} } + {"Olaf format" {.emt} } + {"TET format" {.tet} } + {"Pro/ENGINEER neutral format" {.fnf} } + } + set file [tk_getOpenFile -filetypes $types ] + if {$file != ""} { + Ng_ImportMesh $file + set selectvisual mesh + Ng_SetVisParameters + redraw + Ng_ReadStatus; + } + } + +.ngmenu.file add command -label "Export Mesh..." \ + -command { + if { $exportfiletype == "Elmer Format" } { + set file [tk_chooseDirectory] + } else { + set file [tk_getSaveFile] + } + if {$file != ""} { + Ng_ExportMesh $file $exportfiletype + } + } + +.ngmenu.file add cascade -label "Export Filetype" -menu .ngmenu.file.filetype + +menu .ngmenu.file.filetype + + +.ngmenu.file add separator + + +.ngmenu.file add command -label "Save Solution..." \ + -command { + set types { + {"Solution File" {.sol} } + {"VTK File" {.vtk} } + } + set file [tk_getSaveFile -filetypes $types ] + if {$file != ""} { + Ng_SaveSolution $file + } + } +#-defaultextension ".sol" ] + +.ngmenu.file add command -label "Import Solution..." \ + -command { + set types { {"Solution File" {.sol} } } + set file [tk_getOpenFile -filetypes $types -defaultextension ".sol" ] + if {$file != ""} { + Ng_ImportSolution $file + set selectvisual solution + Ng_SetVisParameters + redraw + } + } + + + + + + +set demostarttime [clock clicks -millisecond] +set stopdemo 0 +proc demoredraw { } { + global demostarttime + global stopdemo + set curtime [clock clicks -millisecond] + set result [ Ng_DemoSetTime [expr $curtime - $demostarttime] ] + redraw + global videoactive + if { $videoactive == 1 } { + puts "addframe" + .ndraw Ng_VideoClip addframe + } + if { $result == 0 && $stopdemo == 0 } { + after 1 { demoredraw } + } +} +.ngmenu.file add command -label "Show Demo..." \ + -command { + set types { {"Demo File" {.dem} } } + set file [tk_getOpenFile -filetypes $types -defaultextension ".dem" ] + if {$file != ""} { + Ng_ShowDemo $file + set demostarttime [clock clicks -millisecond] + set stopdemo 0 + demoredraw + } + } + + + + +.ngmenu.file add separator + +.ngmenu.file add command -label "Snapshot..." \ + -command { + set types { + {"JPG file" {.jpg} } + {"GIF file" {.gif} } + {"PPM file" {.ppm} } + } + set file [tk_getSaveFile -filetypes $types] +# -defaultextension ".ppm"] + if {$file != ""} { + .ndraw Ng_SnapShot $file } + } + + +.ngmenu.file add cascade -label "Video clip" -menu .ngmenu.file.video +menu .ngmenu.file.video + +set videoactive 0 +.ngmenu.file.video add command -label "start..." \ + -command { + set types { + {"MPG file" {.mpg} } + } + set file [tk_getSaveFile -filetypes $types] + if {$file != ""} { + .ndraw Ng_VideoClip init $file + global videoactive + set videoactive 1 + } + } + +.ngmenu.file.video add command -label "add frame..." \ + -command {.ndraw Ng_VideoClip addframe } + +.ngmenu.file.video add command -label "one cycle" \ + -command { + set visoptions.redrawperiodic 1 + for { set j 0 } { $j < 100 } { incr j } { + puts "j = $j" + Ng_Vis_Set time [expr (1000 * $j / 100)] + redraw + .ndraw Ng_VideoClip addframe + after 200 + } + } + +.ngmenu.file.video add command -label "finalize..." \ + -command { + .ndraw Ng_VideoClip finalize + global videoactive + set videoactive 0 + } + + + +.ngmenu.file add command -label "Save Options" \ + -command { saveoptions } + + + + +.ngmenu.file add separator + + +## herbert tcl load menue +.ngmenu.file add command -label "Run tests ..." \ + -command { runtestdialog } +## +.ngmenu.file add separator + +.ngmenu.file add command -label "Quit" -accelerator "" \ + -command { puts "Thank you for using $progname"; Ng_Exit; destroy . } +# exit + + +##################################################### +# # +# Menu Mesh # +# # +##################################################### + +menu .ngmenu.mesh +.ngmenu.mesh add command -label "Generate Mesh" -accelerator "" \ + -command { + Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep} + Ng_ReadStatus + set selectvisual mesh + Ng_SetVisParameters + redraw + } + +.ngmenu.mesh add command -label "Stop Meshing" \ + -command { Ng_StopMeshing } + +.ngmenu.mesh add command -label "Meshing Options..." \ + -command meshingoptionsdialog + +.ngmenu.mesh add separator + +.ngmenu.mesh add command -label "Delete Mesh" \ + -command { Ng_New mesh; Ng_ReadStatus; redraw } + +.ngmenu.mesh add command -label "Delete Vol Mesh" \ + -command { Ng_DeleteVolMesh; Ng_ReadStatus; redraw } + + +.ngmenu.mesh add command -label "Mesh Info" \ + -command { + set dim [Ng_MeshInfo dim] + set np [Ng_MeshInfo np] + set ne [Ng_MeshInfo ne] + set nse [Ng_MeshInfo nse] + set nseg [Ng_MeshInfo nseg] + set bbox [Ng_MeshInfo bbox] + tk_messageBox -message "Dimension: $dim\nPoints: $np\nElements: $ne\nSurface Els: $nse\nSegments: $nseg\nxmin [lindex $bbox 0] xmax [lindex $bbox 1]\nymin [lindex $bbox 2] ymax [lindex $bbox 3]\nzmin [lindex $bbox 4] zmax [lindex $bbox 5]" + } + + +.ngmenu.mesh add command -label "Mesh Quality" \ + -command { + set inplanemin 0 + set inplanemax 0 + set betplanemin 0 + set betplanemax 0 + Ng_MeshQuality inplanemin inplanemax betplanemin betplanemax + puts "Triangle angles : $inplanemin - $inplanemax" + puts "Tet angles : $betplanemin - $betplanemax" + tk_messageBox -message "Triangle angles : $inplanemin - $inplanemax \n Tet angles : $betplanemin - $betplanemax" + } + +# .ngmenu.mesh add command -label "Quality Plot" \ +# -command { qualityviewdialog 1 } + + + + +.ngmenu.mesh add command -label "Check Surface Mesh" \ + -command { Ng_CheckSurfaceMesh } +.ngmenu.mesh add command -label "Check Volume Mesh" \ + -command { Ng_CheckVolumeMesh } + +.ngmenu.mesh add command -label "Edit Boundary Conditions..." \ + -command { bcpropdialog } + +if { $userlevel == 3 } { + .ngmenu.mesh add command -label "Mesh Doctor..." \ + -command { meshdoctordialog } +} + +.ngmenu.mesh add command -label "METIS Mesh Partitioning..." \ + -command { METISdialog } + +.ngmenu.mesh add separator + +.ngmenu.mesh add command -label "Analyze Geometry" \ + -command { Ng_GenerateMesh ag ag; Ng_ReadStatus; redraw } +.ngmenu.mesh add command -label "Mesh Edges" \ + -command { Ng_GenerateMesh me me; Ng_ReadStatus; redraw } +.ngmenu.mesh add command -label "Mesh Surface" \ + -command { set selectvisual mesh; Ng_SetVisParameters; \ + Ng_GenerateMesh ms ms; Ng_ReadStatus; redraw } + +.ngmenu.mesh add command -label "Optimize Surface" \ + -command { Ng_GenerateMesh os os cmsmSm; redraw } + +.ngmenu.mesh add cascade -label "Surface Optim. Step" -menu .ngmenu.mesh.surfoptstep + +menu .ngmenu.mesh.surfoptstep +.ngmenu.mesh.surfoptstep add command -label "Mesh Smoothing" \ + -command { Ng_GenerateMesh os os m; redraw} +.ngmenu.mesh.surfoptstep add command -label "Edge swapping (topologic)" \ + -command { Ng_GenerateMesh os os s; redraw} +.ngmenu.mesh.surfoptstep add command -label "Edge swapping (metric)" \ + -command { Ng_GenerateMesh os os S; redraw} +.ngmenu.mesh.surfoptstep add command -label "Combine points" \ + -command { Ng_GenerateMesh os os c; redraw} + + +.ngmenu.mesh add separator +.ngmenu.mesh add command -label "Mesh Volume" \ + -command { Ng_GenerateMesh mv mv; Ng_ReadStatus } +.ngmenu.mesh add command -label "Optimize Volume" \ + -command { Ng_GenerateMesh ov ov; Ng_ReadStatus } +.ngmenu.mesh add command -label "Smooth Opt Volume" \ + -command { Ng_GenerateMesh ov ov m; Ng_ReadStatus } +.ngmenu.mesh add command -label "Smooth Opt Volume Jacobian" \ + -command { Ng_GenerateMesh ov ov j; Ng_ReadStatus } + + + +##################################################### +# # +# Menu Geometry # +# # +##################################################### + +menu .ngmenu.geometry +.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 + +.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 + +.ngmenu.geometry add command -label "IGES/STEP Topology Explorer/Doctor..." \ + -command { occdialog; } + + +.ngmenu.geometry add command -label "OCC Construction" \ + -command { Ng_OCCConstruction; } + +if { [Ng_ACISCommand isACISavailable] == "yes" } { + .ngmenu.geometry add command -label "ACIS Topology Explorer..." \ + -command { acisdialog; } + + .ngmenu.geometry add command -label "ACIS combine all" \ + -command { Ng_ACISCommand combineall } + .ngmenu.geometry add command -label "ACIS Create CT" \ + -command { Ng_ACISCommand createct } +} + + + + + +##################################################### +# # +# Menu View # +# # +##################################################### + +menu .ngmenu.view +.ngmenu.view add command -label "Zoom all" \ + -command { Ng_ZoomAll; redraw } +.ngmenu.view add command -label "Center" \ + -command { Ng_Center; redraw } + +.ngmenu.view add command -label "x-y plane" \ + -command { Ng_StandardRotation xy; redraw } +.ngmenu.view add command -label "y-x plane" \ + -command { Ng_StandardRotation yx; redraw } +.ngmenu.view add command -label "x-z plane" \ + -command { Ng_StandardRotation xz; redraw } +.ngmenu.view add command -label "z-x plane" \ + -command { Ng_StandardRotation zx; redraw } +.ngmenu.view add command -label "y-z plane" \ + -command { Ng_StandardRotation yz; redraw } +.ngmenu.view add command -label "z-y plane" \ + -command { Ng_StandardRotation zy; redraw } + +.ngmenu.view add command -label "Viewing Options..." \ + -command { viewingoptionsdialog; redraw } +.ngmenu.view add command -label "Clipping Plane..." \ + -command { clippingdialog; redraw } +.ngmenu.view add command -label "Solution Data..." \ + -command { visual_dialog; redraw } +.ngmenu.view add checkbutton -variable viewqualityplot \ + -label "Quality Plot" \ + -command { qualityviewdialog $viewqualityplot } +.ngmenu.view add checkbutton -variable memuseplot \ + -label "Memory Usage" \ + -command { memusedialog $memuseplot } + + + + +##################################################### +# # +# Menu Refinement # +# # +##################################################### +# +# Mesh size menu +# +menu .ngmenu.meshsize +.ngmenu.meshsize add command -label "Refine uniform" \ + -command { Ng_Refine; Ng_HighOrder ${options.elementorder}; Ng_ReadStatus; redraw } + +.ngmenu.meshsize add command -label "Second Order" \ + -command { Ng_SecondOrder; Ng_ReadStatus; redraw } + +.ngmenu.meshsize add command -label "Validate Second Order" \ + -command { Ng_ValidateSecondOrder; Ng_ReadStatus; redraw } + +.ngmenu.meshsize add command -label "High Order" \ + -command { Ng_HighOrder ${options.elementorder}; Ng_ReadStatus; redraw } + +.ngmenu.meshsize add separator + +.ngmenu.meshsize add command -label "Refinement Dialog..." \ + -command { refinementdialog } +.ngmenu.meshsize add command -label "Load Meshsize..." \ + -command { + set types { + {"Meshsize file" {.msz} } } + set file [tk_getOpenFile -filetypes $types] + if {$file != ""} { + Ng_LoadMeshSize $file; + } + } +.ngmenu.meshsize add command -label "MS from Surf Mesh" \ + -command { Ng_MeshSizeFromSurfaceMesh } + + +if { $userlevel == 3 } { +.ngmenu.meshsize add command -label "Singular point ms" \ + -command { Ng_SingularPointMS; } + +.ngmenu.meshsize add command -label "Singular edge ms" \ + -command { Ng_SingularEdgeMS; } + +.ngmenu.meshsize add separator + +set bisectfilename ""; + +.ngmenu.meshsize add command -label "Bisection" \ + -command { Ng_ReadStatus; set oldnp 0; set newnp $status_np; +# Ng_BisectCopyMesh; +# Ng_Split2Tets; + Ng_ReadStatus; + + while { $oldnp < $newnp } { +# if { $level == 0 } { +# Ng_ExportMesh feppmesh.vol fepp; +# } { +# Ng_ExportMesh feppmesh$level feppml +# } + set level [expr $level+1] + if { $bisectfilename == ""} { + Ng_Bisect; + } else { + Ng_Bisect $bisectfilename; + } +# Ng_HighOrder ${options.elementorder} "noparallel" +# Ng_Split2Tets; + Ng_ReadStatus; + redraw; + + if { $bisectfilename == ""} { + set oldnp $newnp; + set newnp $status_np; + puts "oldnp $oldnp newnp $newnp"; + } else { + set oldnp $newnp; + } + } + } +# -command { Ng_Bisect; Ng_ReadStatus; redraw } +# -command { exec netgen abc >outfile 2>errfile; Ng_ReadStatus; redraw } + +} + +.ngmenu.meshsize add command -label "Load Refinement Info..." \ + -command { + set types { + {"Refinement info" {.refine} }} + set bisectfilename [tk_getOpenFile -filetypes $types] + } + +.ngmenu.meshsize add command -label "Z-Refinement" \ + -command { Ng_ZRefinement 2; Ng_ReadStatus; redraw } + + +# .ngmenu.meshsize add command -label "hp-Refinement" \ +\# -command { Ng_HPRefinement 4; Ng_ReadStatus; redraw } + +.ngmenu.meshsize add cascade -label "hp-Refinement" -menu .ngmenu.meshsize.hpref +menu .ngmenu.meshsize.hpref +.ngmenu.meshsize.hpref add command -label "1 Level" \ + -command { Ng_HPRefinement 1; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "2 Levels" \ + -command { Ng_HPRefinement 2; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "3 Levels" \ + -command { Ng_HPRefinement 3; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "4 Levels" \ + -command { Ng_HPRefinement 4; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "5 Levels" \ + -command { Ng_HPRefinement 5; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "6 Levels" \ + -command { Ng_HPRefinement 6; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "7 Levels" \ + -command { Ng_HPRefinement 7; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "8 Levels" \ + -command { Ng_HPRefinement 8; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "9 Levels" \ + -command { Ng_HPRefinement 9; Ng_ReadStatus; redraw } +.ngmenu.meshsize.hpref add command -label "10 Levels" \ + -command { Ng_HPRefinement 10; Ng_ReadStatus; redraw } + + +.ngmenu.meshsize add command -label "Split to Tets" \ + -command { Ng_Split2Tets; Ng_ReadStatus; redraw } + + + + + +##################################################### +# # +# Menu Special # +# # +##################################################### + +menu .ngmenu.special +.ngmenu.special add command -label "Insert virtual boundary layer" \ + -command { Ng_InsertVirtualBL; redraw } +.ngmenu.special add command -label "Cut off and combine with other" \ + -command { + set types { {"Mesh file" {.vol} } } + set file [tk_getOpenFile -filetypes $types] + if {$file != ""} { + Ng_CutOffAndCombine $file; } + redraw + } +.ngmenu.special add command -label "Helmholtz Mesh grading" \ + -command { Ng_HelmholtzMesh; } + + + +# menu .mbar.stl.menu +# .mbar.stl.menu add command -label "STL options" \ +# -command { stloptionsdialog; } +#.mbar.stl.menu add command -label "STL Doctor" \ +# -command { stldoctordialog; } + + + +##################################################### +# # +# Menu Help # +# # +##################################################### + + +menu .ngmenu.help +.ngmenu.help add command -label "Ng Help..." \ + -command { help_main } +# .ngmenu.view add checkbutton -variable showsensitivehelp \ +# -label "Sensitve Help" \ +# -command { sensitivehelpdialog $showsensitivehelp } +.ngmenu.view add checkbutton -label "Help Line" -variable showhelpline \ + -command { + if { $showhelpline == 1} { + pack .helpline -before .statbar -side bottom -fill x -padx 3p + } { + pack forget .helpline + } +} + +.ngmenu.help add command -label "About..." \ + -command { +tk_messageBox -message "This is NETGEN \n mainly written by \n Joachim Sch�erl \n thanks to \n R. Gaisbauer, J. Gerstmayr" +} + +# tk_menuBar .mbar .mbar.file .mbar.mesh .mbar.test .mbar.help +# focus .mbar + + + + + +##################################################### +# # +# Button bar # +# # +##################################################### + +frame .bubar -relief raised -bd 2 +pack .bubar -side top -fill x + +button .bubar.testb -text "Test" -command { Ng_SaveGeometry } +button .bubar.surfm -text "Generate Mesh" -command \ + { set selectvisual mesh; + Ng_SetVisParameters; + Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep} + redraw + } +button .bubar.stopm -text "Stop" -command \ + { Ng_StopMeshing; set stopdemo 1 } +button .bubar.exitb -text "Quit" \ + -command { .ngmenu.file invoke "Quit" } +pack .bubar.exitb .bubar.surfm .bubar.stopm -side left + +#button .bubar.scan -text "Scan" \ +# -command { Ng_ParseGeometry; set selectvisual geometry; Ng_SetVisParameters; redraw } + +# fuer parallel - buttons :) +Ng_IsParallel; +if { $parallel_netgen } { +# catch{ +# source ${ngdir}/ngtcltk/parallel_dialog.tcl +# } + button .bubar.visallb -text "Parallel" -command \ + { paralleldialog; redraw } + pack .bubar.visallb -side left +} + +button .bubar.zoomall -text "Zoom All" \ + -command { Ng_ZoomAll; redraw } + +button .bubar.center -text "Center" \ + -command { Ng_Center; redraw } + +# tk_optionMenu .bubar.modesel drawmode "rotate" "move " "zoom " +tixOptionMenu .bubar.modesel \ + -options { + label.width 0 + label.anchor e + menubutton.width 6 + } \ + -variable drawmode + +.bubar.modesel add command rotate -label Rotate +.bubar.modesel add command move -label Move +.bubar.modesel add command zoom -label Zoom + + + + + + +set viewvals { geometry specpoints mesh solution} +if { $userlevel == 3} { + set viewvals { geometry mesh specpoints surfmeshing modelview solution} +} + +set viewvallabs(cross) "Cross" +set viewvallabs(geometry) "Geometry" +set viewvallabs(mesh) "Mesh" +set viewvallabs(specpoints) "Edges" +set viewvallabs(surfmeshing) "Mesh Gen" +set viewvallabs(modelview) "Modeller" +set viewvallabs(solution) "Solution" + +tixOptionMenu .bubar.selview \ + -options { + label.width 0 + label.anchor e + menubutton.width 10 + } \ + +foreach viewv $viewvals { + .bubar.selview add command $viewv -label $viewvallabs($viewv) +} + + +.bubar.selview config -variable selectvisual +.bubar.selview config -command { Ng_SetVisParameters; redraw } + + +pack .bubar.modesel -side right +pack forget .bubar.modesel +pack .bubar.center .bubar.zoomall .bubar.selview -side right + +.ngmenu.view add checkbutton -variable viewrotatebutton \ + -label "Enable LeftButton Selection" \ + -command { + if { $viewrotatebutton } { + pack .bubar.modesel -side right + } { + pack forget .bubar.modesel + } + } + + +##################################################### +# # +# Status bar # +# # +##################################################### + +label .helpline -text "None" +pack forget .helpline -side bottom -fill x + +frame .statbar -relief flat -bd 2 +pack .statbar -side bottom -fill x + +label .statbar.ptslabel -text "Points: " +label .statbar.ptsval -textvariable status_np +label .statbar.elslabel -text " Elements: " +label .statbar.elsval -textvariable status_ne +label .statbar.selslabel -text " Surf Elements: " +label .statbar.selsval -textvariable status_nse +# label .statbar.memlabel -text " Mem: " +# label .statbar.memval -textvariable mem_moveable +label .statbar.task -textvariable status_task + +pack .statbar.ptslabel .statbar.ptsval -side left -ipady 3p +pack .statbar.elslabel .statbar.elsval -side left -ipady 3p +pack .statbar.selslabel .statbar.selsval -side left -ipady 3p + +# if { $userlevel == 3 } { +# pack .statbar.memlabel .statbar.memval -side left -ipady 3p +# } + + +tixMeter .statbar.per -value 0 -text 0% +.statbar.per configure -fillcolor blue + +pack .statbar.per -side right +pack .statbar.task -side right -ipady 4 + +set qualbaraxis(0) 0 +set qualbar(0) 0 +set qualbarnull(0) 0 + + + +proc timer2 { } { + global status_np + global status_ne + global status_nse + global multithread_running + global multithread_redraw + global status_working + global status_task + global status_percent + global status_tetqualclasses + + + Ng_ReadStatus + + if { $multithread_redraw == 1 } { + set multithread_redraw 0; + redraw; + + global videoactive + if { $videoactive == 1 } { + puts "addframe" + .ndraw Ng_VideoClip addframe + } + } + + global mem_moveable + set mem_moveable [Ng_MemInfo moveable] + + + .statbar.per config -value [expr $status_percent/100] -text [format %2.1f [expr 0.1*int(10*$status_percent)]]% + + + if { $multithread_running } { + pack .statbar.per -side right -before .statbar.task -padx 6 + } { + pack forget .statbar.per + } + + + + # tet quality + if {[winfo exists .qualityview_dlg] == 1} { + + global qualbar + global qualbarnull + global qualbaraxis + + set maxval 0 + for {set i 0} {$i < 20} {incr i} { + if {[lindex $status_tetqualclasses $i] > $maxval} { + set maxval [lindex $status_tetqualclasses $i] + } + } + + set ubound 1 + while { $ubound < $maxval } { + set ubound [expr {10 * $ubound}] + } + if { $ubound/5 > $maxval } { + set ubound [expr $ubound/5] + } + if { $ubound/2 > $maxval } { + set ubound [expr $ubound/2] + } + + + + for {set i 1} {$i <= 5} {incr i} { + # global qualbaraxis($i) + + set value [expr { $i * $ubound / 5 }] + .qualityview_dlg.c dchars $qualbaraxis($i) 0 end + .qualityview_dlg.c insert $qualbaraxis($i) end $value + } + + + for {set i 0} {$i < 20} {incr i} { + set x1 [expr {100 + ($i*15) + 2}] + set x2 [expr {$x1+10}] + + set nbrs [lindex $status_tetqualclasses $i] + set y [expr (249 - (200 * $nbrs / $ubound ) )] + + # global qualbar($i) + .qualityview_dlg.c coords $qualbar($i) $x1 250 $x2 $y + +# global qualbarnull($i) + if { $nbrs == 0 } { + .qualityview_dlg.c itemconfigure $qualbarnull($i) -text 0 + } { + .qualityview_dlg.c itemconfigure $qualbarnull($i) -text "" + } + } + + } + + + + if {[winfo exists .memuse_dlg] == 1} { + + global memmark + set usemb [Ng_MemInfo usedmb] + for {set i 0} {$i < [string length $usemb] } {incr i} { + if { [string index $usemb $i] == 0 } { + .memuse_dlg.c coords $memmark($i) [expr 50+$i] 68 [expr 50+$i] 70 + } { + .memuse_dlg.c coords $memmark($i) [expr 50+$i] 50 [expr 50+$i] 70 + } + } + + } + + + + + + after 200 { timer2 } +} +# after 1000 { timer2 } +timer2 + + + + + +proc bgerror { error } { + global errorInfo userlevel + if { $userlevel == 3} { + puts "ERROR: $error" + puts "errinfo: $errorInfo" + } + tk_messageBox -title "Error Message" -message $error -type ok +} + + + + + + +proc smh2 { menuitem } { + if {[catch {$menuitem entrycget active -label} name]} { + set name " " + } + show_menu_help $name + update idletasks +} + +bind .ngmenu <> { smh2 %W } +bind .ngmenu.file <> { smh2 %W } +bind .ngmenu.geometry <> { smh2 %W } +bind .ngmenu.mesh <> { smh2 %W } +bind .ngmenu.view <> { smh2 %W } +bind .ngmenu.meshsize <> { smh2 %W } +bind .ngmenu.special <> { smh2 %W } +bind .ngmenu.help <> { smh2 %W } + + +# command bindings +bind . { .ngmenu.file invoke "Quit" } +bind . { .ngmenu.file invoke "Load Geometry..." } ; +bind . { .ngmenu.file invoke "Load Mesh..." } ; +bind . { .ngmenu.file invoke "Save Mesh..." } ; +bind . { .ngmenu.file activate "Recent Files" } ; +bind .

{ newprimitivedialog } ; # +bind .

{ editprimitivedialog } +bind . { newsoliddialog } +bind . { .ngmenu.mesh invoke "Generate Mesh" } ; + +# bind . { .bubar.selview configure activate mesh } ; + + + + diff --git a/ng/ng.tcl b/ng/ng.tcl new file mode 100644 index 00000000..6804b702 --- /dev/null +++ b/ng/ng.tcl @@ -0,0 +1,302 @@ +puts "found ng.tcl" + + +if {[catch {package require Tix }]} { + puts "cannot find package Tix" +} + +# if {[catch {package require Togl 1.7}]} { +# puts "cannot find package Togl 1.7" +# } + + + +# userlevel 1..standard user 2..power-user 3..developer + +set userlevel 3 +if { [Ng_GetCommandLineParameter expert]=="defined" } { + set userlevel 3 +} + +set progname "NETGEN" + +set ngdir "" +if { [lsearch [array names env] NETGENDIR] != -1 } { + set ngdir $env(NETGENDIR) +} +if { [string length $ngdir] == 0 } { + set ngdir "." +} + + + +set batchmode [Ng_GetCommandLineParameter batchmode] + +set solvemode 0 +if { [Ng_GetCommandLineParameter solve] != "undefined" || [Ng_GetCommandLineParameter recent] == "defined" } { + set solvemode defined +} + +set shellmode [Ng_GetCommandLineParameter shellmode] + +if { $shellmode == "defined" } { + set batchmode "defined" +} + + +if { $batchmode != "defined" } { + catch { + wm withdraw . + + wm title . $progname + wm geometry . =800x600 + wm minsize . 400 300 + } +} + + +source ${ngdir}/variables.tcl +source ${ngdir}/parameters.tcl + +if { $batchmode != "defined" } { + catch { + source ${ngdir}/menustat.tcl + } +} + +catch { + source ${ngdir}/dialog.tcl +} +catch { + source ${ngdir}/drawing.tcl +} + +catch { + source ${ngdir}/nghelp.tcl +} +catch { + source ${ngdir}/ngvisual.tcl +} + +catch { + source ${ngdir}/sockets.tcl +} + +catch { + source ${ngdir}/acis.tcl +} + + + +catch { source ${ngdir}/ngsolve/ngsolve.tcl } +# catch { [source ${ngdir}/ngsolve/preproc.tcl] } +# catch { [source ${ngdir}/ngsolve/pdecreator.tcl] } + +# some applications: +# source ${ngdir}/demoapp/demoapp.tcl +# source ${ngdir}/metis/ngmetis.tcl + + +# trafo/zugstange : menu +################################################## +set zugstange 0 + + +catch { source ${ngdir}/trafo/menu.tcl } + + + +setgranularity ${meshoptions.fineness} + +Ng_SetMeshingParameters +Ng_SetVisParameters +Ng_SetDebugParameters +Ng_STLDoctor +Ng_GeometryOptions set +Ng_SetOCCVisParameters + +if { $batchmode != "defined" } { + catch { + wm protocol . WM_DELETE_WINDOW { .ngmenu.file invoke "Quit" } + wm deiconify . + } +} + +set trafoapp 0 +catch { source ${ngdir}/trafoapp/trafoapp.tcl } + +set geofilename [Ng_GetCommandLineParameter geofile] + +if { $geofilename != "undefined" && + [info exists trafo] == 0 && $zugstange == 0} { + + if { [ catch { Ng_LoadGeometry $geofilename } errstring] == 0 } { + if { $batchmode != "defined" } { + AddRecentFile $geofilename + } + Ng_ParseGeometry + if { $batchmode != "defined" } { + set selectvisual geometry + Ng_SetVisParameters + redraw + wm title . [concat "$progname - " $geofilename] + } + set dirname [file dirname $geofilename] + set basefilename [file tail [file rootname $geofilename]] + } { + puts "Problem with input file:" + puts "$errstring" + } +} + + +set cnt 0 +foreach { gran } { verycoarse coarse moderate fine veryfine } { + set cnt [expr $cnt + 1] + if { [Ng_GetCommandLineParameter $gran] == "defined" } { + set meshoptions.fineness $cnt + setgranularity ${meshoptions.fineness} + } +} + + +set meshfilename [Ng_GetCommandLineParameter meshfile] +if { $meshfilename == "undefined" } { + set meshfilename out.mesh +} + +set meshfiletype [Ng_GetCommandLineParameter meshfiletype] +if { $meshfiletype == "undefined" } { + set meshfiletype netgen +} + +set inputmeshfilename [Ng_GetCommandLineParameter inputmeshfile] + +set mergemeshfilename [Ng_GetCommandLineParameter mergefile] + +set meshsizefilename [Ng_GetCommandLineParameter meshsizefile] + +if { $meshsizefilename != "undefined" } { + set options.meshsizefilename $meshsizefilename +} + +set refinementfilename [Ng_GetCommandLineParameter refinementfile] + + +if { $batchmode == "defined" && $solvemode != "defined"} { + set options.parthread 0 + if { $shellmode == "undefined" } { +# old batchmode: only processes commandline arguments + set selectvisual mesh + Ng_SetVisParameters + + set meshsize [Ng_GetCommandLineParameter meshsize] + if {$meshsize != "undefined"} { set options.meshsize $meshsize } + + if { $inputmeshfilename == "undefined" } { + Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep} + } else { + Ng_LoadMesh $inputmeshfilename + if { $mergemeshfilename != "undefined" } { + Ng_MergeMesh $mergemeshfilename + } + } + + if { $refinementfilename != "undefined" } { + Ng_Bisect $refinementfilename + } + + if { $meshfiletype == "netgen" } { + Ng_SaveMesh $meshfilename + } else { + if { [catch { Ng_ExportMesh $meshfilename $meshfiletype } ] == 1 } { + puts "Unknown file format $meshfiletype" + } + } + Ng_Exit; + + exit + } else { + set code [catch { source ${ngdir}/ngshell.tcl } errcode] + if {$code} { + puts "error: $errcode" + } + set code [ catch {Ng_RunShell} errcode] + if {$code} { + puts "error: $errcode" + } + + Ng_Exit; + exit + } + +} + +set stereo [Ng_GetCommandLineParameter stereo] +if { $stereo == "defined" } { + set viewoptions.stereo 1 + puts "use stereo mode" + Ng_SetVisParameters; + redraw +} + + +set scriptfilename [Ng_GetCommandLineParameter script] +if { $scriptfilename != "undefined" } { + if { [catch { source $scriptfilename } errstring] == 1 } { + puts "Error in input: $errstring" + } +} + + +if { [Ng_GetCommandLineParameter help]=="defined" } { + if { $zugstange == 1 } { + print_zug_commandline_help + exit; + } { + if { $trafoapp == 1 } { + print_trafo_commandline_help; + } { + print_commandline_help; + Ng_Exit; + exit + } + } +} + +if { [file exists startup.tcl] } { + source startup.tcl } + + + + +################################################## +catch { source ${ngdir}/trafo/trafo.tcl } + +catch { source ${ngdir}/trafoapp/smallmodels.tcl } + +catch { + source ${ngdir}/ngshell.tcl + source ${ngdir}/ngtesting.tcl +} + + + +# source ngusers/ebg/elasticity/ebgelast.tcl + + +if { [catch { load libngsolve.so ngsolve }] } { + puts "cannot load ngsolve" +} { + source ${ngdir}/ngsolve.tcl +} + + +catch { source ${ngdir}/demoapp.tcl } + + +if { [catch { load libdemoapp.so demoapp }] } { + puts "cannot load demoapp" +} { +} + diff --git a/ng/nghelp.tcl b/ng/nghelp.tcl new file mode 100644 index 00000000..e13ab7c3 --- /dev/null +++ b/ng/nghelp.tcl @@ -0,0 +1,338 @@ +proc print_commandline_help { } { + + puts "Usage: ng { options }" + + puts "-geofile=filename Input geometry file (alternative: ng filename)" + puts "-meshfile=filename Output mesh file" + puts "-verycoarse, -coarse, -moderate, -fine, -veryfine" + puts " Automatic mesh-size selection" + puts "-meshsizefile=filename Load mesh-size file with local mesh sizes" + puts "-meshfiletype={\"Neutral Format\", ...}" + puts " Filetype of output file, default is netgen file" + puts "-batchmode Run Netgen in batchmode" + puts "-inputmeshfile=filename" + puts " Input mesh file (batchmode only)" + puts "-mergefile=filename Merge with mesh file (batchmode only)" + puts "-refinementfile=filename" + puts " Use refinementinfo from file (batchmode only)" + puts "-serversocket=\#num Start a Netgen server with port \#num" + puts "-V Print additional information" + puts "-testout=filename file for test output" + + if { [catch { NGS_GetData } ] == 0 } { + puts "\nNGSolve parameters:" + puts "-pdefile=filename Load pde input file" + puts "-solve Solve pde once" + puts "-solve=n Solve pde by n adaptive refinement steps" + puts "-recent Load and solve most recently loaded pde" + } + +} + + + +proc set_menu_help { entry helpmsg } { + global menuhelps + set menuhelps($entry) $helpmsg +} + +proc show_menu_help { entry } { + global menuhelps + + + if {[catch {set helptext $menuhelps($entry)}]} { + set helptext "no help available " + } + + .helpline configure -text $helptext + + if {[winfo exists .senshelp_dlg]==1} { + .senshelp_dlg.text delete 1.0 end + .senshelp_dlg.text insert end "Menu item: $entry\n\n" + .senshelp_dlg.text insert end $helptext + } +} + + +tixBalloon .balloon -statusbar .helpline + +proc set_control_help { control helpmsg } { + bind $control "show_control_help {$helpmsg}" + bind $control "show_control_help {None}" + .balloon bind $control -balloonmsg $helpmsg -statusmsg $helpmsg +# puts "Add Help to $control" +} + +proc show_control_help { helpmsg } { + .helpline configure -text $helpmsg + if {[winfo exists .senshelp_dlg]==1} { + .senshelp_dlg.text delete 1.0 end + .senshelp_dlg.text insert end $helpmsg + } +} + + +proc sensitivehelpdialog { show } { + + set w .senshelp_dlg + + if {[winfo exists .senshelp_dlg] == 1} { + + if { $show == 1 } { + wm withdraw .senshelp_dlg + wm deiconify $w + focus $w + } { + wm withdraw $w + } + } { + toplevel $w +# wm minsize $w 200 150 + + global senshelptext + + text $w.text -yscrollcommand "$w.scroll set" -setgrid true \ + -width 40 -height 10 -wrap word + scrollbar $w.scroll -command "$w.text yview" + pack $w.scroll -side right -fill y + pack $w.text -expand yes -fill both + + frame $w.bu + pack $w.bu + # -fill x + + button $w.close -text "Close" \ + -command { + wm withdraw .senshelp_dlg + set showsensitivehelp 0 + } + pack $w.close + + + if { $show == 1 } { + wm withdraw $w + wm geom $w +100+100 + wm deiconify $w + wm title $w "Help" + focus $w + } + } +} + + + +set_menu_help "File" "In File menu you can load and store geometries, meshes etc." + +set_menu_help "New Geometry" "Deletes current geometry" +set_menu_help "Load Geometry" "Loads Geometry file in one of the formats STL (ASCII or binary), Constructive Solid Geometry (.geo) or 2D geometry. Please have a look into Netgen User's manuel for more details." +set_menu_help "Save Geometry" "Saves STL Geometry in in either ASCII or binary STL format." +set_menu_help "Load Mesh" "Loads surface and volume mesh in Netgen internal format." +set_menu_help "Save Mesh" "Saves surface and volume mesh in Netgen internal format." +set_menu_help "Write EPS File" "Dumps OpenGL rendering to EPS File." +set_menu_help "Save Options" "Saves current options in file \"ng.opt\". These options will be loaded again when starting ng in the same directory." +set_menu_help "Export Mesh" "Exports mesh in format defined by Export Filetype." +set_menu_help "Export Filetype" "Selects file format for exporting mesh. Please have a look into the Netgen User's manual for more information." +set_menu_help "Import Mesh" "Imports surface or volume mesh in exchange format." +set_menu_help "Quit" "Quits Netgen" + +set_menu_help "Geometry" "Preparing geometries, visualiztion of geometries." +set_menu_help "Scan CSG Geometry" "Generates surface triangulation for rendering" +set_menu_help "CSG Options" "Sets Options for CSG visualization (bounding box, detail size, number of facets)." +set_menu_help "CSG Properties" "Defines appearence of current CSG geometry (color, visibility, transparency)" +set_menu_help "STL Doctor" "Calls STL Doctor for preprocessing STL geometry files." +set_menu_help "STL Info" "Retrieves information about current STL geometry." + +set_menu_help "Mesh" "Menu for mesh generation" +set_menu_help "Generate Mesh" "Generates mesh from geometry, same as Button \"Generate Mesh\"" +set_menu_help "Stop Meshing" "Terminates meshgeneration. It may take a while until meshing terminates, please be patient." +set_menu_help "Meshing Options" "Set options for mesh generation." +set_menu_help "Delete Mesh" "Deletes mesh. Not necessary before generation of new mesh." +set_menu_help "Delete Vol Mesh" "Deletes only volume mesh." +set_menu_help "Mesh Quality" "Computs element shape measures. Triangle angles are inner angles of all triangles (faces of tetrahedra). Tet angles are angles between faces of tetrahedra." +set_menu_help "Check Surface Mesh" "Checks consistency and overlap of surface mesh. Marks overlapping elements as bad elements, please enable visualization of bad elements in View->Mesh." +set_menu_help "Check Volume Mesh" "Checks conformity of volume mesh." +set_menu_help "Edit Boundary Conditions" "Open dialog for setting boundary condition numbers for individual faces." +set_menu_help "Analyze Geometry" "Perform only first step in mesh generation. Action depends on geometry type, e.g. generates charts for STL mesh, find vertices in CSG geometries." +set_menu_help "Mesh Edges" "Meshes edges" +set_menu_help "Mesh Surface" "Generates surface mesh. Includes already surface optimization for some geomtry types." +set_menu_help "Optimize Surface" "Optimizes surface mesh." +set_menu_help "Surface Optim. Step" "Performs a specific surface optimiztion step. Mesh smoothing moves nodes. edge swapping swaps the diagonal of a quadrilateral built by two triangles, criterion either by number of nodes, or anlges. Combine points eliminates triangles by combining points (in the center of gravity)." +set_menu_help "Mesh Volume" "Performs volume meshing. Algorithm is a combination of Delaunay and Rule-based Advancing Front" +set_menu_help "Optimize Volume" "Performs additional volume optimization steps" +set_menu_help "Smooth Opt Volume" "Performs optimization steps by smoothing iterations" +set_menu_help "Smooth Opt Volume Jacobian" "Volume optimization by smoothing iterations. Criterion is optimization of Jacobi determinants. This optimization step is also available for 10-node tetrahedra." + +set_menu_help "View" "Sets viewing options" +set_menu_help "Zoom all" "Zooms scene to show whole object" +set_menu_help "Center" "Defines center of rotation" +set_menu_help "Viewing Options" "Sets viewing options for geometry, mesh, lighting" +set_menu_help "Clipping Plane" "Introduces clipping plane. The clipping plane is defined by the normal vector, and a scaled offset. Clipping of performed by OpenGl rendering" +set_menu_help "Quality Plot" "Shows the element quality distribution histogram. Measure is volume scaled by edge-length to the third. Optimal elements have measure 1." +set_menu_help "Sensitve Help" "Shows this help window" + +set_menu_help "Mesh-size" "Manipulations of existing mesh" +set_menu_help "Refine uniform" "Refines mesh by splitting elements into eight childs (algorithm of J. Bey)" +set_menu_help "Second Order" "Converts 4 node elements to 10 node elements. Edge-midpoitns are projected to the geometry." +set_menu_help "Refinement Dialog" "Controls local mesh refinement" +set_menu_help "Load Meshsize" "Loads mesh-size file for local mesh refinement." +set_menu_help "MS from Surf Mesh" "Defines mesh-size by the surface mesh." + + + + +set f .options_dlg.nb.nbframe.general +# set_control_help $f "General meshing page" +set_control_help $f.fine "Controls relative mesh size.\nThis control affects other mesh-size controls in common" +set_control_help $f.first "First step in mesh generation. Usually, meshing starts from \"analyze geometry\". If the surface mesh is already available \"First step\" should be set to \"mesh volume\"" +set_control_help $f.last "Last step in mesh generation. If only the surface mesh is required, please set \"Last Step\" to \"Optimize Surface\"" + +set_control_help .bubar.surfm "Start mesh generation" +set_control_help .bubar.stopm "Start mesh generation" + +proc help_item { helptext } {p + puts $helptext +} + + + + + + + +proc show_help { } { + + set w .help + + if {[winfo exists .help] == 1} { + wm withdraw $w + wm deiconif $w + focus $w + } { + + toplevel $w + + frame $w.buttons + pack $w.buttons -side bottom -fill x -pady 2m + button $w.buttons.done -text Done -command "destroy $w" + pack $w.buttons.done -side left -expand 1 + + text $w.text -yscrollcommand "$w.scroll set" -setgrid true \ + -width 60 -height 24 -wrap word + scrollbar $w.scroll -command "$w.text yview" + pack $w.scroll -side right -fill y + pack $w.text -expand yes -fill both + + } + $w.text configure -state normal + $w.text delete 1.0 end +} + + + + + + +set bold "-background #43ce80 -relief raised -borderwidth 1" +set normal "-background {} -relief flat" + + +proc help_main { } { + + show_help; + set w .help + global bold + global normal + + + + $w.text insert 0.0 \ + {NETGEN Help} + $w.text insert end \n\n + $w.text insert end \ + {1. General} d1 + $w.text insert end \n\n + $w.text insert end \ + {2. Menu items } d2 + $w.text insert end \n\n + + foreach tag {d1 d2} { + $w.text tag bind $tag "$w.text tag configure $tag $bold" + $w.text tag bind $tag "$w.text tag configure $tag $normal" + } + + $w.text tag bind d1 <1> { puts "general"; help_general } + $w.text tag bind d2 <1> { help_menus } + + $w.text configure -state disabled +} + + + + + + +proc help_general { } { + + show_help; + set w .help + global bold + global normal + + puts "general called" + + $w.text insert 0.0 \ + {NETGEN is an automatic three dimensional tetrahedral mesh generation system. It accepts input from constructive solid geometry (CSG) or boundary representation (BRep) from STEP or STL file format. NETGEN contains modules for mesh optimization and hierarchical mesh refinement.} + + $w.text configure -state disabled +} + + + + + +proc help_menus { } { + + show_help; + set w .help + global bold + global normal + + + $w.text insert 0.0 \ + {The NETGEN Menu items are} + $w.text insert end \n\n + $w.text insert end \ + {1. File} d1 + $w.text insert end \n\n + $w.text insert end \ + {2. Geometry } d2 + $w.text insert end \n\n + $w.text insert end \ + {3. Mesh } d3 + $w.text insert end \n\n + $w.text insert end \ + {4. View } d4 + $w.text insert end \n\n + $w.text insert end \ + {5. Mesh-size } d5 + $w.text insert end \n\n + $w.text insert end \ + {6. STL } d6 + + foreach tag {d1 d2 d3 d4 d5 d6} { + $w.text tag bind $tag "$w.text tag configure $tag $bold" + $w.text tag bind $tag "$w.text tag configure $tag $normal" + } + + $w.text tag bind d1 <1> {puts "File menu"} + $w.text tag bind d2 <1> {puts "Geometry menu"} + $w.text tag bind d3 <1> {puts "Mesh menu"} + $w.text tag bind d4 <1> {puts "View menu"} + $w.text tag bind d5 <1> {puts "Mesh-size menu"} + $w.text tag bind d6 <1> {puts "STL menu"} + + $w.text configure -state disabled +} + + + diff --git a/ng/ngicon.tcl b/ng/ngicon.tcl new file mode 100644 index 00000000..d8b95ac6 --- /dev/null +++ b/ng/ngicon.tcl @@ -0,0 +1,75 @@ +set icon_data { +/* XPM */ +static char *icon2[] = { +/* width height num_colors chars_per_pixel */ +" 60 60 6 1", +/* colors */ +". c #000000", +"# c #008000", +"a c #00b700", +"b c #00c700", +"c c #00ff00", +"d s c None c None", +/* pixels */ +"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", +"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", +"dddddddddddddddd..........dddddddddddddddddddddddddddddddddd", +"ddddddddddddddd.c..cc#####................dddddddddddddddddd", +"ddddddddddddd..cccc..ccccccccccccccccc...#...............ddd", +"dddddddddddd.cccccccc..cccccccccccc...ccc..cccccccccc###..dd", +"ddddddddddd.ccccccccccc..ccccccccc.cccccccc.ccccccccccc...dd", +"dddddddddd.cccccccccccccc.cccccc..cccccccccc.ccccccccc.b..dd", +"ddddddddd.cccccccccccccccc..ccc.ccccccccccccc..cccccc.bb..dd", +"ddddddd........................cccccccccccccccc.cccc.bbb..dd", +"dddddd.ccc.ccccccccccccccccc..#..............ccc.c..bbbb..dd", +"dddd..ccccc..cccccccccccccc.#..##############.....bbbbb.b.dd", +"ddd.ccccccccc..ccccccccccc.##.#.#################.bbbbb.b.dd", +"dd.cccccccccccc..cccccccc.###.##.################.bbbbb.b.dd", +"d..cccccccccccccc..ccccc.####.###.###############.bbbbb.b.dd", +"d.a..............cc..cc.#####.####.##############.bbbb.bb.dd", +"d..aaaaaaaaaaaaaa......######.#####.#############.bbbb.bb.dd", +"d.a.aaaaaaaaaaaaaaaaa...#####.######..###########.bbbb.bb.dd", +"d.aa.aaaaaaaaaaaaaaaa...#####.########.##########.bbbb.bb.dd", +"d.aaa.aaaaaaaaaaaaaaa..#.####.#########.##########..b.bbb.dd", +"d.aaaa.aaaaaaaaaaaaaa..#.####.##########.#########..b.bbb.dd", +"d.aaaaa..aaaaaaaaaaaa..##.###.###########.########..b.bbb.dd", +"d.aaaaaaa.aaaaaaaaaaa..###.###.###########.#######..b.bbb.dd", +"d.aaaaaaaa.aaaaaaaaaa..###.###.############.######..b.bbb#.d", +"d.aaaaaaaaa.aaaaaaaaa..####.##.#############.#####...bbbb#.d", +"d.aaaaaaaaaa.aaaaaaaa..#####.#.##############.####...bbbb#.d", +"d.aaaaaaaaaaa.aaaaaaa..#####.#.###############.###...bbbb#.d", +"d.aaaaaaaaaaaa.aaaaaa..######..################.##...bbbb#.d", +"d.aaaaaaaaaaaaa.aaaaaaa.#####..#################.#..bbbbb#.d", +"d.aaaaaaaaaaaaaa.aaaaaa.#####.............#######...bbbbb#.d", +"d.aaaaaaaaaaaaaaa.aaaaa.####.###.#########..........bbbbbb.d", +"dd.aaaaaaaaaaaaaaa.aaaa.###.#####..##############...bbbbbb.d", +"dd.aaaaaaaaaaaaaaaa.aaa.##.########.############.b...bbbbb.d", +"dd.aaaaaaaaaaaaaaaaa.aa.#.##########...########.b.bbb.bbbb.d", +"dd.aaaaaaaaaaaaaaaaaa....##############.######.bb.bbb.bbbb.d", +"dd.aaaaaaaaaaaaaaaaaaaa...##############..###.bbb.bbbb.bbb.d", +"dd.aaaaaaaaaaaaaaaaaa..a.a..............##.#.bbbb.bbbb.bbb.d", +"dd.aaaaaaaaaaaaaaaaa.aaaa.aaaaaaaaaaaaaa....bbbb.bbbbbb.bb.d", +"dd.aaaaaaaaaaaaaaaa.aaaaa.aaaaaaaaaaaaaaaaa.bbbb.bbbbbbb.b.d", +"dd.aaaaaaaaaaaaaaa.aaaaaaa.aaaaaaaaaaaaaaaa.bbbb.bbbbbbb.b.d", +"dd.aaaaaaaaaaaaaa.aaaaaaaaa.aaaaaaaaaaaaaaa.bbbb.bbbbbbbb..d", +"dd.aaaaaaaaaaaaa.aaaaaaaaaaa.aaaaaaaaaaaaaa.bbb.bbbbbbbbb..d", +"dd.aaaaaaaaaaaa.aaaaaaaaaaaaa.aaaaaaaaaaaaa.bbb.bbbbbbbbbb.d", +"dd.aaaaaaaaaaa.aaaaaaaaaaaaaaa.aaaaaaaaaaaa.bbb.bbbbbbbbbb.d", +"dd.aaaaaaaaaa.aaaaaaaaaaaaaaaaa.aaaaaaaaaaaa.bb.bbbbbbbbb.dd", +"dd.aaaaaaaaa.aaaaaaaaaaaaaaaaaaa.aaaaaaaaaaa.bb.bbbbbbbb.ddd", +"dd.aaaaaaaa.aaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaa.b.bbbbbbbb.dddd", +"dd.aaaaaaa.aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaa.b.bbbbbbb.ddddd", +"dd.aaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa.b.bbbbbb.dddddd", +"dd.aaaa..aaaaaaaaaaaaaaaaaaaaaaaaaaa..aaaaaa.b.bbbbb.ddddddd", +"ddd.aa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaa..bbbb..dddddddd", +"ddd.a.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaa..bbb.dddddddddd", +"ddd..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaa..bb.ddddddddddd", +"ddd........aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aa..b.dddddddddddd", +"ddddddddddd.............aaaaaaaaaaaaaaaaaa.a...ddddddddddddd", +"dddddddddddddddddddddddd............aaaaaaa...dddddddddddddd", +"dddddddddddddddddddddddddddddddddddd.........ddddddddddddddd", +"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", +"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", +"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +}; +} diff --git a/ng/ngshell.tcl b/ng/ngshell.tcl new file mode 100644 index 00000000..c42a751d --- /dev/null +++ b/ng/ngshell.tcl @@ -0,0 +1,253 @@ +## the shell loop + +proc dotest {} { + source ngtest.tcl +} + +proc Ng_RunShell {} { + puts "Wellcome to NG Shell mode" + set line 1 + while { 1 } { + puts -nonewline "$line: " + flush stdout + set cmdline [gets stdin] + if { [catch $cmdline errcode] } { +# puts "error in command: '$cmdline'" + puts "$errcode" + } + incr line 1 + } +} + +## global list for help index +set cmdindex {} +set hlpindex {} +set secindex {} + +# print comd list +proc Ng_PrintCmdIndex { } { + global cmdindex + foreach { lst } $cmdindex { + puts $lst + } +} + +# print formatted help index +proc Ng_PrintHlpIndex { } { + global hlpindex + global secindex + foreach {sec} $secindex { + puts "\n * $sec:" + foreach {lst} $hlpindex { + if {$sec == [lindex $lst 1]} { + puts " * [lindex $lst 2]: [lindex $lst 3]" + } + } + } +} + +# register a cmd to the help index +proc Ng_RegisterCmd { cmd section syntax {help ""} } { + global hlpindex + global cmdindex + global secindex + if { [lsearch $cmdindex cmd] != -1 } { + puts "command '$cmd' already defined" + } else { + lappend cmdindex $cmd + + lappend hlpindex [list $cmd $section $syntax $help] + if {[lsearch $secindex $section]==-1} { + lappend secindex $section + } +# puts "registered command $cmd" + } +} + +# general purpose commands +Ng_RegisterCmd "exit" "general" "exit" "exit Netgen shell mode" +#Ng_RegisterCmd "Ng_LoadGeometry" "netgen" "Ng_LoadGeometry " "load geometry file" +#Ng_RegisterCmd "Ng_ParseGeometry" "netgen" "Ng_ParseGeometry" "parse geometry" +#Ng_RegisterCmd "Ng_GenerateMesh" "netgen" "Ng_GenerateMesh" "generate mesh" +#Ng_RegisterCmd "Ng_SaveMesh" "netgen" "Ng_SaveMesh " "save mesh to file" + + +## public domain shell functions + +# print hel information +proc nghelp { {sec ""} } { + global secindex + global hlpindex + global cmdindex + if { $sec == "" } { + Ng_PrintHlpIndex + puts "\n type help 'section'\n" + return + } + + + if { [lsearch $secindex $sec] != -1} { + foreach {lst} $hlpindex { + if {[lindex $lst 1] == $sec } { + puts " * [lindex $lst 2]: [lindex $lst 3]" + } + } + return + } + + set ind [lsearch $cmdindex $sec] + if {$ind != -1} { + set lst [lindex $hlpindex $ind] + puts " * [lindex $lst 2]: [lindex $lst 3]" + return + } + + puts " unknown section or command $sec" +} + +set ngtimer 0 + +proc nggettimer {} { + return [clock clicks -milliseconds] +} + +proc ngtic {} { + set ::ngtimer [nggettimer] +} + + +proc ngtoc { {logfile stdout} } { + set end [nggettimer] + set tim [expr ($end - $::ngtimer)/1000.0] + puts $logfile "$tim s" +} + + +# load geometry file +proc ngloadgeometry { fname } { + if { ![file exists $fname] } { + puts "error: file $fname does not exist" + } else { + set err [catch {Ng_LoadGeometry $fname}] + if {$err != 0} { + puts "error: loading geometry failed" + } + } +} +Ng_RegisterCmd "ngloadgeometry" "netgen" "ngloadgeometry " "load geometry file" + +# parse geometry +proc ngparsegeometry {} { + set err [catch {Ng_ParseGeometry}] + if {$err} { + puts "error: parsing geometry failed" + } +} +Ng_RegisterCmd "ngparsegeometry" "netgen" "ngparsegeometry" "parse geometry" + +# generate mesh +proc nggeneratemesh {} { + set err [catch {Ng_GenerateMesh}] + if {$err} { + puts "error: mesh generation failed" + } +} +Ng_RegisterCmd "nggeneratemesh" "netgen" "nggeneratemesh" "generate mesh" + +# save mesh +proc ngsavemesh { fname } { + if { [file exists $fname]} { + puts "warning: existing file $fname overwritten" + } else { + set err [catch {Ng_SaveMesh $fname}] + if {$err != 0} { + puts "error: saving mesh failed" + } + } +} +Ng_RegisterCmd "ngsavemesh" "netgen" "ngsavemesh " "save mesh to file" + +#set option +proc ngset { opt {val 0} } { + if {$opt == "meshsize"} { + set ::options.meshsize $val + Ng_SetMeshingParameters + } elseif {$opt == "printmsg"} { + set ::options.printmsg $val + Ng_SetMeshingParameters + } else { + puts "error: unknown option $opt"; + } +} +Ng_RegisterCmd "ngset" "netgen" "ngset